ATLAS Offline Software
CrestApi.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2019-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 
16 #ifndef CRESTAPI_CRESAPI_H
17 #define CRESTAPI_CRESAPI_H
18 
19 #include <string>
20 #include <map>
21 #include <list>
22 #include <iosfwd>
23 #include <cstdint>
24 #include "nlohmann/json.hpp"
25 #include <curl/curl.h>
26 #include <iostream>
27 
28 
29 namespace Crest {
30 
31 // AUXILIARY CLASS to store URL request parameters
33  {
34  private:
35  std::string m_str {};
36  public:
37  void add(const std::string& key, const std::string& value) {
38  if (m_str.empty()) {
39  m_str = key;
40  m_str += '=';
41  m_str += value;
42  } else {
43  m_str +='&';
44  m_str += key;
45  m_str += '=';
46  m_str += value;
47  }
48  }
49 
50  const std::string &getParams() const {
51  return m_str;
52  }
53 
54  void reset() {
55  m_str.clear();
56  }
57  };
58 
59 
60 
62  {
63  private:
64  std::string make_url(const std::string &address) const;
65  std::string m_host {};
66  std::string m_port {};
67  int m_mode {};
68  std::string m_root_folder {};
69  std::string m_data_folder {};
70  std::map<std::string, nlohmann::json> m_data {};
71  bool m_isRewrite {};
72  std::string m_currentTag {};
73 
74  std::string m_PATH = "/api-v4.0";
75  char* m_CREST_PROXY = NULL;
76  const char* m_CREST_PROXY_VAR = "SOCKS_PROXY";
77  inline static const std::string s_TAG_PATH = "/tags";
78  inline static const std::string s_ADMIN_PATH = "/admin";
79  inline static const std::string s_IOV_PATH = "/iovs";
80 
81  inline static const std::string s_IOV_SIZE_PATH = "/size";
82 
83  inline static const std::string s_GLOBALTAG_PATH = "/globaltags";
84  inline static const std::string s_GLOBALTAG_MAP_PATH = "/globaltagmaps";
85  inline static const std::string s_PAYLOAD_PATH = "/payloads";
86  inline static const std::string s_MONITORING_PAYLOAD_PATH = "/monitoring/payloads";
87  inline static const std::string s_META_PATH = "/meta";
88  inline static const std::string s_DATA_PATH = "/data";
89 
90  inline static const std::string s_FOLDER_PATH = "/folders";
91  inline static const std::string s_RUNINFO_PATH = "/runinfo";
92  inline static const std::string s_RUNINFO_LIST_PATH = "/list";
93 
94  inline static const std::string s_METHOD_IOVS = "IOVS";
95  inline static const std::string s_METHOD_GROUPS = "GROUPS";
96  inline static const std::string s_METHOD_MONITOR = "MONITOR";
97 
98 
99  // parameters for CREST file storage:
100 
101  inline static const std::string s_FS_TAG_PATH = "/tags";
102  inline static const std::string s_FS_GLOBALTAG_PATH = "/globaltags";
103  inline static const std::string s_FS_DATA_PATH = "/data";
104 
105  inline static const std::string s_FS_TAG_FILE = "/tag.json";
106  inline static const std::string s_FS_IOV_FILE = "/iovs.json";
107  inline static const std::string s_FS_TAGMETAINFO_FILE = "/tagmetainfo.json";
108 
109  inline static const std::string s_FS_META_FILE = "/meta.json";
110  inline static const std::string s_FS_PALOAD_FILE = "/payload.json";
111 
112  inline static const std::string s_FS_GLOBALTAG_FILE = "/globaltag.json";
113  inline static const std::string s_FS_MAP_FILE = "/maps.json";
114 
115  inline static const std::string s_FS_PATH = "";
116 
117  inline static const int s_FS_PREFIX_LENGTH = 3;
118 
119  // CREST Server data paths:
120  inline static const std::string s_MGMT_PATH = "/mgmt";
121  inline static const std::string s_MGMT_INFO_PATH = "/info";
122  inline static const std::string s_CREST_CLIENT_VERSION = "4.0";
123  inline static const std::string s_MGMT_INFO_PATH_2 = "/actuator/info";
124 
125  enum CrestMode {
127  };
128  enum Action {
129  GET = 0, POST = 1, PUT = 2, DELETE = 3
130  };
131 
132 
133 // ====================================================
134 // REQUEST METHODS
135 
146  std::string performRequest(const std::string& current_path, Action action, nlohmann::json& js);
147 
148 
159  std::string performRequest(const std::string& current_path, Action action, nlohmann::json& js, std::ofstream& out);
160 
161 
173  std::string performRequest(const std::string& current_path, Action action, nlohmann::json& js,
174  const char* method_name);
175 
183  std::string storeBatchPayloadRequest(const std::string& tag, uint64_t endtime, const std::string& js);
184 
185 
186 // ====================================================
187 // AUXILLARY METHODS
188 
195 
196 
203 
204 
210  void checkFsException(const char* method_name);
211 
212 
225  int checkErrors(const nlohmann::json& js, const char* method);
226 
232  std::string ParseXMLOutput(std::string_view xmlBuffer);
233 
239  std::string removeCR(const std::string& str);
240 
241 
250  void checkResult(CURLcode res, long response_code, const std::string& st, const char* method_name);
251 
252  // NEW:
253 
254 void getProxyPath();
255 
256 
257  public:
258 
259  inline static const bool s_CREST_CLIENT_CHECK = false;
260 
261 // ===================================
262 // CONSTRUCTORS
263 
270  CrestClient(bool rewriteIfExists, const std::string& root_folder = "/tmp/crest_dump");
271 
272 
281  CrestClient(const std::string& _host, const std::string& _port, bool check_version = s_CREST_CLIENT_CHECK);
282 
297  CrestClient(std::string_view url, bool check_version = s_CREST_CLIENT_CHECK);
298 
299  ~CrestClient();
300 
301 
302 
303 // ==========================================
304 // Utilities
305 
306 
313  nlohmann::json getJson(const std::string& str); // string to json
314 
320  bool isJson(const std::string& str);
321 
322 
323  private:
324 
332  nlohmann::json getJson(const std::string& str, const char* method); // string to json
333 
340  std::string getFileString(const std::string& path); // method to read file as a string
341 
348  void getFileList(const std::string& path);
349 
350 
351  public:
352 
353 //=====================================================
354 // AdminApi
355 //
356 
362  void removeGlobalTag(const std::string& name);
363 
364 
370  void removeTag(const std::string& tagName);
371 
372 
396  void updateGlobalTag(const std::string& name, nlohmann::json body);
397 
398 //=====================================================
399 
400 //=====================================================
401 // FoldersApi
402 //
403 
408  std::string createFolder(nlohmann::json& body); //method does not work, maybe the parameters were wrong
409 
410 
416 
417 
418 //=====================================================
419 
420 //=====================================================
421 // GlobaltagmapsApi
422 //
423 
440 
441 
442 
451  void createGlobalTagMap(const std::string& globaltag, const std::string& tagname,
452  const std::string& record, const std::string& label);
453 
480  nlohmann::json findGlobalTagMap(const std::string& name);
481 
482 
483 //=====================================================
484 
485 //=====================================================
486 // GlobaltagsApi
487 //
488 
513 
519  void createGlobalTag(const std::string& tag);
520 
540  void createGlobalTag(const std::string& tagname, const std::string& description);
541 
542 
552  std::string findGlobalTagAsString(const std::string& name);
553 
596  nlohmann::json findGlobalTag(const std::string& name);
597 
598 
627 
628 
629 
639  nlohmann::json listGlobalTags(const std::string& name, int size, int page, const std::string& sort);
640 
647  std::string listGlobalTagsAsString();
648 
649 
650 //=====================================================
651 
652 // ====================================================
653 // IovsApi
654 
655 
673 
674 
701  nlohmann::json findAllIovs(const std::string& tagname);
702 
715  nlohmann::json findAllIovs(const std::string& tagname, int size, int page, const std::string& sort,
716  const std::string& dateformat);
717 
718 
724  int getSize(const std::string& tagname);
725 
726 
727 
733  nlohmann::json selectGroups(const std::string& tagname);
734 
735 
742  nlohmann::json selectGroups(const std::string& tagname, long snapshot);
743 
744 
754  nlohmann::json selectIovs(const std::string& tagname);
755 
756 
766  nlohmann::json selectIovs(const std::string& tagname, long snapshot);
767 
768 
774  void storeBatchIOVs(nlohmann::json& js);
775 
776 
777 
778 //=======================================================
779 
780 //=======================================================
781 // MonitoringApi
782 //
783 
810 
818  nlohmann::json listPayloadTagInfo(const std::string& tagname);
819 
820 //=======================================================
821 
822 //=======================================================
823 // PayloadsApi
824 //
825 
826 
843  void createPayload(nlohmann::json& js);
844 
845 
851  std::string getBlob(const std::string& hash);
852 
860  std::string getBlobInStream(const std::string& hash, std::ofstream& out);
861 
862 
868  nlohmann::json getPayloadAsJson(const std::string& hash);
869 
870 
876  std::string getPayloadAsString(const std::string& hash);
877 
878 
899  nlohmann::json getPayloadMetaInfo(const std::string& hash);
900 
909  std::string getPayloadMetaInfoAsString(const std::string& hash);
910 
911 
912 
921  void storePayload(const std::string& tag, uint64_t since, const std::string& js);
922 
923 // Stores payloads in batch mode
924 
940  void storeBatchPayloads(const std::string& tag_name, uint64_t endtime, const std::string& iovsetupload);
941 
942 
959  void storeBatchPayloads(const std::string& tag_name, uint64_t endtime, nlohmann::json& js);
960 
976  void storeBatchPayloads(const std::string& tag_name, const std::string& iovsetupload, uint64_t endtime = 0);
977 
994  void storeBatchPayloads(const std::string& tag_name, nlohmann::json& js, uint64_t endtime = 0);
995 
996 //=======================================================
997 
998 //=======================================================
999 // RuninfoApi
1000 //
1001 
1002 
1014  void createRunLumiInfo(nlohmann::json& body);
1015 
1016 
1031 
1032 
1038 
1039 //=======================================================
1040 
1041 //=======================================================
1042 // TagsApi
1043 
1044 // CREATE TAG
1045 
1046 
1067  void createTag(nlohmann::json& js);
1068 
1069 
1077  void createTag(const std::string& name, const std::string& desc, const std::string& timeType);
1078 
1087  void createTag(const std::string& name, const std::string& desc, const std::string& timeType,
1088  const std::string& payloadSpec);
1089 
1090 //std::string uploadPayload(std::string tag,std::string since, std::string& js);
1091 
1092 
1130  nlohmann::json findTag(const std::string& name);
1131 
1132 
1133 // TAG LIST methods:
1134 
1158  nlohmann::json listTags(void);
1159 
1168  nlohmann::json listTags(int size, int page);
1169 
1170 
1181  nlohmann::json listTags(const std::string& name, int size, int page, const std::string& sort);
1182 
1183 
1184 // UPDATE TAG
1185 
1202  void updateTag(const std::string& tagname, nlohmann::json body);
1203 
1204 
1211  void updateTagSpecification(const std::string& tagname, const std::string& objectType);
1212 
1213 // FILE SYSTEM METHODS
1214 
1215 //Dump methods
1216 
1224  void createTagDump(nlohmann::json& js);
1225 
1231  void flush();
1232 
1242  void storePayloadDump(const std::string& tag, uint64_t since, const std::string& js);
1243 
1244 
1251  std::list<std::string> shortListTagsFs();
1252 
1261  nlohmann::json findTagFs(const std::string& name);
1262 
1271  nlohmann::json findAllIovsFs(const std::string& tagname);
1272 
1283  nlohmann::json findAllIovsFs(const std::string& tagname, int size, int page);
1284 
1290  std::string getFileName(const std::string& path);
1291 
1292 
1300  std::string getBlobFs(const std::string& hash);
1301 
1310  std::string getBlobInStreamFs(const std::string& hash, std::ofstream& out);
1311 
1312 
1326  void storeBatchPayloadsFs(const std::string& tag_name, std::string& iovsetupload);
1327 
1342  void storeBatchPayloadsFs(const std::string& tag_name, nlohmann::json& js);
1343 
1344 
1349  void streamTest();
1350 
1351  private:
1352 
1358  std::string getEnvA(const char* varname);
1359 
1364  std::string getDataPath();
1365 
1366  public:
1367 
1368 // Tag Meta Info Methods
1369 
1387 
1408  void createTagMetaInfo(const std::string& tagname, nlohmann::json& js);
1409 
1410 
1440  nlohmann::json getTagMetaInfo(const std::string& tagname);
1441 
1459 
1460 
1478  void updateTagMetaInfo(const std::string& tagname, nlohmann::json& js);
1479 
1480 
1498 
1505  nlohmann::json getTagMetaInfoFs(const std::string& name);
1506 
1507 
1525  void updateTagMetaInfoFs(const std::string& tagname, nlohmann::json& js);
1526 
1540  std::string getTagMetaInfoElement(const std::string& name, nlohmann::json& js);
1541 
1542 
1550 
1551 
1559 
1560  private:
1561 
1568  std::vector<std::string> split(std::string_view str, char delim);
1569 
1570  public:
1571 
1576  nlohmann::json getTagMetaInfoIOVDbSvc(const std::string& tagname);
1577 
1578 
1596  void createTagMetaInfoIOVDbSvc(const std::string& tagname, nlohmann::json& js);
1597 
1616  void createTagMetaInfoIOVDbSvc(const std::string& tagname, nlohmann::json& js, const std::string& description);
1617 
1618 //=====================================================
1619 // Global Tag and Global Tag Map methods for the file storage
1620 //
1621 
1646 
1647 
1656  nlohmann::json findGlobalTagFs(const std::string& name);
1657 
1658 
1675 
1686  nlohmann::json findGlobalTagMapFs(const std::string& name);
1687 
1688 
1689 //=====================================================
1690 // Payloads methods for the file storage
1691 //
1692 
1699  std::string getPayloadAsStringFS(const std::string& hash);
1700 
1707  nlohmann::json getPayloadAsJsonFS(const std::string& hash);
1708 
1718  std::string getPayloadMetaInfoAsStringFS(const std::string& hash);
1719 
1729  nlohmann::json getPayloadMetaInfoAsJsonFS(const std::string& hash);
1730 
1731 
1732 
1733 //=====================================================
1734 // IOV number methods for the file storage
1735 //
1736 
1743  int getSizeFS(const std::string& tagname);
1744 
1745 
1754 
1755 
1756 //=====================================================
1757 // select IOV list methods
1758 //
1759 
1760 
1773  nlohmann::json selectIovs(const std::string& tagname, long since, long until, long snapshot = 0);
1774 
1775 
1787  nlohmann::json selectIovsFS(const std::string& tagname, long since, long until);
1788 
1789 
1790 //=====================================================
1791 // Auxillary methods
1792 //
1793 
1799  std::string getHash(std::string_view str);
1800 
1806  std::string getDateAndTime();
1807 
1815 
1823  void getTagDataInfo(const std::string& tagname);
1824 
1831  std::string getFirstLetters(const std::string& str);
1832 
1833 
1834 //=====================================================
1835 // Methods to check the CREST Server and CrestApi versions
1836 //
1837 
1855 
1859  std::string getCrestVersion();
1860 
1864  std::string getClientVersion();
1865 
1870  int getMajorVersion(std::string& str);
1871 
1878  void checkCrestVersion();
1879 
1880 //===================================
1881 // Second version of the version checking:
1882 //
1883 
1903 
1907  std::string getCrestVersion2();
1908 
1915  void checkCrestVersion2();
1916 
1917 // NEW:
1918 
1926  void removeTagFromGlobalTagMap(const std::string& global_tag,const std::string& tag,const std::string& label);
1927 
1928 
1947  void storeBatchPayloadsFiles(const std::string& tag_name, uint64_t endtime, nlohmann::json& js);
1948 
1949 
1956  std::string storeBatchPayloadFilesRequest(const std::string& tag, uint64_t endtime, const std::string& js);
1957 
1958 
1966  void storeData(const std::string& tag, uint64_t endtime, uint64_t since, const std::string& file);
1967 
1968 
1992  void storeDataArray(const std::string& tag, uint64_t endtime, std::map<uint64_t, std::string> m);
1993 
2000  void replaceSymbols(std::string& str, const std::string& from, const std::string& to);
2001 
2002  };
2003 
2004 } // namespace
2005 
2006 
2007 #endif // not CRESTAPI_CRESAPI_H
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
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
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
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
Crest::CrestClient::getBlob
std::string getBlob(const std::string &hash)
This method finds payload data by hash; the payload object contains the real BLOB.
Definition: CrestApi.cxx:915
Crest::CrestClient::getFileName
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).
Definition: CrestApi.cxx:1802
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
Crest::CrestClient::m_currentTag
std::string m_currentTag
Definition: CrestApi.h:72
Crest::CrestClient::selectIovs
nlohmann::json selectIovs(const std::string &tagname)
Select iovs for a given tagname.
Definition: CrestApi.cxx:493
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
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
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
Crest::CrestClient::getTagDataInfo
void getTagDataInfo(const std::string &tagname)
This is an auxillary method for checking how many unique IOVs(hashcodes) are in an IOV list.
Definition: CrestApi.cxx:2712
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
Crest::CrestClient::getProxyPath
void getProxyPath()
Definition: CrestApi.cxx:3149
Crest::CrestClient::getDateAndTime
std::string getDateAndTime()
The auxillary method to get a current data and time.
Definition: CrestApi.cxx:2534
Crest::CrestClient::createTagMetaInfoIOVDbSvc
void createTagMetaInfoIOVDbSvc(const std::string &tagname, nlohmann::json &js)
This method creates a tag meta info in the CREST database.
Definition: CrestApi.cxx:2134
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
Crest::CrestClient::s_ADMIN_PATH
static const std::string s_ADMIN_PATH
Definition: CrestApi.h:78
Crest::CrestClient::s_FS_TAGMETAINFO_FILE
static const std::string s_FS_TAGMETAINFO_FILE
Definition: CrestApi.h:107
Crest::CrestClient::getBlobInStream
std::string getBlobInStream(const std::string &hash, std::ofstream &out)
This method finds payload data by hash; the payload object contains the real BLOB.
Definition: CrestApi.cxx:936
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::findGlobalTagMap
nlohmann::json findGlobalTagMap(const std::string &name)
This method search for mappings using the global tag name.
Definition: CrestApi.cxx:849
Crest::CrestClient::s_IOV_PATH
static const std::string s_IOV_PATH
Definition: CrestApi.h:79
Crest::CrestClient::createGlobalTag
void createGlobalTag(nlohmann::json &js)
Create a global tag in the database.
Definition: CrestApi.cxx:688
Crest::CrestClient::s_FS_TAG_PATH
static const std::string s_FS_TAG_PATH
Definition: CrestApi.h:101
Crest::CrestClient::findRunLumiInfo
nlohmann::json findRunLumiInfo(const urlParameters &params)
Finds a run/lumi information lists using parameters.
Definition: CrestApi.cxx:1228
Crest::CrestClient::s_METHOD_IOVS
static const std::string s_METHOD_IOVS
Definition: CrestApi.h:94
Crest::CrestClient::PUT
@ PUT
Definition: CrestApi.h:129
Crest::CrestClient::selectIovsFS
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).
Definition: CrestApi.cxx:2689
Crest::CrestClient::storeData
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...
Definition: CrestApi.cxx:3119
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
Crest::CrestClient::getTagMetaInfoElement
std::string getTagMetaInfoElement(const std::string &name, nlohmann::json &js)
Auxillary method to get an element by name from the Tag Meta Info.
Definition: CrestApi.cxx:1936
Crest::CrestClient::getSize
int getSize(const std::string &tagname)
This metghod gets the number of iovs for the given tag.
Definition: CrestApi.cxx:454
athena.value
value
Definition: athena.py:122
Crest::CrestClient::streamTest
void streamTest()
this is test only, later it will be deleted (The old method name is streamtest)
Definition: CrestApi.cxx:1810
Crest::CrestClient::FILESYSTEM_MODE
@ FILESYSTEM_MODE
Definition: CrestApi.h:126
Crest::CrestClient::m_host
std::string m_host
Definition: CrestApi.h:65
Crest::CrestClient::findGlobalTag
nlohmann::json findGlobalTag(const std::string &name)
Finds a global tag by name.
Definition: CrestApi.cxx:745
Crest::CrestClient::m_PATH
std::string m_PATH
Definition: CrestApi.h:74
Crest::CrestClient::s_FS_PALOAD_FILE
static const std::string s_FS_PALOAD_FILE
Definition: CrestApi.h:110
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::listGlobalTags
nlohmann::json listGlobalTags()
This method finds a global tag lists.
Definition: CrestApi.cxx:773
Crest::CrestClient::updateGlobalTag
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.
Definition: CrestApi.cxx:672
Crest::CrestClient::POST
@ POST
Definition: CrestApi.h:129
Crest::CrestClient::DELETE
@ DELETE
Definition: CrestApi.h:129
Crest::CrestClient::checkCrestVersion2
void checkCrestVersion2()
This method is a CREST version test.
Definition: CrestApi.cxx:2889
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
Crest::CrestClient::s_METHOD_MONITOR
static const std::string s_METHOD_MONITOR
Definition: CrestApi.h:96
Crest::CrestClient::getPayloadMetaInfo
nlohmann::json getPayloadMetaInfo(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:956
Crest::CrestClient::storeDataArray
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.
Definition: CrestApi.cxx:3130
Crest
Definition: CrestApi.h:29
Crest::CrestClient::s_RUNINFO_PATH
static const std::string s_RUNINFO_PATH
Definition: CrestApi.h:91
Crest::CrestClient::~CrestClient
~CrestClient()
Definition: CrestApi.cxx:86
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
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
physics_parameters.url
string url
Definition: physics_parameters.py:27
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::removeTagFromGlobalTagMap
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...
Definition: CrestApi.cxx:2902
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
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::urlParameters::m_str
std::string m_str
Definition: CrestApi.h:35
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
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::s_CREST_CLIENT_CHECK
static const bool s_CREST_CLIENT_CHECK
Definition: CrestApi.h:259
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
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
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::createPayload
void createPayload(nlohmann::json &js)
This method creates a payload in the CREST DB.
Definition: CrestApi.cxx:1088
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
Crest::CrestClient::s_FS_META_FILE
static const std::string s_FS_META_FILE
Definition: CrestApi.h:109
Crest::CrestClient::s_META_PATH
static const std::string s_META_PATH
Definition: CrestApi.h:87
Crest::CrestClient::updateTag
void updateTag(const std::string &tagname, nlohmann::json body)
This method allows to update tag record in the CREST DB.
Definition: CrestApi.cxx:278
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::urlParameters::reset
void reset()
Definition: CrestApi.h:54
Crest::CrestClient::getPayloadAsString
std::string getPayloadAsString(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:1066
Crest::CrestClient::s_METHOD_GROUPS
static const std::string s_METHOD_GROUPS
Definition: CrestApi.h:95
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
Crest::CrestClient::createGlobalTagMapFs
void createGlobalTagMapFs(nlohmann::json &js)
The auxillary method to create a global tag map in file storage.
Definition: CrestApi.cxx:2329
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
Crest::CrestClient::CrestMode
CrestMode
Definition: CrestApi.h:125
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
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
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
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
Crest::CrestClient::findTag
nlohmann::json findTag(const std::string &name)
This method finds a tag by the name.
Definition: CrestApi.cxx:226
Crest::CrestClient::s_FS_DATA_PATH
static const std::string s_FS_DATA_PATH
Definition: CrestApi.h:103
Crest::CrestClient::createGlobalTagMap
void createGlobalTagMap(nlohmann::json &gt)
Method to create a global tag map.
Definition: CrestApi.cxx:872
Crest::CrestClient::GET
@ GET
Definition: CrestApi.h:129
Crest::CrestClient::getResFirst
nlohmann::json getResFirst(nlohmann::json &js)
Auxillary method to get the first element from resources of the new CREST server response.
Definition: CrestApi.cxx:1922
Crest::CrestClient::s_DATA_PATH
static const std::string s_DATA_PATH
Definition: CrestApi.h:88
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::shortListTagsFs
std::list< std::string > shortListTagsFs()
This method returns a tag list stored in the file storage.
Definition: CrestApi.cxx:1749
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
Crest::CrestClient::Action
Action
Definition: CrestApi.h:128
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
Crest::CrestClient::listPayloadTagInfo
nlohmann::json listPayloadTagInfo()
This method retrieves monitoring information on all payloads as a list of payload tag information.
Definition: CrestApi.cxx:1023
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::getSizeByTagFS
nlohmann::json getSizeByTagFS(const std::string &tagname)
This method gets the number of iovs for tags matching pattern.
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::updateTagMetaInfo
void updateTagMetaInfo(nlohmann::json &js)
This method updates a tag meta info in the CREST database.
Definition: CrestApi.cxx:2060
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
Crest::CrestClient::storePayload
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.
Definition: CrestApi.cxx:1252
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
Crest::urlParameters::add
void add(const std::string &key, const std::string &value)
Definition: CrestApi.h:37
Crest::CrestClient::updateTagSpecification
void updateTagSpecification(const std::string &tagname, const std::string &objectType)
This method cahnges object type specification.
Definition: CrestApi.cxx:293
Crest::CrestClient::checkCrestVersion
void checkCrestVersion()
This method is a CREST version test.
Definition: CrestApi.cxx:2833
Crest::CrestClient::listFolders
nlohmann::json listFolders()
This method returns the folder list on CREST DB.
Definition: CrestApi.cxx:1163
Crest::CrestClient::getMgmtInfo
nlohmann::json getMgmtInfo()
This is an auxillary method to read the CREST Server properties.
Definition: CrestApi.cxx:2767
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
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:32
MyPlots.page
page
Definition: MyPlots.py:234
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
Crest::CrestClient::m_port
std::string m_port
Definition: CrestApi.h:66
Crest::CrestClient::createIov
void createIov(nlohmann::json &iov)
This method creates an iov for a given tag in the CREST DB for the created payload.
Definition: CrestApi.cxx:370
Crest::CrestClient::getDataPath
std::string getDataPath()
Auxillary method to get an environment variable DAT_PATH.
Definition: CrestApi.cxx:1866
Crest::CrestClient::selectGroups
nlohmann::json selectGroups(const std::string &tagname)
Select groups for a given tagname.
Definition: CrestApi.cxx:579
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
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
Definition: CrestApi.h:62
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
Crest::CrestClient::removeTag
void removeTag(const std::string &tagName)
This method allows to remove a Tag.
Definition: CrestApi.cxx:209
tagname
Definition: tagname.h:29
str
Definition: BTagTrackIpAccessor.cxx:11
Crest::CrestClient::listRunLumiInfo
nlohmann::json listRunLumiInfo()
This method gets full list of run/lumi information data.
Definition: CrestApi.cxx:1198
Crest::CrestClient::getFileList
void getFileList(const std::string &path)
Auxillary method to get a file list in the given directory.
Definition: CrestApi.cxx:1739
Crest::CrestClient::s_FOLDER_PATH
static const std::string s_FOLDER_PATH
Definition: CrestApi.h:90
Crest::CrestClient::s_FS_PATH
static const std::string s_FS_PATH
Definition: CrestApi.h:115
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
Crest::CrestClient::getPayloadAsJson
nlohmann::json getPayloadAsJson(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:1042
Crest::CrestClient::getTagMetaInfoIOVDbSvc
nlohmann::json getTagMetaInfoIOVDbSvc(const std::string &tagname)
This method gets a tag meta info from the CREST database in IOVDbSvc format.
Definition: CrestApi.cxx:2120
Crest::CrestClient::createFolder
std::string createFolder(nlohmann::json &body)
Method to create a folder.
Definition: CrestApi.cxx:1181
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
Crest::CrestClient::s_FS_GLOBALTAG_FILE
static const std::string s_FS_GLOBALTAG_FILE
Definition: CrestApi.h:112
Crest::CrestClient::getPayloadMetaInfoAsString
std::string getPayloadMetaInfoAsString(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:980
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
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
Crest::CrestClient::createRunLumiInfo
void createRunLumiInfo(nlohmann::json &body)
This method creates an entry for run information.
Definition: CrestApi.cxx:1216
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
Crest::urlParameters
Definition: CrestApi.h:33
Crest::CrestClient::m_data_folder
std::string m_data_folder
Definition: CrestApi.h:69
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::removeGlobalTag
void removeGlobalTag(const std::string &name)
This method allows to remove a Global Tag form CREST DB.
Definition: CrestApi.cxx:758
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::urlParameters::getParams
const std::string & getParams() const
Definition: CrestApi.h:50
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
Crest::CrestClient::listGlobalTagsAsString
std::string listGlobalTagsAsString()
This method finds a global tag lists.
Definition: CrestApi.cxx:788
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Crest::CrestClient::s_IOV_SIZE_PATH
static const std::string s_IOV_SIZE_PATH
Definition: CrestApi.h:81