cppDataPipeline 0.3.0
C++ Implementation of the FAIR Data Pipeline API
Loading...
Searching...
No Matches
config.hxx
Go to the documentation of this file.
1
12#ifndef __FDP_CONFIG_HXX__
13#define __FDP_CONFIG_HXX__
14
15#include <string>
16#include <ghc/filesystem.hpp>
17#include <yaml-cpp/yaml.h>
18#include <map>
19#include <regex>
20#include <ghc/filesystem.hpp>
21#include <stdio.h>
22
23#include "fdp/objects/metadata.hxx"
24#include "fdp/registry/api.hxx"
25#include "fdp/objects/api_object.hxx"
26#include "fdp/objects/io_object.hxx"
27
28namespace FairDataPipeline {
33 class Config {
34 public:
35 typedef std::shared_ptr< Config > sptr;
36
37 typedef std::map< std::string, IOObject > map_type;
38
39 private:
40 const ghc::filesystem::path config_file_path_;
41 const ghc::filesystem::path config_dir_;
42 const ghc::filesystem::path script_file_path_;
43 YAML::Node config_data_;
44 std::string api_url_;
45 std::string token_;
46 API::sptr api_;
47
48 ApiObject::sptr user_;
49 ApiObject::sptr author_;
50
51 ApiObject::sptr config_storage_root_;
52 ApiObject::sptr config_storage_location_;
53 ApiObject::sptr config_file_type_;
54 ApiObject::sptr config_obj_;
55
56 ApiObject::sptr script_storage_root_;
57 ApiObject::sptr script_storage_location_;
58 ApiObject::sptr script_file_type_;
59 ApiObject::sptr script_obj_;
60
61 ApiObject::sptr code_repo_storage_root_;
62 ApiObject::sptr code_repo_storage_location_;
63 ApiObject::sptr code_repo_obj_;
64
65 ApiObject::sptr code_run_;
66
67 map_type writes_;
68 map_type reads_;
69
70 map_type outputs_;
71 map_type inputs_;
72
73 RESTAPI rest_api_location_ = RESTAPI::LOCAL;
74
75 bool config_has_writes() const;
76 bool config_has_reads() const;
77
78 void initialise(RESTAPI api_location);
79 void validate_config(ghc::filesystem::path yaml_path, RESTAPI api_location);
88 Config(const ghc::filesystem::path &config_file_path,
89 const ghc::filesystem::path &script_file_path,
90 const std::string &token,
91 RESTAPI api_location);
92
93
94 public:
95
96 static Config::sptr construct(const ghc::filesystem::path &config_file_path,
97 const ghc::filesystem::path &script_file_path,
98 const std::string &token,
99 RESTAPI api_location);
100
101
106 ~Config();
107
113 YAML::Node meta_data_() const;
119 YAML::Node config_writes_() const;
120
126 YAML::Node config_reads_() const;
127
134 bool has_reads() const;
141 bool has_writes() const;
148 bool has_outputs() const;
155 bool has_inputs() const;
156
163 ghc::filesystem::path get_config_file_path() const {return config_file_path_;}
175 ghc::filesystem::path get_script_file_path() const {return script_file_path_;}
176
182 std::string get_token() const {return token_;}
183
189 std::string get_api_url() const {return api_url_;}
195 ghc::filesystem::path get_data_store() const;
196
202 std::string get_default_input_namespace() const;
203
209 std::string get_default_output_namespace() const;
210
216 std::string get_config_directory() const;
217
223 std::string get_code_run_uuid() const;
224
232 ghc::filesystem::path link_write( const std::string &data_product);
233
240 ghc::filesystem::path link_read(const std::string& data_product);
241
248 void finalise();
249
256 static YAML::Node parse_yaml(ghc::filesystem::path yaml_path);
257
263 YAML::Node get_config_data() const {return config_data_;}
264
270 API::sptr get_api() const {return api_;}
271
277 RESTAPI get_rest_api_location() const {return rest_api_location_;}
278
279 };
280};
281#endif
class for interacting with confifurations
Definition: config.hxx:33
YAML::Node meta_data_() const
Returns the meta_data Yaml Node from the config.
Definition: config.cxx:40
ghc::filesystem::path link_read(const std::string &data_product)
Return the filepath to a given data product.
Definition: config.cxx:470
YAML::Node get_config_data() const
Get the config data as a Yaml Node.
Definition: config.hxx:263
ghc::filesystem::path get_config_file_path() const
Get the config file path object.
Definition: config.hxx:163
std::string get_default_output_namespace() const
Get the default output namespace.
Definition: config.cxx:91
ghc::filesystem::path get_data_store() const
Get the data store path.
Definition: config.cxx:82
static YAML::Node parse_yaml(ghc::filesystem::path yaml_path)
Read a given yaml file into a Yaml Node.
Definition: config.cxx:34
std::string get_api_url() const
Get the api url.
Definition: config.hxx:189
bool has_writes() const
Check whether the config has writes.
Definition: config.cxx:66
bool has_outputs() const
Check whether any outputs have been added.
Definition: config.cxx:78
std::string get_token() const
Get the token as a string.
Definition: config.hxx:182
void finalise()
Finalise the pipeline Write any pending metadata to the registry Rename any pending writes to their n...
Definition: config.cxx:613
ghc::filesystem::path get_script_file_path() const
Get the script file path object.
Definition: config.hxx:175
API::sptr get_api() const
Get the api object (used to interact with the pipeline directly)
Definition: config.hxx:270
ghc::filesystem::path link_write(const std::string &data_product)
Provide a tempory file path for a given data product to be written whilst recording metadata.
Definition: config.cxx:377
bool has_inputs() const
Check whether any inputs have been added.
Definition: config.cxx:74
YAML::Node config_writes_() const
Returns the writes Yaml Node from the config.
Definition: config.cxx:44
RESTAPI get_rest_api_location() const
Get the rest api location (local / remote)
Definition: config.hxx:277
YAML::Node config_reads_() const
Returns the reads Yaml Node from the config.
Definition: config.cxx:48
~Config()
Destroy the Config object.
Definition: config.cxx:31
std::string get_default_input_namespace() const
Get the default input namespace.
Definition: config.cxx:87
std::string get_config_directory() const
Get the config directory path as a string.
Definition: config.cxx:368
std::string get_code_run_uuid() const
Get the code run uuid.
Definition: config.cxx:372
bool has_reads() const
Check whether the config has reads.
Definition: config.cxx:70