ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Crest::CrestClientExt Class Reference

#include <CrestApiExt.h>

Inheritance diagram for Crest::CrestClientExt:
Collaboration diagram for Crest::CrestClientExt:

Public Member Functions

 CrestClientExt (bool rewriteIfExists, const std::string &root_folder="/tmp/crest_dump")
 
 CrestClientExt (const std::string &_host, const std::string &_port, bool _check_version=s_CREST_CLIENT_CHECK)
 
 CrestClientExt (const std::string &url, bool check_version=s_CREST_CLIENT_CHECK)
 
 BOOST_PARAMETER_MEMBER_FUNCTION ((nlohmann::json), listTagsParams, tag,(required)(optional(name,(std::string), "")(size,(int), 1000)(page,(int), 0)(sort,(std::string), "name:ASC")))
 This method returns the tag list. More...
 
 BOOST_PARAMETER_MEMBER_FUNCTION ((nlohmann::json), findAllIovsParams, tag,(required(tagname,(std::string)))(optional(size,(int), 1000)(page,(int), 0)(sort,(std::string), "id.since:ASC")(dateformat,(std::string), "ms")))
 This method finds all iovs for a given tag name. More...
 
 BOOST_PARAMETER_MEMBER_FUNCTION ((nlohmann::json), listGlobalTagsParams, tag,(required)(optional(name,(std::string), "")(size,(int), 1000)(page,(int), 0)(sort,(std::string), "id.since:ASC")))
 This method returns the global tag list. More...
 
nlohmann::json getJson (const std::string &str)
 Auxillary method to convert string in to JSON object. More...
 
bool isJson (const std::string &str)
 This method checks if a string is in the JSON format. More...
 
void removeGlobalTag (const std::string &name)
 This method allows to remove a Global Tag form CREST DB. More...
 
void removeTag (const std::string &tagName)
 This method allows to remove a Tag. More...
 
void updateGlobalTag (const std::string &name, nlohmann::json body)
 This method allows to update a GlobalTag.Arguments: the name has to uniquely identify a global tag. More...
 
std::string createFolder (nlohmann::json &body)
 Method to create a folder. More...
 
nlohmann::json listFolders ()
 This method returns the folder list on CREST DB. More...
 
void createGlobalTagMap (nlohmann::json &gt)
 Method to create a global tag map. More...
 
void createGlobalTagMap (const std::string &globaltag, const std::string &tagname, const std::string &record, const std::string &label)
 Method to create a global tag map. More...
 
nlohmann::json findGlobalTagMap (const std::string &name)
 This method search for mappings using the global tag name. More...
 
void createGlobalTag (nlohmann::json &js)
 Create a global tag in the database. More...
 
void createGlobalTag (const std::string &tag)
 Create a global tag in the database. More...
 
void createGlobalTag (const std::string &tagname, const std::string &description)
 Create a global tag in the database. More...
 
std::string findGlobalTagAsString (const std::string &name)
 Finds a global tag by name. More...
 
nlohmann::json findGlobalTag (const std::string &name)
 Finds a global tag by name. More...
 
nlohmann::json listGlobalTags ()
 This method finds a global tag lists. More...
 
nlohmann::json listGlobalTags (const std::string &name, int size, int page, const std::string &sort)
 This method returns the global tag list. More...
 
std::string listGlobalTagsAsString ()
 This method finds a global tag lists. More...
 
void createIov (nlohmann::json &iov)
 This method creates an iov for a given tag in the CREST DB for the created payload. More...
 
nlohmann::json findAllIovs (const std::string &tagname)
 This method finds all iovs for a given tag name. More...
 
nlohmann::json findAllIovs (const std::string &tagname, int size, int page, const std::string &sort, const std::string &dateformat)
 This method finds all iovs for a given tag name. More...
 
int getSize (const std::string &tagname)
 This metghod gets the number of iovs for the given tag. More...
 
nlohmann::json selectGroups (const std::string &tagname)
 Select groups for a given tagname. More...
 
nlohmann::json selectGroups (const std::string &tagname, long snapshot)
 Select groups for a given tagname. More...
 
nlohmann::json selectIovs (const std::string &tagname)
 Select iovs for a given tagname. More...
 
nlohmann::json selectIovs (const std::string &tagname, long snapshot)
 Select iovs for a given tagname. More...
 
nlohmann::json selectIovs (const std::string &tagname, long since, long until, long snapshot=0)
 This method selects all iovs for a given tag name and for the selected time interval (since-until). More...
 
void storeBatchIOVs (nlohmann::json &js)
 This method stores an IOV set on the CREST server. More...
 
nlohmann::json listPayloadTagInfo ()
 This method retrieves monitoring information on all payloads as a list of payload tag information. More...
 
nlohmann::json listPayloadTagInfo (const std::string &tagname)
 This method retrieves monitoring information on payload as a list of payload tag information. More...
 
void createPayload (nlohmann::json &js)
 This method creates a payload in the CREST DB. More...
 
std::string getBlob (const std::string &hash)
 This method finds payload data by hash; the payload object contains the real BLOB. More...
 
std::string getBlobInStream (const std::string &hash, std::ofstream &out)
 This method finds payload data by hash; the payload object contains the real BLOB. More...
 
nlohmann::json getPayloadAsJson (const std::string &hash)
 This method finds a payload resource associated to the hash. More...
 
std::string getPayloadAsString (const std::string &hash)
 This method finds a payload resource associated to the hash. More...
 
nlohmann::json getPayloadMetaInfo (const std::string &hash)
 This method finds a payload resource associated to the hash. More...
 
std::string getPayloadMetaInfoAsString (const std::string &hash)
 This method finds a payload resource associated to the hash. More...
 
void storePayload (const std::string &tag, uint64_t since, const std::string &js)
 Create a payload in the database, associated to a given iov since and tag name. More...
 
void storeBatchPayloads (const std::string &tag_name, uint64_t endtime, const std::string &iovsetupload)
 This method stores several payloads in batch mode. More...
 
void storeBatchPayloads (const std::string &tag_name, uint64_t endtime, nlohmann::json &js)
 This method stores several payloads in batch mode. More...
 
void storeBatchPayloads (const std::string &tag_name, const std::string &iovsetupload, uint64_t endtime=0)
 This method stores several payloads in batch mode. More...
 
void storeBatchPayloads (const std::string &tag_name, nlohmann::json &js, uint64_t endtime=0)
 This method stores several payloads in batch mode. More...
 
void createRunLumiInfo (nlohmann::json &body)
 This method creates an entry for run information. More...
 
nlohmann::json findRunLumiInfo (const urlParameters &params)
 Finds a run/lumi information lists using parameters. More...
 
nlohmann::json listRunLumiInfo ()
 This method gets full list of run/lumi information data. More...
 
void createTag (nlohmann::json &js)
 This method creates a tag in the CREST database. More...
 
void createTag (const std::string &name, const std::string &desc, const std::string &timeType)
 This method create a tag in the CREST database. More...
 
void createTag (const std::string &name, const std::string &desc, const std::string &timeType, const std::string &payloadSpec)
 This method create a tag in the CREST database. More...
 
nlohmann::json findTag (const std::string &name)
 This method finds a tag by the name. More...
 
nlohmann::json listTags (void)
 This method returns the tag list. More...
 
nlohmann::json listTags (int size, int page)
 This method returns the tag list. More...
 
nlohmann::json listTags (const std::string &name, int size, int page, const std::string &sort)
 This method returns the tag list. More...
 
void updateTag (const std::string &tagname, nlohmann::json body)
 This method allows to update tag record in the CREST DB. More...
 
void updateTagSpecification (const std::string &tagname, const std::string &objectType)
 This method cahnges object type specification. More...
 
void createTagDump (nlohmann::json &js)
 Method to store a tag in the local file system. More...
 
void flush ()
 Auxillary method to write all the data at the end of a session. More...
 
void storePayloadDump (const std::string &tag, uint64_t since, const std::string &js)
 Method to store a payload in the local file system. More...
 
std::list< std::string > shortListTagsFs ()
 This method returns a tag list stored in the file storage. More...
 
nlohmann::json findTagFs (const std::string &name)
 This method finds a tag by the tag name in the file storage. More...
 
nlohmann::json findAllIovsFs (const std::string &tagname)
 This method finds all iovs by the tag name in the file storage. More...
 
nlohmann::json findAllIovsFs (const std::string &tagname, int size, int page)
 This method finds all iovs for a given tag name. More...
 
std::string getFileName (const std::string &path)
 Auxillary method to extract the file name from iov hash (the hash is a path in the file storage). More...
 
std::string getBlobFs (const std::string &hash)
 This method finds payload data by hash in the file storage; the payload object contains the real BLOB. More...
 
std::string getBlobInStreamFs (const std::string &hash, std::ofstream &out)
 This method finds payload data by hash; the payload object contains the real BLOB. More...
 
void storeBatchPayloadsFs (const std::string &tag_name, std::string &iovsetupload)
 This auxillary method stores several payloads in batch mode in the file storage. More...
 
void storeBatchPayloadsFs (const std::string &tag_name, nlohmann::json &js)
 This auxillary method stores several payloads in batch mode in the file storage. More...
 
void streamTest ()
 this is test only, later it will be deleted (The old method name is streamtest) More...
 
void createTagMetaInfo (nlohmann::json &js)
 This method creates a tag meta info in the CREST database. More...
 
void createTagMetaInfo (const std::string &tagname, nlohmann::json &js)
 This method creates a tag meta info in the CREST database. More...
 
nlohmann::json getTagMetaInfo (const std::string &tagname)
 This method gets a tag meta info from the CREST database. More...
 
void updateTagMetaInfo (nlohmann::json &js)
 This method updates a tag meta info in the CREST database. More...
 
void updateTagMetaInfo (const std::string &tagname, nlohmann::json &js)
 This method updates a tag meta info in the CREST database. More...
 
void createTagMetaInfoFs (nlohmann::json &js)
 This is an auxillary method, it creates a tag meta info on the file system storage. More...
 
nlohmann::json getTagMetaInfoFs (const std::string &name)
 This is an auxillary method, it gets a tag meta info from file system storage. More...
 
void updateTagMetaInfoFs (const std::string &tagname, nlohmann::json &js)
 This auxillary method updates a tag meta info in local file storage. More...
 
std::string getTagMetaInfoElement (const std::string &name, nlohmann::json &js)
 Auxillary method to get an element by name from the Tag Meta Info. More...
 
nlohmann::json convertTagMetaInfo2IOVDbSvc (nlohmann::json &js)
 Auxillary method to convert a Tag Meta Info from the JSON CREST Server format in to IOVDbSvc format. More...
 
nlohmann::json convertTagMetaInfo2CREST (nlohmann::json &js)
 Auxillary method to convert a Tag Meta Info from the JSON IOVDbSvc format in CREST Server format. More...
 
nlohmann::json getTagMetaInfoIOVDbSvc (const std::string &tagname)
 This method gets a tag meta info from the CREST database in IOVDbSvc format. More...
 
void createTagMetaInfoIOVDbSvc (const std::string &tagname, nlohmann::json &js)
 This method creates a tag meta info in the CREST database. More...
 
void createTagMetaInfoIOVDbSvc (const std::string &tagname, nlohmann::json &js, const std::string &description)
 This method creates a tag meta info in the CREST database. More...
 
void createGlobalTagFs (nlohmann::json &js)
 The auxillary method to create a global tag in file storage. More...
 
nlohmann::json findGlobalTagFs (const std::string &name)
 The auxillary method to find a global tag by name stored in file storage. More...
 
void createGlobalTagMapFs (nlohmann::json &js)
 The auxillary method to create a global tag map in file storage. More...
 
nlohmann::json findGlobalTagMapFs (const std::string &name)
 The auxillary method to find a global tag by name for the file storage. More...
 
std::string getPayloadAsStringFS (const std::string &hash)
 This auxillary method finds a payload resource associated to the hash in the local file storage. More...
 
nlohmann::json getPayloadAsJsonFS (const std::string &hash)
 This auxillary method finds a payload resource associated to the hash in the local file storage. More...
 
std::string getPayloadMetaInfoAsStringFS (const std::string &hash)
 This auxillary method finds a payload resource associated to the hash in the local file storage. More...
 
nlohmann::json getPayloadMetaInfoAsJsonFS (const std::string &hash)
 This auxillary method finds a payload resource associated to the hash in the local file storage. More...
 
int getSizeFS (const std::string &tagname)
 This metghod gets the number of iovs for the given tag. More...
 
nlohmann::json getSizeByTagFS (const std::string &tagname)
 This method gets the number of iovs for tags matching pattern. More...
 
nlohmann::json selectIovsFS (const std::string &tagname, long since, long until)
 This method selects all iovs for a given tag name and for the selected time interval (since-until). More...
 
std::string getHash (std::string_view str)
 The auxillary method to calculate a hash code for a given string. More...
 
std::string getDateAndTime ()
 The auxillary method to get a current data and time. More...
 
nlohmann::json returnJArray (nlohmann::json js)
 This auxillary method creates a JSON array from a JSON object. More...
 
void getTagDataInfo (const std::string &tagname)
 This is an auxillary method for checking how many unique IOVs(hashcodes) are in an IOV list. More...
 
std::string getFirstLetters (const std::string &str)
 This is an auxillary method extract first letters from the string (hash). More...
 
nlohmann::json getMgmtInfo ()
 This is an auxillary method to read the CREST Server properties. More...
 
std::string getCrestVersion ()
 This method returns the full CREST Server version. More...
 
std::string getClientVersion ()
 This method returns the full CrestApi version. More...
 
int getMajorVersion (std::string &str)
 This is an auxillary method to extract a major version number from full version string. More...
 
void checkCrestVersion ()
 This method is a CREST version test. More...
 
nlohmann::json getMgmtInfo2 ()
 This is an auxillary method to read the CREST Server properties. More...
 
std::string getCrestVersion2 ()
 This method returns the full CREST Server version. More...
 
void checkCrestVersion2 ()
 This method is a CREST version test. More...
 
void removeTagFromGlobalTagMap (const std::string &global_tag, const std::string &tag, const std::string &label)
 This method removes a tag with the name tag and the label from the global tag map with name global_tag. More...
 
void storeBatchPayloadsFiles (const std::string &tag_name, uint64_t endtime, nlohmann::json &js)
 This method stores several payloads from files in batch mode. More...
 
std::string storeBatchPayloadFilesRequest (const std::string &tag, uint64_t endtime, const std::string &js)
 This is an auxilary method to make an request to store several payloads from files in the batch mode. More...
 
void storeData (const std::string &tag, uint64_t endtime, uint64_t since, const std::string &file)
 This method stores a payload from a file in the database, associated to a given IOV since and tag name. More...
 
void storeDataArray (const std::string &tag, uint64_t endtime, std::map< uint64_t, std::string > m)
 This method stores several payloads from files in batch mode. More...
 
void replaceSymbols (std::string &str, const std::string &from, const std::string &to)
 This auxilary method replaces the substring from by the substring to. More...
 

Static Public Attributes

static const bool s_CREST_CLIENT_CHECK = false
 

Private Types

enum  CrestMode { SERVER_MODE = 1, FILESYSTEM_MODE = 2 }
 
enum  Action { GET = 0, POST = 1, PUT = 2, DELETE = 3 }
 

Private Member Functions

std::string make_url (const std::string &address) const
 
std::string performRequest (const std::string &current_path, Action action, nlohmann::json &js)
 General auxiliary method to make request to the CREST Server. More...
 
std::string performRequest (const std::string &current_path, Action action, nlohmann::json &js, std::ofstream &out)
 General auxillary method to make request to the CREST Server. More...
 
std::string performRequest (const std::string &current_path, Action action, nlohmann::json &js, const char *method_name)
 General auxillary method to make request to the CREST Server. More...
 
std::string storeBatchPayloadRequest (const std::string &tag, uint64_t endtime, const std::string &js)
 This is an auxillary method to make an request to store several payloads in the batch mode. More...
 
nlohmann::json getResources (nlohmann::json &js)
 Auxillary method to get a resources parameter from new CREST server response. More...
 
nlohmann::json getResFirst (nlohmann::json &js)
 Auxillary method to get the first element from resources of the new CREST server response. More...
 
void checkFsException (const char *method_name)
 Auxillary method to check if the CrestApi library initialized to work with the file system. More...
 
int checkErrors (const nlohmann::json &js, const char *method)
 Auxillary method to check if the JSON object contain an error message. More...
 
std::string ParseXMLOutput (std::string_view xmlBuffer)
 This method removes all XML/HTML tags from a string. More...
 
std::string removeCR (const std::string &str)
 This method removes all end of line and carriage return symbols from a string. More...
 
void checkResult (CURLcode res, long response_code, const std::string &st, const char *method_name)
 This auxillary method checks the CURL response. More...
 
void getProxyPath ()
 
nlohmann::json getJson (const std::string &str, const char *method)
 Auxillary method to convert string in to JSON object. More...
 
std::string getFileString (const std::string &path)
 Auxillary method to get a file as a string. More...
 
void getFileList (const std::string &path)
 Auxillary method to get a file list in the given directory. More...
 
std::string getEnvA (const char *varname)
 Auxillary method to get an environment variable. More...
 
std::string getDataPath ()
 Auxillary method to get an environment variable DAT_PATH. More...
 
std::vector< std::string > split (std::string_view str, char delim)
 Auxillary method to split a string. More...
 

Private Attributes

std::string m_host {}
 
std::string m_port {}
 
int m_mode {}
 
std::string m_root_folder {}
 
std::string m_data_folder {}
 
std::map< std::string, nlohmann::jsonm_data {}
 
bool m_isRewrite {}
 
std::string m_currentTag {}
 
std::string m_PATH = "/api-v4.0"
 
char * m_CREST_PROXY = NULL
 
const char * m_CREST_PROXY_VAR = "SOCKS_PROXY"
 

Static Private Attributes

static const std::string s_TAG_PATH = "/tags"
 
static const std::string s_ADMIN_PATH = "/admin"
 
static const std::string s_IOV_PATH = "/iovs"
 
static const std::string s_IOV_SIZE_PATH = "/size"
 
static const std::string s_GLOBALTAG_PATH = "/globaltags"
 
static const std::string s_GLOBALTAG_MAP_PATH = "/globaltagmaps"
 
static const std::string s_PAYLOAD_PATH = "/payloads"
 
static const std::string s_MONITORING_PAYLOAD_PATH = "/monitoring/payloads"
 
static const std::string s_META_PATH = "/meta"
 
static const std::string s_DATA_PATH = "/data"
 
static const std::string s_FOLDER_PATH = "/folders"
 
static const std::string s_RUNINFO_PATH = "/runinfo"
 
static const std::string s_RUNINFO_LIST_PATH = "/list"
 
static const std::string s_METHOD_IOVS = "IOVS"
 
static const std::string s_METHOD_GROUPS = "GROUPS"
 
static const std::string s_METHOD_MONITOR = "MONITOR"
 
static const std::string s_FS_TAG_PATH = "/tags"
 
static const std::string s_FS_GLOBALTAG_PATH = "/globaltags"
 
static const std::string s_FS_DATA_PATH = "/data"
 
static const std::string s_FS_TAG_FILE = "/tag.json"
 
static const std::string s_FS_IOV_FILE = "/iovs.json"
 
static const std::string s_FS_TAGMETAINFO_FILE = "/tagmetainfo.json"
 
static const std::string s_FS_META_FILE = "/meta.json"
 
static const std::string s_FS_PALOAD_FILE = "/payload.json"
 
static const std::string s_FS_GLOBALTAG_FILE = "/globaltag.json"
 
static const std::string s_FS_MAP_FILE = "/maps.json"
 
static const std::string s_FS_PATH = ""
 
static const int s_FS_PREFIX_LENGTH = 3
 
static const std::string s_MGMT_PATH = "/mgmt"
 
static const std::string s_MGMT_INFO_PATH = "/info"
 
static const std::string s_CREST_CLIENT_VERSION = "4.0"
 
static const std::string s_MGMT_INFO_PATH_2 = "/actuator/info"
 

Detailed Description

Definition at line 30 of file CrestApiExt.h.

Member Enumeration Documentation

◆ Action

enum Crest::CrestClient::Action
privateinherited
Enumerator
GET 
POST 
PUT 
DELETE 

Definition at line 128 of file CrestApi.h.

128  {
129  GET = 0, POST = 1, PUT = 2, DELETE = 3
130  };

◆ CrestMode

enum Crest::CrestClient::CrestMode
privateinherited
Enumerator
SERVER_MODE 
FILESYSTEM_MODE 

Definition at line 125 of file CrestApi.h.

125  {
127  };

Constructor & Destructor Documentation

◆ CrestClientExt() [1/3]

Crest::CrestClientExt::CrestClientExt ( bool  rewriteIfExists,
const std::string &  root_folder = "/tmp/crest_dump" 
)
inline

Definition at line 32 of file CrestApiExt.h.

32  : CrestClient(
33  rewriteIfExists, root_folder) {}

◆ CrestClientExt() [2/3]

Crest::CrestClientExt::CrestClientExt ( const std::string &  _host,
const std::string &  _port,
bool  _check_version = s_CREST_CLIENT_CHECK 
)
inline

Definition at line 34 of file CrestApiExt.h.

34 : CrestClient(_host, _port, _check_version) {}

◆ CrestClientExt() [3/3]

Crest::CrestClientExt::CrestClientExt ( const std::string &  url,
bool  check_version = s_CREST_CLIENT_CHECK 
)
inline

Definition at line 35 of file CrestApiExt.h.

35 : CrestClient(url, check_version) {}

Member Function Documentation

◆ BOOST_PARAMETER_MEMBER_FUNCTION() [1/3]

Crest::CrestClientExt::BOOST_PARAMETER_MEMBER_FUNCTION ( (nlohmann::json ,
findAllIovsParams  ,
tag  ,
(required(tagname,(std::string)))(optional(size,(int), 1000)(page,(int), 0)(sort,(std::string), "id.since:ASC")(dateformat,(std::string), "ms"))   
)
inline

This method finds all iovs for a given tag name.

The result is a JSON object. It is a verion of this method with all parameters. (This method is an analogue of the find_all_iovs method in Python)

Parameters
tagname- tag name.
_size- page size. Default value is 1000.
_page- page number. Default value is 0.
_sort- sorting order, "id.since:ASC" or "id.since:DESC". Default value is "id.since:ASC"
_dateformat- date format Examples:
  nlohmann::json list1 = myCrestClient.findAllIovsParams("myTag");
  nlohmann::json list2 = myCrestClient.findAllIovsParams("myTag",100,200);
  nlohmann::json list2 = myCrestClient.findAllIovsParams("myTag",_page=3,_size=5);

Definition at line 88 of file CrestApiExt.h.

98  :ASC")
99  (dateformat, (std::string), "ms")
100  )
101  ) {
102  return findAllIovs(tagname, size, page, sort, dateformat);
103  }

◆ BOOST_PARAMETER_MEMBER_FUNCTION() [2/3]

Crest::CrestClientExt::BOOST_PARAMETER_MEMBER_FUNCTION ( (nlohmann::json ,
listGlobalTagsParams  ,
tag  ,
(required)(optional(name,(std::string), "")(size,(int), 1000)(page,(int), 0)(sort,(std::string), "id.since:ASC"))   
)
inline

This method returns the global tag list.

It has boost parameters, all of them are optional.

Parameters
_name- global tag name pattern, optional parameter,
_size- page size, a number of tags per a page, optional parameter, default value is 1000,
_page- page number optional parameter, default value is 0,
_sort- sorting order, default value is "name:ASC". If you dont use the optional parameter names, you have to use the same parameter order. Example:
  nlohmann::json list1 = myCrestClient.listGlobalTagsParams();
  nlohmann::json list2 = myCrestClient.listGlobalTagsParams("",3,5);
  nlohmann::json list2 = myCrestClient.listGlobalTagsParams(_page=3,_size=5);

nlohmann::json listGlobalTagsParams(std::string _name, int _size, int _page);

Definition at line 121 of file CrestApiExt.h.

131  :ASC")
132  )
133  ) {
134  return listGlobalTags(name, size, page, sort);
135  }

◆ BOOST_PARAMETER_MEMBER_FUNCTION() [3/3]

Crest::CrestClientExt::BOOST_PARAMETER_MEMBER_FUNCTION ( (nlohmann::json ,
listTagsParams  ,
tag  ,
(required)(optional(name,(std::string), "")(size,(int), 1000)(page,(int), 0)(sort,(std::string), "name:ASC"))   
)
inline

This method returns the tag list.

It has boost parameters, all of them are optional. (This method is an analogue of the list_tags method in Python)

Parameters
_name- tag name pattern, optional parameter,
_size- page size, a number of tags per a page, optional parameter, default value is 1000,
_page- page number optional parameter, default value is 0,
_sort- sorting order, default value is "name:ASC". If you dont use the optional parameter names, you have to use the same parameter order. Example:
  nlohmann::json list1 = myCrestClient.listTagsParams();
  nlohmann::json list2 = myCrestClient.listTagsParams("",3,5);
  nlohmann::json list2 = myCrestClient.listTagsParams(_page=3,_size=5);

nlohmann::json listTagsParams(std::string _name, int _size, int _page);

Definition at line 56 of file CrestApiExt.h.

66  :ASC")
67  )
68  ) {
69  return listTags(name, size, page, sort);
70  }

