![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
16 #ifndef CRESTAPI_CRESAPI_H
17 #define CRESTAPI_CRESAPI_H
24 #include "nlohmann/json.hpp"
25 #include <curl/curl.h>
70 std::map<std::string, nlohmann::json>
m_data {};
174 const char* method_name);
250 void checkResult(CURLcode
res,
long response_code,
const std::string& st,
const char* method_name);
270 CrestClient(
bool rewriteIfExists,
const std::string& root_folder =
"/tmp/crest_dump");
370 void removeTag(
const std::string& tagName);
452 const std::string& record,
const std::string&
label);
716 const std::string& dateformat);
1077 void createTag(
const std::string&
name,
const std::string&
desc,
const std::string& timeType);
1087 void createTag(
const std::string&
name,
const std::string&
desc,
const std::string& timeType,
1088 const std::string& payloadSpec);
1568 std::vector<std::string>
split(std::string_view
str,
char delim);
2007 #endif // not CRESTAPI_CRESAPI_H
void checkFsException(const char *method_name)
Auxillary method to check if the CrestApi library initialized to work with the file system.
nlohmann::json getPayloadAsJsonFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
static const std::string s_TAG_PATH
std::string m_root_folder
bool isJson(const std::string &str)
This method checks if a string is in the JSON format.
std::string getBlob(const std::string &hash)
This method finds payload data by hash; the payload object contains the real BLOB.
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).
static const std::string s_FS_IOV_FILE
std::string getBlobInStreamFs(const std::string &hash, std::ofstream &out)
This method finds payload data by hash; the payload object contains the real BLOB.
nlohmann::json selectIovs(const std::string &tagname)
Select iovs for a given tagname.
nlohmann::json findGlobalTagMapFs(const std::string &name)
The auxillary method to find a global tag by name for the file storage.
nlohmann::json findAllIovs(const std::string &tagname)
This method finds all iovs for a given tag name.
static const std::string s_MGMT_INFO_PATH
const char * m_CREST_PROXY_VAR
void getTagDataInfo(const std::string &tagname)
This is an auxillary method for checking how many unique IOVs(hashcodes) are in an IOV list.
path
python interpreter configuration --------------------------------------—
std::string getDateAndTime()
The auxillary method to get a current data and time.
void createTagMetaInfoIOVDbSvc(const std::string &tagname, nlohmann::json &js)
This method creates a tag meta info in the CREST database.
nlohmann::json getPayloadMetaInfoAsJsonFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
nlohmann::json getJson(const std::string &str)
Auxillary method to convert string in to JSON object.
void createTag(nlohmann::json &js)
This method creates a tag in the CREST database.
std::string getFileString(const std::string &path)
Auxillary method to get a file as a string.
static const std::string s_ADMIN_PATH
static const std::string s_FS_TAGMETAINFO_FILE
std::string getBlobInStream(const std::string &hash, std::ofstream &out)
This method finds payload data by hash; the payload object contains the real BLOB.
nlohmann::json findTagFs(const std::string &name)
This method finds a tag by the tag name in the file storage.
std::map< std::string, nlohmann::json > m_data
nlohmann::json getTagMetaInfo(const std::string &tagname)
This method gets a tag meta info from the CREST database.
nlohmann::json findGlobalTagMap(const std::string &name)
This method search for mappings using the global tag name.
static const std::string s_IOV_PATH
void createGlobalTag(nlohmann::json &js)
Create a global tag in the database.
static const std::string s_FS_TAG_PATH
nlohmann::json findRunLumiInfo(const urlParameters ¶ms)
Finds a run/lumi information lists using parameters.
static const std::string s_METHOD_IOVS
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).
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 nam...
static const std::string s_GLOBALTAG_MAP_PATH
std::string getTagMetaInfoElement(const std::string &name, nlohmann::json &js)
Auxillary method to get an element by name from the Tag Meta Info.
int getSize(const std::string &tagname)
This metghod gets the number of iovs for the given tag.
void streamTest()
this is test only, later it will be deleted (The old method name is streamtest)
nlohmann::json findGlobalTag(const std::string &name)
Finds a global tag by name.
static const std::string s_FS_PALOAD_FILE
std::string getHash(std::string_view str)
The auxillary method to calculate a hash code for a given string.
nlohmann::json listGlobalTags()
This method finds a global tag lists.
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.
void checkCrestVersion2()
This method is a CREST version test.
std::string performRequest(const std::string ¤t_path, Action action, nlohmann::json &js)
General auxiliary method to make request to the CREST Server.
static const std::string s_METHOD_MONITOR
nlohmann::json getPayloadMetaInfo(const std::string &hash)
This method finds a payload resource associated to the hash.
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.
static const std::string s_RUNINFO_PATH
void updateTagMetaInfoFs(const std::string &tagname, nlohmann::json &js)
This auxillary method updates a tag meta info in local file storage.
nlohmann::json getTagMetaInfoFs(const std::string &name)
This is an auxillary method, it gets a tag meta info from file system storage.
std::string getPayloadAsStringFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
static const std::string s_FS_GLOBALTAG_PATH
static const std::string s_MONITORING_PAYLOAD_PATH
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_ta...
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...
std::string removeCR(const std::string &str)
This method removes all end of line and carriage return symbols from a string.
void storeBatchPayloadsFs(const std::string &tag_name, std::string &iovsetupload)
This auxillary method stores several payloads in batch mode in the file storage.
nlohmann::json convertTagMetaInfo2IOVDbSvc(nlohmann::json &js)
Auxillary method to convert a Tag Meta Info from the JSON CREST Server format in to IOVDbSvc format.
static const bool s_CREST_CLIENT_CHECK
void createTagMetaInfoFs(nlohmann::json &js)
This is an auxillary method, it creates a tag meta info on the file system storage.
static const std::string s_GLOBALTAG_PATH
nlohmann::json convertTagMetaInfo2CREST(nlohmann::json &js)
Auxillary method to convert a Tag Meta Info from the JSON IOVDbSvc format in CREST Server format.
void storeBatchPayloadsFiles(const std::string &tag_name, uint64_t endtime, nlohmann::json &js)
This method stores several payloads from files in batch mode.
void createPayload(nlohmann::json &js)
This method creates a payload in the CREST DB.
std::vector< std::string > split(std::string_view str, char delim)
Auxillary method to split a string.
nlohmann::json listTags(void)
This method returns the tag list.
static const std::string s_MGMT_INFO_PATH_2
static const std::string s_FS_META_FILE
static const std::string s_META_PATH
void updateTag(const std::string &tagname, nlohmann::json body)
This method allows to update tag record in the CREST DB.
void storeBatchPayloads(const std::string &tag_name, uint64_t endtime, const std::string &iovsetupload)
This method stores several payloads in batch mode.
std::string getPayloadAsString(const std::string &hash)
This method finds a payload resource associated to the hash.
static const std::string s_METHOD_GROUPS
std::string getCrestVersion()
This method returns the full CREST Server version.
static const std::string s_MGMT_PATH
void createGlobalTagMapFs(nlohmann::json &js)
The auxillary method to create a global tag map in file storage.
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.
nlohmann::json returnJArray(nlohmann::json js)
This auxillary method creates a JSON array from a JSON object.
std::string ParseXMLOutput(std::string_view xmlBuffer)
This method removes all XML/HTML tags from a string.
std::pair< std::vector< unsigned int >, bool > res
static const std::string s_FS_MAP_FILE
int getSizeFS(const std::string &tagname)
This metghod gets the number of iovs for the given tag.
static const int s_FS_PREFIX_LENGTH
nlohmann::json findTag(const std::string &name)
This method finds a tag by the name.
static const std::string s_FS_DATA_PATH
void createGlobalTagMap(nlohmann::json >)
Method to create a global tag map.
nlohmann::json getResFirst(nlohmann::json &js)
Auxillary method to get the first element from resources of the new CREST server response.
static const std::string s_DATA_PATH
std::string getPayloadMetaInfoAsStringFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
std::string getCrestVersion2()
This method returns the full CREST Server version.
std::list< std::string > shortListTagsFs()
This method returns a tag list stored in the file storage.
static const std::string s_CREST_CLIENT_VERSION
CrestClient(bool rewriteIfExists, const std::string &root_folder="/tmp/crest_dump")
CrestClient constructor for file storage mode.
void flush()
Auxillary method to write all the data at the end of a session.
void storePayloadDump(const std::string &tag, uint64_t since, const std::string &js)
Method to store a payload in the local file system.
nlohmann::json listPayloadTagInfo()
This method retrieves monitoring information on all payloads as a list of payload tag information.
nlohmann::json getResources(nlohmann::json &js)
Auxillary method to get a resources parameter from new CREST server response.
std::string getFirstLetters(const std::string &str)
This is an auxillary method extract first letters from the string (hash).
nlohmann::json getSizeByTagFS(const std::string &tagname)
This method gets the number of iovs for tags matching pattern.
std::string getClientVersion()
This method returns the full CrestApi version.
void updateTagMetaInfo(nlohmann::json &js)
This method updates a tag meta info in the CREST database.
int checkErrors(const nlohmann::json &js, const char *method)
Auxillary method to check if the JSON object contain an error message.
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.
static const std::string s_PAYLOAD_PATH
void add(const std::string &key, const std::string &value)
void updateTagSpecification(const std::string &tagname, const std::string &objectType)
This method cahnges object type specification.
void checkCrestVersion()
This method is a CREST version test.
nlohmann::json listFolders()
This method returns the folder list on CREST DB.
nlohmann::json getMgmtInfo()
This is an auxillary method to read the CREST Server properties.
std::string findGlobalTagAsString(const std::string &name)
Finds a global tag by name.
void storeBatchIOVs(nlohmann::json &js)
This method stores an IOV set on the CREST server.
void createIov(nlohmann::json &iov)
This method creates an iov for a given tag in the CREST DB for the created payload.
std::string getDataPath()
Auxillary method to get an environment variable DAT_PATH.
nlohmann::json selectGroups(const std::string &tagname)
Select groups for a given tagname.
void createTagMetaInfo(nlohmann::json &js)
This method creates a tag meta info in the CREST database.
void replaceSymbols(std::string &str, const std::string &from, const std::string &to)
This auxilary method replaces the substring from by the substring to.
int getMajorVersion(std::string &str)
This is an auxillary method to extract a major version number from full version string.
void removeTag(const std::string &tagName)
This method allows to remove a Tag.
nlohmann::json listRunLumiInfo()
This method gets full list of run/lumi information data.
void getFileList(const std::string &path)
Auxillary method to get a file list in the given directory.
static const std::string s_FOLDER_PATH
static const std::string s_FS_PATH
nlohmann::json getPayloadAsJson(const std::string &hash)
This method finds a payload resource associated to the hash.
nlohmann::json getTagMetaInfoIOVDbSvc(const std::string &tagname)
This method gets a tag meta info from the CREST database in IOVDbSvc format.
std::string createFolder(nlohmann::json &body)
Method to create a folder.
static const std::string s_FS_TAG_FILE
static const std::string s_FS_GLOBALTAG_FILE
std::string getPayloadMetaInfoAsString(const std::string &hash)
This method finds a payload resource associated to the hash.
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.
static const std::string s_RUNINFO_LIST_PATH
void checkResult(CURLcode res, long response_code, const std::string &st, const char *method_name)
This auxillary method checks the CURL response.
void createRunLumiInfo(nlohmann::json &body)
This method creates an entry for run information.
nlohmann::json findGlobalTagFs(const std::string &name)
The auxillary method to find a global tag by name stored in file storage.
std::string m_data_folder
std::string getEnvA(const char *varname)
Auxillary method to get an environment variable.
void createGlobalTagFs(nlohmann::json &js)
The auxillary method to create a global tag in file storage.
void removeGlobalTag(const std::string &name)
This method allows to remove a Global Tag form CREST DB.
nlohmann::json findAllIovsFs(const std::string &tagname)
This method finds all iovs by the tag name in the file storage.
void createTagDump(nlohmann::json &js)
Method to store a tag in the local file system.
const std::string & getParams() const
std::string make_url(const std::string &address) const
nlohmann::json getMgmtInfo2()
This is an auxillary method to read the CREST Server properties.
std::string listGlobalTagsAsString()
This method finds a global tag lists.
std::string description
glabal timer - how long have I taken so far?
static const std::string s_IOV_SIZE_PATH