a class which handles the fetching and posting of information to the FDP data pipeline RestAPI
More...
#include <fdp/registry/api.hxx>
|
|
typedef std::shared_ptr< API > | sptr |
| |
|
| Json::Value | get_request (const std::string &addr_path, long expected_response=200, std::string token="") |
| | sends the given 'packet' of information to the RestAPI More...
|
| |
|
Json::Value | patch (const std::string addr_path, Json::Value &post_data, const std::string &token, long expected_response=200) |
| |
| Json::Value | post (const std::string addr_path, Json::Value &post_data, const std::string &token, long expected_response=201) |
| | post information from a JSON value object to the RestAPI More...
|
| |
|
Json::Value | post_storage_root (Json::Value &post_data, const std::string &token) |
| |
|
Json::Value | post_file_type (Json::Value &post_data, const std::string &token) |
| |
|
Json::Value | get_by_json_query (const std::string &addr_path, Json::Value &query_data, long expected_response=200, std::string token="") |
| |
| Json::Value | get_by_id (const std::string &table, int const &id, long expected_response=200, std::string token="") |
| | get an object from the api by it's id More...
|
| |
| std::string | get_url_root () const |
| | returns the root URL for the RestAPI used by the API instance More...
|
| |
| std::string | json_to_query_string (Json::Value &json_value) |
| | Formats a json object into a string representation which can be used as a url endpoint query. More...
|
| |
| std::string | escape_space (std::string &str) |
| | escapes space " " characters within a string with it's html character code (%20) More...
|
| |
a class which handles the fetching and posting of information to the FDP data pipeline RestAPI
- Author
- K. Zarebski (UKAEA) & R. Field
The API class has know specific knowledge about the RestAPI but rather provides the interface for sending/receiving data as JSON strings
◆ append_with_forward_slash()
| std::string FairDataPipeline::API::append_with_forward_slash |
( |
std::string |
string | ) |
|
|
static |
Static function to append a given string with a "/" unless the string is empty or already ends with a "/".
- Parameters
-
| string | String to be appended with "/" |
- Returns
- std::string Appended string
◆ construct()
| API::sptr FairDataPipeline::API::construct |
( |
const std::string & |
url_root | ) |
|
|
static |
construct an API object using the given URL as the root
- Author
- K. Zarebski (UKAEA)
- Parameters
-
| url_root | the root of the query address, e.g. localhost:8000/api |
◆ escape_space()
| std::string FairDataPipeline::API::escape_space |
( |
std::string & |
str | ) |
|
escapes space " " characters within a string with it's html character code (%20)
- Parameters
-
| str | string containing space characters |
- Returns
- std::string string with space characters represented by html character code "%20"
◆ get_by_id()
| Json::Value FairDataPipeline::API::get_by_id |
( |
const std::string & |
table, |
|
|
int const & |
id, |
|
|
long |
expected_response = 200, |
|
|
std::string |
token = "" |
|
) |
| |
get an object from the api by it's id
- Parameters
-
| table | Api endpoint (table) |
| id | id of the object |
| expected_response | expected responce of the request (default 200) |
- Returns
- Json::Value
◆ get_request()
| Json::Value FairDataPipeline::API::get_request |
( |
const std::string & |
addr_path, |
|
|
long |
expected_response = 200, |
|
|
std::string |
token = "" |
|
) |
| |
sends the given 'packet' of information to the RestAPI
- Parameters
-
| addr_path | the api endpoint a.k.a the table name e.g. "coderun" |
| expected_response | the expected return HTTP code |
| token | |
- Returns
- Json::Value JSON object containing the information returned by the request
◆ get_url_root()
| std::string FairDataPipeline::API::get_url_root |
( |
| ) |
const |
|
inline |
returns the root URL for the RestAPI used by the API instance
- Author
- K. Zarebski (UKAEA)
- Returns
- URL of the RestAPI query endpoint
◆ json_to_query_string()
| std::string FairDataPipeline::API::json_to_query_string |
( |
Json::Value & |
json_value | ) |
|
Formats a json object into a string representation which can be used as a url endpoint query.
- Parameters
-
| json_value | the json object to be converted typically returned by the post method |
- Returns
- std::string
◆ post()
| Json::Value FairDataPipeline::API::post |
( |
const std::string |
addr_path, |
|
|
Json::Value & |
post_data, |
|
|
const std::string & |
token, |
|
|
long |
expected_response = 201 |
|
) |
| |
post information from a JSON value object to the RestAPI
- Author
- K. Zarebski (UKAEA) & R. Field
- Parameters
-
| addr_path | the api endpoint a.k.a the table name e.g. "coderun" |
| post_data | the data to transmit as a Json::Value object |
| key | api token |
| expected_response | the expected HTTP return code, default is 201 |
- Returns
- the result of the API post as a JSON object
◆ remove_leading_forward_slash()
| std::string FairDataPipeline::API::remove_leading_forward_slash |
( |
std::string |
str | ) |
|
|
static |
Remove the leading forward slash from a given string.
- Parameters
-
- Returns
- std::string
The documentation for this class was generated from the following files:
- include/fdp/registry/api.hxx
- src/registry/api.cxx