◆ checkCrestVersion()

void Crest::CrestClient::checkCrestVersion ( )
inherited

This method is a CREST version test.

It checks if the major CREST server is equal to the major CrestApi vesrion. If the versions are different an error is thrown.

Exceptions
std::runtime_error- error, if the versions are different.

Definition at line 2833 of file CrestApi.cxx.

2833  {
2834  std::string client = getClientVersion();
2835  std::string server = getCrestVersion();
2836 
2837  int clientVersion = getMajorVersion(client);
2838  int serverVersion = getMajorVersion(server);
2839 
2840  if (clientVersion != serverVersion) {
2841  throw std::runtime_error("ERROR in CrestClient::checkCrestVersion: CrestApi version \"" + client + "\" does not correspond to the server version \"" + server + "\".");
2842  }
2843  }

◆ checkCrestVersion2()

void Crest::CrestClient::checkCrestVersion2 ( )
inherited

This method is a CREST version test.

It checks if the major CREST server is equal to the major CrestApi vesrion. If the versions are different an error is thrown.

Exceptions
std::runtime_error- error, if the versions are different.

Definition at line 2889 of file CrestApi.cxx.

2889  {
2890  std::string client = getClientVersion();
2891  std::string server = getCrestVersion2();
2892 
2893  int clientVersion = getMajorVersion(client);
2894  int serverVersion = getMajorVersion(server);
2895 
2896  if (clientVersion != serverVersion) {
2897  throw std::runtime_error("ERROR in CrestClient::checkCrestVersion: CrestApi version \"" + client + "\" does not correspond to the server version \"" + server + "\".");
2898  }
2899  }

◆ checkErrors()

int Crest::CrestClient::checkErrors ( const nlohmann::json js,
const char *  method 
)
privateinherited

Auxillary method to check if the JSON object contain an error message.

Parameters
js- a JSON object to be checked. Example:
   nlohmann::json js =
   {
      "message": "Cannot create tag because name already exists: test_MvG3b",
      "type": "error"
   }
method- method name, where was the error.

Definition at line 1875 of file CrestApi.cxx.

1875  {
1876  int result = 0;
1877  auto res = js.find("type");
1878 
1879  // Old format parsing:
1880 
1881  if (res != js.end()) {
1882  std::string type = js.value("type", " unknown type ");
1883  if (type == "error" || type == "info") {
1884  std::string message = js.value("message", " unknown message ");
1885  throw std::runtime_error("ERROR in " + std::string(method) + " | CREST response: " + message);
1886  }
1887  }
1888 
1889  // New format parsing:
1890 
1891  auto r1 = js.find("error");
1892  auto r2 = js.find("message");
1893 
1894  if (r1 != js.end()) {
1895  std::string error = js.value("error", " unknown error ");
1896  if (r2 != js.end()) {
1897  std::string message = js.value("message", "");
1898  if (message == "") {
1899  throw std::runtime_error("ERROR in " + std::string(method) + " | CREST response: " + error);
1900  } else {
1901  throw std::runtime_error("ERROR in " + std::string(method) + " | CREST response: " + message);
1902  }
1903  }
1904  }
1905  return result;
1906  }

◆ checkFsException()

void Crest::CrestClient::checkFsException ( const char *  method_name)
privateinherited

Auxillary method to check if the CrestApi library initialized to work with the file system.

It was used to throw an exception if the library method not implemented for file system.

Parameters
method_name- method name.

Definition at line 1908 of file CrestApi.cxx.

1908  {
1909  if (m_mode == FILESYSTEM_MODE) {
1910  throw std::runtime_error("ERROR in " + std::string(
1911  method_name) + " This methods is unsupported for FILESYSTEM mode");
1912  }
1913  return;
1914  }

◆ checkResult()

void Crest::CrestClient::checkResult ( CURLcode  res,
long  response_code,
const std::string &  st,
const char *  method_name 
)
privateinherited

This auxillary method checks the CURL response.

It contais a error checking routine (common for all CURL request methods).

Parameters
res- CURL response status,
response_code- the CURL response code,
st- the CURL response,
method_name- the name on a method which calls one of the perform request methods.

Definition at line 1698 of file CrestApi.cxx.

1699  {
1700  // Bad HTTP response:
1701 
1702  if (res != CURLE_OK) {
1703  std::string mes = "ERROR in ";
1704  mes += method_name;
1705  mes += " | ";
1706  throw std::runtime_error(mes + std::to_string(response_code));
1707  }
1708 
1709  // Errors, decoded from JSON CREST Server messages:
1710 
1711  if (isJson(st)) {
1712  nlohmann::json respond = getJson(st);
1713  checkErrors(respond, method_name);
1714  }
1715 
1716  // HTTP response code error interval:
1717 
1718  if (response_code >= 400 || response_code == 303) {
1719  std::string s = ParseXMLOutput(st); // to remove HTML tags
1720  s = removeCR(s); // to remove end lines and carridge returns
1721  std::string mes = "ERROR in ";
1722  mes += method_name;
1723  mes += " | ";
1724  throw std::runtime_error(mes + "CREST Server response : " + s);
1725  }
1726  }

◆ convertTagMetaInfo2CREST()

nlohmann::json Crest::CrestClient::convertTagMetaInfo2CREST ( nlohmann::json js)
inherited

Auxillary method to convert a Tag Meta Info from the JSON IOVDbSvc format in CREST Server format.

Parameters
js- the Tag Meta Info in CREST Server JSON format.

Definition at line 1955 of file CrestApi.cxx.

1955  {
1956  int colsize = 0;
1957 
1958  std::string tagInfo = js.dump();
1959 
1961  result["tagInfo"] = std::move(tagInfo);
1962  result["description"] = "none";
1963 
1964  std::string node_desc = js["node_description"];
1965  std::string payload_spec = js["payload_spec"];
1966  nlohmann::json chan_list = js["channel_list"];
1967  int chan_size = chan_list.size();
1968  result["chansize"] = chan_size;
1969 
1970  try{
1971  colsize = split(payload_spec, ',').size();
1972  }
1973  catch (...) {
1974  colsize = 0;
1975  }
1976 
1977  result["colsize"] = colsize;
1978 
1979  return result;
1980  }

◆ convertTagMetaInfo2IOVDbSvc()

nlohmann::json Crest::CrestClient::convertTagMetaInfo2IOVDbSvc ( nlohmann::json js)
inherited

Auxillary method to convert a Tag Meta Info from the JSON CREST Server format in to IOVDbSvc format.

Parameters
js- the Tag Meta Info in CREST Server JSON format.

Definition at line 1948 of file CrestApi.cxx.

1948  {
1949  std::string jsName = "tagInfo";
1950  const char* method_name = "CrestClient::convertTagMetaInfo2IOVDbSvc";
1951  nlohmann::json res = getJson(js[jsName], method_name);
1952  return res;
1953  }

◆ createFolder()

std::string Crest::CrestClient::createFolder ( nlohmann::json body)
inherited

Method to create a folder.

It is not yet realized (This method is an analogue of the create_folder method in Python)

Definition at line 1181 of file CrestApi.cxx.

1181  {
1182  const char* method_name = "CrestClient::createFolder";
1183 
1184  checkFsException(method_name);
1185 
1186  std::string current_path = m_PATH + s_FOLDER_PATH;
1187 
1188  std::string retv;
1189 
1190  retv = performRequest(current_path, POST, body, method_name);
1191 
1192  return retv;
1193  }

◆ createGlobalTag() [1/3]

void Crest::CrestClient::createGlobalTag ( const std::string &  tag)
inherited

Create a global tag in the database.

This method allows to insert a global tag. (This method is an analogue of the create_global_tag method in Python)

Parameters
tag- global tag as JSON string (std::string).

Definition at line 702 of file CrestApi.cxx.

702  {
703  const char* method_name = "CrestClient::createGlobalTag";
704 
705  nlohmann::json js = getJson(tag, method_name);
706  createGlobalTag(js);
707  }

◆ createGlobalTag() [2/3]

void Crest::CrestClient::createGlobalTag ( const std::string &  tagname,
const std::string &  description 
)
inherited

Create a global tag in the database.

This method allows to insert a global tag, it has a reduced parameterset: the global tag name and the global tag description. (This method is an analogue of the create_global_tag method in Python) The method set the following default parameters:

  {
      "release": "1",
      "scenario": "undefined",
      "type": "UPD",
      "validity": 0,
      "workflow": "undefined"
  }
 
Parameters
tagname- global tag name,
description- global tag description,

Definition at line 709 of file CrestApi.cxx.

709  {
710  nlohmann::json js =
711  {
712  {"name", tagname},
713  {"description", description},
714  {"validity", 0},
715  {"release", 1},
716  {"scenario", "undefined"},
717  {"workflow", "undefined"},
718  {"type", "UPD"}
719  };
720 
721  createGlobalTag(js);
722  }

◆ createGlobalTag() [3/3]

void Crest::CrestClient::createGlobalTag ( nlohmann::json js)
inherited

Create a global tag in the database.

This method allows to insert a global tag. (This method is an analogue of the create_global_tag method in Python)

Parameters
js- global tag in the JSON format. Example:
json js =
   {
      {"name","M_TEST_01"},
      {"validity",0},
      {"description","test"},
      {"release","1"},
      {"insertionTime","2018-12-18T11:32:58.081+0000"},
      {"snapshotTime","2018-12-18T11:32:57.952+0000"},
      {"scenario","test"},
      {"workflow","M"},
      {"type","t"},
      {"snapshotTimeMilli","null"},
      {"insertionTimeMilli","null"}
   };
 

Definition at line 688 of file CrestApi.cxx.

688  {
689  const char* method_name = "CrestClient::createGlobalTag";
690 
691  if (m_mode == FILESYSTEM_MODE) {
692  createGlobalTagFs(js);
693  return;
694  }
695 
696  std::string current_path = m_PATH;
697  current_path += s_GLOBALTAG_PATH;
698  std::string retv;
699  retv = performRequest(current_path, POST, js, method_name);
700  }

◆ createGlobalTagFs()

void Crest::CrestClient::createGlobalTagFs ( nlohmann::json js)
inherited

The auxillary method to create a global tag in file storage.

(This method is an analogue of the create_global_tag method in Python)

Parameters
js- global tag in the JSON format. Example:
json js =
   {
      {"name","M_TEST_01"},
      {"validity",0},
      {"description","test"},
      {"release","1"},
      {"insertionTime","2018-12-18T11:32:58.081+0000"},
      {"snapshotTime","2018-12-18T11:32:57.952+0000"},
      {"scenario","test"},
      {"workflow","M"},
      {"type","t"},
      {"snapshotTimeMilli","null"},
      {"insertionTimeMilli","null"}
   };
 

Definition at line 2266 of file CrestApi.cxx.

2266  {
2267  std::string name = "";
2268  try{
2269  name = static_cast<std::string>(js["name"]);
2270  }
2271  catch (...) {
2272  throw std::runtime_error("ERROR in CrestClient::createGlobalTagFs: cannot get the global tag name from JSON.");
2273  }
2274 
2275  std::string gTagDir = m_root_folder;
2276  gTagDir += s_FS_GLOBALTAG_PATH;
2277  std::string workDir = gTagDir;
2278  workDir += '/';
2279  workDir += name;
2280  std::string globalTagFile = workDir;
2281  globalTagFile += s_FS_GLOBALTAG_FILE;
2282 
2283 
2285  std::filesystem::create_directory(std::filesystem::path(gTagDir));
2286  }
2287 
2289  std::filesystem::create_directory(std::filesystem::path(workDir));
2290  }
2291 
2292  if (m_isRewrite) {
2293  if (std::filesystem::exists(std::filesystem::path(globalTagFile))) {
2295  }
2296 
2297  std::ofstream myfile;
2298 
2299  myfile.open(globalTagFile.c_str());
2300  myfile << js;
2301  myfile.close();
2302  }
2303 
2304  return;
2305  }

◆ createGlobalTagMap() [1/2]

void Crest::CrestClient::createGlobalTagMap ( const std::string &  globaltag,
const std::string &  tagname,
const std::string &  record,
const std::string &  label 
)
inherited

Method to create a global tag map.

(This method is an analogue of the create_global_tag_map method in Python)

Parameters
globaltag- global tag name,
tagname- tag name,
record- record,
label- label,

Definition at line 888 of file CrestApi.cxx.

889  {
890  const char* method_name = "CrestClient::createGlobalTagMap";
891 
892  nlohmann::json js =
893  {
894  {"globalTagName", globaltag},
895  {"record", record},
896  {"label", label},
897  {"tagName", tagname}
898  };
899 
900  if (m_mode == FILESYSTEM_MODE) {
902  return;
903  }
904 
905  std::string current_path = m_PATH + s_GLOBALTAG_MAP_PATH;
906 
907  std::string retv;
908 
909  retv = performRequest(current_path, POST, js, method_name);
910  }

◆ createGlobalTagMap() [2/2]

void Crest::CrestClient::createGlobalTagMap ( nlohmann::json gt)
inherited

Method to create a global tag map.

(This method is an analogue of the create_global_tag_map method in Python)

Parameters
gt- global tag map in the JSON format. Example:
json gt =
   {
     {"globalTagName", "M_TEST"},
     {"record", "testing2"},
     {"label", "test2"},
     {"tagName", "test_MvG3"}
   }

Definition at line 872 of file CrestApi.cxx.

872  {
873  const char* method_name = "CrestClient::createGlobalTagMap";
874 
875  if (m_mode == FILESYSTEM_MODE) {
877  return;
878  }
879 
880  std::string current_path = m_PATH;
881  current_path += s_GLOBALTAG_MAP_PATH;
882 
883  std::string retv;
884 
885  retv = performRequest(current_path, POST, js, method_name);
886  }

◆ createGlobalTagMapFs()

void Crest::CrestClient::createGlobalTagMapFs ( nlohmann::json js)
inherited

The auxillary method to create a global tag map in file storage.

(This method is an analogue of the create_global_tag_map method in Python)

Parameters
gt- global tag map in the JSON format. Example:
json gt =
   {
     {"globalTagName", "M_TEST"},
     {"record", "testing2"},
     {"label", "test2"},
     {"tagName", "test_MvG3"}
   }

Definition at line 2329 of file CrestApi.cxx.

2329  {
2330  // global tag name:
2331  std::string name = "";
2332  try{
2333  name = static_cast<std::string>(js["globalTagName"]);
2334  }
2335  catch (...) {
2336  throw std::runtime_error("ERROR in CrestClient::createGlobalTagMapFs: cannot get the global tag name from JSON.");
2337  }
2338 
2339  // tag name:
2340  std::string tagname = "";
2341  try{
2342  tagname = static_cast<std::string>(js["tagName"]);
2343  }
2344  catch (...) {
2345  throw std::runtime_error("ERROR in CrestClient::createGlobalTagMapFs: cannot get the tag name from JSON.");
2346  }
2347 
2348  std::string fname = "/";
2349  fname += tagname;
2350  fname += ".json";
2351 
2352 
2353  std::string gTagDir = m_root_folder + s_FS_GLOBALTAG_PATH;
2354  std::string workDir = gTagDir;
2355  workDir += '/';
2356  workDir += name;
2357 
2358 
2360  std::filesystem::create_directory(std::filesystem::path(workDir));
2361  }
2362 
2364  std::filesystem::create_directory(std::filesystem::path(workDir));
2365  }
2366 
2367 
2368  std::string catalogFile = workDir + s_FS_MAP_FILE;
2369 
2371  // cathalogue file exists:
2372 
2373  std::string array_lst = getFileString(catalogFile);
2374  nlohmann::json cathalogue = getJson(array_lst, "CrestClient::createGlobalTagMapFs");
2375 
2377  // the file storage contains the record of the global tag map:
2378  int m = cathalogue.size();
2379  for (int i = 0; i < m; i++) {
2380  const std::string& tn = cathalogue[i]["tagName"];
2381  if (tn == tagname) {
2382  cathalogue.erase(i);
2383  }
2384  }
2385  } else {
2386  // the file storage does not contain the record of the global tag map:
2387  }
2389  cathalogue.push_back(js);
2390  std::ofstream myfile;
2391 
2392  myfile.open(catalogFile.c_str());
2393  myfile << cathalogue;
2394  myfile.close();
2395  } else {
2396  // cathalogue file does not exist (creation):
2397 
2398  nlohmann::json cathalogue = nlohmann::json::array();
2399  cathalogue.push_back(js);
2400 
2401  std::ofstream myfile;
2402 
2403  myfile.open(catalogFile.c_str());
2404  myfile << cathalogue;
2405  myfile.close();
2406  }
2407 
2408 
2409  return;
2410  }

◆ createIov()

void Crest::CrestClient::createIov ( nlohmann::json iov)
inherited

This method creates an iov for a given tag in the CREST DB for the created payload.

The tag name is used in the iov creation. This tag has to be defined in the CREST DB before creating iov (This method is an analogue of the create_iov method in Python)

Parameters
iov- an iov in the JSON format (JSON object). Example:
   json js3b =
   {
     {"tagName","test_MvG3"},
     {"since",100},
     {"insertionTime","2018-12-18T11:32:58.329+0000"},
     {"payloadHash","ABRACADABRA4"},
   };

Definition at line 370 of file CrestApi.cxx.

370  {
371  const char* method_name = "CrestClient::createIov";
372 
373  checkFsException(method_name);
374 
376  iovList.push_back(js);
377 
378  try{
380  }
381  catch (const std::exception& e) {
382  std::string message = "ERROR in ";
383  message += method_name;
384  message += e.what();
385  throw std::runtime_error(message);
386  }
387 
388  }

◆ createPayload()

void Crest::CrestClient::createPayload ( nlohmann::json js)
inherited

This method creates a payload in the CREST DB.

(This method is an analogue of the create_payload method in Python)

Parameters
js- payload in the JSON format. Example:
json js =
   {  {"hash", "ABRACADABRA"},
      {"version", "string"},
      {"objectType", "string"},
      {"data", "none"},
      {"streamerInfo", "none"},
      {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 1088 of file CrestApi.cxx.

1088  {
1089  const char* method_name = "CrestClient::createPayload";
1090 
1091  checkFsException(method_name);
1092 
1093  std::string current_path = m_PATH + s_PAYLOAD_PATH;
1094 
1095  std::string retv;
1096 
1097  retv = performRequest(current_path, POST, js, method_name);
1098  }

◆ createRunLumiInfo()

void Crest::CrestClient::createRunLumiInfo ( nlohmann::json body)
inherited

This method creates an entry for run information.

Run informations go into a separate table. (This method is an analogue of the create_run_lumi_info method in Python)

Parameters
body- run information in JSON format. Example:
   std::string str19 =
"{\"since\":\"10\",\"run\":\"7777771\",\"lb\":\"62\",\"starttime\":\"10\",\"endtime\":\"200\"}";
   json body = json::parse(str19);

Definition at line 1216 of file CrestApi.cxx.

1216  {
1217  const char* method_name = "CrestClient::createRunLumiInfo";
1218 
1219  checkFsException(method_name);
1220 
1221  std::string current_path = m_PATH + s_RUNINFO_PATH;
1222 
1223  std::string retv;
1224 
1225  retv = performRequest(current_path, POST, body, method_name);
1226  }

◆ createTag() [1/3]

void Crest::CrestClient::createTag ( const std::string &  name,
const std::string &  desc,
const std::string &  timeType 
)
inherited

This method create a tag in the CREST database.

(This method is an analogue of the create_tag method in Python)

Parameters
name- tag name.
desc- description.
timeType- time type.

Definition at line 246 of file CrestApi.cxx.

246  {
247  nlohmann::json js2 = {{"description", desc}, {"endOfValidity", 0},
248  {"lastValidatedTime", 0}, {"synchronization", "none"}, {"payloadSpec", "json"},
249  {"name", name}, {"timeType", timeType}};
250  createTag(js2);
251  }

◆ createTag() [2/3]

void Crest::CrestClient::createTag ( const std::string &  name,
const std::string &  desc,
const std::string &  timeType,
const std::string &  payloadSpec 
)
inherited

This method create a tag in the CREST database.

(This method is an analogue of the create_tag method in Python)

Parameters
name- tag name.
desc- description.
timeType- time type..
payloadSpec- payload specification.

Definition at line 253 of file CrestApi.cxx.

254  {
255  nlohmann::json js2 = {{"description", desc}, {"endOfValidity", 0},
256  {"lastValidatedTime", 0}, {"synchronization", "none"}, {"payloadSpec", payloadSpec},
257  {"name", name}, {"timeType", timeType}};
258 
259  createTag(js2);
260  }

◆ createTag() [3/3]

void Crest::CrestClient::createTag ( nlohmann::json js)
inherited

This method creates a tag in the CREST database.

(This method is an analogue of the create_tag method in Python)

Parameters
js- tag in the JSON format. Example:
   json js =
   {
     {"description", "none"},
     {"endOfValidity", 0},
     {"insertionTime", "2018-12-06T11:18:35.641+0000"},
     {"lastValidatedTime", 0},
     {"modificationTime", "2018-12-06T11:18:35.641+0000"},
     {"name", "test_M"},
     {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
     {"synchronization", "none"},
     {"timeType", "time"}
   };

Definition at line 262 of file CrestApi.cxx.

262  {
263  const char* method_name = "CrestClient::createTag";
264 
265  if (m_mode == FILESYSTEM_MODE) {
266  createTagDump(js);
267  return;
268  }
269 
270  std::string current_path = m_PATH;
271  current_path += s_TAG_PATH;
272 
273  std::string retv;
274 
275  retv = performRequest(current_path, POST, js, method_name);
276  }

◆ createTagDump()

void Crest::CrestClient::createTagDump ( nlohmann::json js)
inherited

Method to store a tag in the local file system.

The path to stored data defined by a CrestClient constructor (m_root_folder and m_data_folder variables). (This method is an analogue of the create_tag method in Python)

Parameters
js- tag as a JSON object.

Definition at line 311 of file CrestApi.cxx.

311  {
312  std::string name = js["name"];
313 
314  std::string rootDir = m_root_folder;
315  rootDir += s_FS_TAG_PATH;
317  std::filesystem::create_directory(std::filesystem::path(rootDir));
318  }
319 
320  std::string workDir = m_root_folder;
321  workDir += s_FS_TAG_PATH;
322  workDir += '/';
323  workDir += name;
325  std::filesystem::create_directory(std::filesystem::path(workDir));
326  }
327  if (name.compare(m_currentTag) != 0 && m_isRewrite) {
328  flush();
329  }
330  m_currentTag = name;
331  std::string tagFile = workDir + s_FS_TAG_FILE;
332  std::string iovFile = workDir + s_FS_IOV_FILE;
333 
334  if (m_isRewrite) {
337  }
340  }
341  std::ofstream myfile;
342  myfile.open(tagFile.c_str());
343  myfile << js;
344  myfile.close();
345  }
346  if (m_data.find(name) == m_data.end()) {
347  m_data.insert(std::pair<std::string, nlohmann::json>(name, nlohmann::json(nlohmann::json::value_t::array)));
348  }
349  }

◆ createTagMetaInfo() [1/2]

void Crest::CrestClient::createTagMetaInfo ( const std::string &  tagname,
nlohmann::json js 
)
inherited

This method creates a tag meta info in the CREST database.

(The tag meta info JSON contains the tag name, that is why it is better to use the method variant without tagname parameter. This method exists for the compatibility reasons.)

