ATLAS Offline Software
CrestApi.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <CrestApi/CrestApi.h>
7 #include <CrestApi/CrestModel.h>
8 
9 #include <boost/uuid/uuid.hpp> // uuid class
10 #include <boost/uuid/uuid_generators.hpp> // generators
11 #include <boost/uuid/uuid_io.hpp>
12 #include <boost/asio.hpp>
13 
14 #include <fstream>
15 #include <filesystem>
16 #include <iostream>
17 #include <sstream>
18 
19 #include <CrestApi/picosha2.h>
20 
21 #include <cstdio>
22 #include <ctime>
23 #include <cstdlib>
24 
25 namespace Crest
26 {
27 
36  CrestClient::CrestClient(const std::string &_host, const std::string &_port, bool check_version) : m_host(_host), m_port(_port)
37  {
38  if (check_version == true)
39  {
41  }
45  }
46 
61  CrestClient::CrestClient(std::string_view url, bool check_version)
62  {
63  size_t found = url.find_first_of(':');
64  size_t n = url.size();
65 
66  std::string_view url_new = url.substr(found + 3); // url_new is the url excluding the http part
67  m_prefix = url.substr(0,found + 3); // URL prefix "http://" or "https://"
68 
69  size_t found1 = url_new.find_first_of(':');
70  size_t found2 = url_new.find_first_of('/');
71 
72  std::string_view host;
73  std::string_view port;
74  std::string_view resources;
75  if (found1 != std::string::npos && found2 != std::string::npos) {
76  host = url_new.substr(0, found1);
77  port = url_new.substr(found1 + 1, found2 - found1 - 1);
78  } else if (found1 != std::string::npos) {
79  host = url_new.substr(0, found1);
80  port = url_new.substr(found1 + 1);
81  } else if (found2 != std::string::npos) {
82  if (m_prefix == "https://") {
83  port = "443";
84  }
85  else port = "80";
86  host = url_new.substr(0, found2);
87  } else {
88  if (m_prefix == "https://") {
89  port = "443";
90  }
91  else port = "80";
92  host = url_new;
93  }
94 
95  if (found2 < n - 1)
96  {
97  resources = url_new.substr(found2, n - 1);
98  m_PATH = resources;
99  }
100 
101  m_port = std::string(port);
102  m_host = std::string(host);
106 
107  if (check_version == true)
108  {
110  }
111  std::cout << "CrestClient::CrestClient: host = " << m_host << ", port = " << m_port << ", path = " << m_PATH << std::endl;
112  }
113 
118 
119 
120  // The auxillary method to remove XML/HTML tags from a std::string
121  std::string CrestClient::parseXMLOutput(const std::string_view xmlBuffer) const
122  {
123  bool copy = true;
124 
125  std::string plainString = "";
126 
127  // remove all xml tags
128  for (long unsigned int i = 0; i < xmlBuffer.length(); i++)
129  {
130  char convertc = xmlBuffer[i];
131 
132  if (convertc == '<')
133  copy = false;
134  else if (convertc == '>')
135  {
136  copy = true;
137  continue;
138  }
139 
140  if (copy)
141  plainString += convertc;
142  }
143 
144  return plainString;
145  }
146 
147 
148  // The auxillary method to remove carridge returns from a std::string
149  std::string CrestClient::removeCR(const std::string &str) const
150  {
151  std::string str2 = str;
152  std::replace(str2.begin(), str2.end(), '\n', '|');
153  char needle = '\r';
154  size_t pos;
155  while ((pos = str2.find(needle)) != str2.npos)
156  {
157  str2.erase(pos, 1);
158  }
159  return str2;
160  }
161 
162 
169  nlohmann::json CrestClient::getJson(const std::string &str, const char *method) const
170  {
171  nlohmann::json js = nullptr;
172  try
173  {
175  }
176  catch (nlohmann::json::parse_error &e)
177  {
178  if (method == nullptr || *method == '\0')
179  {
180  // method name is undefined
181 
182  std::string wh = e.what();
183  throw CrestException("ERROR in JSON conversion: " + wh + " | In string: " + str);
184  }
185  else
186  {
187  std::string str2 = parseXMLOutput(str); // to remove HTML tags use this function
188  std::string str3 = removeCR(str2); // to remove carridge return
189  throw CrestException("ERROR in " + std::string(method) + " | CREST Server response : " + str3);
190  }
191  }
192  catch (const std::exception &e)
193  {
194  throw CrestException("ERROR in CrestClient::" + (std::string)method + ": " + e.what());
195  }
196  return js;
197  }
198 
200  {
201  const char *method_name = "getMgmtInfo";
202 
203  std::string current_path = s_MGMT_PATH + s_MGMT_INFO_PATH;
204  std::string retv;
205  nlohmann::json js = nullptr;
206 
207  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
208 
209  nlohmann::json respond = getJson(retv, method_name);
210 
211  return respond;
212  }
213 
215  {
216 
217  std::string version = "";
218  nlohmann::json buildInfo;
220  // The CREST Server response has the following structure:
221  // { "build": { "artifact": "crestdb", "name": "crest", "version": "4.0", "group": "hep.crest"} }
222  try
223  {
224  buildInfo = info["build"];
225  version = buildInfo["version"];
226  }
227  catch (const std::exception &e)
228  {
229  throw CrestException("ERROR in CrestClient::getCrestVersion: " + to_string(info) + " does not contain version info.");
230  }
231  return version;
232  }
233 
234 
236  {
237  int v = -1;
238  int n = str.find('.');
239 
240  if (n < 1)
241  {
242  throw CrestException("ERROR in CrestClient::getMajorVersion: string \"" + str + "\" does not contain major version.");
243  }
244 
245  std::string vers = str.substr(0, n);
246 
247  try
248  {
249  v = std::stoi(str);
250  }
251  catch (const std::exception &e)
252  {
253  throw CrestException("ERROR in CrestClient::getMajorVersion: string \"" + str + "\" does not contain major version.");
254  }
255 
256  return v;
257  }
258 
260  {
261  std::string client = getClientVersion();
262  std::string server = getCrestVersion();
263 
264  int clientVersion = getMajorVersion(client);
265  int serverVersion = getMajorVersion(server);
266 
267  if (clientVersion != serverVersion)
268  {
269  throw CrestException("ERROR in CrestClient::checkCrestVersion: CrestApi version \"" + client + "\" does not correspond to the server version \"" + server + "\".");
270  }
271  }
272 
273  std::string CrestClient::makeUrl(const std::string &address) const
274  {
275  std::string str = m_prefix;
276  str += m_host;
277  str += ':';
278  str += m_port;
279  str += address;
280  return str;
281  }
282  //==============================================================================================================
283  // GlobalTag methods:
285  {
286  const char *method_name = "CrestClient::createGlobalTag";
287 
288  std::string current_path = m_PATH;
289  current_path += s_GLOBALTAG_PATH;
290  std::string retv;
291  nlohmann::json js = dto.to_json();
292  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
293  }
294 
296  {
297  const char *method_name = "CrestClient::findGlobalTag";
298 
299  std::string current_path = m_PATH;
300  current_path += s_GLOBALTAG_PATH;
301  current_path += '/';
302  current_path += name;
303  std::string retv;
304 
305  nlohmann::json js = nullptr;
306  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
307  nlohmann::json response = getJson(retv, method_name);
308 
310  std::vector<GlobalTagDto> v = dto.resources;
311  // Only one element is expected:
312  return v[0];
313  }
314 
315  GlobalTagSetDto CrestClient::listGlobalTags(const std::string &name, int size, int page, const std::string &sort)
316  {
317  const char *method_name = "CrestClient::listGlobalTags";
318 
319  std::string current_path = m_PATH;
320  current_path += s_GLOBALTAG_PATH;
321  current_path += '?';
322  if (name != "")
323  {
324  current_path += "name=";
325  current_path += name;
326  current_path += '&';
327  }
328  if (size != -1)
329  {
330  current_path += "size=";
331  current_path += std::to_string(size);
332  current_path += '&';
333  }
334  if (page != -1)
335  {
336  current_path += "page=";
337  current_path += std::to_string(page);
338  current_path += '&';
339  }
340  if (sort != "")
341  {
342  current_path += "sort=";
343  current_path += sort;
344  current_path += '&';
345  }
346  std::string retv;
347 
348  nlohmann::json js = nullptr;
349  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
350  nlohmann::json response = getJson(retv, method_name);
351 
353 
354  return dto;
355  }
356 
357  // The method to remove a global tag:
358  void CrestClient::removeGlobalTag(const std::string &name)
359  {
360  const char *method_name = "CrestClient::removeGlobalTag";
361 
362  std::string current_path = m_PATH;
363  current_path += s_ADMIN_PATH;
364  current_path += s_GLOBALTAG_PATH;
365  current_path += '/';
366  current_path += name;
367  std::string retv;
368  nlohmann::json js = nullptr;
369  retv = m_request.performRequest(current_path, Action::DELETE, js, method_name);
370  }
371 
372  //==============================================================================================================
373  // Tag methods:
375  {
376  const char *method_name = "CrestClient::createTag";
377 
378  std::string current_path = m_PATH;
379  current_path += s_TAG_PATH;
380  std::string retv;
381  nlohmann::json js = dto.to_json();
382  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
383  }
384 
385  // The method to find a tag:
386  TagDto CrestClient::findTag(const std::string &name)
387  {
388  const char *method_name = "CrestClient::findTag";
389 
390  std::string current_path = m_PATH;
391  current_path += s_TAG_PATH;
392  current_path += '/';
393  current_path += name;
394  std::string retv;
395  nlohmann::json js = nullptr;
396  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
397  nlohmann::json response = getJson(retv, method_name);
399 
400  std::vector<TagDto> v = dto.resources;
401  // Only one element is expected:
402  return v[0];
403  }
404 
405  TagSetDto CrestClient::listTags(const std::string &name, int size, int page, const std::string &sort)
406  {
407  const char *method_name = "CrestClient::listTags";
408 
409  std::string current_path = m_PATH;
410  current_path += s_TAG_PATH;
411  current_path += '?';
412  if (name != "")
413  {
414  current_path += "name=";
415  current_path += name;
416  current_path += '&';
417  }
418  if (size != -1)
419  {
420  current_path += "size=";
421  current_path += std::to_string(size);
422  current_path += '&';
423  }
424  if (page != -1)
425  {
426  current_path += "page=";
427  current_path += std::to_string(page);
428  current_path += '&';
429  }
430  if (sort != "")
431  {
432  current_path += "sort=";
433  current_path += sort;
434  current_path += '&';
435  }
436  std::string retv;
437 
438  nlohmann::json js = nullptr;
439  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
440  nlohmann::json response = getJson(retv, method_name);
441 
443 
444  return dto;
445  }
446 
447  // The method to remove a tag:
448  void CrestClient::removeTag(const std::string &name)
449  {
450  const char *method_name = "CrestClient::removeTag";
451 
452  std::string current_path = m_PATH;
453  current_path += s_ADMIN_PATH;
454  current_path += s_TAG_PATH;
455  current_path += '/';
456  current_path += name;
457  std::string retv;
458  nlohmann::json js = nullptr;
459  retv = m_request.performRequest(current_path, Action::DELETE, js, method_name);
460  }
461 
462  //==============================================================================================================
463  // TagMeta methods:
465  {
466  const char *method_name = "CrestClient::createTagMeta";
467 
468  std::string current_path = m_PATH;
469  current_path += s_TAG_PATH;
470  current_path += '/';
471  current_path += dto.tagName;
472  current_path += s_META_PATH;
473 
474  std::string retv;
475  nlohmann::json js = dto.to_json();
476  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
477  }
478 
480  {
481  const char *method_name = "CrestClient::updateTagMeta";
482 
483  std::string current_path = m_PATH;
484  current_path += s_TAG_PATH;
485  current_path += '/';
486  current_path += dto.tagName;
487  current_path += s_META_PATH;
488 
489  std::string retv;
490  nlohmann::json js = dto.to_json();
491  retv = m_request.performRequest(current_path, Action::PUT, js, method_name);
492  }
493 
495  {
496  const char *method_name = "CrestClient::findTagMeta";
497 
498  std::string current_path = m_PATH;
499  current_path += s_TAG_PATH;
500  current_path += '/';
501  current_path += name;
502  current_path += s_META_PATH;
503  std::string retv;
504  nlohmann::json js = nullptr;
505  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
506  nlohmann::json response = getJson(retv, method_name);
507 
509  std::vector<TagMetaDto> v = dto.resources;
510  // Only one element is expected:
511  return v[0];
512  }
513 
514 
515  int CrestClient::getSize(const std::string &tagname)
516  {
517  const char *method_name = "CrestClient::getSize";
518 
519  std::string current_path = m_PATH;
520  current_path += s_IOV_PATH;
521  current_path += s_IOV_SIZE_PATH;
522  current_path += "?tagname=";
523  current_path += tagname;
524 
525  std::string retv;
526 
527  nlohmann::json js = nullptr;
528  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
529  nlohmann::json respond = getJson(retv, method_name);
530 
531  auto res = respond.find("resources");
533 
534  if (res != respond.end())
535  {
536  r = respond["resources"][0];
537  }
538 
539  int result = 0;
540  if (r.find("niovs") != r.end())
541  {
542  result = r["niovs"];
543  }
544  else
545  {
546  throw CrestException("ERROR in CrestClient::getSize CREST Server JSON response has no \"size\" key.");
547  }
548 
549  return result;
550  }
551 
552  //==============================================================================================================
553  // GlobalTagMaps methods:
555  {
556  const char *method_name = "CrestClient::createGlobalTagMap";
557 
558  std::string current_path = m_PATH;
559  current_path += s_GLOBALTAG_MAP_PATH;
560  std::string retv;
561  nlohmann::json js = dto.to_json();
562  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
563  }
564 
565  GlobalTagMapSetDto CrestClient::findGlobalTagMap(const std::string &name, const std::string &xCrestMapMode)
566  {
567  const char *method_name = "CrestClient::findGlobalTagMap";
568 
569  std::string current_path = m_PATH;
570  current_path += s_GLOBALTAG_MAP_PATH;
571  current_path += '/';
572  current_path += name;
573  std::string headers_params = "";
574 
575  if (xCrestMapMode != "")
576  {
577  headers_params += "X-Crest-MapMode: ";
578  headers_params += xCrestMapMode;
579  }
580  else
581  {
582  headers_params += "X-Crest-MapMode: ";
583  headers_params += "Trace";
584  }
585  std::string retv;
586  nlohmann::json js = nullptr;
587  retv = m_request.performRequest(current_path, Action::GET, js, method_name, headers_params);
588  nlohmann::json response = getJson(retv, method_name);
590 
591  return dto;
592  }
593 
594  void CrestClient::removeGlobalTagMap(const std::string &name, const std::string &record, const std::string &label, const std::string &tagname)
595  {
596  const char *method_name = "CrestClient::removeGlobalTagMap";
597 
598  std::string current_path = m_PATH;
599  current_path += s_GLOBALTAG_MAP_PATH;
600  current_path += '/';
601  current_path += name;
602  current_path += '?';
603  if (tagname != "")
604  {
605  current_path += "tagname=";
606  current_path += tagname;
607  current_path += '&';
608  }
609  if (record != "")
610  {
611  current_path += "record=";
612  current_path += record;
613  current_path += '&';
614  }
615  if (label != "")
616  {
617  current_path += "label=";
618  current_path += label;
619  current_path += '&';
620  }
621 
622  std::string retv;
623  nlohmann::json js = nullptr;
624  retv = m_request.performRequest(current_path, Action::DELETE, js, method_name);
625  }
626 
627  //==============================================================================================================
628  // Iovs methods:
629  IovSetDto CrestClient::selectIovs(const std::string &name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string &sort)
630  {
631  const char *method_name = "CrestClient::selectIovs";
632 
633  std::string current_path = m_PATH;
634  current_path += s_IOV_PATH;
635 
636  current_path += "?method=";
637  current_path += s_METHOD_IOVS;
638  current_path += "&tagname=";
639 
640  current_path += name;
641  current_path += "&since=";
642  current_path += std::to_string(since);
643  current_path += "&until=";
644  if (until == static_cast<uint64_t>(-1))
645  {
646  current_path += "INF";
647  }
648  else
649  {
650  current_path += std::to_string(until);
651  }
652  current_path += "&snapshot=";
653  current_path += std::to_string(snapshot);
654  //
655  current_path += "&size=";
656  current_path += std::to_string(size);
657  current_path += "&page=";
658  current_path += std::to_string(page);
659  current_path += "&sort=";
660  current_path += sort;
661  //
662 
663  std::string retv;
664 
665  nlohmann::json js = nullptr;
666  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
667  nlohmann::json response = getJson(retv, method_name);
668 
670 
671  return dto;
672  }
673 
674  IovSetDto CrestClient::selectGroups(const std::string &name, long snapshot, int size, int page, const std::string &sort)
675  {
676  const char *method_name = "CrestClient::selectGroups";
677 
678  std::string current_path = m_PATH;
679  current_path += s_IOV_PATH;
680 
681  current_path += "?method=";
682  current_path += s_METHOD_GROUPS;
683  current_path += "&tagname=";
684 
685  current_path += name;
686  current_path += "&snapshot=";
687  current_path += std::to_string(snapshot);
688 
689  //
690  current_path += "&size=";
691  current_path += std::to_string(size);
692  current_path += "&page=";
693  current_path += std::to_string(page);
694  current_path += "&sort=";
695  current_path += sort;
696  //
697 
698  std::string retv;
699 
700  nlohmann::json js = nullptr;
701  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
702  nlohmann::json response = getJson(retv, method_name);
703 
705 
706  return dto;
707  }
708 
709  //==============================================================================================================
710  // Payload methods:
711  void CrestClient::storeData(const std::string &tag,
712  const StoreSetDto &storeSetJson,
713  const std::string &payloadFormat,
714  const std::string &objectType,
715  const std::string &compressionType,
716  const std::string &version,
718  {
719 
720  std::string current_path = m_PATH;
721  current_path += s_PAYLOAD_PATH;
722  std::vector<std::string> files;
723  std::string retv;
724  nlohmann::json js = storeSetJson.to_json();
725  if (payloadFormat == "JSON")
726  {
727  retv = m_request.uploadPayload(current_path, tag, endTime, js, objectType, compressionType, version, files);
728  }
729  else
730  {
731  // Assumes the data content in the JSON is just a file path.
732  nlohmann::json resources = nullptr;
733 
734  auto subjectIdIter1 = js.find("resources");
735  if (subjectIdIter1 != js.end())
736  {
737  resources = js["resources"];
738  }
739  int partN = resources.size();
740  for (int i = 0; i < partN; i++)
741  {
742  nlohmann::json element = resources[i];
743  std::string file_param;
744 
745  auto subjectIdIter1 = element.find("data");
746  if (subjectIdIter1 != element.end())
747  {
748  file_param = element["data"];
749  }
750  //
751  int found_dots = file_param.find_first_of(':');
752  int word_size = file_param.size();
753  std::string data_file = file_param.substr(found_dots + 3, word_size);
754  files.push_back(data_file);
755  }
756  retv = m_request.uploadPayload(current_path, tag, endTime, js, objectType, compressionType, version, files);
757  }
758  }
759 
760  std::string CrestClient::getPayload(const std::string &hash)
761  {
762  const char *method_name = "CrestClient::getPayload";
763 
764  std::string current_path = m_PATH;
765  current_path += s_PAYLOAD_PATH;
766  current_path += "/data?format=BLOB&hash=";
767  current_path += hash;
768  std::string retv;
769  nlohmann::json js = nullptr;
770  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
771  checkHash(hash, retv, method_name);
772  return retv;
773  }
774 
776  {
777  const char *method_name = "CrestClient::getPayloadMeta";
778 
779  std::string current_path = m_PATH;
780  current_path += s_PAYLOAD_PATH;
781  current_path += '/';
782  current_path += hash;
783  current_path += "?format=META";
784  std::string retv;
785  nlohmann::json js = nullptr;
786  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
787  nlohmann::json response = getJson(retv, method_name);
788 
790  std::vector<PayloadDto> v = dto.resources;
791  // Only one element is expected:
792  return v[0];
793  }
794 
795  void CrestClient::checkHash(const std::string &hash, const std::string &str, const char* method_name)
796  {
797  std::string calculatedHash = getHash(str);
798  if (hash != calculatedHash) {
799  throw CrestException("ERROR in " + (std::string)method_name + ": payload is corrupted.");
800  }
801  return;
802  }
803 
804 } // namespace Crest
805 
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
grepfile.info
info
Definition: grepfile.py:38
GlobalTagMapSetDto::from_json
static GlobalTagMapSetDto from_json(const json &j)
Definition: CrestModel.cxx:264
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Crest::CrestClient::s_TAG_PATH
static const std::string s_TAG_PATH
Definition: CrestApi.h:39
Crest::CrestClient::findGlobalTagMap
GlobalTagMapSetDto findGlobalTagMap(const std::string &name, const std::string &xCrestMapMode) override
This method searches for tag mappings using the global tag name or tag name on the CREST server.
Definition: CrestApi.cxx:565
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
beamspotman.r
def r
Definition: beamspotman.py:676
Crest::CrestClient::getJson
nlohmann::json getJson(const std::string &str, const char *method) const
Auxiliary method to convert string in to JSON object.
Definition: CrestApi.cxx:169
Crest::CrestClient::removeGlobalTag
void removeGlobalTag(const std::string &name) override
This method removes a global tag on the CREST server.
Definition: CrestApi.cxx:358
GlobalTagMapDto::to_json
json to_json() const
Definition: CrestModel.cxx:235
Crest::CrestClient::s_MGMT_INFO_PATH
static const std::string s_MGMT_INFO_PATH
Definition: CrestApi.h:61
get_generator_info.result
result
Definition: get_generator_info.py:21
Crest::CrestClient::getSize
int getSize(const std::string &tagname) override
This method gets the number of IOVs for the given tag.
Definition: CrestApi.cxx:515
Crest::Action::POST
@ POST
json
nlohmann::json json
Definition: HistogramDef.cxx:9
response
MDT_Response response
Definition: MDT_ResponseTest.cxx:28
GlobalTagSetDto::resources
std::vector< GlobalTagDto > resources
Definition: CrestModel.h:83
Crest::CrestClient::s_ADMIN_PATH
static const std::string s_ADMIN_PATH
Definition: CrestApi.h:40
TagDto::to_json
json to_json() const
Definition: CrestModel.cxx:172
Crest::CrestClient::makeUrl
std::string makeUrl(const std::string &address) const
Definition: CrestApi.cxx:273
PayloadSetDto::resources
std::vector< PayloadDto > resources
Definition: CrestModel.h:368
Crest::CrestClient::listTags
TagSetDto listTags(const std::string &name, int size, int page, const std::string &sort) override
This method returns the tag list as TagSetDto from the CREST server.
Definition: CrestApi.cxx:405
Crest::CrestClient::removeTag
void removeTag(const std::string &name) override
This method removes a tag from the CREST server.
Definition: CrestApi.cxx:448
Crest::CrestClient::s_IOV_PATH
static const std::string s_IOV_PATH
Definition: CrestApi.h:41
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1082
Crest::Action::DELETE
@ DELETE
CrestModel.h
Crest::CrestClient::s_METHOD_IOVS
static const std::string s_METHOD_IOVS
Definition: CrestApi.h:56
Crest::CrestRequest::performRequest
std::string performRequest(const std::string &current_path, Action action, nlohmann::json &js, const std::string &header_params="")
General auxiliary method to make request to the CREST Server.
Crest::CrestClient::s_GLOBALTAG_MAP_PATH
static const std::string s_GLOBALTAG_MAP_PATH
Definition: CrestApi.h:46
Crest::CrestRequest::uploadPayload
std::string uploadPayload(const std::string &current_path, const std::string &tag, uint64_t endtime, const nlohmann::json &js, const std::string &objectType, const std::string &compressionType, const std::string &version, const std::vector< std::string > &files)
Definition: CrestRequest.cxx:241
TagSetDto
Definition: CrestModel.h:126
Crest::CrestClient::m_host
std::string m_host
Definition: CrestApi.h:67
Crest::CrestClient::m_PATH
std::string m_PATH
Definition: CrestApi.h:37
Crest::CrestRequest::setPrefix
void setPrefix(const std::string &prefix)
Definition: CrestRequest.cxx:43
Crest::CrestClient::findGlobalTag
GlobalTagDto findGlobalTag(const std::string &name) override
This method finds a global tag by name on the CREST server.
Definition: CrestApi.cxx:295
TagMetaDto::to_json
json to_json() const
Definition: CrestModel.cxx:389
GlobalTagSetDto
Definition: CrestModel.h:81
Crest
Definition: CrestApi.h:30
Crest::CrestClient::~CrestClient
~CrestClient()
CrestClient destructor.
Definition: CrestApi.cxx:117
Crest::CrestApiBase::getHash
std::string getHash(std::string_view str)
This method method calculates the hash for string.
Definition: CrestApiBase.cxx:32
physics_parameters.url
string url
Definition: physics_parameters.py:27
CrestApi.h
Header file for CREST C++ Client Library.
TagMetaDto
Definition: CrestModel.h:238
hotSpotInTAG.objectType
objectType
Definition: hotSpotInTAG.py:107
Crest::CrestClient::findTag
TagDto findTag(const std::string &name) override
This method finds a tag by the name on the CREST server.
Definition: CrestApi.cxx:386
PayloadDto
Definition: CrestModel.h:345
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::Action::GET
@ GET
Crest::CrestRequest::setHost
void setHost(const std::string &host)
Definition: CrestRequest.cxx:33
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::createTagMeta
void createTagMeta(TagMetaDto &tag) override
This method creates a tag meta info on the CREST server.
Definition: CrestApi.cxx:464
Crest::CrestClient::s_GLOBALTAG_PATH
static const std::string s_GLOBALTAG_PATH
Definition: CrestApi.h:45
TagSetDto::resources
std::vector< TagDto > resources
Definition: CrestModel.h:128
Crest::CrestClient::s_META_PATH
static const std::string s_META_PATH
Definition: CrestApi.h:49
Crest::CrestClient::updateTagMeta
void updateTagMeta(TagMetaDto &tag) override
This method updates a tag meta info on the CREST server.
Definition: CrestApi.cxx:479
defineDB.tagname
string tagname
Definition: JetTagCalibration/share/defineDB.py:19
Crest::CrestClient::selectIovs
IovSetDto selectIovs(const std::string &name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string &sort) override
This method selects IOVs for a given tagname on the CREST server.
Definition: CrestApi.cxx:629
Crest::CrestClient::s_METHOD_GROUPS
static const std::string s_METHOD_GROUPS
Definition: CrestApi.h:57
lumiFormat.i
int i
Definition: lumiFormat.py:85
GlobalTagDto
Definition: CrestModel.h:55
CrestRequest.h
Crest::CrestClient::s_MGMT_PATH
static const std::string s_MGMT_PATH
Definition: CrestApi.h:60
beamspotman.n
n
Definition: beamspotman.py:731
Crest::CrestClient::getCrestVersion
std::string getCrestVersion() override
This method returns the full CREST Server version.
Definition: CrestApi.cxx:214
TagDto
The TagDto class It contains all fields of the TagDto class from the CREST API.
Definition: CrestModel.h:98
Crest::CrestClient::createTag
void createTag(TagDto &tag) override
This method creates a tag on the CREST server.
Definition: CrestApi.cxx:374
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
TagMetaSetDto
Definition: CrestModel.h:257
calibdata.exception
exception
Definition: calibdata.py:496
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
PayloadSetDto::from_json
static PayloadSetDto from_json(const json &j)
Definition: CrestModel.cxx:658
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
Crest::CrestClient::getPayloadMeta
PayloadDto getPayloadMeta(const std::string &hash) override
This method finds a payload meta info for the hash on the CREST server.
Definition: CrestApi.cxx:775
Crest::CrestClient::CrestClient
CrestClient(const std::string &host, const std::string &port, bool checkVersion=false)
CrestClient constructor.
Definition: CrestApi.cxx:36
parseDir.wh
wh
Definition: parseDir.py:46
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
Crest::CrestClient::findTagMeta
TagMetaDto findTagMeta(const std::string &name) override
This method reads a tag meta info by the tag name from the CREST server.
Definition: CrestApi.cxx:494
Crest::CrestClient::storeData
void storeData(const std::string &tag, const StoreSetDto &storeSetJson, const std::string &payloadFormat="JSON", const std::string &objectType="none", const std::string &compressionType="none", const std::string &version="1.0", uint64_t endTime=-1) override
This method stores several payloads in batch mode on the CREST server.
Definition: CrestApi.cxx:711
GlobalTagMapSetDto
Definition: CrestModel.h:160
Crest::CrestClient::createGlobalTagMap
void createGlobalTagMap(GlobalTagMapDto &globalTagMap) override
This method creates a global tag map on the CREST server.
Definition: CrestApi.cxx:554
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Crest::Action::PUT
@ PUT
Crest::CrestClient::s_PAYLOAD_PATH
static const std::string s_PAYLOAD_PATH
Definition: CrestApi.h:47
PayloadSetDto
Definition: CrestModel.h:366
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Crest::CrestClient::checkCrestVersion
void checkCrestVersion()
This method is a CREST version test.
Definition: CrestApi.cxx:259
Crest::CrestClient::getMgmtInfo
nlohmann::json getMgmtInfo()
This is an auxiliary method to read the CREST Server properties.
Definition: CrestApi.cxx:199
IovSetDto::from_json
static IovSetDto from_json(const json &j)
Definition: CrestModel.cxx:518
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
Crest::CrestClient::m_prefix
std::string m_prefix
Definition: CrestApi.h:69
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Crest::CrestClient::getPayload
std::string getPayload(const std::string &hash) override
This method finds a payload resource associated to the hash on the CREST server.
Definition: CrestApi.cxx:760
MyPlots.page
page
Definition: MyPlots.py:234
python.PyAthena.v
v
Definition: PyAthena.py:154
get_generator_info.version
version
Definition: get_generator_info.py:33
Crest::CrestClient::listGlobalTags
GlobalTagSetDto listGlobalTags(const std::string &name, int size, int page, const std::string &sort) override
This method finds the global tags on the CREST server.
Definition: CrestApi.cxx:315
Crest::CrestClient::removeGlobalTagMap
void removeGlobalTagMap(const std::string &name, const std::string &record, const std::string &label, const std::string &tagname) override
This method removes a global tag map on the CREST server.
Definition: CrestApi.cxx:594
Crest::CrestClient::m_port
std::string m_port
Definition: CrestApi.h:68
Crest::CrestClient::m_request
Crest::CrestRequest m_request
Definition: CrestApi.h:71
TagMetaDto::tagName
std::string tagName
Definition: CrestModel.h:240
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
StoreSetDto::to_json
json to_json() const
Definition: CrestModel.cxx:576
GlobalTagDto::to_json
json to_json() const
Definition: CrestModel.cxx:138
Crest::CrestClient::parseXMLOutput
std::string parseXMLOutput(const std::string_view xmlBuffer) const
This method removes all XML/HTML tags from a string.
Definition: CrestApi.cxx:121
IovSetDto
Definition: CrestModel.h:287
TagSetDto::from_json
static TagSetDto from_json(const json &j)
Definition: CrestModel.cxx:223
Crest::CrestClient::createGlobalTag
void createGlobalTag(GlobalTagDto &globalTag) override
This method creates a global tag on CREST server.
Definition: CrestApi.cxx:284
Crest::CrestApiBase::getClientVersion
const std::string & getClientVersion()
This method returns the full CrestApi version.
Definition: CrestApiBase.cxx:38
Crest::CrestClient::getMajorVersion
int getMajorVersion(std::string &str)
This is an auxiliary method to extract a major version number from full version string.
Definition: CrestApi.cxx:235
picosha2.h
tagname
Definition: tagname.h:29
Crest::CrestClient::checkHash
void checkHash(const std::string &hash, const std::string &str, const char *method_name)
This checks the hash of payload from IOV (hash) with the hash calculated for the payload in the std::...
Definition: CrestApi.cxx:795
TagMetaSetDto::resources
std::vector< TagMetaDto > resources
Definition: CrestModel.h:259
str
Definition: BTagTrackIpAccessor.cxx:11
Crest::CrestClient::removeCR
std::string removeCR(const std::string &str) const
This method removes all end of line and carriage return symbols from a string.
Definition: CrestApi.cxx:149
calibdata.copy
bool copy
Definition: calibdata.py:27
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
StoreSetDto
Definition: CrestModel.h:331
python.html.AtlRunQueryDQSummary.server
server
Definition: AtlRunQueryDQSummary.py:22
GlobalTagSetDto::from_json
static GlobalTagSetDto from_json(const json &j)
Definition: CrestModel.cxx:113
TagMetaSetDto::from_json
static TagMetaSetDto from_json(const json &j)
Definition: CrestModel.cxx:432
Crest::CrestClient::selectGroups
IovSetDto selectGroups(const std::string &name, long snapshot, int size, int page, const std::string &sort) override
This method returns IOV groups for a given tagname on CREST server.
Definition: CrestApi.cxx:674
Crest::CrestRequest::setPort
void setPort(const std::string &port)
Definition: CrestRequest.cxx:38
Crest::CrestException
Definition: CrestException.h:9
GlobalTagMapDto
Definition: CrestModel.h:139
lumiFormat.endTime
endTime
Definition: lumiFormat.py:100
Crest::CrestClient::s_IOV_SIZE_PATH
static const std::string s_IOV_SIZE_PATH
Definition: CrestApi.h:43