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 
235  {
236  return s_CREST_CLIENT_VERSION;
237  }
238 
240  {
241  int v = -1;
242  int n = str.find('.');
243 
244  if (n < 1)
245  {
246  throw CrestException("ERROR in CrestClient::getMajorVersion: string \"" + str + "\" does not contain major version.");
247  }
248 
249  std::string vers = str.substr(0, n);
250 
251  try
252  {
253  v = std::stoi(str);
254  }
255  catch (const std::exception &e)
256  {
257  throw CrestException("ERROR in CrestClient::getMajorVersion: string \"" + str + "\" does not contain major version.");
258  }
259 
260  return v;
261  }
262 
264  {
265  std::string client = getClientVersion();
266  std::string server = getCrestVersion();
267 
268  int clientVersion = getMajorVersion(client);
269  int serverVersion = getMajorVersion(server);
270 
271  if (clientVersion != serverVersion)
272  {
273  throw CrestException("ERROR in CrestClient::checkCrestVersion: CrestApi version \"" + client + "\" does not correspond to the server version \"" + server + "\".");
274  }
275  }
276 
277  std::string CrestClient::makeUrl(const std::string &address) const
278  {
279  std::string str = m_prefix;
280  str += m_host;
281  str += ':';
282  str += m_port;
283  str += address;
284  return str;
285  }
286  //==============================================================================================================
287  // GlobalTag methods:
289  {
290  const char *method_name = "CrestClient::createGlobalTag";
291 
292  std::string current_path = m_PATH;
293  current_path += s_GLOBALTAG_PATH;
294  std::string retv;
295  nlohmann::json js = dto.to_json();
296  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
297  }
298 
300  {
301  const char *method_name = "CrestClient::findGlobalTag";
302 
303  std::string current_path = m_PATH;
304  current_path += s_GLOBALTAG_PATH;
305  current_path += '/';
306  current_path += name;
307  std::string retv;
308 
309  nlohmann::json js = nullptr;
310  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
311  nlohmann::json response = getJson(retv, method_name);
312 
314  std::vector<GlobalTagDto> v = dto.resources;
315  // Only one element is expected:
316  return v[0];
317  }
318 
319  GlobalTagSetDto CrestClient::listGlobalTags(const std::string &name, int size, int page, const std::string &sort)
320  {
321  const char *method_name = "CrestClient::listGlobalTags";
322 
323  std::string current_path = m_PATH;
324  current_path += s_GLOBALTAG_PATH;
325  current_path += '?';
326  if (name != "")
327  {
328  current_path += "name=";
329  current_path += name;
330  current_path += '&';
331  }
332  if (size != -1)
333  {
334  current_path += "size=";
335  current_path += std::to_string(size);
336  current_path += '&';
337  }
338  if (page != -1)
339  {
340  current_path += "page=";
341  current_path += std::to_string(page);
342  current_path += '&';
343  }
344  if (sort != "")
345  {
346  current_path += "sort=";
347  current_path += sort;
348  current_path += '&';
349  }
350  std::string retv;
351 
352  nlohmann::json js = nullptr;
353  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
354  nlohmann::json response = getJson(retv, method_name);
355 
357 
358  return dto;
359  }
360 
361  // The method to remove a global tag:
362  void CrestClient::removeGlobalTag(const std::string &name)
363  {
364  const char *method_name = "CrestClient::removeGlobalTag";
365 
366  std::string current_path = m_PATH;
367  current_path += s_ADMIN_PATH;
368  current_path += s_GLOBALTAG_PATH;
369  current_path += '/';
370  current_path += name;
371  std::string retv;
372  nlohmann::json js = nullptr;
373  retv = m_request.performRequest(current_path, Action::DELETE, js, method_name);
374  }
375 
376  //==============================================================================================================
377  // Tag methods:
379  {
380  const char *method_name = "CrestClient::createTag";
381 
382  std::string current_path = m_PATH;
383  current_path += s_TAG_PATH;
384  std::string retv;
385  nlohmann::json js = dto.to_json();
386  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
387  }
388 
389  // The method to find a tag:
390  TagDto CrestClient::findTag(const std::string &name)
391  {
392  const char *method_name = "CrestClient::findTag";
393 
394  std::string current_path = m_PATH;
395  current_path += s_TAG_PATH;
396  current_path += '/';
397  current_path += name;
398  std::string retv;
399  nlohmann::json js = nullptr;
400  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
401  nlohmann::json response = getJson(retv, method_name);
403 
404  std::vector<TagDto> v = dto.resources;
405  // Only one element is expected:
406  return v[0];
407  }
408 
409  TagSetDto CrestClient::listTags(const std::string &name, int size, int page, const std::string &sort)
410  {
411  const char *method_name = "CrestClient::listTags";
412 
413  std::string current_path = m_PATH;
414  current_path += s_TAG_PATH;
415  current_path += '?';
416  if (name != "")
417  {
418  current_path += "name=";
419  current_path += name;
420  current_path += '&';
421  }
422  if (size != -1)
423  {
424  current_path += "size=";
425  current_path += std::to_string(size);
426  current_path += '&';
427  }
428  if (page != -1)
429  {
430  current_path += "page=";
431  current_path += std::to_string(page);
432  current_path += '&';
433  }
434  if (sort != "")
435  {
436  current_path += "sort=";
437  current_path += sort;
438  current_path += '&';
439  }
440  std::string retv;
441 
442  nlohmann::json js = nullptr;
443  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
444  nlohmann::json response = getJson(retv, method_name);
445 
447 
448  return dto;
449  }
450 
451  // The method to remove a tag:
452  void CrestClient::removeTag(const std::string &name)
453  {
454  const char *method_name = "CrestClient::removeTag";
455 
456  std::string current_path = m_PATH;
457  current_path += s_ADMIN_PATH;
458  current_path += s_TAG_PATH;
459  current_path += '/';
460  current_path += name;
461  std::string retv;
462  nlohmann::json js = nullptr;
463  retv = m_request.performRequest(current_path, Action::DELETE, js, method_name);
464  }
465 
466  //==============================================================================================================
467  // TagMeta methods:
469  {
470  const char *method_name = "CrestClient::createTagMeta";
471 
472  std::string current_path = m_PATH;
473  current_path += s_TAG_PATH;
474  current_path += '/';
475  current_path += dto.tagName;
476  current_path += s_META_PATH;
477 
478  std::string retv;
479  nlohmann::json js = dto.to_json();
480  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
481  }
482 
484  {
485  const char *method_name = "CrestClient::updateTagMeta";
486 
487  std::string current_path = m_PATH;
488  current_path += s_TAG_PATH;
489  current_path += '/';
490  current_path += dto.tagName;
491  current_path += s_META_PATH;
492 
493  std::string retv;
494  nlohmann::json js = dto.to_json();
495  retv = m_request.performRequest(current_path, Action::PUT, js, method_name);
496  }
497 
499  {
500  const char *method_name = "CrestClient::findTagMeta";
501 
502  std::string current_path = m_PATH;
503  current_path += s_TAG_PATH;
504  current_path += '/';
505  current_path += name;
506  current_path += s_META_PATH;
507  std::string retv;
508  nlohmann::json js = nullptr;
509  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
510  nlohmann::json response = getJson(retv, method_name);
511 
513  std::vector<TagMetaDto> v = dto.resources;
514  // Only one element is expected:
515  return v[0];
516  }
517 
518 
519  int CrestClient::getSize(const std::string &tagname)
520  {
521  const char *method_name = "CrestClient::getSize";
522 
523  std::string current_path = m_PATH;
524  current_path += s_IOV_PATH;
525  current_path += s_IOV_SIZE_PATH;
526  current_path += "?tagname=";
527  current_path += tagname;
528 
529  std::string retv;
530 
531  nlohmann::json js = nullptr;
532  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
533  nlohmann::json respond = getJson(retv, method_name);
534 
535  auto res = respond.find("resources");
537 
538  if (res != respond.end())
539  {
540  r = respond["resources"][0];
541  }
542 
543  int result = 0;
544  if (r.find("niovs") != r.end())
545  {
546  result = r["niovs"];
547  }
548  else
549  {
550  throw CrestException("ERROR in CrestClient::getSize CREST Server JSON response has no \"size\" key.");
551  }
552 
553  return result;
554  }
555 
556  //==============================================================================================================
557  // GlobalTagMaps methods:
559  {
560  const char *method_name = "CrestClient::createGlobalTagMap";
561 
562  std::string current_path = m_PATH;
563  current_path += s_GLOBALTAG_MAP_PATH;
564  std::string retv;
565  nlohmann::json js = dto.to_json();
566  retv = m_request.performRequest(current_path, Action::POST, js, method_name);
567  }
568 
569  GlobalTagMapSetDto CrestClient::findGlobalTagMap(const std::string &name, const std::string &xCrestMapMode)
570  {
571  const char *method_name = "CrestClient::findGlobalTagMap";
572 
573  std::string current_path = m_PATH;
574  current_path += s_GLOBALTAG_MAP_PATH;
575  current_path += '/';
576  current_path += name;
577  std::string headers_params = "";
578 
579  if (xCrestMapMode != "")
580  {
581  headers_params += "X-Crest-MapMode: ";
582  headers_params += xCrestMapMode;
583  }
584  else
585  {
586  headers_params += "X-Crest-MapMode: ";
587  headers_params += "Trace";
588  }
589  std::string retv;
590  nlohmann::json js = nullptr;
591  retv = m_request.performRequest(current_path, Action::GET, js, method_name, headers_params);
592  nlohmann::json response = getJson(retv, method_name);
594 
595  return dto;
596  }
597 
598  void CrestClient::removeGlobalTagMap(const std::string &name, const std::string &record, const std::string &label, const std::string &tagname)
599  {
600  const char *method_name = "CrestClient::removeGlobalTagMap";
601 
602  std::string current_path = m_PATH;
603  current_path += s_GLOBALTAG_MAP_PATH;
604  current_path += '/';
605  current_path += name;
606  current_path += '?';
607  if (tagname != "")
608  {
609  current_path += "tagname=";
610  current_path += tagname;
611  current_path += '&';
612  }
613  if (record != "")
614  {
615  current_path += "record=";
616  current_path += record;
617  current_path += '&';
618  }
619  if (label != "")
620  {
621  current_path += "label=";
622  current_path += label;
623  current_path += '&';
624  }
625 
626  std::string retv;
627  nlohmann::json js = nullptr;
628  retv = m_request.performRequest(current_path, Action::DELETE, js, method_name);
629  }
630 
631  //==============================================================================================================
632  // Iovs methods:
633  IovSetDto CrestClient::selectIovs(const std::string &name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string &sort)
634  {
635  const char *method_name = "CrestClient::selectIovs";
636 
637  std::string current_path = m_PATH;
638  current_path += s_IOV_PATH;
639 
640  current_path += "?method=";
641  current_path += s_METHOD_IOVS;
642  current_path += "&tagname=";
643 
644  current_path += name;
645  current_path += "&since=";
646  current_path += std::to_string(since);
647  current_path += "&until=";
648  if (until == static_cast<uint64_t>(-1))
649  {
650  current_path += "INF";
651  }
652  else
653  {
654  current_path += std::to_string(until);
655  }
656  current_path += "&snapshot=";
657  current_path += std::to_string(snapshot);
658  //
659  current_path += "&size=";
660  current_path += std::to_string(size);
661  current_path += "&page=";
662  current_path += std::to_string(page);
663  current_path += "&sort=";
664  current_path += sort;
665  //
666 
667  std::string retv;
668 
669  nlohmann::json js = nullptr;
670  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
671  nlohmann::json response = getJson(retv, method_name);
672 
674 
675  return dto;
676  }
677 
678  IovSetDto CrestClient::selectGroups(const std::string &name, long snapshot, int size, int page, const std::string &sort)
679  {
680  const char *method_name = "CrestClient::selectGroups";
681 
682  std::string current_path = m_PATH;
683  current_path += s_IOV_PATH;
684 
685  current_path += "?method=";
686  current_path += s_METHOD_GROUPS;
687  current_path += "&tagname=";
688 
689  current_path += name;
690  current_path += "&snapshot=";
691  current_path += std::to_string(snapshot);
692 
693  //
694  current_path += "&size=";
695  current_path += std::to_string(size);
696  current_path += "&page=";
697  current_path += std::to_string(page);
698  current_path += "&sort=";
699  current_path += sort;
700  //
701 
702  std::string retv;
703 
704  nlohmann::json js = nullptr;
705  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
706  nlohmann::json response = getJson(retv, method_name);
707 
709 
710  return dto;
711  }
712 
713  //==============================================================================================================
714  // Payload methods:
715  void CrestClient::storeData(const std::string &tag,
716  const StoreSetDto &storeSetJson,
717  const std::string &payloadFormat,
718  const std::string &objectType,
719  const std::string &compressionType,
720  const std::string &version,
722  {
723 
724  std::string current_path = m_PATH;
725  current_path += s_PAYLOAD_PATH;
726  std::vector<std::string> files;
727  std::string retv;
728  nlohmann::json js = storeSetJson.to_json();
729  if (payloadFormat == "JSON")
730  {
731  retv = m_request.uploadPayload(current_path, tag, endTime, js, objectType, compressionType, version, files);
732  }
733  else
734  {
735  // Assumes the data content in the JSON is just a file path.
736  nlohmann::json resources = nullptr;
737 
738  auto subjectIdIter1 = js.find("resources");
739  if (subjectIdIter1 != js.end())
740  {
741  resources = js["resources"];
742  }
743  int partN = resources.size();
744  for (int i = 0; i < partN; i++)
745  {
746  nlohmann::json element = resources[i];
747  std::string file_param;
748 
749  auto subjectIdIter1 = element.find("data");
750  if (subjectIdIter1 != element.end())
751  {
752  file_param = element["data"];
753  }
754  //
755  int found_dots = file_param.find_first_of(':');
756  int word_size = file_param.size();
757  std::string data_file = file_param.substr(found_dots + 3, word_size);
758  files.push_back(data_file);
759  }
760  retv = m_request.uploadPayload(current_path, tag, endTime, js, objectType, compressionType, version, files);
761  }
762  }
763 
764  std::string CrestClient::getPayload(const std::string &hash)
765  {
766  const char *method_name = "CrestClient::getPayload";
767 
768  std::string current_path = m_PATH;
769  current_path += s_PAYLOAD_PATH;
770  current_path += "/data?format=BLOB&hash=";
771  current_path += hash;
772  std::string retv;
773  nlohmann::json js = nullptr;
774  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
775  return retv;
776  }
777 
779  {
780  const char *method_name = "CrestClient::getPayloadMeta";
781 
782  std::string current_path = m_PATH;
783  current_path += s_PAYLOAD_PATH;
784  current_path += '/';
785  current_path += hash;
786  current_path += "?format=META";
787  std::string retv;
788  nlohmann::json js = nullptr;
789  retv = m_request.performRequest(current_path, Action::GET, js, method_name);
790  nlohmann::json response = getJson(retv, method_name);
791 
793  std::vector<PayloadDto> v = dto.resources;
794  // Only one element is expected:
795  return v[0];
796  }
797 } // namespace Crest
798 
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:569
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:362
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:519
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:277
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
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:409
Crest::CrestClient::removeTag
void removeTag(const std::string &name) override
This method removes a tag from the CREST server.
Definition: CrestApi.cxx:452
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:1054
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:299
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
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:390
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:468
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:483
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:633
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::getCrestVersion
std::string getCrestVersion()
This method returns the full CREST Server version.
Definition: CrestApi.cxx:214
Crest::CrestClient::s_MGMT_PATH
static const std::string s_MGMT_PATH
Definition: CrestApi.h:60
beamspotman.n
n
Definition: beamspotman.py:731
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:378
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
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:778
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:498
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:715
GlobalTagMapSetDto
Definition: CrestModel.h:160
Crest::CrestClient::s_CREST_CLIENT_VERSION
static const std::string s_CREST_CLIENT_VERSION
Definition: CrestApi.h:62
Crest::CrestClient::createGlobalTagMap
void createGlobalTagMap(GlobalTagMapDto &globalTagMap) override
This method creates a global tag map on the CREST server.
Definition: CrestApi.cxx:558
Crest::CrestClient::getClientVersion
std::string getClientVersion()
This method returns the full CrestApi version.
Definition: CrestApi.cxx:234
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:263
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:764
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:319
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:598
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:288
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:239
picosha2.h
tagname
Definition: tagname.h:29
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:678
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