Parameters
tagname- tag name,
js- tag meta info in the JSON format. Example:
   nlohmann::json js =
   {
     {"tagName", "test_MvG4"},
     {"description", "desc-01"},
     {"tagInfo", "taginf-01"},
     {"chansize", 0},
     {"colsize", 0},
     {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 2028 of file CrestApi.cxx.

2028  {
2029  std::string name = js["tagName"];
2030  if (tagname != name) {
2031  throw std::runtime_error("ERROR in CrestClient::createTagMetaInfo tagname in method and in JSON are different.");
2032  }
2033  createTagMetaInfo(js);
2034  return;
2035  }

◆ createTagMetaInfo() [2/2]

void Crest::CrestClient::createTagMetaInfo ( nlohmann::json js)
inherited

This method creates a tag meta info in the CREST database.

Parameters
js- tag meta info in the JSON format. Example:
   nlohmann::json js =
   {
     {"tagName", "test_MvG4"},
     {"description", "desc-01"},
     {"tagInfo", "taginf-01"},
     {"chansize", 0},
     {"colsize", 0},
     {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 1998 of file CrestApi.cxx.

1998  {
1999  const char* method_name = "CrestClient::createTagMetaInfo";
2000 
2001  if (m_mode == FILESYSTEM_MODE) {
2002  createTagMetaInfoFs(js);
2003  return;
2004  }
2005 
2006  std::string tagname = "";
2007  try{
2008  tagname = static_cast<std::string> (js["tagName"]);
2009  }
2010  catch (...) {
2011  throw std::runtime_error(
2012  "ERROR in CrestClient::createTagMetaInfo cannot get the tag name from tag meta info JSON.");
2013  }
2014 
2015  std::string current_path = m_PATH;
2016  current_path += s_TAG_PATH;
2017  current_path += '/';
2018  current_path += tagname;
2019  current_path += s_META_PATH;
2020 
2021  std::string retv;
2022 
2023  retv = performRequest(current_path, POST, js, method_name);
2024 
2025  nlohmann::json respond = getJson(retv, method_name);
2026  }

◆ createTagMetaInfoFs()

void Crest::CrestClient::createTagMetaInfoFs ( nlohmann::json js)
inherited

This is an auxillary method, it creates a tag meta info on the file system storage.

Parameters
js- tag meta info in the JSON format. Example:
   nlohmann::json js =
   {
     {"tagName", "test_MvG4"},
     {"description", "desc-01"},
     {"tagInfo", "taginf-01"},
     {"chansize", 0},
     {"colsize", 0},
     {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 2165 of file CrestApi.cxx.

2165  {
2166  std::string name = "";
2167  try{
2168  name = static_cast<std::string> (js["tagName"]);
2169  }
2170  catch (...) {
2171  throw std::runtime_error(
2172  "ERROR in CrestClient::createTagMetaInfoFs cannot get the tag name from tag meta info JSON.");
2173  }
2174  std::string workDir = m_root_folder;
2175  workDir += s_FS_TAG_PATH;
2176 
2178  std::filesystem::create_directory(std::filesystem::path(workDir));
2179  }
2180 
2181  workDir += '/';
2182  workDir += name;
2183  std::string tagMetaFile = workDir;
2184  tagMetaFile += s_FS_TAGMETAINFO_FILE;
2185 
2187  std::filesystem::create_directory(std::filesystem::path(workDir));
2188  }
2189 
2190  if (m_isRewrite) {
2191  if (std::filesystem::exists(std::filesystem::path(tagMetaFile))) {
2193  }
2194 
2195  std::ofstream myfile;
2196 
2197  myfile.open(tagMetaFile.c_str());
2198  myfile << js;
2199  myfile.close();
2200  }
2201 
2202  return;
2203  }

◆ createTagMetaInfoIOVDbSvc() [1/2]

void Crest::CrestClient::createTagMetaInfoIOVDbSvc ( const std::string &  tagname,
nlohmann::json js 
)
inherited

This method creates a tag meta info in the CREST database.

Parameters
tagname- tag name
js- tag meta info in the JSON IOVDbSvc format. Example:
{
   "channel_list": [
       {"0": "ATLAS_PREFERRED0"},
       {"1": "ATLAS_PREFERRED1"}
    ],
   "node_description": "description of the node",
   "payload_spec":
     "AlgorithmID:UInt32,LBAvInstLumi:Float,LBAvEvtsPerBX:Float,LumiType:UInt32,Valid:UInt32,BunchInstLumi:Blob64k"
 }

Definition at line 2134 of file CrestApi.cxx.

2134  {
2135  const char* method_name = "CrestClient::createTagMetaInfoIOVDbSvc";
2136 
2137  checkFsException(method_name);
2138 
2140  arg["tagName"] = tagname;
2141 
2143 
2144  return;
2145  }

◆ createTagMetaInfoIOVDbSvc() [2/2]

void Crest::CrestClient::createTagMetaInfoIOVDbSvc ( const std::string &  tagname,
nlohmann::json js,
const std::string &  description 
)
inherited

This method creates a tag meta info in the CREST database.

Parameters
tagname- tag name
description- tag meta info description, this parameter is a part of the tag meta info in CREST format
js- tag meta info in the JSON IOVDbSvc format. Example:
 {
   "channel_list": [
       {"0": "ATLAS_PREFERRED0"},
       {"1": "ATLAS_PREFERRED1"}
    ],
   "node_description": "description of the node",
   "payload_spec":
     "AlgorithmID:UInt32,LBAvInstLumi:Float,LBAvEvtsPerBX:Float,LumiType:UInt32,Valid:UInt32,BunchInstLumi:Blob64k"
}

Definition at line 2147 of file CrestApi.cxx.

2148  {
2149  const char* method_name = "CrestClient::createTagMetaInfoIOVDbSvc";
2150 
2151  checkFsException(method_name);
2152 
2154  arg["tagName"] = tagname;
2155  arg["description"] = description;
2156 
2158 
2159  return;
2160  }

◆ findAllIovs() [1/2]

nlohmann::json Crest::CrestClient::findAllIovs ( const std::string &  tagname)
inherited

This method finds all iovs for a given tag name.

The result is a JSON object. (This method is an analogue of the find_all_iovs method in Python)

Parameters
tagname- tag name.
Returns
JSON array with the IOV list. Example:
IOV list =
[
   {
      "tagName": "CaloOflHadDMCorr2-R123-FTFP-BERT-IOVDEP-01",
      "since": 0,
      "insertionTime": "2023-09-13T12:53:46+0000",
      "payloadHash": "ba26ca6b4e17b0c33b008045c5e703bdf049a1546e731ec7c3d2d39789b1ce1f"
  },
  ...
]

IOV JSON parameters:

 tagName          string              tag name
 since            number              since time parameter
 insertionTime    string($date-time)  insertion time
 payloadHash      string              payload hash

Definition at line 390 of file CrestApi.cxx.

390  {
391  const char* method_name = "CrestClient::findAllIovs";
392 
393  if (m_mode == FILESYSTEM_MODE) {
394  return findAllIovsFs(tagname);
395  }
396 
397  std::string current_path = m_PATH;
398  current_path += s_IOV_PATH;
399  current_path += "?method=";
400  current_path += s_METHOD_IOVS;
401  current_path += "&tagname=";
402  current_path += tagname;
403 
404  std::string retv;
405 
406  nlohmann::json js = nullptr;
407  retv = performRequest(current_path, GET, js, method_name);
408 
409  nlohmann::json respond = getJson(retv, method_name);
410 
411  auto answer = getResources(respond);
412  return answer;
413  }

◆ findAllIovs() [2/2]

nlohmann::json Crest::CrestClient::findAllIovs ( const std::string &  tagname,
int  size,
int  page,
const std::string &  sort,
const std::string &  dateformat 
)
inherited

This method finds all iovs for a given tag name.

The result is a JSON object. It is a version of this method with all parameters. (This method is an analogue of the find_all_iovs method in Python)

Parameters
tagname- tag name.
size- page size.
page- page number.
sort- sort pattern (for example "{id.since:ASC}").
dateformat- format of the input time fields.
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 415 of file CrestApi.cxx.

416  {
417  const char* method_name = "CrestClient::findAllIovs";
418 
419  if (m_mode == FILESYSTEM_MODE) {
420  return findAllIovsFs(tagname);
421  }
422 
423  // http request examples:
424  // http://crest-01.cern.ch:9090/crestapi/iovs?method=IOVS&tagname=MuonAlignMDTBarrelAlign-RUN2-BA_ROLLING_12-BLKP-UPD4-00
425  // http://crest-02.cern.ch:8090/crestapi/tags?size=10&page=2&sort=name:DESC
426 
427  std::string current_path = m_PATH;
428  current_path += s_IOV_PATH;
429  current_path += "?method=";
430  current_path += s_METHOD_IOVS;
431  current_path += "&tagname=";
432  current_path += tagname;
433  current_path += "&size=";
434  current_path += std::to_string(size);
435  current_path += "&page=";
436  current_path += std::to_string(page);
437  current_path += "&sort=";
438  current_path += sort;
439  current_path += "&dateformat=";
440  current_path += dateformat;
441 
442 
443  std::string retv;
444 
445  nlohmann::json js = nullptr;
446 
447  retv = performRequest(current_path, GET, js, method_name);
448 
449  nlohmann::json respond = getJson(retv, method_name);
450 
451  return getResources(respond);
452  }

◆ findAllIovsFs() [1/2]

nlohmann::json Crest::CrestClient::findAllIovsFs ( const std::string &  tagname)
inherited

This method finds all iovs by the tag name in the file storage.

This is the auxilary method. It is called by find_all_iovs method when CrestClient is initialized in the file storage mode. (This method is an analogue of the find_all_iovs method in Python)

Parameters
tagname- tag name.
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 1781 of file CrestApi.cxx.

1781  {
1782  nlohmann::json js = nullptr;
1783  std::string file_path = m_root_folder;
1784  file_path += '/';
1786  file_path += '/';
1787  file_path += tagname;
1789 
1790  try{
1791  std::string tag = getFileString(file_path);
1792  js = nlohmann::json::parse(tag);
1793  }
1794  catch (...) {
1795  throw std::runtime_error("ERROR in CrestClient::findAllIovsFs : cannot get the iov information form file storage");
1796  }
1797 
1798  return js;
1799  }

◆ findAllIovsFs() [2/2]

nlohmann::json Crest::CrestClient::findAllIovsFs ( const std::string &  tagname,
int  size,
int  page 
)
inherited

This method finds all iovs for a given tag name.

The result is a JSON object. It is a verion of this method with all parameters. This method works with the file data storage. (This method is an analogue of the find_all_iovs method in Python)

Parameters
tagname- tag name.
size- page size.
page- page number.
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 2664 of file CrestApi.cxx.

2664  {
2666  int dataSize = getSizeFS(tagname);
2667 
2668  if (dataSize == 0) return js; // the data is absent
2669 
2670  // index interval to load the data from JSON array:
2671  int kmin = size * page;
2672  int kmax = size * (page + 1);
2673 
2674  // check if the interval is correct:
2675  if (kmin > dataSize - 1) return js; // out of range
2676 
2677  if (kmax > dataSize - 1) { // this step is not full
2678  kmax = dataSize;
2679  }
2680 
2682 
2683  for (int i = kmin; i < kmax; i++) {
2684  js.push_back(data[i]);
2685  }
2686  return js;
2687  }

◆ findGlobalTag()

nlohmann::json Crest::CrestClient::findGlobalTag ( const std::string &  name)
inherited

Finds a global tag by name.

This method will search for a global tag with the given name. Only one global tag should be returned. (This method is an analogue of the find_global_tag method in Python) This method returns the global tag as a JSON object.

Parameters
name- global tag name
Returns
JSON with the global tag. Example:
globalTag(ATLAS-P2-ITK-22-02-00)=
 [
   {
     "name": "ATLAS-P2-ITK-22-02-00",
     "validity": 1,
     "description": "A geometry like global tag",
     "release": "1",
     "insertionTime": "2023-11-01T08:45:09+0000",
     "snapshotTime": "2023-11-01T08:45:09+0000",
     "scenario": "undefined",
     "workflow": "undefined",
     "type": "U",
     "insertionTimeMilli": 1698828309000,
     "snapshotTimeMilli": 1698828309000
  }
]

Global Tag JSON parameters:

name                    string              global tag name
validity                number              validity
description             string              global tag description
release                 string              release
insertionTime           string($date-time)  insertion time
snapshotTime            string($date-time)  snapshot time
scenario                string              scenario
workflow                string              workfow
type                    string              type
snapshotTimeMilli       integer($int64)     snapshot time (in milliseconds)
insertionTimeMilli      integer($int64)     insertion time (in milliseconds)

Definition at line 745 of file CrestApi.cxx.

745  {
746  const char* method_name = "CrestClient::findGlobalTag";
747 
748  if (m_mode == FILESYSTEM_MODE) {
749  return findGlobalTagFs(name);
750  }
751 
752  std::string retv = findGlobalTagAsString(name);
753  nlohmann::json respond = getJson(retv, method_name);
754 
755  return getResources(respond);
756  }

◆ findGlobalTagAsString()

std::string Crest::CrestClient::findGlobalTagAsString ( const std::string &  name)
inherited

Finds a global tag by name.

This method will search for a global tag with the given name. Only one global tag should be returned. (This method is an analogue of the find_global_tag_as_string method in Python) This method returns the global tag as a string.

Parameters
name- global tag name
Returns
string with the global tag in JSON format.
See the global tag JSON description in CrestClient::findGlobalTag method.

Definition at line 724 of file CrestApi.cxx.

724  {
725  const char* method_name = "CrestClient::findGlobalTagAsString";
726 
727  if (m_mode == FILESYSTEM_MODE) {
729  std::string s = j.dump();
730  return s;
731  }
732 
733  std::string current_path = m_PATH;
734  current_path += s_GLOBALTAG_PATH;
735  current_path += '/';
736  current_path += name;
737  std::string retv;
738 
739  nlohmann::json js = nullptr;
740  retv = performRequest(current_path, GET, js, method_name);
741 
742  return retv;
743  }

◆ findGlobalTagFs()

nlohmann::json Crest::CrestClient::findGlobalTagFs ( const std::string &  name)
inherited

The auxillary method to find a global tag by name stored in file storage.

(This method is an analogue of the find_global_tag method in Python) This method returns the global tag as a JSON object.

Parameters
name- global tag name
Returns
JSON with the global tag.
See the tag JSON description in CrestClient::findGlobalTag method.

Definition at line 2307 of file CrestApi.cxx.

2307  {
2308  nlohmann::json js = nullptr;
2309 
2310  std::string workDir = m_root_folder;
2311  workDir += s_FS_GLOBALTAG_PATH;
2312  workDir += '/';
2313  workDir += name;
2314  std::string file_path = workDir;
2316 
2317  try{
2318  std::string tag = getFileString(file_path);
2319  js = nlohmann::json::parse(tag);
2320  }
2321  catch (...) {
2322  throw std::runtime_error(
2323  "ERROR in CrestClient::getGlobalTagFs: cannot get the global tag " + name + " form the file storage.");
2324  }
2325 
2326  return returnJArray(js);
2327  }

◆ findGlobalTagMap()

nlohmann::json Crest::CrestClient::findGlobalTagMap ( const std::string &  name)
inherited

This method search for mappings using the global tag name.

(This method is an analogue of the find_global_tag_map method in Python)

Parameters
name- name of a global tag
Returns
JSON with the global tag map. Example:
 global tag map(CREST-MC23-SDR-RUN3-02)=
 [
   {
      "globalTagName": "CREST-MC23-SDR-RUN3-02",
      "record": "None",
      "label": "/TGC/NSW/CHARGE/SIDEA",
      "tagName": "sTgcPdoSideA-Const-1p0-icpt0"
   },
   ...
 ]
 Global Tag Map JSON parameters:
 
 globalTagName    string   global tag name
 record           string   record
 label            string   label
 tagName          string   tag name

Definition at line 849 of file CrestApi.cxx.

849  {
850  const char* method_name = "CrestClient::findGlobalTagMap";
851 
852  if (m_mode == FILESYSTEM_MODE) {
853  return findGlobalTagMapFs(name);
854  }
855 
856  std::string current_path = m_PATH;
857  current_path += s_GLOBALTAG_MAP_PATH;
858  current_path += '/';
859  current_path += name;
860 
861  std::string retv;
862 
863  nlohmann::json js = nullptr;
864 
865  retv = performRequest(current_path, GET, js, method_name);
866 
867  nlohmann::json respond = getJson(retv, method_name);
868 
869  return getResources(respond);
870  }

◆ findGlobalTagMapFs()

nlohmann::json Crest::CrestClient::findGlobalTagMapFs ( const std::string &  name)
inherited

The auxillary method to find a global tag by name for the file storage.

This method will search for a global tag with the given name. Only one global tag should be returned. (This method is an analogue of the find_global_tag method in Python) This method returns the global tag as a JSON object.

Parameters
name- global tag name
Returns
JSON with the global tag map.
See the global tag map JSON description in CrestClient::findGlobalTagMap method.

Definition at line 2412 of file CrestApi.cxx.

2412  {
2413  nlohmann::json js = nullptr;
2414 
2415  std::string workDir = m_root_folder + s_FS_GLOBALTAG_PATH;
2416  std::string file_path = workDir;
2417  file_path += '/';
2418  file_path += name;
2420 
2421  try{
2422  std::string tag = getFileString(file_path);
2423  js = nlohmann::json::parse(tag);
2424  }
2425  catch (...) {
2426  throw std::runtime_error(
2427  "ERROR in CrestClient::getGlobalTagMapFs: cannot get the global tag map " + name +
2428  " form the file storage.");
2429  }
2430 
2431  return js;
2432  }

◆ findRunLumiInfo()

nlohmann::json Crest::CrestClient::findRunLumiInfo ( const urlParameters params)
inherited

Finds a run/lumi information lists using parameters.

This method allows to perform search. (This method is an analogue of the find_run_lumi_info method in Python) @params params - search parameters. Example:

   urlParameters params28;
   params28.add("from","2018010101");
   params28.add("to","2019050500");
   params28.add("format","Time");
   json tag_info28 = myCrestClientF.findRunLumiInfo(params28);

Definition at line 1228 of file CrestApi.cxx.

1228  {
1229  const char* method_name = "CrestClient::findRunLumiInfo";
1230 
1231  checkFsException(method_name);
1232 
1233  std::string current_path = m_PATH;
1234  current_path += s_RUNINFO_PATH;
1235  current_path += s_RUNINFO_LIST_PATH;
1236  current_path += '?';
1237  current_path += params.getParams();
1238 
1239  std::string retv;
1240 
1241  nlohmann::json js = nullptr;
1242 
1243  retv = performRequest(current_path, GET, js, method_name);
1244 
1245  nlohmann::json respond = getJson(retv, method_name);
1246 
1247  return getResources(respond);
1248  }

◆ findTag()

nlohmann::json Crest::CrestClient::findTag ( const std::string &  name)
inherited

This method finds a tag by the name.

The result is a JSON object (This method is an analogue of the find_tag method in Python)

Parameters
name- tag name
Returns
JSON with the tag. Example:
tag(AtlasLayerMat_v16_ATLAS-R1-2012-02)=
[
  {
      "name": "AtlasLayerMat_v16_ATLAS-R1-2012-02",
      "timeType": "run-lumi",
      "payloadSpec": "crest-json-single-iov",
      "synchronization": "none",
      "description": "Migrated from {\"dbname":"OFLP200","nodeFullpath":"/GLOBAL/TrackingGeo/LayerMaterialV2","schemaName":"COOLOFL_GLOBAL"}",
      "lastValidatedTime": 0,
      "endOfValidity": 0,
      "insertionTime": "2023-09-22T12:22:07+0000",
      "modificationTime": "2023-09-22T12:22:07+0000",
  }
]

JSON parameters:

 name                string              tag  name 
 timeType            string              time type 
 payloadSpec         string              payload specification
 synchronization     string              synchronization
 description         string              tag description
 lastValidatedTime   number              last validated time
 endOfValidity       number              end of validity
 insertionTime       string($date-time)  insertion time
 modificationTime    string($date-time)  modification time

See the tag JSON description in CrestClient::findTag method.

Definition at line 226 of file CrestApi.cxx.

226  {
227  const char* method_name = "findTag";
228 
229  if (m_mode == FILESYSTEM_MODE) {
230  return findTagFs(tagName);
231  }
232 
233  std::string current_path = m_PATH + s_TAG_PATH + '/' + tagName;
234 
235  std::string retv;
236 
237  nlohmann::json js = nullptr;
238 
239  retv = performRequest(current_path, GET, js, method_name);
240 
241  nlohmann::json respond = getJson(retv, method_name);
242 
243  return getResources(respond);
244  }

◆ findTagFs()

nlohmann::json Crest::CrestClient::findTagFs ( const std::string &  name)
inherited

This method finds a tag by the tag name in the file storage.

This is the auxilary method. It is called by findTag method when CrestClient is initialized in the file storage mode. (This method is an analogue of the find_tag method in Python)

Parameters
name- tag name.
Returns
JSON with the tag.
See the tag JSON description in CrestClient::findTag method.

Definition at line 1762 of file CrestApi.cxx.

1762  {
1763  nlohmann::json js = nullptr;
1764  std::string file_path = m_root_folder;
1765  file_path += '/';
1767  file_path += '/';
1768  file_path += name;
1770  try{
1771  std::string tag = getFileString(file_path);
1772  js = nlohmann::json::parse(tag);
1773  }
1774  catch (...) {
1775  throw std::runtime_error("ERROR in CrestClient::findTagFs cannot get the tag information form file storage.");
1776  }
1777 
1778  return returnJArray(js);
1779  }

◆ flush()

void Crest::CrestClient::flush ( )
inherited

Auxillary method to write all the data at the end of a session.

The path to stored data defined by a CrestClient constructor (in m_root_folder and m_data_folder variables).

Definition at line 351 of file CrestApi.cxx.

351  {
352  if (m_mode == SERVER_MODE) return;
353 
354  for (auto& item : m_data) {
355  nlohmann::json iov = item.second;
356  std::string name = item.first;
357  std::string workDir = m_root_folder + s_FS_TAG_PATH + '/' + name;
358  std::ofstream myfile;
359  std::string tagFile = workDir + s_FS_IOV_FILE;
360  myfile.open(tagFile.c_str());
361  myfile << iov;
362  myfile.close();
363  }
364 
365  m_data.clear();
366  }

◆ getBlob()

std::string Crest::CrestClient::getBlob ( const std::string &  hash)
inherited

This method finds payload data by hash; the payload object contains the real BLOB.

The result returns as a string. (This method is an analogue of the get_blob method in Python)

Parameters
hash- hash

Definition at line 915 of file CrestApi.cxx.

915  {
916  const char* method_name = "CrestClient::getBlob";
917 
918  if (m_mode == FILESYSTEM_MODE) {
919  return getBlobFs(hash);
920  }
921 
922  std::string current_path = m_PATH;
923  current_path += s_PAYLOAD_PATH;
924  current_path += '/';
925  current_path += hash;
926 
927  std::string retv;
928 
929  nlohmann::json js = nullptr;
930 
931  retv = performRequest(current_path, GET, js, method_name);
932 
933  return retv;
934  }

◆ getBlobFs()

std::string Crest::CrestClient::getBlobFs ( const std::string &  hash)
inherited

This method finds payload data by hash in the file storage; the payload object contains the real BLOB.

The result returns as a string. This is an auxillary method called by getBlob method when CrestClient innitialized in the file storage mode. (This method is an analogue of the get_blob method in Python)

Parameters
hash- hash

Definition at line 2600 of file CrestApi.cxx.

2600  {
2601  try{
2602  std::string str = getPayloadAsStringFS(hash);
2603  return str;
2604  }
2605  catch (...) {
2606  throw std::runtime_error("ERROR in CrestClient::getBlobFs : cannot get the blob information form file storage");
2607  }
2608  }

◆ getBlobInStream()

std::string Crest::CrestClient::getBlobInStream ( const std::string &  hash,
std::ofstream &  out 
)
inherited

This method finds payload data by hash; the payload object contains the real BLOB.

The result returns in the stream "out" (BE CAREFUL!). (This method is an analogue of the get_blob method in Python)

Parameters
hash- hash
[out]out- output stream to get the result.

Definition at line 936 of file CrestApi.cxx.

936  {
937  if (m_mode == FILESYSTEM_MODE) {
938  return getBlobInStreamFs(hash, out);
939  }
940 
941  std::string current_path = m_PATH;
942  current_path += s_PAYLOAD_PATH;
943  current_path += '/';
944  current_path += hash;
945 
946  std::string retv;
947 
948  nlohmann::json js = nullptr;
949  retv = performRequest(current_path, GET, js, out);
950 
951  return retv;
952  }

◆ getBlobInStreamFs()

std::string Crest::CrestClient::getBlobInStreamFs ( const std::string &  hash,
std::ofstream &  out 
)
inherited

This method finds payload data by hash; the payload object contains the real BLOB.

The result returns in the stream "out" (BE CARREFULL!). This is an auxillary method called by getBlobInStream method when CrestClient innitialized in the file storage mode. (This method is an analogue of the get_blob method in Python)

Parameters
hash- hash
[out]out- output stream to get the result.

Definition at line 2610 of file CrestApi.cxx.

2610  {
2611  std::string line;
2612  std::string str = "";
2613 
2614  std::string workDir = m_data_folder;
2615  workDir += '/';
2616  workDir += getFirstLetters(hash);
2617  workDir += '/';
2618  workDir += hash;
2619 
2620  std::string file_path = workDir;
2621  file_path += "/payload.json";
2622 
2623  std::ifstream in(file_path);
2624 
2625  if (in.is_open() && out.is_open()) {
2626 
2627  while (getline(in, line)) {
2628  out << line << std::endl;
2629  }
2630  } else {
2631  throw std::runtime_error(
2632  "ERROR in CrestClient::getBlobInStreamFs : cannot get the blob information form file storage");
2633  }
2634  in.close();
2635 
2636  return str;
2637  }

◆ getClientVersion()

std::string Crest::CrestClient::getClientVersion ( )
inherited

This method returns the full CrestApi version.

Definition at line 2809 of file CrestApi.cxx.

2809  {
2810  return s_CREST_CLIENT_VERSION;
2811  }

◆ getCrestVersion()

std::string Crest::CrestClient::getCrestVersion ( )
inherited

This method returns the full CREST Server version.

Definition at line 2783 of file CrestApi.cxx.

2783  {
2784  const char* method_name = "getCrestVersion";
2785  checkFsException(method_name);
2786 
2787  std::string version = "";
2789 
2790  auto subjectIdIter1 = info.find("build");
2791  if (subjectIdIter1 != info.end()){
2792  nlohmann::json build = info["build"];
2793  auto subjectIdIter2 = build.find("version");
2794  if (subjectIdIter2 != build.end()){
2795  version = build["version"];
2796  }
2797  else {
2798  throw std::runtime_error("ERROR in CrestClient::" + (std::string) method_name + ": CREST Server response has no \"version\" key.");
2799  } // iterator 2
2800 
2801  }
2802  else {
2803  throw std::runtime_error("ERROR in CrestClient::" + (std::string) method_name + ": CREST Server response has no \"build\" key.");
2804  } // iterator 1
2805 
2806  return version;
2807  }

◆ getCrestVersion2()

std::string Crest::CrestClient::getCrestVersion2 ( )
inherited

This method returns the full CREST Server version.

Definition at line 2863 of file CrestApi.cxx.

2863  {
2864  const char* method_name = "getCrestVersion";
2865  checkFsException(method_name);
2866 
2867  std::string version = "";
2869 
2870  auto subjectIdIter1 = info.find("build");
2871  if (subjectIdIter1 != info.end()){
2872  nlohmann::json build = info["build"];
2873  auto subjectIdIter2 = build.find("version");
2874  if (subjectIdIter2 != build.end()){
2875  version = build["version"];
2876  }
2877  else {
2878  throw std::runtime_error("ERROR in CrestClient::" + (std::string) method_name + ": CREST Server response has no \"version\" key.");
2879  } // iterator 2
2880 
2881  }
2882  else {
2883  throw std::runtime_error("ERROR in CrestClient::" + (std::string) method_name + ": CREST Server response has no \"build\" key.");
2884  } // iterator 1
2885 
2886  return version;
2887  }

◆ getDataPath()

std::string Crest::CrestClient::getDataPath ( )
privateinherited

Auxillary method to get an environment variable DAT_PATH.

Definition at line 1866 of file CrestApi.cxx.

1866  {
1867  const char* varName = "DAT_PATH";
1868 
1869  std::string respond = getEnvA(varName);
1870  respond += "/data/crestapi";
1871 
1872  return respond;
1873  }

◆ getDateAndTime()

std::string Crest::CrestClient::getDateAndTime ( )
inherited

The auxillary method to get a current data and time.

It used to create a payload meta info on the local file storage using the storePayloadDump method.

Definition at line 2534 of file CrestApi.cxx.

2534  {
2535  time_t now = time(0);
2536  struct tm tstruct;
2537  char buf[80];
2538 
2539  localtime_r(&now, &tstruct);
2540  strftime(buf, sizeof(buf), "%Y-%m-%d %X", &tstruct);
2541  return buf;
2542  }

◆ getEnvA()

std::string Crest::CrestClient::getEnvA ( const char *  varname)
privateinherited

Auxillary method to get an environment variable.

Parameters
varname- a variable name.

Definition at line 1856 of file CrestApi.cxx.

1856  {
1857  std::string respond = "";
1858 
1859  char* pPath;
1860  const char* c = varname;
1861  pPath = std::getenv(c);
1862  if (pPath != NULL) respond = std::string(pPath);
1863  return respond;
1864  }

◆ getFileList()

void Crest::CrestClient::getFileList ( const std::string &  path)
privateinherited

Auxillary method to get a file list in the given directory.

(The old method name - get_file_list)

Parameters
path- path to the directory.

Definition at line 1739 of file CrestApi.cxx.

1739  {
1741  for (auto i = std::filesystem::directory_iterator(p); i != std::filesystem::directory_iterator(); i++) {
1742  std::string file = i->path().filename().string();
1743  if (file != "data") {
1744  std::cout << file << std::endl;
1745  } else continue;
1746  }
1747  }

◆ getFileName()

std::string Crest::CrestClient::getFileName ( const std::string &  path)
inherited

Auxillary method to extract the file name from iov hash (the hash is a path in the file storage).

(The old method name is get_filename)

Parameters
path- an iov hash.

Definition at line 1802 of file CrestApi.cxx.

1802  {
1803  int size = path.size();
1804  int pos = path.find(':');
1805 
1806  return path.substr(pos + 3, size);
1807  }

◆ getFileString()

std::string Crest::CrestClient::getFileString ( const std::string &  path)
privateinherited

Auxillary method to get a file as a string.

(The old method name - get_file_string)

Parameters
path- path to the file.

Definition at line 1733 of file CrestApi.cxx.

1733  {
1734  std::ifstream ifs(path);
1735  return std::string((std::istreambuf_iterator<char>(ifs)),
1736  (std::istreambuf_iterator<char>()));
1737  }

◆ getFirstLetters()

std::string Crest::CrestClient::getFirstLetters ( const std::string &  str)
inherited

This is an auxillary method extract first letters from the string (hash).

The letter number is in the s_FS_PREFIX_LENGTH variable. This method is used to create a catalogue sub directory in the file storage.

Parameters
str- string to extract first letters.

Definition at line 2762 of file CrestApi.cxx.

2762  {
2763  std::string result = str.substr(0, s_FS_PREFIX_LENGTH);
2764  return result;
2765  }

◆ getHash()

std::string Crest::CrestClient::getHash ( std::string_view  str)
inherited

The auxillary method to calculate a hash code for a given string.

This method uses SHA256 algorithm (PicoSHA2 C++ library)

Parameters
str- a string

Definition at line 2441 of file CrestApi.cxx.

2441  {
2442  std::string hash_hex_str = picosha2::hash256_hex_string(str.begin(), str.end());
2443  return hash_hex_str;
2444  }

◆ getJson() [1/2]

nlohmann::json Crest::CrestClient::getJson ( const std::string &  str)
inherited

Auxillary method to convert string in to JSON object.

Parameters
str- string (std::string)
Returns
- JSON object as nlohmann::json

Definition at line 1650 of file CrestApi.cxx.

1650  {
1651  return getJson(str, "");
1652  }

◆ getJson() [2/2]

nlohmann::json Crest::CrestClient::getJson ( const std::string &  str,
const char *  method 
)
privateinherited

Auxillary method to convert string in to JSON object.

Parameters
str- string (std::string)
method- method name, wthich calls this method. This parameter is used to throw an error exception.
Returns
- JSON object as nlohmann::json

Definition at line 1631 of file CrestApi.cxx.

1631  {
1632  try {
1634  return js;
1635  }
1636  catch (nlohmann::json::parse_error& e) {
1637  if (method == nullptr || *method == '\0') {
1638  // method name is undefined
1639 
1640  std::string wh = e.what();
1641  throw std::runtime_error("ERROR in JSON conversion: " + wh + " | In string: " + str);
1642  } else {
1643  std::string str2 = ParseXMLOutput(str); // to remove HTML tags use this function
1644  std::string str3 = removeCR(str2); // to remove carridge return
1645  throw std::runtime_error("ERROR in " + std::string(method) + " | CREST Server response : " + str3);
1646  }
1647  }
1648  }

◆ getMajorVersion()

int Crest::CrestClient::getMajorVersion ( std::string &  str)
inherited

This is an auxillary method to extract a major version number from full version string.

Definition at line 2813 of file CrestApi.cxx.

2813  {
2814  int v = -1;
2815  int n = str.find('.');
2816 
2817  if (n < 1) {
2818  throw std::runtime_error("ERROR in CrestClient::getMajorVersion: string \"" + str + "\" does not contain major version.");
2819  }
2820 
2821  std::string vers = str.substr(0,n);
2822 
2823  try {
2824  v = std::stoi( str );
2825  }
2826  catch (const std::exception& e) {
2827  throw std::runtime_error("ERROR in CrestClient::getMajorVersion: string \"" + str + "\" does not contain major version.");
2828  }
2829 
2830  return v;
2831  }

◆ getMgmtInfo()

nlohmann::json Crest::CrestClient::getMgmtInfo ( )
inherited

This is an auxillary method to read the CREST Server properties.

Returns
JSON with CREST server properties. Example:
 {
  "build":{
    "artifact":"crestdb",
    "name":"crestdb",
    "time":"2023-12-02T15:21:57.045Z",
    "version":"4.2.1",
    "group":"hep.crest"
  }
 }

Definition at line 2767 of file CrestApi.cxx.

2767  {
2768  const char* method_name = "getMgmtInfo";
2769 
2770  checkFsException(method_name);
2771 
2772  std::string current_path = s_MGMT_PATH + s_MGMT_INFO_PATH;
2773  std::string retv;
2774  nlohmann::json js = nullptr;
2775 
2776  retv = performRequest(current_path, GET, js, method_name);
2777 
2778  nlohmann::json respond = getJson(retv, method_name);
2779 
2780  return respond;
2781  }

◆ getMgmtInfo2()

nlohmann::json Crest::CrestClient::getMgmtInfo2 ( )
inherited

This is an auxillary method to read the CREST Server properties.

This method is an analogue of the getMgmtInfo() method, but it uses another path to get the data.

Returns
JSON with CREST server properties. Example:
 {
  "build":{
    "artifact":"crestdb",
    "name":"crestdb",
    "time":"2023-12-02T15:21:57.045Z",
    "version":"4.2.1",
    "group":"hep.crest"
  }
 }

Definition at line 2847 of file CrestApi.cxx.

2847  {
2848  const char* method_name = "getMgmtInfo2";
2849 
2850  checkFsException(method_name);
2851 
2852  std::string current_path = s_MGMT_INFO_PATH_2;
2853  std::string retv;
2854  nlohmann::json js = nullptr;
2855 
2856  retv = performRequest(current_path, GET, js, method_name);
2857 
2858  nlohmann::json respond = getJson(retv, method_name);
2859 
2860  return respond;
2861  }

◆ getPayloadAsJson()

nlohmann::json Crest::CrestClient::getPayloadAsJson ( const std::string &  hash)
inherited

This method finds a payload resource associated to the hash.

The payload returns as a JSON object. (This method is an analogue of the get_payload method in Python)

Parameters
hash- hash.

Definition at line 1042 of file CrestApi.cxx.

1042  {
1043  const char* method_name = "CrestClient::getPayloadAsJson";
1044 
1045  if (m_mode == FILESYSTEM_MODE) {
1046  return getPayloadAsJsonFS(hash);
1047  }
1048 
1049  std::string current_path = m_PATH;
1050  current_path += s_PAYLOAD_PATH;
1051  current_path += '/';
1052  current_path += hash;
1053  current_path += "?format=DTO";
1054 
1055  std::string retv;
1056 
1057  nlohmann::json js = nullptr;
1058 
1059  retv = performRequest(current_path, GET, js, method_name);
1060 
1061  nlohmann::json respond = getJson(retv, method_name);
1062 
1063  return respond;
1064  }

◆ getPayloadAsJsonFS()

nlohmann::json Crest::CrestClient::getPayloadAsJsonFS ( const std::string &  hash)
inherited

This auxillary method finds a payload resource associated to the hash in the local file storage.

The payload returns as a JSON object. (This method is an analogue of the get_payload method in Python)

Parameters
hash- hash.

Definition at line 2566 of file CrestApi.cxx.

2566  {
2567  std::string res = getPayloadAsStringFS(hash);
2568  nlohmann::json respond = getJson(res, "getPayloadAsJsonFS");
2569  return respond;
2570  }

◆ getPayloadAsString()

std::string Crest::CrestClient::getPayloadAsString ( const std::string &  hash)
inherited

This method finds a payload resource associated to the hash.

The payload returns as a string. (This method is an analogue of the get_payload method in Python)

Parameters
hash- hash.

Definition at line 1066 of file CrestApi.cxx.

1066  {
1067  const char* method_name = "CrestClient::getPayloadAsString";
1068 
1069  if (m_mode == FILESYSTEM_MODE) {
1070  return getPayloadAsStringFS(hash);
1071  }
1072 
1073  std::string current_path = m_PATH;
1074  current_path += s_PAYLOAD_PATH;
1075  current_path += '/';
1076  current_path += hash;
1077  current_path += "?format=BLOB";
1078 
1079  std::string retv;
1080 
1081  nlohmann::json js = nullptr;
1082 
1083  retv = performRequest(current_path, GET, js, method_name);
1084 
1085  return retv;
1086  }

◆ getPayloadAsStringFS()

std::string Crest::CrestClient::getPayloadAsStringFS ( const std::string &  hash)
inherited

This auxillary method finds a payload resource associated to the hash in the local file storage.

The payload returns as a string. (This method is an analogue of the get_payload method in Python)

Parameters
hash- hash.

Definition at line 2547 of file CrestApi.cxx.

2547  {
2548  std::string workDir = m_data_folder;
2549  workDir += '/';
2550  workDir += getFirstLetters(hash);
2551  workDir += '/';
2552  workDir += hash;
2553  std::string filePath = workDir + "/payload.json";
2554  std::string res = "";
2555 
2556  try{
2558  }
2559  catch (...) {
2560  throw std::runtime_error("ERROR in CrestClient::getPayloadAsStringFS cannot get the payload form file storage.");
2561  }
2562 
2563  return res;
2564  }

◆ getPayloadMetaInfo()

nlohmann::json Crest::CrestClient::getPayloadMetaInfo ( const std::string &  hash)
inherited

This method finds a payload resource associated to the hash.

This method retrieves metadata of the payload resource. The result is a JSON object. (This method is an analogue of the get_payload_meta_info method in Python)

Parameters
hash- hash.
Returns
JSON with the payload meta info. Example:
 {
    "checkSum": "SHA-256",
    "compressionType": "none",
    "hash": "8f7b558c70032fb0e93f608408b0d49d2af75572d29877013226c65ffc01dbc5",
    "insertionTime": "2023-09-22T12:22:07+0000",
    "objectName": "none",
    "objectType": "iovs",
    "size": 246,
    "version": "default"
 }

Definition at line 956 of file CrestApi.cxx.

956  {
957  const char* method_name = "CrestClient::getPayloadMetaInfo";
958 
959  if (m_mode == FILESYSTEM_MODE) {
961  }
962 
963  std::string current_path = m_PATH;
964  current_path += s_PAYLOAD_PATH;
965  current_path += '/';
966  current_path += hash;
967  current_path += "?format=META";
968 
969  std::string retv;
970 
971  nlohmann::json js = nullptr;
972 
973  retv = performRequest(current_path, GET, js, method_name);
974 
975  nlohmann::json respond = getJson(retv, method_name);
976 
977  return respond;
978  }

◆ getPayloadMetaInfoAsJsonFS()

nlohmann::json Crest::CrestClient::getPayloadMetaInfoAsJsonFS ( const std::string &  hash)
inherited

This auxillary method finds a payload resource associated to the hash in the local file storage.

This method retrieves metadata of the payload resource. The result is a JSON object. (This method is an analogue of the get_payload_meta_info method in Python)

Parameters
hash- hash.
Returns
JSON with the payload meta info.
See the payload meta info JSON example in CrestClient::getPayloadMetaInfo method.

Definition at line 2594 of file CrestApi.cxx.

2594  {
2595  std::string res = getPayloadMetaInfoAsStringFS(hash);
2596  nlohmann::json respond = getJson(res, "getPayloadAsJsonFS");
2597  return returnJArray(respond);
2598  }

◆ getPayloadMetaInfoAsString()

std::string Crest::CrestClient::getPayloadMetaInfoAsString ( const std::string &  hash)
inherited

This method finds a payload resource associated to the hash.

This method retrieves metadata of the payload resource. The result is a string. (This method is an analogue of the get_payload_meta_info method in Python)

Parameters
hash- hash.
Returns
JSON as a string with the payload meta info.
See the payload meta info JSON example in CrestClient::getPayloadMetaInfo method.

Definition at line 980 of file CrestApi.cxx.

980  {
981  const char* method_name = "CrestClient::getPayloadMetaInfoAsString";
982 
983  if (m_mode == FILESYSTEM_MODE) {
985  }
986 
987  std::string current_path = m_PATH;
988  current_path += s_PAYLOAD_PATH;
989  current_path += '/';
990  current_path += hash;
991  current_path += "?format=META";
992 
993  std::string retv;
994 
995  nlohmann::json js = nullptr;
996 
997  retv = performRequest(current_path, GET, js, method_name);
998 
999  return retv;
1000  }

◆ getPayloadMetaInfoAsStringFS()

std::string Crest::CrestClient::getPayloadMetaInfoAsStringFS ( const std::string &  hash)
inherited

This auxillary method finds a payload resource associated to the hash in the local file storage.

This method retrieves metadata of the payload resource. The result is a string. (This method is an analogue of the get_payload_meta_info method in Python)

Parameters
hash- hash.
Returns
JSON as a string with the payload meta info.
See the payload meta info JSON example in CrestClient::getPayloadMetaInfo method.

Definition at line 2572 of file CrestApi.cxx.

2572  {
2573  std::string workDir = m_data_folder;
2574  workDir += '/';
2575  workDir += getFirstLetters(hash);
2576  workDir += '/';
2577  workDir += hash;
2578 
2579  std::string filePath = workDir;
2580  filePath += "/meta.json";
2581 
2582  std::string res = "";
2583 
2584  try{
2586  }
2587  catch (...) {
2588  throw std::runtime_error("ERROR in CrestClient::getPayloadAsStringFS cannot get the payload form file storage.");
2589  }
2590 
2591  return res;
2592  }

◆ getProxyPath()

void Crest::CrestClient::getProxyPath ( )
privateinherited

Definition at line 3149 of file CrestApi.cxx.

3149  {
3150  char * val = getenv( m_CREST_PROXY_VAR );
3151  if (val != NULL){
3152  m_CREST_PROXY = val;
3153  }
3154  }

◆ getResFirst()

nlohmann::json Crest::CrestClient::getResFirst ( nlohmann::json js)
privateinherited

Auxillary method to get the first element from resources of the new CREST server response.

Parameters
js- CREST server response.

Definition at line 1922 of file CrestApi.cxx.

1922  {
1923  nlohmann::json jNull = getJson("[]");
1924  nlohmann::json res = js.value("resources", jNull);
1926  try {
1927  result = res.at(0);
1928  }
1929  catch (...) {
1930  nlohmann::json result0 = nullptr;
1931  return result0;
1932  }
1933  return result;
1934  }

◆ getResources()

nlohmann::json Crest::CrestClient::getResources ( nlohmann::json js)
privateinherited

Auxillary method to get a resources parameter from new CREST server response.

Parameters
js- CREST server response.

Definition at line 1916 of file CrestApi.cxx.

1916  {
1917  nlohmann::json js2 = getJson("[]");
1918  nlohmann::json result = js.value("resources", js2);
1919  return result;
1920  }

◆ getSize()

int Crest::CrestClient::getSize ( const std::string &  tagname)
inherited

This metghod gets the number of iovs for the given tag.

This method allows to select the count of iovs in a tag. (This method is an analogue of the get_size method in Python)

Parameters
tagname- tag name.

Definition at line 454 of file CrestApi.cxx.

454  {
455  const char* method_name = "CrestClient::getSize";
456 
457  if (m_mode == FILESYSTEM_MODE) {
458  return getSizeFS(tagname);
459  }
460 
461  std::string current_path = m_PATH;
462  current_path += s_IOV_PATH;
463  current_path += s_IOV_SIZE_PATH;
464  current_path += "?tagname=";
465  current_path += tagname;
466 
467  std::string retv;
468 
469  nlohmann::json js = nullptr;
470 
471  retv = performRequest(current_path, GET, js, method_name);
472 
473 
474  nlohmann::json respond = getJson(retv, method_name);
475  nlohmann::json res = getResources(respond)[0];
476 
477  int result = 0;
478 
479  if (respond.find("size") != respond.end()) {
480  int sizeR = respond["size"];
481  if (sizeR == 0) return result;
482  }
483 
484  if (res.find("niovs") != res.end()) {
485  result = res["niovs"];
486  } else {
487  throw std::runtime_error("ERROR in CrestClient::getSize CREST Server JSON response has no \"size\" key.");
488  }
489 
490  return result;
491  }

◆ getSizeByTagFS()

nlohmann::json Crest::CrestClient::getSizeByTagFS ( const std::string &  tagname)
inherited

This method gets the number of iovs for tags matching pattern.

This method allows to select the count of iovs in a tag. This method works with the file storage. (This method is an analogue of the get_size_by_tag method in Python) The result is a JSON object.

Parameters
tagname- tag name.

◆ getSizeFS()

int Crest::CrestClient::getSizeFS ( const std::string &  tagname)
inherited

This metghod gets the number of iovs for the given tag.

This method allows to select the count of iovs in a tag. This method works with the file storage. This method works with the file storage. (This method is an analogue of the get_size method in Python)

Parameters
tagname- tag name.

Definition at line 2645 of file CrestApi.cxx.

2645  {
2646  int res = 0;
2647 
2648  try {
2650  int length = iovs.size();
2651  return length;
2652  }
2653  catch (...) {
2654  return res;
2655  }
2656 
2657  return res;
2658  }

◆ getTagDataInfo()

void Crest::CrestClient::getTagDataInfo ( const std::string &  tagname)
inherited

This is an auxillary method for checking how many unique IOVs(hashcodes) are in an IOV list.

It is used to check how many payload files are in the data storage, and how this number corresponds to the unique hashcode number. It works with the file data storage.

Parameters
tagname- tag name.

Definition at line 2712 of file CrestApi.cxx.

2712  {
2713  std::cout << std::endl << "test: getTagDataInfo" << std::endl;
2714 
2715  try {
2716  int info = getSizeFS(tagname);
2717  std::cout << std::endl << "IOV Number (" << tagname << ") = "
2718  << info << std::endl;
2719  }
2720  catch (const std::exception& e) {
2721  std::cout << std::endl << "test: getTagDataInfo (failed)" << std::endl;
2722  std::cout << e.what() << std::endl;
2723  }
2724 
2725  try {
2727  int niovs = iovList.size();
2728  std::list <std::string> hashList;
2729 
2730  for (int i = 0; i < niovs; i++) {
2731  if (iovList[i].find("payloadHash") != iovList[i].end()) {
2732  std::string hash = iovList[i]["payloadHash"];
2733  std :: list < std::string > :: iterator pos;
2734  pos = find(hashList.begin(), hashList.end(), hash);
2735  if (pos != hashList.end()) {
2736  } else {
2737  hashList.push_back(hash);
2738  }
2739  }
2740  }
2741 
2742  int hashNumber = hashList.size();
2743  std::cout << "Hash Number (" << tagname << ") = "
2744  << hashNumber << std::endl;
2745  }
2746  catch (const std::exception& e) {
2747  std::cout << std::endl << "ERROR getTagDataInfo: cannot get IOV List" << std::endl;
2748  std::cout << e.what() << std::endl;
2749  }
2750 
2751  std::string path = m_root_folder + s_FS_DATA_PATH;
2752  int dirNumber = 0;
2753 
2754  for (auto it : std::filesystem::directory_iterator(path)) {
2755  dirNumber = dirNumber + 1;
2756  }
2757  std::cout << "Directory Number (" << tagname << ") = "
2758  << dirNumber << std::endl;
2759  }

◆ getTagMetaInfo()

nlohmann::json Crest::CrestClient::getTagMetaInfo ( const std::string &  tagname)
inherited

This method gets a tag meta info from the CREST database.

Parameters
tagname- tag name
Returns
JSON with the tag meta information. Example:
tagMetaInfo(AtlasLayerMat_v16_ATLAS-R1-2012-02)=
  [
    {
     "tagName": "AtlasLayerMat_v16_ATLAS-R1-2012-02",
     "description": "{\"dbname\":\"OFLP200\",\"nodeFullpath\":\"/GLOBAL/TrackingGeo/LayerMaterialV2\",\"schemaName\":\"COOLOFL_GLOBAL\"}",
     "chansize": 1,
     "colsize": 1,
     "tagInfo": "{\"channel_list\":[{\"0\":\"\"}],\"node_description\":\"<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\\\"256\\\" clid=\\\"142190734\\\" /></addrHeader><typeName>Trk::LayerMaterialMap</typeName>\",\"payload_spec\":\"PoolRef:String4k\"}",
     "insertionTime": "2023-09-22T12:22:07+0000"
   }
 ]

Tag Meta Info JSON parameters:

tagName        string
description    string
chansize       integer($int32)
colsize        integer($int32)
tagInfo        string
insertionTime  string($date-time)

Definition at line 2037 of file CrestApi.cxx.

2037  {
2038  const char* method_name = "CrestClient::getTagMetaInfo";
2039 
2040  if (m_mode == FILESYSTEM_MODE) {
2041  return getTagMetaInfoFs(tagname);
2042  }
2043 
2044  std::string current_path = m_PATH;
2045  current_path += s_TAG_PATH;
2046  current_path += '/';
2047  current_path += tagname;
2048  current_path += s_META_PATH;
2049 
2050  std::string retv;
2051 
2052  nlohmann::json js = nullptr;
2053  retv = performRequest(current_path, GET, js, method_name);
2054 
2055  nlohmann::json respond = getJson(retv, method_name);
2056 
2057  return getResources(respond);
2058  }

◆ getTagMetaInfoElement()

std::string Crest::CrestClient::getTagMetaInfoElement ( const std::string &  name,
nlohmann::json js 
)
inherited

Auxillary method to get an element by name from the Tag Meta Info.

Parameters
name- an element name.
js- the Tag Meta Info in JSON format. Example:
  [{"node_description": " string of the folder description "},
   {"channel_list" : [0, 10, 20] },
   {"channel_names: ["first", "second", "third"]},
   {"payload_specification":"stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"}]

Definition at line 1936 of file CrestApi.cxx.

1936  {
1937  std::string result = "";
1938  int array_length = js.size();
1939  for (int i = 0; i < array_length; i++) {
1940  const nlohmann::json& elem = js[i];
1941  if (auto itr = elem.find(name); itr != elem.end()) {
1942  return *itr;
1943  }
1944  }
1945  return result;
1946  }

◆ getTagMetaInfoFs()

nlohmann::json Crest::CrestClient::getTagMetaInfoFs ( const std::string &  name)
inherited

This is an auxillary method, it gets a tag meta info from file system storage.

Parameters
tagname- tag name
Returns
JSON with the tag meta information.
See the tag JSON description in CrestClient::getTagMetaInfo method.

Definition at line 2205 of file CrestApi.cxx.

2205  {
2206  nlohmann::json js = nullptr;
2207  std::string file_path = m_root_folder;
2209  file_path += '/';
2210  file_path += name;
2212  try{
2213  std::string tag = getFileString(file_path);
2214  js = nlohmann::json::parse(tag);
2215  }
2216  catch (...) {
2217  throw std::runtime_error(
2218  "ERROR in CrestClient::getTagMetaInfoFs cannot get the tag meta information form file storage.");
2219  }
2220 
2221  return returnJArray(js);
2222  }

◆ getTagMetaInfoIOVDbSvc()

nlohmann::json Crest::CrestClient::getTagMetaInfoIOVDbSvc ( const std::string &  tagname)
inherited

This method gets a tag meta info from the CREST database in IOVDbSvc format.

Parameters
tagname- tag name

Definition at line 2120 of file CrestApi.cxx.

2120  {
2121  const char* method_name = "CrestClient::updateTagMetaInfo";
2122 
2123  checkFsException(method_name);
2124 
2126 
2127  nlohmann::json resource = js.at(0);
2128 
2130 
2131  return result;
2132  }

◆ isJson()

bool Crest::CrestClient::isJson ( const std::string &  str)
inherited

This method checks if a string is in the JSON format.

(It is an auxillary method to check the CREST Server response format.)

Parameters
str- the string to be checked.

Definition at line 1688 of file CrestApi.cxx.

1688  {
1689  try {
1691  return true;
1692  }
1693  catch (nlohmann::json::parse_error& e) {
1694  return false;
1695  }
1696  }

◆ listFolders()

nlohmann::json Crest::CrestClient::listFolders ( )
inherited

This method returns the folder list on CREST DB.

(This method is an analogue of the list_folders method in Python)

Definition at line 1163 of file CrestApi.cxx.

1163  {
1164  const char* method_name = "CrestClient::listFolders";
1165 
1166  checkFsException(method_name);
1167 
1168  std::string current_path = m_PATH + s_FOLDER_PATH;
1169 
1170  std::string retv;
1171 
1172  nlohmann::json js = nullptr;
1173 
1174  retv = performRequest(current_path, GET, js, method_name);
1175 
1176  nlohmann::json respond = getJson(retv, method_name);
1177 
1178  return getResources(respond);
1179  }

◆ listGlobalTags() [1/2]

nlohmann::json Crest::CrestClient::listGlobalTags ( )
inherited

This method finds a global tag lists.

The result is a JSON object. (This method is an analogue of the list_global_tags method in Python)

Returns
JSON array with the global tag list. Example:
Global tag list =
 [
   {
      "description": "A geometry like global tag",
      "insertionTime": "2023-11-01T08:45:09+0000",
      "insertionTimeMilli": 1698828309000,
      "name": "ATLAS-P2-ITK-22-02-00",
      "release": "1",
      "scenario": "undefined",
      "snapshotTime": "2023-11-01T08:45:09+0000",
      "snapshotTimeMilli": 1698828309000,
      "type": "U",
      "validity": 1,
      "workflow": "undefined"
   },
   ...
 ]

See the single global tag JSON description in CrestClient::findGlobalTag method.

Definition at line 773 of file CrestApi.cxx.

773  {
774  const char* method_name = "CrestClient::listGlobalTags";
775 
776  checkFsException(method_name);
777 
778  std::string current_path = m_PATH;
779  current_path += s_GLOBALTAG_PATH;
780  std::string retv;
781  nlohmann::json js = nullptr;
782  retv = performRequest(current_path, GET, js, method_name);
783  nlohmann::json respond = getJson(retv, method_name);
784 
785  return getResources(respond);
786  }

◆ listGlobalTags() [2/2]

nlohmann::json Crest::CrestClient::listGlobalTags ( const std::string &  name,
int  size,
int  page,
const std::string &  sort 
)
inherited

This method returns the global tag list.

It is a verion of this method with all parameters.

Parameters
name- global tag name pattern,
size- page size,
page- page number,
sort- sorting order.
Returns
JSON array with the global tag list.
See the global tag list JSON description in CrestClient::listGlobalTags method.

Definition at line 805 of file CrestApi.cxx.

805  {
806  const char* method_name = "CrestClient::listGlobalTags";
807 
808  checkFsException(method_name);
809 
810  std::string tagname = name;
811 
812  if (tagname.find("%25") == std::string::npos) {
813  replaceSymbols(tagname, "%", "%25");
814  replaceSymbols(tagname, "*", "%25");
815  }
816 
817  std::string current_path = m_PATH;
818  current_path += s_GLOBALTAG_PATH;
819  if (!name.empty()) {
820  std::string nameString = "?name=";
821  nameString += tagname;
822  current_path += nameString;
823  current_path += "&size=";
824  current_path += std::to_string(size);
825  current_path += "&page=";
826  current_path += std::to_string(page);
827  current_path += "&sort=";
828  current_path += sort;
829  } else {
830  current_path += "?size=";
831  current_path += std::to_string(size);
832  current_path += "&page=";
833  current_path += std::to_string(page);
834  current_path += "&sort=";
835  current_path += sort;
836  }
837 
838  std::string retv;
839  nlohmann::json js = nullptr;
840  retv = performRequest(current_path, GET, js, method_name);
841  nlohmann::json respond = getJson(retv, method_name);
842 
843  return getResources(respond);
844  }

◆ listGlobalTagsAsString()

std::string Crest::CrestClient::listGlobalTagsAsString ( )
inherited

This method finds a global tag lists.

The rusult is a string. (This method is an analogue of the list_global_tags_as_string method in Python)

Returns
string with the JSON array with the global tag list.
See the global tag list JSON description in CrestClient::listGlobalTags method.

Definition at line 788 of file CrestApi.cxx.

788  {
789  const char* method_name = "CrestClient::listGlobalTagsAsString";
790 
791  checkFsException(method_name);
792 
793  std::string current_path = m_PATH;
794  current_path += s_GLOBALTAG_PATH;
795 
796  std::string retv;
797 
798  nlohmann::json js = nullptr;
799 
800  retv = performRequest(current_path, GET, js, method_name);
801 
802  return retv;
803  }

◆ listPayloadTagInfo() [1/2]

nlohmann::json Crest::CrestClient::listPayloadTagInfo ( )
inherited

This method retrieves monitoring information on all payloads as a list of payload tag information.

(This method is an analogue of the list_payload_tag_info method in Python)

Returns
JSON array with the payload monitoring tag information. Example:
 payloadTagInfo(TrtCalibT0-MC-run2-run3_00-01)=
 [
    {
       "tagname": "TrtCalibT0-MC-run2-run3_00-01",
       "niovs": 9,
       "totvolume": 63630.0,
       "avgvolume": 7070.0
    }
 ]

JSON parameters:

 tagname     string          tag name
 niovs       integer         number of IOVs
 totvolume   number($float)  total volume
 avgvolume   number($float)  average volume
 

Definition at line 1023 of file CrestApi.cxx.

1023  {
1024  const char* method_name = "CrestClient::getPayloadTagInfo";
1025 
1026  checkFsException(method_name);
1027 
1028  std::string current_path = m_PATH;
1029  current_path += s_MONITORING_PAYLOAD_PATH;
1030 
1031  std::string retv;
1032 
1033  nlohmann::json js = nullptr;
1034 
1035  retv = performRequest(current_path, GET, js, method_name);
1036 
1037  nlohmann::json respond = getJson(retv, method_name);
1038 
1039  return getResources(respond);
1040  }

◆ listPayloadTagInfo() [2/2]

nlohmann::json Crest::CrestClient::listPayloadTagInfo ( const std::string &  tagname)
inherited

This method retrieves monitoring information on payload as a list of payload tag information.

(This method is an analogue of the list_payload_tag_info method in Python) @params tagname - tag name.

Returns
JSON array with the payload monitoring tag information.
See CrestClient::listPayloadTagInfo method.

Definition at line 1002 of file CrestApi.cxx.

1002  {
1003  const char* method_name = "CrestClient::getPayloadTagInfo";
1004 
1005  checkFsException(method_name);
1006 
1007  std::string current_path = m_PATH;
1008  current_path += s_MONITORING_PAYLOAD_PATH;
1009  current_path += "?tagname=";
1010  current_path += tagname;
1011 
1012  std::string retv;
1013 
1014  nlohmann::json js = nullptr;
1015 
1016  retv = performRequest(current_path, GET, js, method_name);
1017 
1018  nlohmann::json respond = getJson(retv, method_name);
1019 
1020  return getResources(respond);
1021  }

◆ listRunLumiInfo()

nlohmann::json Crest::CrestClient::listRunLumiInfo ( )
inherited

This method gets full list of run/lumi information data.

(This method is an analogue of the list_run_lumi_info method in Python)

Definition at line 1198 of file CrestApi.cxx.

1198  {
1199  const char* method_name = "CrestClient::listRunLumiInfo";
1200 
1201  checkFsException(method_name);
1202 
1203  std::string current_path = m_PATH + s_RUNINFO_PATH;
1204 
1205  std::string retv;
1206 
1207  nlohmann::json js = nullptr;
1208 
1209  retv = performRequest(current_path, GET, js, method_name);
1210 
1211  nlohmann::json respond = getJson(retv, method_name);
1212 
1213  return getResources(respond);
1214  }

◆ listTags() [1/3]

nlohmann::json Crest::CrestClient::listTags ( const std::string &  name,
int  size,
int  page,
const std::string &  sort 
)
inherited

This method returns the tag list.

It is a verion of this method with all parameters. (This method is an analogue of the list_tags method in Python)

Parameters
name- tag name pattern,
size- page size,
page- page number,
sort- sorting order.
Returns
JSON array with the tag list.
See the taglist JSON description in CrestClient::listTags method.

Definition at line 167 of file CrestApi.cxx.

167  {
168  const char* method_name = "CrestClient::listTags";
169 
170  checkFsException(method_name);
171 
172  std::string tagname = name;
173 
174  if (tagname.find("%25") == std::string::npos) {
175  replaceSymbols(tagname, "%", "%25");
176  replaceSymbols(tagname, "*", "%25");
177  }
178 
179  std::string current_path = m_PATH;
180  current_path += s_TAG_PATH;
181 
182  if (!name.empty()) {
183  std::string nameString = "?name=";
184  nameString += tagname;
185  current_path += nameString;
186  current_path += "&size=";
187  current_path += std::to_string(size);
188  current_path += "&page=";
189  current_path += std::to_string(page);
190  current_path += "&sort=";
191  current_path += sort;
192  } else {
193  current_path += "?size=";
194  current_path += std::to_string(size);
195  current_path += "&page=";
196  current_path += std::to_string(page);
197  current_path += "&sort=";
198  current_path += sort;
199  }
200 
201  nlohmann::json js = nullptr;
202  std::string retv = performRequest(current_path, GET, js, method_name);
203 
204  nlohmann::json respond = getJson(retv, method_name);
205 
206  return getResources(respond);
207  }

◆ listTags() [2/3]

nlohmann::json Crest::CrestClient::listTags ( int  size,
int  page 
)
inherited

This method returns the tag list.

It is a verion of this method with additional parameters. (This method is an analogue of the list_tags method in Python)

Parameters
size- page size.
page- page number.
Returns
JSON array with the tag list.
See the taglist JSON description in CrestClient::listTags method.

Definition at line 121 of file CrestApi.cxx.

121  {
122  const char* method_name = "CrestClient::listTags";
123 
124  checkFsException(method_name);
125 
126  int size_default = 1000;
127  int page_default = 0;
128  std::string size_param = "";
129  std::string page_param = "";
130  std::string params = "";
131 
132  if (size == size_default && page == page_default) {
133  nlohmann::json respond = listTags();
134  return getResources(respond);
135  }
136 
137  if (size != size_default) {
138  size_param = "size=";
139  size_param += std::to_string(size);
140  params += size_param;
141  }
142  if (page != page_default) {
143  page_param = "page=";
144  page_param += std::to_string(page);
145  if (page_param.empty()) {
146  params += page_param;
147  } else {
148  params += '&';
149  params += page_param;
150  }
151  }
152 
153  std::string current_path = m_PATH;
154  current_path += s_TAG_PATH;
155  current_path += '?';
156  current_path += params;
157  std::string retv;
158 
159  nlohmann::json js = nullptr;
160  retv = performRequest(current_path, GET, js, method_name);
161 
162  nlohmann::json respond = getJson(retv, method_name);
163 
164  return getResources(respond);
165  }

◆ listTags() [3/3]

nlohmann::json Crest::CrestClient::listTags ( void  )
inherited

This method returns the tag list.

(This method is an analogue of the list_tags method in Python)

Returns
JSON array with the tag list. Example:
[
   {
       "description": "A new tag for testing",
       "endOfValidity": 0,
       "insertionTime": "2023-04-27T18:51:44+0000",
       "lastValidatedTime": -1,
       "modificationTime": "2023-10-27T13:05:38+0000",
       "name": "A-TEST-TAG-03",
       "payloadSpec": "JSON",
       "synchronization": "any",
       "timeType": "time"
   },
 ...
]

See the single tag JSON description in CrestClient::findTag method.

Definition at line 103 of file CrestApi.cxx.

103  {
104  const char* method_name = "CrestClient::listTags";
105 
106  checkFsException(method_name);
107 
108  std::string current_path = m_PATH;
109  current_path += s_TAG_PATH;
110 
111  std::string retv;
112 
113  nlohmann::json js = nullptr;
114  retv = performRequest(current_path, GET, js, method_name);
115 
116  nlohmann::json respond = getJson(retv, method_name);
117 
118  return getResources(respond);
119  }

◆ make_url()

std::string Crest::CrestClient::make_url ( const std::string &  address) const
privateinherited

Definition at line 90 of file CrestApi.cxx.

90  {
91  std::string str("http://");
92  str += m_host;
93  str += ':';
94  str += m_port;
95  str += address;
96  return str;
97 }

◆ ParseXMLOutput()

std::string Crest::CrestClient::ParseXMLOutput ( std::string_view  xmlBuffer)
privateinherited

This method removes all XML/HTML tags from a string.

(It is an auxillary method to clear the CREST Server response.)

Parameters
xmlBuffer- the text (a std::string ) to be cleared.

Definition at line 1656 of file CrestApi.cxx.

1656  {
1657  bool copy = true;
1658 
1659  std::string plainString = "";
1660 
1661  // remove all xml tags
1662  for (long unsigned int i = 0; i < xmlBuffer.length(); i++) {
1663  char convertc = xmlBuffer[i];
1664 
1665  if (convertc == '<') copy = false;
1666  else if (convertc == '>') {
1667  copy = true;
1668  continue;
1669  }
1670 
1671  if (copy) plainString += convertc;
1672  }
1673 
1674  return plainString;
1675  }

◆ performRequest() [1/3]

std::string Crest::CrestClient::performRequest ( const std::string &  current_path,
Action  action,
nlohmann::json js 
)
privateinherited

General auxiliary method to make request to the CREST Server.

This method is used by other methods realizing the requests with the concrete kinds of data (iovs|payloads|tags…).

Parameters
current_path- URL request path
action- Action (GET|POST|DELETE)
js- a JSON object which has to be send or changed with this request. If this argument has to be void it has to be set as nullptr.

Definition at line 1366 of file CrestApi.cxx.

1366  {
1367  const char* method = "Unknown";
1368 
1369  return performRequest(current_path, action, js, method);
1370  }

◆ performRequest() [2/3]

std::string Crest::CrestClient::performRequest ( const std::string &  current_path,
Action  action,
nlohmann::json js,
const char *  method_name 
)
privateinherited

General auxillary method to make request to the CREST Server.

This method is used by other methods realizing the requests with the concrete kinds of data (iovs|payloads|tags…).

Parameters
current_path- URL request path
action- Action (GET|POST|DELETE)
js- a JSON object which has to be send or changed with this request. If this argument has to be void it has to be set as nullptr.
method_name- the name of method which called this method. This parameter is used in the error messages.

Definition at line 1289 of file CrestApi.cxx.

1290  {
1291  CURL* curl;
1292  CURLcode res;
1293 
1294 
1295  /* Enable tracing of ascii data */
1296  //sanitise the current path
1297  std::string sanitisedPath(current_path);
1298  auto caretPosition = sanitisedPath.find('^');
1299  if (caretPosition != std::string::npos) sanitisedPath.replace(caretPosition, 1, "%5E");
1300  /* get a curl handle */
1301  curl = curl_easy_init();
1302  std::string stt;
1303  struct curl_slist* headers = NULL;
1304  if (curl) {
1305  std::string url = make_url(sanitisedPath);
1306  std::string s;
1307  std::cout << "cURL request to " << url << std::endl;
1308 
1309  if (m_CREST_PROXY) {
1310  // The environment variable exists, and 'socksProxy' now contains its value
1311  std::cout << "SOCKS proxy: " << m_CREST_PROXY << std::endl;
1312  // Set the proxy type (replace with your proxy type details)
1313  curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
1314 
1315  // Set the proxy address and port (replace with your SOCKS proxy details)
1316  curl_easy_setopt(curl, CURLOPT_PROXY, m_CREST_PROXY);
1317  }
1318 
1319  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
1320  if (js.is_null()) {
1321  if (action == DELETE) curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
1322  } else {
1323  stt = js.dump();
1324 
1325  if (action == PUT) curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
1326  headers = curl_slist_append(headers, "Accept: */*");
1327  headers = curl_slist_append(headers, "Content-Type: application/json");
1328 
1329  headers = curl_slist_append(headers, "Expect:");
1330  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
1331  curl_easy_setopt(curl, CURLOPT_POST, 1L);
1332 
1333  /* set where to read from (on Windows you need to use READFUNCTION too) */
1334  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, stt.c_str());
1335  }
1336 
1337  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
1338  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
1339 
1340 
1341  /* Perform the request, res will get the return code */
1342  res = curl_easy_perform(curl);
1343 
1344 
1345  // data to check the errors in the server response:
1346  long response_code;
1347  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
1348 
1349  /* always cleanup */
1350  curl_easy_cleanup(curl);
1351  curl_slist_free_all(headers);
1352 
1353  curl_global_cleanup();
1354 
1355  // error checking in the server response:
1356  checkResult(res, response_code, s, method_name);
1357 
1358  return s;
1359  }
1360 
1361  throw std::runtime_error(std::string("ERROR in ") + std::string(method_name) + " | CURL not init");
1362  }

◆ performRequest() [3/3]

std::string Crest::CrestClient::performRequest ( const std::string &  current_path,
Action  action,
nlohmann::json js,
std::ofstream &  out 
)
privateinherited

General auxillary method to make request to the CREST Server.

This method used to get a Blob as a stream. See method getBlobInStream(std::string& hash, std::ofstream& out).

Parameters
current_path- URL request path
action- Action (GET|POST|DELETE)
js- a JSON object which has to be send or changed with this request. If this argument has to be void it has to be set as nullptr.
out- stream to get the result

Definition at line 1378 of file CrestApi.cxx.

1379  {
1380  boost::asio::streambuf response;
1381  boost::asio::io_service io_service;
1382 
1383  try {
1384  // Get a list of endpoints corresponding to the server name.
1387  boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
1388 
1389  // Try each endpoint until we successfully establish a connection.
1390  boost::asio::ip::tcp::socket socket(io_service);
1391  boost::asio::connect(socket, endpoint_iterator);
1392 
1393  std::string retv = "Invalid response\n";
1394 
1395  boost::asio::streambuf request;
1396  std::ostream request_stream(&request);
1397 
1398  std::string cmd_line = "";
1399  if (action == GET) cmd_line = "GET";
1400  else if (action == PUT) cmd_line = "PUT";
1401  else if (action == DELETE) cmd_line = "DELETE";
1402 
1403  if (js.is_null()) {
1404  request_stream << cmd_line << " " << current_path << " HTTP/1.0\r\n";
1405  request_stream << "Host: " << m_host << ':' << m_port << " \r\n";
1406  request_stream << "Accept: */*\r\n";
1407  request_stream << "Connection: close\r\n\r\n";
1408  } else {
1409  std::string s = js.dump();
1410  request_stream << action << " " << current_path << " HTTP/1.0\r\n";
1411  request_stream << "Host: " << m_host << ':' << m_port << " \r\n";
1412  request_stream << "Content-Type: application/json; \r\n";
1413  request_stream << "Accept: */*\r\n";
1414  request_stream << "Content-Length: " << s.length() << "\r\n";
1415  request_stream << "Connection: close\r\n\r\n";
1416  request_stream << s;
1417  }
1418 
1419 
1420  //begin request
1421 
1422  // Send the request.
1423  boost::asio::write(socket, request);
1424 
1425  // Read the response status line. The response streambuf will automatically
1426  // grow to accommodate the entire line. The growth may be limited by passing
1427  // a maximum size to the streambuf constructor.
1428 
1429  boost::asio::read_until(socket, response, "\r\n");
1430 
1431 
1432 
1433  boost::asio::read_until(socket, response, "\r\n");
1434 
1435  // Check that response is OK.
1436  std::istream response_stream(&response);
1437  std::string http_version;
1438  response_stream >> http_version;
1439  unsigned int status_code;
1440  response_stream >> status_code;
1441 
1442  std::string status_message;
1443  std::getline(response_stream, status_message);
1444 
1445 
1446  if (!response_stream || http_version.substr(0, 5) != "HTTP/") {
1447  std::cout << "Invalid response" << std::endl;
1448  std::cout << "response_stream : " << status_code << std::endl; // new
1449  return retv;
1450  }
1451  if (status_code != 200) {
1452  std::cout << "Response returned with status code " << status_code << std::endl;
1453 
1454  return retv;
1455  }
1456 
1457  // Read the response headers, which are terminated by a blank line.
1458  boost::asio::read_until(socket, response, "\r\n\r\n");
1459 
1460  // Process the response headers.
1461  std::string header;
1462  while (std::getline(response_stream, header) && header != "\r") {
1463  std::cout << header << std::endl;
1464  }
1465  std::cout << std::endl;
1466 
1467  std::ostringstream txt;
1468 
1469  // Write whatever content we already have to output.
1470  if (response.size() > 0) out << &response;
1471 
1472 
1473  // Read until EOF, writing data to output as we go.
1475  while (boost::asio::read(socket, response,
1476  boost::asio::transfer_at_least(1), error))
1477  out << &response;
1478 
1479  if (error != boost::asio::error::eof) {
1480  std::cerr << "connection error" << std::endl;
1481  std::string st0 = "";
1482  return st0;
1483  }
1484 
1485  retv = status_code;
1486  return retv;
1487 
1488  //end request
1489  }
1490  catch (boost::system::system_error& e) {
1491  std::cerr << e.what() << " | " << e.code() << std::endl;
1492  std::string st0 = "";
1493  return st0;
1494  }
1495  catch (...) {
1496  std::cerr << "connection error" << std::endl;
1497  std::string st0 = "";
1498  return st0;
1499  }
1500  }

◆ removeCR()

std::string Crest::CrestClient::removeCR ( const std::string &  str)
privateinherited

This method removes all end of line and carriage return symbols from a string.

(It is an auxillary method to clear the CREST Server response.)

Parameters
str- the text (a std::string ) to be cleared.

Definition at line 1677 of file CrestApi.cxx.

1677  {
1678  std::string str2 = str;
1679  std::replace(str2.begin(), str2.end(), '\n', '|');
1680  char needle = '\r';
1681  size_t pos;
1682  while ((pos = str2.find(needle)) != str2.npos) {
1683  str2.erase(pos, 1);
1684  }
1685  return str2;
1686  }

◆ removeGlobalTag()

void Crest::CrestClient::removeGlobalTag ( const std::string &  name)
inherited

This method allows to remove a Global Tag form CREST DB.

(This method is an analogue of the remove_global_tag method in Python)

Parameters
name- global tag name

Definition at line 758 of file CrestApi.cxx.

758  {
759  const char* method_name = "CrestClient::removeGlobalTag";
760 
761  checkFsException(method_name);
762 
763  std::string current_path = m_PATH;
764  current_path += s_ADMIN_PATH;
765  current_path += s_GLOBALTAG_PATH;
766  current_path += '/';
767  current_path += name;
768  std::string retv;
769  nlohmann::json js = nullptr;
770  retv = performRequest(current_path, DELETE, js, method_name);
771  }

◆ removeTag()

void Crest::CrestClient::removeTag ( const std::string &  tagName)
inherited

This method allows to remove a Tag.

(This method is an analogue of the remove_tag method in Python)

Parameters
tagName- tag name

Definition at line 209 of file CrestApi.cxx.

209  {
210  const char* method_name = "removeTag";
211 
212  checkFsException(method_name);
213 
214  std::string current_path = m_PATH;
215  current_path += s_ADMIN_PATH;
216  current_path += s_TAG_PATH;
217  current_path += '/';
218  current_path += tagName;
219  std::string retv;
220 
221  nlohmann::json js = nullptr;
222 
223  retv = performRequest(current_path, DELETE, js, method_name);
224  }

◆ removeTagFromGlobalTagMap()

void Crest::CrestClient::removeTagFromGlobalTagMap ( const std::string &  global_tag,
const std::string &  tag,
const std::string &  label 
)
inherited

This method removes a tag with the name tag and the label from the global tag map with name global_tag.

Parameters
global_tag- global tag name.
tag- tag name.
label- tag label in the global tag map.

Definition at line 2902 of file CrestApi.cxx.

2902  {
2903 
2904  const char* method_name = "CrestClient::removeTagFromGlobalTagMap";
2905 
2906  checkFsException(method_name);
2907 
2908  std::string current_path = m_PATH;
2909  current_path += s_GLOBALTAG_MAP_PATH;
2910  current_path += '/';
2911  current_path += global_tag;
2912  current_path += '?';
2913  current_path += "tagname=";
2914  current_path += tag;
2915  current_path += "&label=";
2916  current_path += label;
2917 
2918  std::string retv;
2919 
2920  nlohmann::json js = nullptr;
2921 
2922  retv = performRequest(current_path, DELETE, js, method_name);
2923  }

◆ replaceSymbols()

void Crest::CrestClient::replaceSymbols ( std::string &  str,
const std::string &  from,
const std::string &  to 
)
inherited

This auxilary method replaces the substring from by the substring to.

Parameters
str- the string, where it is necessary to replace a substring.
from- the substring to be replaced.
to- the new substring to replace to replace the old one.

Definition at line 3156 of file CrestApi.cxx.

3157  {
3158  size_t pos = 0;
3159  while((pos = subject.find(search, pos)) != std::string::npos) {
3160  subject.replace(pos, search.length(), replace);
3161  pos += replace.length();
3162  }
3163  }

◆ returnJArray()

nlohmann::json Crest::CrestClient::returnJArray ( nlohmann::json  js)
inherited

This auxillary method creates a JSON array from a JSON object.

It used to convert a single objects (such as tags and global tags to JSON array in methods which retrive the data from a file starage.

Parameters
js- JSON object.

Definition at line 2639 of file CrestApi.cxx.

2639  {
2641  result.push_back(js);
2642  return result;
2643  }

◆ selectGroups() [1/2]

nlohmann::json Crest::CrestClient::selectGroups ( const std::string &  tagname)
inherited

Select groups for a given tagname.

This method allows to select a list of groups. The result is a JSON object. (This method is an analogue of the select_groups method in Python)

Parameters
tagname- tag name.

Definition at line 579 of file CrestApi.cxx.

579  {
580  const char* method_name = "CrestClient::selectGroups";
581 
582  checkFsException(method_name);
583 
584  std::string current_path = m_PATH;
585  current_path += s_IOV_PATH;
586 
587  current_path += "?method=";
588  current_path += s_METHOD_GROUPS;
589  current_path += "&tagname=";
590 
591  current_path += tagname;
592 
593  std::string retv;
594 
595  nlohmann::json js = nullptr;
596 
597  retv = performRequest(current_path, GET, js, method_name);
598 
599  nlohmann::json respond = getJson(retv, method_name);
600 
601  return getResources(respond);
602  }

◆ selectGroups() [2/2]

nlohmann::json Crest::CrestClient::selectGroups ( const std::string &  tagname,
long  snapshot 
)
inherited

Select groups for a given tagname.

This method allows to select a list of groups. The result is a JSON object. (This method is an analogue of the select_groups method in Python)

Parameters
tagname- tag name.
snapshot- snapshot.

Definition at line 604 of file CrestApi.cxx.

604  {
605  const char* method_name = "CrestClient::selectGroups";
606 
607  checkFsException(method_name);
608 
609  std::string current_path = m_PATH;
610  current_path += s_IOV_PATH;
611 
612  current_path += "?method=";
613  current_path += s_METHOD_GROUPS;
614  current_path += "&tagname=";
615 
616  current_path += tagname;
617  current_path += "&snapshot=";
618  current_path += std::to_string(snapshot);
619 
620  std::string retv;
621 
622  nlohmann::json js = nullptr;
623  retv = performRequest(current_path, GET, js, method_name);
624 
625  nlohmann::json respond = getJson(retv, method_name);
626 
627  return getResources(respond);
628  }

◆ selectIovs() [1/3]

nlohmann::json Crest::CrestClient::selectIovs ( const std::string &  tagname)
inherited

Select iovs for a given tagname.

This method allows to select a list of iovs in a tag for a given snapshot time. The result is a JSON object. (This method is an analogue of the select_iovs method in Python)

Parameters
tagname- tag name.
snapshot- snapshot.
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 493 of file CrestApi.cxx.

493  {
494  const char* method_name = "CrestClient::selectIovs";
495 
496  checkFsException(method_name);
497 
498  std::string current_path = m_PATH;
499  current_path += s_IOV_PATH;
500  current_path += "?method=";
501  current_path += s_METHOD_IOVS;
502  current_path += "&tagname=";
503 
504  current_path += tagname;
505 
506  std::string retv;
507 
508  nlohmann::json js = nullptr;
509 
510  retv = performRequest(current_path, GET, js, method_name);
511 
512  nlohmann::json respond = getJson(retv, method_name);
513 
514  return getResources(respond);
515  }

◆ selectIovs() [2/3]

nlohmann::json Crest::CrestClient::selectIovs ( const std::string &  tagname,
long  since,
long  until,
long  snapshot = 0 
)
inherited

This method selects all iovs for a given tag name and for the selected time interval (since-until).

The result is a JSON array. It is a verion of this method with all parameters. This method works with the CREST server. If until=-1 it means until is infinity, in this case "until=INF" in the URL request.

Parameters
tagname- tag name.
since- start time.
until- end time.
snapshot- snapshot (the default value is 0)
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 544 of file CrestApi.cxx.

544  {
545  const char* method_name = "CrestClient::selectIovs";
546 
547  checkFsException(method_name);
548 
549  std::string current_path = m_PATH;
550  current_path += s_IOV_PATH;
551 
552  current_path += "?method=";
553  current_path += s_METHOD_IOVS;
554  current_path += "&tagname=";
555 
556  current_path += tagname;
557  current_path += "&since=";
558  current_path += std::to_string(since);
559  current_path += "&until=";
560  if (until == -1) {
561  current_path += "INF";
562  } else {
563  current_path += std::to_string(until);
564  }
565  current_path += "&snapshot=";
566  current_path += std::to_string(snapshot);
567 
568  std::string retv;
569 
570  nlohmann::json js = nullptr;
571 
572  retv = performRequest(current_path, GET, js, method_name);
573 
574  nlohmann::json respond = getJson(retv, method_name);
575 
576  return getResources(respond);
577  }

◆ selectIovs() [3/3]

nlohmann::json Crest::CrestClient::selectIovs ( const std::string &  tagname,
long  snapshot 
)
inherited

Select iovs for a given tagname.

This method allows to select a list of iovs in a tag for a given snapshot time. The result is a JSON object. (This method is an analogue of the select_iovs method in Python)

Parameters
tagname- tag name.
snapshot- snapshot.
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 517 of file CrestApi.cxx.

517  {
518  const char* method_name = "CrestClient::selectIovs";
519 
520  checkFsException(method_name);
521 
522  std::string current_path = m_PATH;
523  current_path += s_IOV_PATH;
524 
525  current_path += "?method=";
526  current_path += s_METHOD_IOVS;
527  current_path += "&tagname=";
528 
529  current_path += tagname;
530  current_path += "&snapshot=";
531  current_path += std::to_string(snapshot);
532 
533  std::string retv;
534 
535  nlohmann::json js = nullptr;
536 
537  retv = performRequest(current_path, GET, js, method_name);
538 
539  nlohmann::json respond = getJson(retv, method_name);
540 
541  return getResources(respond);
542  }

◆ selectIovsFS()

nlohmann::json Crest::CrestClient::selectIovsFS ( const std::string &  tagname,
long  since,
long  until 
)
inherited

This method selects all iovs for a given tag name and for the selected time interval (since-until).

The result is a JSON array. It is a verion of this method with all parameters. This method works with the file storage. If until=-1 it means until is infinity, in this case "until=INF" in the URL request.

Parameters
tagname- tag name.
since- start time.
until- end time.
Returns
JSON array with the IOV list.
See the IOV list JSON description in CrestClient::findAllIovs method.

Definition at line 2689 of file CrestApi.cxx.

2689  {
2691 
2692  try{
2694  int niovs = iovList.size();
2695  for (int i = 0; i < niovs; i++) {
2696  if (iovList[i].find("since") != iovList[i].end()) {
2697  ;
2698  long currentS = iovList[i]["since"];
2699  if (currentS >= since && currentS <= until) {
2700  js.push_back(iovList[i]);
2701  }
2702  }
2703  }
2704  }
2705  catch (...) {
2706  throw std::runtime_error("ERROR in CrestClient::selectIovsFS : cannot get the iov list form file storage");
2707  }
2708 
2709  return js;
2710  }

◆ shortListTagsFs()

std::list< std::string > Crest::CrestClient::shortListTagsFs ( )
inherited

This method returns a tag list stored in the file storage.

This is the auxilary method. The result is the tag names only (as a string list). (The old name of this method is short_list_tags_fs)

Definition at line 1749 of file CrestApi.cxx.

1749  {
1750  std::list<std::string> tag_list;
1752  for (auto i = std::filesystem::directory_iterator(p); i != std::filesystem::directory_iterator(); i++) {
1753  std::string file = i->path().filename().string();
1754 
1755  if (file != "data") {
1756  tag_list.push_back(file);
1757  } else continue;
1758  }
1759  return tag_list;
1760  }

◆ split()

std::vector< std::string > Crest::CrestClient::split ( std::string_view  str,
char  delim 
)
privateinherited

Auxillary method to split a string.

Parameters
str- a string to split.
delim- a deliminator.

Definition at line 1982 of file CrestApi.cxx.

1982  {
1983  std::vector<std::string> tokens;
1984  std::size_t prev = 0, pos = 0;
1985  do {
1986  pos = str.find(delim, prev);
1987  if (pos == std::string::npos) pos = str.length();
1988  std::string_view token = str.substr(prev, pos - prev);
1989  if (!token.empty()) tokens.emplace_back(token);
1990  prev = pos + 1;
1991  } while (pos < str.length() && prev < str.length());
1992  return tokens;
1993  }

◆ storeBatchIOVs()

void Crest::CrestClient::storeBatchIOVs ( nlohmann::json js)
inherited

This method stores an IOV set on the CREST server.

The IOVs are send as a JSON array.

Parameters
js- IOV set.

Definition at line 630 of file CrestApi.cxx.

630  {
631  const char* method_name = "CrestClient::storeBatchIOVs";
632 
633  checkFsException(method_name);
634 
635  /*
636 
637  Request Example:
638 
639  curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST
640  http://crest-02.cern.ch:8090/crestapi/iovs/storebatch
641  -d '{"size": 2, "datatype": "iovs", "format": "IovSetDto","resources":
642  [
643  {"payloadHash": "9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0","since": 200,"tagName":
644  "test_MvG10"},
645  {"payloadHash": "3e744b9dc39389baf0c5a0660589b8402f3dbb49b89b3e75f2c9355852a3c677","since": 250,"tagName":
646  "test_MvG10"}
647  ]
648  }'
649  */
650 
651  int n = js.size();
652 
654  {
655  {"size", n},
656  {"datatype", "iovs"},
657  {"format", "IovSetDto"},
658  {"resources", js}
659  };
660 
661 
662  std::string current_path = m_PATH;
663  current_path += s_IOV_PATH;
664 
665  std::string retv;
666 
667  retv = performRequest(current_path, POST, arg, method_name);
668  }

◆ storeBatchPayloadFilesRequest()

std::string Crest::CrestClient::storeBatchPayloadFilesRequest ( const std::string &  tag,
uint64_t  endtime,
const std::string &  js 
)
inherited

This is an auxilary method to make an request to store several payloads from files in the batch mode.

Parameters
tag- tag name.
endtime- end time.
js- payloads in the JSON format.

Definition at line 2948 of file CrestApi.cxx.

2948  {
2949  std::string current_path = m_PATH;
2950  current_path += s_PAYLOAD_PATH;
2951 
2952  nlohmann::json json0 = getJson(js);
2953  nlohmann::json resources = nullptr;
2954 
2955  auto subjectIdIter1 = json0.find("resources");
2956  if (subjectIdIter1 != json0.end()){
2957  resources = json0["resources"];
2958  }
2959 
2960  int partN = resources.size();
2961 
2962  CURL* curl;
2963  CURLcode res;
2964 
2965  // get a curl handle
2966 
2967  curl_global_init(CURL_GLOBAL_DEFAULT);
2968  curl = curl_easy_init();
2969 
2970  struct curl_slist* headers = NULL;
2971  if (curl) {
2972  std::string url = make_url(current_path);
2973  std::string s;
2974 
2975  if (m_CREST_PROXY) {
2976  // The environment variable exists, and 'socksProxy' now contains its value
2977  std::cout << "SOCKS proxy: " << m_CREST_PROXY << std::endl;
2978  // Set the proxy type (replace with your proxy type details)
2979  curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
2980 
2981  // Set the proxy address and port (replace with your SOCKS proxy details)
2982  curl_easy_setopt(curl, CURLOPT_PROXY, m_CREST_PROXY);
2983  }
2984 
2985  // First set the URL that is about to receive our POST. This URL can
2986  // just as well be a https:
2987  // URL if that is what should receive the data.
2988 
2989  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
2990 
2991  headers = curl_slist_append(headers, "X-Crest-PayloadFormat: FILE"); // MvG
2992  headers = curl_slist_append(headers, "Accept: */*");
2993  headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
2994 
2995  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
2996 
2997  // Create the form for new version
2998 #if LIBCURL_VERSION_MAJOR < 8
2999  struct curl_httppost* formpost = NULL;
3000  struct curl_httppost* lastptr = NULL;
3001  curl_formadd(&formpost,
3002  &lastptr,
3003  CURLFORM_COPYNAME, "tag",
3004  CURLFORM_COPYCONTENTS, tag.c_str(),
3005  CURLFORM_END);
3006 #else
3007  curl_mime* mime = curl_mime_init(curl);
3008  {
3009  curl_mimepart* part = curl_mime_addpart(mime);
3010  curl_mime_name(part, "tag");
3011  curl_mime_data(part, tag.c_str(), tag.size());
3012  }
3013 #endif
3014  if (endtime != 0) {
3015 #if LIBCURL_VERSION_MAJOR < 8
3016  curl_formadd(&formpost,
3017  &lastptr,
3018  CURLFORM_COPYNAME, "endtime",
3019  CURLFORM_COPYCONTENTS, std::to_string(endtime).c_str(),
3020  CURLFORM_END);
3021 #else
3022  std::string endtime_s = std::to_string(endtime);
3023  curl_mimepart* part = curl_mime_addpart(mime);
3024  curl_mime_name(part, "endtime");
3025  curl_mime_data(part, endtime_s.c_str(), endtime_s.size());
3026 #endif
3027  }
3028 #if LIBCURL_VERSION_MAJOR < 8
3029  curl_formadd(&formpost,
3030  &lastptr,
3031  CURLFORM_COPYNAME, "storeset",
3032  CURLFORM_COPYCONTENTS, js.c_str(),
3033  CURLFORM_END);
3034 
3035  for (int i = 0; i < partN; i++){
3036  nlohmann::json element = resources[i];
3037  std::string file_param;
3038 
3039  auto subjectIdIter1 = element.find("data");
3040  if (subjectIdIter1 != element.end()){
3041  file_param = element["data"];
3042  }
3043 
3044  int found_dots = file_param.find_first_of(':');
3045  int word_size = file_param.size();
3046  std::string data_file = file_param.substr(found_dots + 3, word_size);
3047 
3048  curl_formadd(&formpost, &lastptr,
3049  CURLFORM_COPYNAME, "files",
3050  CURLFORM_FILE, data_file.c_str(),
3051  CURLFORM_END);
3052 
3053  } // i
3054 
3055  curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
3056 #else
3057  {
3058  curl_mimepart* part = curl_mime_addpart(mime);
3059  curl_mime_name(part, "storeset");
3060  curl_mime_data(part, js.c_str(), js.size());
3061  }
3062 
3063  for (int i = 0; i < partN; i++){
3064  nlohmann::json element = resources[i];
3065  std::string file_param;
3066 
3067  auto subjectIdIter1 = element.find("data");
3068  if (subjectIdIter1 != element.end()){
3069  file_param = element["data"];
3070  }
3071 
3072  int found_dots = file_param.find_first_of(':');
3073  int word_size = file_param.size();
3074  std::string data_file = file_param.substr(found_dots + 3, word_size);
3075 
3076  {
3077  curl_mimepart* part = curl_mime_addpart(mime);
3078  curl_mime_name(part, "files");
3079  curl_mime_filedata(part, data_file.c_str());
3080  }
3081 
3082  } // i
3083 
3084  curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
3085 #endif
3086 
3087  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
3088  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
3089 
3090  // Perform the request, res will get the return code
3091  res = curl_easy_perform(curl);
3092 
3093  // data to check the errors in the server response:
3094  long response_code;
3095  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
3096  const char* method_name = "CrestClient::storeBatchPayloads";
3097 
3098  /* always cleanup */
3099  curl_easy_cleanup(curl);
3100 #if LIBCURL_VERSION_MAJOR < 8
3101  curl_formfree(formpost);
3102  curl_slist_free_all(headers);
3103 #else
3104  curl_slist_free_all(headers);
3105  curl_mime_free(mime);
3106 #endif
3107 
3108  curl_global_cleanup();
3109 
3110  // error checking in the server response:
3111  checkResult(res, response_code, s, method_name);
3112 
3113  return s;
3114  }
3115  std::string mes = "ERROR in CrestClient::storeBatchPayloads";
3116  throw std::runtime_error(mes + " | CURL not init");
3117  }

◆ storeBatchPayloadRequest()

std::string Crest::CrestClient::storeBatchPayloadRequest ( const std::string &  tag,
uint64_t  endtime,
const std::string &  js 
)
privateinherited

This is an auxillary method to make an request to store several payloads in the batch mode.

(The old method name - store_batch_payload_request)

Parameters
tag- tag name.
endtime- end time.
js- payloads in the JSON format.

Definition at line 1505 of file CrestApi.cxx.

1505  {
1506  std::string current_path = m_PATH;
1507  current_path += s_PAYLOAD_PATH;
1508 
1509  CURL* curl;
1510  CURLcode res;
1511 
1512  // get a curl handle
1513 
1514  curl_global_init(CURL_GLOBAL_DEFAULT);
1515  curl = curl_easy_init();
1516 
1517  struct curl_slist* headers = NULL;
1518  if (curl) {
1519  std::string url = make_url(current_path);
1520  std::string s;
1521 
1522  if (m_CREST_PROXY) {
1523  // The environment variable exists, and 'socksProxy' now contains its value
1524  std::cout << "SOCKS proxy: " << m_CREST_PROXY << std::endl;
1525  // Set the proxy type (replace with your proxy type details)
1526  curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
1527 
1528  // Set the proxy address and port (replace with your SOCKS proxy details)
1529  curl_easy_setopt(curl, CURLOPT_PROXY, m_CREST_PROXY);
1530  }
1531 
1532  // First set the URL that is about to receive our POST. This URL can
1533  // just as well be a https:
1534  // URL if that is what should receive the data.
1535 
1536  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
1537  headers = curl_slist_append(headers, "X-Crest-PayloadFormat: JSON");
1538  headers = curl_slist_append(headers, "Accept: */*");
1539  headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
1540 
1541  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
1542 
1543  // Create the form for new version
1544 #if LIBCURL_VERSION_MAJOR < 8
1545  struct curl_httppost* formpost = NULL;
1546  struct curl_httppost* lastptr = NULL;
1547  curl_formadd(&formpost,
1548  &lastptr,
1549  CURLFORM_COPYNAME, "tag",
1550  CURLFORM_COPYCONTENTS, tag.c_str(),
1551  CURLFORM_END);
1552 #else
1553  curl_mime* mime = curl_mime_init(curl);
1554  {
1555  curl_mimepart* part = curl_mime_addpart(mime);
1556  curl_mime_name(part, "tag");
1557  curl_mime_data(part, tag.c_str(), tag.size());
1558  }
1559 #endif
1560  if (endtime != 0) {
1561 #if LIBCURL_VERSION_MAJOR < 8
1562  curl_formadd(&formpost,
1563  &lastptr,
1564  CURLFORM_COPYNAME, "endtime",
1565  CURLFORM_COPYCONTENTS, std::to_string(endtime).c_str(),
1566  CURLFORM_END);
1567 #else
1568  std::string endtime_s = std::to_string(endtime);
1569  curl_mimepart* part = curl_mime_addpart(mime);
1570  curl_mime_name(part, "endtime");
1571  curl_mime_data(part, endtime_s.c_str(), endtime_s.size());
1572 #endif
1573  }
1574 #if LIBCURL_VERSION_MAJOR < 8
1575  curl_formadd(&formpost,
1576  &lastptr,
1577  CURLFORM_COPYNAME, "storeset",
1578  CURLFORM_COPYCONTENTS, js.c_str(),
1579  CURLFORM_CONTENTTYPE, "application/json",
1580  CURLFORM_END);
1581  curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
1582 #else
1583  {
1584  curl_mimepart* part = curl_mime_addpart(mime);
1585  curl_mime_name(part, "storeset");
1586  curl_mime_type(part, "application/json");
1587  curl_mime_data(part, js.c_str(), js.size());
1588  }
1589  curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
1590 #endif
1591 
1592  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWrite_CallbackFunc_StdString);
1593  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
1594 
1595  // Perform the request, res will get the return code
1596  res = curl_easy_perform(curl);
1597 
1598  // data to check the errors in the server response:
1599  long response_code;
1600  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
1601  const char* method_name = "CrestClient::storeBatchPayloads";
1602 
1603  /* always cleanup */
1604  curl_easy_cleanup(curl);
1605 #if LIBCURL_VERSION_MAJOR < 8
1606  curl_formfree(formpost);
1607  curl_slist_free_all(headers);
1608 #else
1609  curl_slist_free_all(headers);
1610  curl_mime_free(mime);
1611 #endif
1612 
1613  curl_global_cleanup();
1614 
1615  // error checking in the server response:
1616  checkResult(res, response_code, s, method_name);
1617 
1618  return s;
1619  }
1620  std::string mes = "ERROR in CrestClient::storeBatchPayloads";
1621  throw std::runtime_error(mes + " | CURL not init");
1622  }

◆ storeBatchPayloads() [1/4]

void Crest::CrestClient::storeBatchPayloads ( const std::string &  tag_name,
const std::string &  iovsetupload,
uint64_t  endtime = 0 
)
inherited

This method stores several payloads in batch mode.

(This method is an analogue of the store_batch_payloads method in Python)

Parameters
tag_name- tag name.
endtime- end time, if endtime = 0, the server does not use this parameter in the internal check.
iovsetupload- iov data as a string.

Example how to use these parameters:

  std::string name58 = "test_MvG3b";
  uint64_t endtime58 = 200;
  std::string str58 = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
  myCrestClient.storeBatchPayloads(name58, endtime58, str58);

Definition at line 1131 of file CrestApi.cxx.

1131  {
1132  const char* method_name = "CrestClient::storeBatchPayloads";
1133 
1134  nlohmann::json js = getJson(iovsetupload, method_name);
1135  storeBatchPayloads(tag_name, endtime, js);
1136  }

◆ storeBatchPayloads() [2/4]

void Crest::CrestClient::storeBatchPayloads ( const std::string &  tag_name,
nlohmann::json js,
uint64_t  endtime = 0 
)
inherited

This method stores several payloads in batch mode.

(This method is an analogue of the store_batch_payloads method in Python)

Parameters
tag_name- tag name.
endtime- end time, if endtime = 0, the server does not use this parameter in the internal check.
iovsetupload- iov data as a JSON object.

Example how to use these parameters:

  std::string name58 = "test_MvG3a";
  uint64_t endtime58 = 200;
  std::string str58 = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
  nlohmann::json js58 = myCrestClient.getJson(str58);
  myCrestClient.storeBatchPayloads(name58, endtime58, js58)

Definition at line 1138 of file CrestApi.cxx.

1138  {
1139  const char* method_name = "CrestClient::storeBatchPayloads";
1140 
1141  if (m_mode == FILESYSTEM_MODE) {
1142  storeBatchPayloadsFs(tag_name, js);
1143  return;
1144  }
1145  if (!js.is_array()) {
1146  throw std::runtime_error("ERROR in " + std::string(method_name) + " JSON has wrong type (must be array)");
1147  }
1148 
1149  nlohmann::json jsObj = {};
1150  jsObj["datatype"] = "iovs";
1151  jsObj["format"] = "StoreSetDto";
1152  jsObj["size"] = js.size();
1153  jsObj["resources"] = js;
1154  std::string str = jsObj.dump();
1155  std::string retv = storeBatchPayloadRequest(tag_name, endtime, str);
1156 
1157  nlohmann::json respond = getJson(retv, method_name);
1158  }

◆ storeBatchPayloads() [3/4]

void Crest::CrestClient::storeBatchPayloads ( const std::string &  tag_name,
uint64_t  endtime,
const std::string &  iovsetupload 
)
inherited

This method stores several payloads in batch mode.

(The deprecated method.) (This method is an analogue of the store_batch_payloads method in Python)

Parameters
tag_name- tag name.
endtime- end time.
iovsetupload- iov data as a string.

Example how to use these parameters:

  std::string name58 = "test_MvG3b";
  uint64_t endtime58 = 200;
  std::string str58 = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
  myCrestClient.storeBatchPayloads(name58, endtime58, str58);

Definition at line 1102 of file CrestApi.cxx.

1102  {
1103  const char* method_name = "CrestClient::storeBatchPayloads";
1104 
1105  nlohmann::json js = getJson(iovsetupload, method_name);
1106  storeBatchPayloads(tag_name, endtime, js);
1107  }

◆ storeBatchPayloads() [4/4]

void Crest::CrestClient::storeBatchPayloads ( const std::string &  tag_name,
uint64_t  endtime,
nlohmann::json js 
)
inherited

This method stores several payloads in batch mode.

(The deprecated method.) (This method is an analogue of the store_batch_payloads method in Python)

Parameters
tag_name- tag name.
endtime- end time.
iovsetupload- iov data as a JSON object.

Example how to use these parameters:

  std::string name58 = "test_MvG3a";
  uint64_t endtime58 = 200;
  std::string str58 = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
  nlohmann::json js58 = myCrestClient.getJson(str58);
  myCrestClient.storeBatchPayloads(name58, endtime58, js58)

Definition at line 1109 of file CrestApi.cxx.

1109  {
1110  const char* method_name = "CrestClient::storeBatchPayloads";
1111 
1112  if (m_mode == FILESYSTEM_MODE) {
1113  storeBatchPayloadsFs(tag_name, js);
1114  return;
1115  }
1116  if (!js.is_array()) {
1117  throw std::runtime_error("ERROR in " + std::string(method_name) + " JSON has wrong type (must be array)");
1118  }
1119 
1120  nlohmann::json jsObj = {};
1121  jsObj["datatype"] = "iovs";
1122  jsObj["format"] = "StoreSetDto";
1123  jsObj["size"] = js.size();
1124  jsObj["resources"] = js;
1125  std::string str = jsObj.dump();
1126  std::string retv = storeBatchPayloadRequest(tag_name, endtime, str);
1127 
1128  nlohmann::json respond = getJson(retv, method_name);
1129  }

◆ storeBatchPayloadsFiles()

void Crest::CrestClient::storeBatchPayloadsFiles ( const std::string &  tag_name,
uint64_t  endtime,
nlohmann::json js 
)
inherited

This method stores several payloads from files in batch mode.

(The deprecated method.)

Parameters
tag_name- tag name.
endtime- end time.
js- iov data as a JSON object.

Example how to use these parameters:

  std::string file1 = "/tmp/mvg01.txt";
  std::string file2 = "/tmp/mvg02.txt";
  std::string d1 = "file://" + file1;
  std::string d2 = "file://" + file2;

  std::string str = "[{\"data\":\"" + d1 + "\",\"since\":100},{\"data\":\"" + d2 + "\",\"since\":150}]";
  nlohmann::json js = myCrestClient.getJson(str);
  myCrestClient.storeBatchPayloadsFiles(tagname, endtime, js);

Definition at line 2925 of file CrestApi.cxx.

2925  {
2926  const char* method_name = "CrestClient::storeBatchPayloads";
2927 
2928  if (m_mode == FILESYSTEM_MODE) {
2929  storeBatchPayloadsFs(tag_name, js);
2930  return;
2931  }
2932  if (!js.is_array()) {
2933  throw std::runtime_error("ERROR in " + std::string(method_name) + " JSON has wrong type (must be array)");
2934  }
2935 
2936  nlohmann::json jsObj = {};
2937  jsObj["datatype"] = "iovs";
2938  jsObj["format"] = "StoreSetDto";
2939  jsObj["size"] = js.size();
2940  jsObj["resources"] = js;
2941  std::string str = jsObj.dump();
2942  std::string retv = storeBatchPayloadFilesRequest(tag_name, endtime, str);
2943 
2944  nlohmann::json respond = getJson(retv, method_name);
2945  }

◆ storeBatchPayloadsFs() [1/2]

void Crest::CrestClient::storeBatchPayloadsFs ( const std::string &  tag_name,
nlohmann::json js 
)
inherited

This auxillary method stores several payloads in batch mode in the file storage.

(This method is an analogue of the store_batch_payloads method in Python)

Parameters
tag_name- tag name.
iovsetupload- iov data as a JSON object.

Example how to use these parameters:

  std::string name39 = "test_M";
  std::string str39 = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
  nlohmann::json js39 = myCrestClient.getJson(str39);
  myCrestClient.storeBatchPayloadsFs(name39, js39);

Definition at line 1837 of file CrestApi.cxx.

1837  {
1838  const char* method_name = "CrestClient::storeBatchPayloadsFs";
1839 
1840  try {
1841  for (auto& kvp : js) {
1842  std::string payload = kvp.value("data", "");
1843  int since = kvp.value("since", 0);
1844  storePayloadDump(tag_name, since, payload);
1845  }
1846  } // end of try
1847  catch (...) {
1848  throw std::runtime_error("ERROR in " + std::string(method_name) + " cannot store the data in a file");
1849  } // end of catch
1850  flush();
1851  }

◆ storeBatchPayloadsFs() [2/2]

void Crest::CrestClient::storeBatchPayloadsFs ( const std::string &  tag_name,
std::string &  iovsetupload 
)
inherited

This auxillary method stores several payloads in batch mode in the file storage.

(This method is an analogue of the store_batch_payloads method in Python)

Parameters
tag_name- tag name.
iovsetupload- iov data as a string.

Example how to use these parameters:

  std::string name39 = "test_M";
  std::string str39 = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
  myCrestClient.storeBatchPayloadsFs(name39, str39);

Definition at line 1826 of file CrestApi.cxx.

1826  {
1827  const char* method_name = "CrestClient::storeBatchPayloadsFs";
1828 
1829  nlohmann::json js = getJson(iovsetupload, method_name);
1830  if (!js.is_array()) {
1831  throw std::runtime_error("ERROR in CrestClient::storeBatchPayloadsFs: JSON has wrong type (must be array");
1832  }
1833 
1834  storeBatchPayloadsFs(tag_name, js);
1835  }

◆ storeData()

void Crest::CrestClient::storeData ( const std::string &  tag,
uint64_t  endtime,
uint64_t  since,
const std::string &  file 
)
inherited

This method stores a payload from a file in the database, associated to a given IOV since and tag name.

This method allows to insert a payload and an IOV.

Parameters
tag- tag name.
since- since. A parameter to create an IOV together with payload.
file- the file name (with the path) which contains the payload.

Definition at line 3119 of file CrestApi.cxx.

3119  {
3120  const char* method_name = "CrestClient::storePayloadAsFile";
3121  checkFsException(method_name);
3122  std::string d = "file://" + file;
3123 
3124  std::string str = "[{\"data\":\"" + d + "\",\"since\":" + std::to_string(since) + "}]";
3125  nlohmann::json js = getJson(str);
3126 
3127  storeBatchPayloadsFiles(tag, endtime, js);
3128  }

◆ storeDataArray()

void Crest::CrestClient::storeDataArray ( const std::string &  tag,
uint64_t  endtime,
std::map< uint64_t, std::string >  m 
)
inherited

This method stores several payloads from files in batch mode.

Parameters
tag_name- tag name.
endtime- end time.
m- map with pairs: since - file name (with the path).

Example how to use these parameters:

  uint64_t endtime = 200;
  uint64_t since1 = 100;
  uint64_t since2 = 150;

  std::string file1 = "/tmp/mvg01.txt";
  std::string file2 = "/tmp/mvg02.txt";

  std::map<uint64_t, std::string> data;

  data[since1] = file1;
  data[since2] = file2;

  myCrestClient.storeBatchFiles(tagname, endtime, data);

Definition at line 3130 of file CrestApi.cxx.

3130  {
3131  nlohmann::json payload_data = nlohmann::json::array();
3132 
3133  std::map<uint64_t, std::string> :: iterator it;
3134  for(it=m.begin();it !=m.end();++it){
3135  std::string file_name = "file://" + it->second;
3136 
3137  nlohmann::json js_element =
3138  {
3139  {"since", it->first},
3140  {"data", file_name}
3141  };
3142 
3143  payload_data.push_back(js_element);
3144  }
3145 
3146  storeBatchPayloadsFiles(tag, endtime, payload_data);
3147  }

◆ storePayload()

void Crest::CrestClient::storePayload ( const std::string &  tag,
uint64_t  since,
const std::string &  js 
)
inherited

Create a payload in the database, associated to a given iov since and tag name.

This method allows to insert a payload and an IOV. (This method is an analogue of the store_payload method in Python)

Parameters
tag- tag name.
since- since. A parameter to create an iov together with payload.
js- payload.

Definition at line 1252 of file CrestApi.cxx.

1252  {
1253  if (m_mode == FILESYSTEM_MODE) {
1254  storePayloadDump(tag, since, js);
1255  return;
1256  }
1257 
1259  nlohmann::json itemD =
1260  {
1261  {"data", js},
1262  {"since", since}
1263  };
1264 
1265  data.push_back(itemD);
1267  }

◆ storePayloadDump()

void Crest::CrestClient::storePayloadDump ( const std::string &  tag,
uint64_t  since,
const std::string &  js 
)
inherited

Method to store a payload in the local file system.

This is an auxillary method. It is used by storePayload method if CrestClient is innitialized in the file storage mode. (The old name of this method is store_payload_dump)

Parameters
tag- tag name.
since- since.
js- payload as a JSON object.

Definition at line 2446 of file CrestApi.cxx.

2446  {
2447  std::ofstream myfile;
2448 
2449  // payload file:
2450  std::string hashCode = getHash(js);
2451  std::string workDir = m_data_folder;
2452  workDir += '/';
2453  workDir += getFirstLetters(hashCode);
2455  std::filesystem::create_directory(std::filesystem::path(workDir));
2456  }
2457  workDir += '/';
2458  workDir += hashCode;
2460  std::filesystem::create_directory(std::filesystem::path(workDir));
2461  }
2462 
2463  std::string tagFile = workDir + "/payload.json";
2464 
2465  myfile.open(tagFile);
2466  myfile << js;
2467  myfile.close();
2468 
2469  /*
2470  // meta info data example:
2471  {
2472  "hash": "9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0",
2473  "insertionTime": "2020-12-08",
2474  "objectType": "JSON",
2475  "size": 3,
2476  "streamerInfo":
2477  "eyJmaWxlbmFtZSI6Ijk4MzQ4NzZkY2ZiMDVjYjE2N2E1YzI0OTUzZWJhNThjNGFjODliMWFkZjU3ZjI4ZjJmOWQwOWFmMTA3ZWU4ZjAiLCJmb3JtYXQiOiJKU09OIiwiaW5zZXJ0aW9uRGF0ZSI6IlR1ZSBEZWMgMDggMTE6MTg6NTAgR01UIDIwMjAifQ==",
2478  "version": "default"
2479  }
2480  */
2481 
2482  nlohmann::json jsn =
2483  {
2484  {"hash", hashCode},
2485  {"objectType", "JSON"},
2486  {"version", "default"},
2487  {"size", js.size()},
2488  {"streamerInfo", "none"},
2489  {"insertionTime", getDateAndTime()}
2490  };
2491 
2492 
2493  // payload meta info file:
2494  std::string metaFile = workDir + "/meta.json";
2495 
2496  myfile.open(metaFile);
2497  myfile << jsn.dump();
2498  myfile.close();
2499 
2500  // check if data exists
2501 
2502  if (m_data.find(tag) == m_data.end()) {
2503  try{
2505  m_data.insert(std::pair<std::string, nlohmann::json>(tag, jsi));
2506  }
2507  catch (...) {
2508  try { // tag exists, but there are no IOVs
2509  nlohmann::json tagJS = findTag(tag);
2511  m_data.insert(std::pair<std::string, nlohmann::json>(tag, jsFree));
2512  }
2513  catch (...) {
2514  throw std::runtime_error(
2515  "ERROR in CrestClient::storePayloadDump cannot get data for tag \"" + tag + "\" from file storage.");
2516  }
2517  }
2518  }
2519 
2521  if (it != m_data.end()) {
2522  std::string link = hashCode;
2523  nlohmann::json iovs = it->second;
2525  obj["tagName"] = tag;
2526  obj["since"] = since;
2527  obj["insertionTime"] = 0;
2528  obj["payloadHash"] = link;
2529  iovs.push_back(obj);
2530  m_data[it->first] = iovs;
2531  }
2532  }

◆ streamTest()

void Crest::CrestClient::streamTest ( )
inherited

this is test only, later it will be deleted (The old method name is streamtest)

Definition at line 1810 of file CrestApi.cxx.

1810  {
1811  std::string line;
1812 
1813  std::ifstream in("./test-03.txt");
1814  std::ofstream fout("./copy.txt");
1815  if (in.is_open() && fout.is_open()) {
1816  while (getline(in, line)) {
1817  fout << line << std::endl;
1818  }
1819  }
1820  in.close();
1821  }

◆ updateGlobalTag()

void Crest::CrestClient::updateGlobalTag ( const std::string &  name,
nlohmann::json  body 
)
inherited

This method allows to update a GlobalTag.Arguments: the name has to uniquely identify a global tag.

(This method is an analogue of the update_global_tag method in Python)

Parameters
name- global tag name
body- JSON object. A new global tag in JSON format. Example for body parameter:
json body =
   {
      {"name","MvG_TEST_01"},
      {"validity",0},
      {"description","test"},
      {"release","1"},
      {"insertionTime","2018-12-18T11:32:58.081+0000"},
      {"snapshotTime","2018-12-18T11:32:57.952+0000"},
      {"scenario","test2"},
      {"workflow","M"},
      {"type","t"},
      {"snapshotTimeMilli","null"},
      {"insertionTimeMilli","null"}
   };
 

Definition at line 672 of file CrestApi.cxx.

672  {
673  const char* method_name = "CrestClient::updateGlobalTag";
674 
675  checkFsException(method_name);
676 
677  std::string current_path = m_PATH;
678  current_path += s_ADMIN_PATH;
679  current_path += s_GLOBALTAG_PATH;
680  current_path += '/';
681  current_path += name;
682 
683  std::string retv;
684 
685  retv = performRequest(current_path, PUT, body, method_name);
686  }

◆ updateTag()

void Crest::CrestClient::updateTag ( const std::string &  tagname,
nlohmann::json  body 
)
inherited

This method allows to update tag record in the CREST DB.

(This method is an analogue of the update_tag method in Python)

Parameters
tagname- tg name.
body- new parameters in the JSON format. This JSON object contain the parameters which have to be changed only. Example:
   json body =
   {
     {"description","none"},
     {"lastValidatedTime",0},
     {"endOfValidity",40}
   }

Definition at line 278 of file CrestApi.cxx.

278  {
279  const char* method_name = "CrestClient::updateTag";
280 
281  checkFsException(method_name);
282 
283  std::string current_path = m_PATH;
284  current_path += s_TAG_PATH;
285  current_path += '/';
286  current_path += tagname;
287 
288  std::string retv;
289 
290  retv = performRequest(current_path, PUT, body, method_name);
291  }

◆ updateTagMetaInfo() [1/2]

void Crest::CrestClient::updateTagMetaInfo ( const std::string &  tagname,
nlohmann::json js 
)
inherited

This method updates a tag meta info in the CREST database.

Parameters
tagname- tag name
js- a JSON object with new parameters (These parameters will be changed in the CREST DB). Example:
   nlohmann::json js =
   {
     {"tagName", "test_MvG4"},
     {"description", "desc-01"},
     {"tagInfo", "taginf-01"},
     {"chansize", 0},
     {"colsize", 0},
     {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 2085 of file CrestApi.cxx.

2085  {
2086  const char* method_name = "CrestClient::updateTagMetaInfo";
2087 
2088  if (m_mode == FILESYSTEM_MODE) {
2089  std::string name = "";
2090  try{
2091  name = static_cast<std::string> (js["tagName"]);
2092  }
2093  catch (...) {
2094  throw std::runtime_error(
2095  "ERROR in CrestClient::updateTagMetaInfo cannot get the tag name from tag meta info JSON.");
2096  }
2097 
2098  if (tagname != name) {
2099  throw std::runtime_error("ERROR in CrestClient::updateTagMetaInfo tagname in method and in JSON are different.");
2100  }
2101 
2103  return;
2104  }
2105 
2106  std::string current_path = m_PATH;
2107  current_path += s_TAG_PATH;
2108  current_path += '/';
2109  current_path += tagname;
2110  current_path += s_META_PATH;
2111 
2112  std::string retv;
2113 
2114  retv = performRequest(current_path, PUT, js, method_name);
2115  }

◆ updateTagMetaInfo() [2/2]

void Crest::CrestClient::updateTagMetaInfo ( nlohmann::json js)
inherited

This method updates a tag meta info in the CREST database.

Parameters
js- a JSON object with new parameters (These parameters will be changed in the CREST DB). Example:
   nlohmann::json js =
   {
     {"tagName", "test_MvG4"},
     {"description", "desc-01"},
     {"tagInfo", "taginf-01"},
     {"chansize", 0},
     {"colsize", 0},
     {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 2060 of file CrestApi.cxx.

2060  {
2061  const char* method_name = "CrestClient::updateTagMetaInfo";
2062 
2063  std::string tagname = "";
2064  try{
2065  tagname = static_cast<std::string> (js["tagName"]);
2066  }
2067  catch (...) {
2068  throw std::runtime_error(
2069  "ERROR in CrestClient::updateTagMetaInfo cannot get the tag name from tag meta info JSON.");
2070  }
2071 
2072 
2073  if (m_mode == FILESYSTEM_MODE) {
2075  return;
2076  }
2077 
2078  std::string current_path = m_PATH + s_TAG_PATH + '/' + tagname + s_META_PATH;
2079 
2080  std::string retv;
2081 
2082  retv = performRequest(current_path, PUT, js, method_name);
2083  }

◆ updateTagMetaInfoFs()

void Crest::CrestClient::updateTagMetaInfoFs ( const std::string &  tagname,
nlohmann::json js 
)
inherited

This auxillary method updates a tag meta info in local file storage.

Parameters
tagname- tag name
js- a JSON object with new parameters (These parameters will be changed in the CREST DB). Example:
   nlohmann::json js =
   {
     {"tagName", "test_MvG4"},
     {"description", "desc-01"},
     {"tagInfo", "taginf-01"},
     {"chansize", 0},
     {"colsize", 0},
     {"insertionTime", "2019-03-14T13:29:25.286Z"}
   };

Definition at line 2224 of file CrestApi.cxx.

2224  {
2225  // Check if JSON contains the correct tag name:
2226  auto it = js.find("tagName");
2227 
2228  if (it != js.end()) {
2229  if (js["tagName"] != tagname) {
2230  throw std::runtime_error("ERROR in CrestClient::updateTagMetaInfoFs: JSON contains wrong tag name.");
2231  }
2232  }
2233 
2234  nlohmann::json jstmp;
2235  try{
2236  jstmp = getTagMetaInfoFs(tagname);
2237  }
2238  catch (const std::exception& e) {
2239  throw std::runtime_error(
2240  "ERROR in CrestClient::updateTagMetaInfoFs: the file storage does not contain the tag meta info for the tag " + tagname +
2241  " .");
2242  }
2243 
2244  // Write all keys/values from new JSON to old one:
2245  for (auto it = js.begin(); it != js.end(); it++) {
2246  jstmp[it.key()] = it.value();
2247  }
2248 
2249  try{
2250  createTagMetaInfoFs(jstmp);
2251  }
2252  catch (const std::exception& e) {
2253  throw std::runtime_error(
2254  "ERROR in CrestClient::updateTagMetaInfoFs: cannot write the tag meta info for the tag " + tagname +
2255  " on file storage.");
2256  }
2257 
2258  return;
2259  }

◆ updateTagSpecification()

void Crest::CrestClient::updateTagSpecification ( const std::string &  tagname,
const std::string &  objectType 
)
inherited

This method cahnges object type specification.

(The old name of this method is update_tag_specification)

Parameters
tagname- tag name.
objectType- new object type.

Definition at line 293 of file CrestApi.cxx.

293  {
294  const char* method_name = "CrestClient::updateTagSpecification";
295 
296  checkFsException(method_name);
297 
298  std::string current_path = m_PATH;
299  current_path += s_TAG_PATH;
300  current_path += '/';
301  current_path += tagname;
302 
303  nlohmann::json body;
304  body["objectType"] = objectType;
305 
306 
307  std::string retv;
308  retv = performRequest(current_path, PUT, body, method_name);
309  }

Member Data Documentation

◆ m_CREST_PROXY

char* Crest::CrestClient::m_CREST_PROXY = NULL
privateinherited

Definition at line 75 of file CrestApi.h.

◆ m_CREST_PROXY_VAR

const char* Crest::CrestClient::m_CREST_PROXY_VAR = "SOCKS_PROXY"
privateinherited

Definition at line 76 of file CrestApi.h.

◆ m_currentTag

std::string Crest::CrestClient::m_currentTag {}
privateinherited

Definition at line 72 of file CrestApi.h.

◆ m_data

std::map<std::string, nlohmann::json> Crest::CrestClient::m_data {}
privateinherited

Definition at line 70 of file CrestApi.h.

◆ m_data_folder

std::string Crest::CrestClient::m_data_folder {}
privateinherited

Definition at line 69 of file CrestApi.h.

◆ m_host

std::string Crest::CrestClient::m_host {}
privateinherited

Definition at line 65 of file CrestApi.h.

◆ m_isRewrite

bool Crest::CrestClient::m_isRewrite {}
privateinherited

Definition at line 71 of file CrestApi.h.

◆ m_mode

int Crest::CrestClient::m_mode {}
privateinherited

Definition at line 67 of file CrestApi.h.

◆ m_PATH

std::string Crest::CrestClient::m_PATH = "/api-v4.0"
privateinherited

Definition at line 74 of file CrestApi.h.

◆ m_port

std::string Crest::CrestClient::m_port {}
privateinherited

Definition at line 66 of file CrestApi.h.

◆ m_root_folder

std::string Crest::CrestClient::m_root_folder {}
privateinherited

Definition at line 68 of file CrestApi.h.

◆ s_ADMIN_PATH

const std::string Crest::CrestClient::s_ADMIN_PATH = "/admin"
inlinestaticprivateinherited

Definition at line 78 of file CrestApi.h.

◆ s_CREST_CLIENT_CHECK

const bool Crest::CrestClient::s_CREST_CLIENT_CHECK = false
inlinestaticinherited

Definition at line 259 of file CrestApi.h.

◆ s_CREST_CLIENT_VERSION

const std::string Crest::CrestClient::s_CREST_CLIENT_VERSION = "4.0"
inlinestaticprivateinherited

Definition at line 122 of file CrestApi.h.

◆ s_DATA_PATH

const std::string Crest::CrestClient::s_DATA_PATH = "/data"
inlinestaticprivateinherited

Definition at line 88 of file CrestApi.h.

◆ s_FOLDER_PATH

const std::string Crest::CrestClient::s_FOLDER_PATH = "/folders"
inlinestaticprivateinherited

Definition at line 90 of file CrestApi.h.

◆ s_FS_DATA_PATH

const std::string Crest::CrestClient::s_FS_DATA_PATH = "/data"
inlinestaticprivateinherited

Definition at line 103 of file CrestApi.h.

◆ s_FS_GLOBALTAG_FILE

const std::string Crest::CrestClient::s_FS_GLOBALTAG_FILE = "/globaltag.json"
inlinestaticprivateinherited

Definition at line 112 of file CrestApi.h.

◆ s_FS_GLOBALTAG_PATH

const std::string Crest::CrestClient::s_FS_GLOBALTAG_PATH = "/globaltags"
inlinestaticprivateinherited

Definition at line 102 of file CrestApi.h.

◆ s_FS_IOV_FILE

const std::string Crest::CrestClient::s_FS_IOV_FILE = "/iovs.json"
inlinestaticprivateinherited

Definition at line 106 of file CrestApi.h.

◆ s_FS_MAP_FILE

const std::string Crest::CrestClient::s_FS_MAP_FILE = "/maps.json"
inlinestaticprivateinherited

Definition at line 113 of file CrestApi.h.

◆ s_FS_META_FILE

const std::string Crest::CrestClient::s_FS_META_FILE = "/meta.json"
inlinestaticprivateinherited

Definition at line 109 of file CrestApi.h.

◆ s_FS_PALOAD_FILE

const std::string Crest::CrestClient::s_FS_PALOAD_FILE = "/payload.json"
inlinestaticprivateinherited

Definition at line 110 of file CrestApi.h.

◆ s_FS_PATH

const std::string Crest::CrestClient::s_FS_PATH = ""
inlinestaticprivateinherited

Definition at line 115 of file CrestApi.h.

◆ s_FS_PREFIX_LENGTH

const int Crest::CrestClient::s_FS_PREFIX_LENGTH = 3
inlinestaticprivateinherited

Definition at line 117 of file CrestApi.h.

◆ s_FS_TAG_FILE

const std::string Crest::CrestClient::s_FS_TAG_FILE = "/tag.json"
inlinestaticprivateinherited

Definition at line 105 of file CrestApi.h.

◆ s_FS_TAG_PATH

const std::string Crest::CrestClient::s_FS_TAG_PATH = "/tags"
inlinestaticprivateinherited

Definition at line 101 of file CrestApi.h.

◆ s_FS_TAGMETAINFO_FILE

const std::string Crest::CrestClient::s_FS_TAGMETAINFO_FILE = "/tagmetainfo.json"
inlinestaticprivateinherited

Definition at line 107 of file CrestApi.h.

◆ s_GLOBALTAG_MAP_PATH

const std::string Crest::CrestClient::s_GLOBALTAG_MAP_PATH = "/globaltagmaps"
inlinestaticprivateinherited

Definition at line 84 of file CrestApi.h.

◆ s_GLOBALTAG_PATH

const std::string Crest::CrestClient::s_GLOBALTAG_PATH = "/globaltags"
inlinestaticprivateinherited

Definition at line 83 of file CrestApi.h.

◆ s_IOV_PATH

const std::string Crest::CrestClient::s_IOV_PATH = "/iovs"
inlinestaticprivateinherited

Definition at line 79 of file CrestApi.h.

◆ s_IOV_SIZE_PATH

const std::string Crest::CrestClient::s_IOV_SIZE_PATH = "/size"
inlinestaticprivateinherited

Definition at line 81 of file CrestApi.h.

◆ s_META_PATH

const std::string Crest::CrestClient::s_META_PATH = "/meta"
inlinestaticprivateinherited

Definition at line 87 of file CrestApi.h.

◆ s_METHOD_GROUPS

const std::string Crest::CrestClient::s_METHOD_GROUPS = "GROUPS"
inlinestaticprivateinherited

Definition at line 95 of file CrestApi.h.

◆ s_METHOD_IOVS

const std::string Crest::CrestClient::s_METHOD_IOVS = "IOVS"
inlinestaticprivateinherited

Definition at line 94 of file CrestApi.h.

◆ s_METHOD_MONITOR

const std::string Crest::CrestClient::s_METHOD_MONITOR = "MONITOR"
inlinestaticprivateinherited

Definition at line 96 of file CrestApi.h.

◆ s_MGMT_INFO_PATH

const std::string Crest::CrestClient::s_MGMT_INFO_PATH = "/info"
inlinestaticprivateinherited

Definition at line 121 of file CrestApi.h.

◆ s_MGMT_INFO_PATH_2

const std::string Crest::CrestClient::s_MGMT_INFO_PATH_2 = "/actuator/info"
inlinestaticprivateinherited

Definition at line 123 of file CrestApi.h.

◆ s_MGMT_PATH

const std::string Crest::CrestClient::s_MGMT_PATH = "/mgmt"
inlinestaticprivateinherited

Definition at line 120 of file CrestApi.h.

◆ s_MONITORING_PAYLOAD_PATH

const std::string Crest::CrestClient::s_MONITORING_PAYLOAD_PATH = "/monitoring/payloads"
inlinestaticprivateinherited

Definition at line 86 of file CrestApi.h.

◆ s_PAYLOAD_PATH

const std::string Crest::CrestClient::s_PAYLOAD_PATH = "/payloads"
inlinestaticprivateinherited

Definition at line 85 of file CrestApi.h.

◆ s_RUNINFO_LIST_PATH

const std::string Crest::CrestClient::s_RUNINFO_LIST_PATH = "/list"
inlinestaticprivateinherited

Definition at line 92 of file CrestApi.h.

◆ s_RUNINFO_PATH

const std::string Crest::CrestClient::s_RUNINFO_PATH = "/runinfo"
inlinestaticprivateinherited

Definition at line 91 of file CrestApi.h.

◆ s_TAG_PATH

const std::string Crest::CrestClient::s_TAG_PATH = "/tags"
inlinestaticprivateinherited

Definition at line 77 of file CrestApi.h.


The documentation for this class was generated from the following file:
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
grepfile.info
info
Definition: grepfile.py:38
Crest::CrestClient::checkFsException
void checkFsException(const char *method_name)
Auxillary method to check if the CrestApi library initialized to work with the file system.
Definition: CrestApi.cxx:1908
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
Crest::CrestClient::getPayloadAsJsonFS
nlohmann::json getPayloadAsJsonFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2566
Crest::CrestClient::s_TAG_PATH
static const std::string s_TAG_PATH
Definition: CrestApi.h:77
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
Crest::CrestClient::m_root_folder
std::string m_root_folder
Definition: CrestApi.h:68
Crest::CrestClient::isJson
bool isJson(const std::string &str)
This method checks if a string is in the JSON format.
Definition: CrestApi.cxx:1688
covarianceTool.headers
headers
Definition: covarianceTool.py:537
Crest::CrestClient::s_FS_IOV_FILE
static const std::string s_FS_IOV_FILE
Definition: CrestApi.h:106
Crest::CrestClient::getBlobInStreamFs
std::string getBlobInStreamFs(const std::string &hash, std::ofstream &out)
This method finds payload data by hash; the payload object contains the real BLOB.
Definition: CrestApi.cxx:2610
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Crest::CrestClient::m_currentTag
std::string m_currentTag
Definition: CrestApi.h:72
checkFileSG.line
line
Definition: checkFileSG.py:75
Crest::CrestClient::findGlobalTagMapFs
nlohmann::json findGlobalTagMapFs(const std::string &name)
The auxillary method to find a global tag by name for the file storage.
Definition: CrestApi.cxx:2412
Crest::CrestClient::findAllIovs
nlohmann::json findAllIovs(const std::string &tagname)
This method finds all iovs for a given tag name.
Definition: CrestApi.cxx:390
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Crest::CrestClient::s_MGMT_INFO_PATH
static const std::string s_MGMT_INFO_PATH
Definition: CrestApi.h:121
Crest::CrestClient::m_mode
int m_mode
Definition: CrestApi.h:67
Crest::CrestClient::m_CREST_PROXY_VAR
const char * m_CREST_PROXY_VAR
Definition: CrestApi.h:76
get_generator_info.result
result
Definition: get_generator_info.py:21
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
header
Definition: hcg.cxx:526
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
Crest::CrestClient::getDateAndTime
std::string getDateAndTime()
The auxillary method to get a current data and time.
Definition: CrestApi.cxx:2534
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Crest::CrestClient::getPayloadMetaInfoAsJsonFS
nlohmann::json getPayloadMetaInfoAsJsonFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2594
Crest::CrestClient::getJson
nlohmann::json getJson(const std::string &str)
Auxillary method to convert string in to JSON object.
Definition: CrestApi.cxx:1650
json
nlohmann::json json
Definition: HistogramDef.cxx:9
Crest::CrestClient::createTag
void createTag(nlohmann::json &js)
This method creates a tag in the CREST database.
Definition: CrestApi.cxx:262
Crest::CrestClient::getFileString
std::string getFileString(const std::string &path)
Auxillary method to get a file as a string.
Definition: CrestApi.cxx:1733
response
MDT_Response response
Definition: MDT_ResponseTest.cxx:28
Crest::CrestClient::s_ADMIN_PATH
static const std::string s_ADMIN_PATH
Definition: CrestApi.h:78
find_tgc_unfilled_channelids.iovs
iovs
Definition: find_tgc_unfilled_channelids.py:12
Crest::CrestClient::s_FS_TAGMETAINFO_FILE
static const std::string s_FS_TAGMETAINFO_FILE
Definition: CrestApi.h:107
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
hist_file_dump.d
d
Definition: hist_file_dump.py:137
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
Crest::CrestClient::findTagFs
nlohmann::json findTagFs(const std::string &name)
This method finds a tag by the tag name in the file storage.
Definition: CrestApi.cxx:1762
Crest::CrestClient::m_data
std::map< std::string, nlohmann::json > m_data
Definition: CrestApi.h:70
Crest::CrestClient::getTagMetaInfo
nlohmann::json getTagMetaInfo(const std::string &tagname)
This method gets a tag meta info from the CREST database.
Definition: CrestApi.cxx:2037
Crest::CrestClient::s_IOV_PATH
static const std::string s_IOV_PATH
Definition: CrestApi.h:79
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:983
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
Crest::CrestClient::createGlobalTag
void createGlobalTag(nlohmann::json &js)
Create a global tag in the database.
Definition: CrestApi.cxx:688
picosha2::hash256_hex_string
void hash256_hex_string(InIter first, InIter last, std::string &hex_str)
Definition: picosha2.h:353
Crest::CrestClient::s_FS_TAG_PATH
static const std::string s_FS_TAG_PATH
Definition: CrestApi.h:101
Crest::CrestClient::s_METHOD_IOVS
static const std::string s_METHOD_IOVS
Definition: CrestApi.h:94
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Crest::CrestClient::PUT
@ PUT
Definition: CrestApi.h:129
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
Crest::CrestClient::s_GLOBALTAG_MAP_PATH
static const std::string s_GLOBALTAG_MAP_PATH
Definition: CrestApi.h:84
get_generator_info.build
build
Definition: get_generator_info.py:33
python.sizes.txt
string txt
Definition: sizes.py:141
Crest::CrestClient::FILESYSTEM_MODE
@ FILESYSTEM_MODE
Definition: CrestApi.h:126
Crest::CrestClient::m_host
std::string m_host
Definition: CrestApi.h:65
Crest::CrestClient::m_PATH
std::string m_PATH
Definition: CrestApi.h:74
LArConditionsTestConfig.catalogFile
catalogFile
Definition: LArConditionsTestConfig.py:83
WriteCaloSwCorrections.tag_list
tag_list
Definition: WriteCaloSwCorrections.py:28
Crest::CrestClient::getHash
std::string getHash(std::string_view str)
The auxillary method to calculate a hash code for a given string.
Definition: CrestApi.cxx:2441
Crest::CrestClient::POST
@ POST
Definition: CrestApi.h:129
Crest::CrestClient::DELETE
@ DELETE
Definition: CrestApi.h:129
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
Crest::CrestClient::performRequest
std::string performRequest(const std::string &current_path, Action action, nlohmann::json &js)
General auxiliary method to make request to the CREST Server.
Definition: CrestApi.cxx:1366
MCP::ScaleSmearParam::r2
@ r2
Crest::CrestClient::s_RUNINFO_PATH
static const std::string s_RUNINFO_PATH
Definition: CrestApi.h:91
Crest::CrestClient::updateTagMetaInfoFs
void updateTagMetaInfoFs(const std::string &tagname, nlohmann::json &js)
This auxillary method updates a tag meta info in local file storage.
Definition: CrestApi.cxx:2224
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Crest::CrestClient::getTagMetaInfoFs
nlohmann::json getTagMetaInfoFs(const std::string &name)
This is an auxillary method, it gets a tag meta info from file system storage.
Definition: CrestApi.cxx:2205
Crest::CrestClient::getPayloadAsStringFS
std::string getPayloadAsStringFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2547
ReweightUtils.message
message
Definition: ReweightUtils.py:15
physics_parameters.url
string url
Definition: physics_parameters.py:27
search
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
Definition: hcg.cxx:738
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
Crest::CrestClient::s_FS_GLOBALTAG_PATH
static const std::string s_FS_GLOBALTAG_PATH
Definition: CrestApi.h:102
Crest::CrestClient::s_MONITORING_PAYLOAD_PATH
static const std::string s_MONITORING_PAYLOAD_PATH
Definition: CrestApi.h:86
Crest::CrestClient::getBlobFs
std::string getBlobFs(const std::string &hash)
This method finds payload data by hash in the file storage; the payload object contains the real BLOB...
Definition: CrestApi.cxx:2600
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
hotSpotInTAG.objectType
objectType
Definition: hotSpotInTAG.py:107
Crest::CrestClient::removeCR
std::string removeCR(const std::string &str)
This method removes all end of line and carriage return symbols from a string.
Definition: CrestApi.cxx:1677
Crest::CrestClient::storeBatchPayloadsFs
void storeBatchPayloadsFs(const std::string &tag_name, std::string &iovsetupload)
This auxillary method stores several payloads in batch mode in the file storage.
Definition: CrestApi.cxx:1826
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
rerun_display.client
client
Definition: rerun_display.py:31
Crest::CrestClient::convertTagMetaInfo2IOVDbSvc
nlohmann::json convertTagMetaInfo2IOVDbSvc(nlohmann::json &js)
Auxillary method to convert a Tag Meta Info from the JSON CREST Server format in to IOVDbSvc format.
Definition: CrestApi.cxx:1948
Crest::CrestClient::createTagMetaInfoFs
void createTagMetaInfoFs(nlohmann::json &js)
This is an auxillary method, it creates a tag meta info on the file system storage.
Definition: CrestApi.cxx:2165
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
query
Definition: query.py:1
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
Crest::CrestClient::s_GLOBALTAG_PATH
static const std::string s_GLOBALTAG_PATH
Definition: CrestApi.h:83
Crest::CrestClient::convertTagMetaInfo2CREST
nlohmann::json convertTagMetaInfo2CREST(nlohmann::json &js)
Auxillary method to convert a Tag Meta Info from the JSON IOVDbSvc format in CREST Server format.
Definition: CrestApi.cxx:1955
Crest::CrestClient::storeBatchPayloadsFiles
void storeBatchPayloadsFiles(const std::string &tag_name, uint64_t endtime, nlohmann::json &js)
This method stores several payloads from files in batch mode.
Definition: CrestApi.cxx:2925
Crest::CrestClient::split
std::vector< std::string > split(std::string_view str, char delim)
Auxillary method to split a string.
Definition: CrestApi.cxx:1982
Crest::CrestClient::listTags
nlohmann::json listTags(void)
This method returns the tag list.
Definition: CrestApi.cxx:103
Crest::CrestClient::s_MGMT_INFO_PATH_2
static const std::string s_MGMT_INFO_PATH_2
Definition: CrestApi.h:123
python.handimod.now
now
Definition: handimod.py:675
Crest::CrestClient::s_META_PATH
static const std::string s_META_PATH
Definition: CrestApi.h:87
defineDB.tagname
string tagname
Definition: JetTagCalibration/share/defineDB.py:19
Crest::CrestClient::storeBatchPayloads
void storeBatchPayloads(const std::string &tag_name, uint64_t endtime, const std::string &iovsetupload)
This method stores several payloads in batch mode.
Definition: CrestApi.cxx:1102
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
Crest::CurlWrite_CallbackFunc_StdString
size_t CurlWrite_CallbackFunc_StdString(void *contents, size_t size, size_t nmemb, std::string *s)
Definition: CrestApi.cxx:1273
Crest::CrestClient::s_METHOD_GROUPS
static const std::string s_METHOD_GROUPS
Definition: CrestApi.h:95
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
Crest::CrestClient::getCrestVersion
std::string getCrestVersion()
This method returns the full CREST Server version.
Definition: CrestApi.cxx:2783
Crest::CrestClient::s_MGMT_PATH
static const std::string s_MGMT_PATH
Definition: CrestApi.h:120
beamspotman.n
n
Definition: beamspotman.py:731
PixelAthClusterMonAlgCfg.varName
string varName
end cluster ToT and charge
Definition: PixelAthClusterMonAlgCfg.py:117
Crest::CrestClient::createGlobalTagMapFs
void createGlobalTagMapFs(nlohmann::json &js)
The auxillary method to create a global tag map in file storage.
Definition: CrestApi.cxx:2329
dqt_zlumi_alleff_HIST.fout
fout
Definition: dqt_zlumi_alleff_HIST.py:59
Crest::CrestClient::storeBatchPayloadFilesRequest
std::string storeBatchPayloadFilesRequest(const std::string &tag, uint64_t endtime, const std::string &js)
This is an auxilary method to make an request to store several payloads from files in the batch mode.
Definition: CrestApi.cxx:2948
Crest::CrestClient::returnJArray
nlohmann::json returnJArray(nlohmann::json js)
This auxillary method creates a JSON array from a JSON object.
Definition: CrestApi.cxx:2639
Crest::CrestClient::ParseXMLOutput
std::string ParseXMLOutput(std::string_view xmlBuffer)
This method removes all XML/HTML tags from a string.
Definition: CrestApi.cxx:1656
Crest::CrestClient::SERVER_MODE
@ SERVER_MODE
Definition: CrestApi.h:126
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
calibdata.exception
exception
Definition: calibdata.py:496
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
Crest::CrestClient::m_CREST_PROXY
char * m_CREST_PROXY
Definition: CrestApi.h:75
athena.file_path
file_path
Definition: athena.py:92
Crest::CrestClient::s_FS_MAP_FILE
static const std::string s_FS_MAP_FILE
Definition: CrestApi.h:113
file
TFile * file
Definition: tile_monitor.h:29
parseDir.wh
wh
Definition: parseDir.py:46
Crest::CrestClient::getSizeFS
int getSizeFS(const std::string &tagname)
This metghod gets the number of iovs for the given tag.
Definition: CrestApi.cxx:2645
Crest::CrestClient::s_FS_PREFIX_LENGTH
static const int s_FS_PREFIX_LENGTH
Definition: CrestApi.h:117
Crest::CrestClient::findTag
nlohmann::json findTag(const std::string &name)
This method finds a tag by the name.
Definition: CrestApi.cxx:226
dumpTgcDigiDeadChambers.resolver
resolver
Definition: dumpTgcDigiDeadChambers.py:16
Crest::CrestClient::s_FS_DATA_PATH
static const std::string s_FS_DATA_PATH
Definition: CrestApi.h:103
Crest::CrestClient::GET
@ GET
Definition: CrestApi.h:129
Crest::CrestClient::getPayloadMetaInfoAsStringFS
std::string getPayloadMetaInfoAsStringFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2572
Crest::CrestClient::getCrestVersion2
std::string getCrestVersion2()
This method returns the full CREST Server version.
Definition: CrestApi.cxx:2863
Crest::CrestClient::s_CREST_CLIENT_VERSION
static const std::string s_CREST_CLIENT_VERSION
Definition: CrestApi.h:122
Crest::CrestClient::CrestClient
CrestClient(bool rewriteIfExists, const std::string &root_folder="/tmp/crest_dump")
CrestClient constructor for file storage mode.
Definition: CrestApi.cxx:28
query_example.query
query
Definition: query_example.py:15
CheckTagAssociation.globaltag
globaltag
Definition: CheckTagAssociation.py:18
Crest::CrestClient::flush
void flush()
Auxillary method to write all the data at the end of a session.
Definition: CrestApi.cxx:351
Crest::CrestClient::storePayloadDump
void storePayloadDump(const std::string &tag, uint64_t since, const std::string &js)
Method to store a payload in the local file system.
Definition: CrestApi.cxx:2446
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
lumiFormat.array
array
Definition: lumiFormat.py:98
Crest::CrestClient::getResources
nlohmann::json getResources(nlohmann::json &js)
Auxillary method to get a resources parameter from new CREST server response.
Definition: CrestApi.cxx:1916
Crest::CrestClient::getFirstLetters
std::string getFirstLetters(const std::string &str)
This is an auxillary method extract first letters from the string (hash).
Definition: CrestApi.cxx:2762
Crest::CrestClient::getClientVersion
std::string getClientVersion()
This method returns the full CrestApi version.
Definition: CrestApi.cxx:2809
Crest::CrestClient::m_isRewrite
bool m_isRewrite
Definition: CrestApi.h:71
Crest::CrestClient::checkErrors
int checkErrors(const nlohmann::json &js, const char *method)
Auxillary method to check if the JSON object contain an error message.
Definition: CrestApi.cxx:1875
hancool.filePath
string filePath
Definition: hancool.py:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Crest::CrestClient::s_PAYLOAD_PATH
static const std::string s_PAYLOAD_PATH
Definition: CrestApi.h:85
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
PayloadHelpers::dataSize
size_t dataSize(TDA::PayloadIterator start)
Size in bytes of the buffer that is needed to decode next fragment data content.
Definition: TriggerEDMDeserialiserAlg.cxx:188
Crest::CrestClient::getMgmtInfo
nlohmann::json getMgmtInfo()
This is an auxillary method to read the CREST Server properties.
Definition: CrestApi.cxx:2767
item
Definition: ItemListSvc.h:43
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
Crest::CrestClient::findGlobalTagAsString
std::string findGlobalTagAsString(const std::string &name)
Finds a global tag by name.
Definition: CrestApi.cxx:724
Crest::CrestClient::storeBatchIOVs
void storeBatchIOVs(nlohmann::json &js)
This method stores an IOV set on the CREST server.
Definition: CrestApi.cxx:630
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
MyPlots.page
page
Definition: MyPlots.py:234
python.PyAthena.v
v
Definition: PyAthena.py:157
get_generator_info.version
version
Definition: get_generator_info.py:33
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
Crest::CrestClient::m_port
std::string m_port
Definition: CrestApi.h:66
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Crest::CrestClient::createTagMetaInfo
void createTagMetaInfo(nlohmann::json &js)
This method creates a tag meta info in the CREST database.
Definition: CrestApi.cxx:1998
Crest::CrestClient::replaceSymbols
void replaceSymbols(std::string &str, const std::string &from, const std::string &to)
This auxilary method replaces the substring from by the substring to.
Definition: CrestApi.cxx:3156
Crest::CrestClient::getMajorVersion
int getMajorVersion(std::string &str)
This is an auxillary method to extract a major version number from full version string.
Definition: CrestApi.cxx:2813
LArHVGainsPredictor.error_code
error_code
Definition: LArHVGainsPredictor.py:229
tagname
Definition: tagname.h:29
pickleTool.object
object
Definition: pickleTool.py:30
PlotCalibFromCool.iovList
iovList
Definition: PlotCalibFromCool.py:351
str
Definition: BTagTrackIpAccessor.cxx:11
calibdata.copy
bool copy
Definition: calibdata.py:27
Crest::CrestClient::s_FOLDER_PATH
static const std::string s_FOLDER_PATH
Definition: CrestApi.h:90
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
Crest::CrestClient::s_FS_TAG_FILE
static const std::string s_FS_TAG_FILE
Definition: CrestApi.h:105
python.html.AtlRunQueryDQSummary.server
server
Definition: AtlRunQueryDQSummary.py:22
makeTOC.header
header
Definition: makeTOC.py:28
MCP::ScaleSmearParam::r1
@ r1
get_generator_info.error
error
Definition: get_generator_info.py:40
Crest::CrestClient::s_FS_GLOBALTAG_FILE
static const std::string s_FS_GLOBALTAG_FILE
Definition: CrestApi.h:112
Crest::CrestClient::storeBatchPayloadRequest
std::string storeBatchPayloadRequest(const std::string &tag, uint64_t endtime, const std::string &js)
This is an auxillary method to make an request to store several payloads in the batch mode.
Definition: CrestApi.cxx:1505
python.PyAthena.obj
obj
Definition: PyAthena.py:135
Crest::CrestClient::s_RUNINFO_LIST_PATH
static const std::string s_RUNINFO_LIST_PATH
Definition: CrestApi.h:92
Crest::CrestClient::checkResult
void checkResult(CURLcode res, long response_code, const std::string &st, const char *method_name)
This auxillary method checks the CURL response.
Definition: CrestApi.cxx:1698
error
Definition: IImpactPoint3dEstimator.h:70
Crest::CrestClient::findGlobalTagFs
nlohmann::json findGlobalTagFs(const std::string &name)
The auxillary method to find a global tag by name stored in file storage.
Definition: CrestApi.cxx:2307
python.compressB64.c
def c
Definition: compressB64.py:93
Crest::CrestClient::m_data_folder
std::string m_data_folder
Definition: CrestApi.h:69
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
Crest::CrestClient::getEnvA
std::string getEnvA(const char *varname)
Auxillary method to get an environment variable.
Definition: CrestApi.cxx:1856
Crest::CrestClient::createGlobalTagFs
void createGlobalTagFs(nlohmann::json &js)
The auxillary method to create a global tag in file storage.
Definition: CrestApi.cxx:2266
Crest::CrestClient::findAllIovsFs
nlohmann::json findAllIovsFs(const std::string &tagname)
This method finds all iovs by the tag name in the file storage.
Definition: CrestApi.cxx:1781
Crest::CrestClient::createTagDump
void createTagDump(nlohmann::json &js)
Method to store a tag in the local file system.
Definition: CrestApi.cxx:311
Crest::CrestClient::make_url
std::string make_url(const std::string &address) const
Definition: CrestApi.cxx:90
Crest::CrestClient::getMgmtInfo2
nlohmann::json getMgmtInfo2()
This is an auxillary method to read the CREST Server properties.
Definition: CrestApi.cxx:2847
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
Crest::CrestClient::s_IOV_SIZE_PATH
static const std::string s_IOV_SIZE_PATH
Definition: CrestApi.h:81