ATLAS Offline Software
CrestApiBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2019-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
14 #ifndef CRESTAPI_CRESAPIBASE_H
15 #define CRESTAPI_CRESAPIBASE_H
16 
17 #include <string>
18 #include <map>
19 #include <list>
20 #include <iosfwd>
21 #include <cstdint>
22 #include "nlohmann/json.hpp"
23 #include <curl/curl.h>
24 #include <iostream>
25 #include <CrestApi/CrestModel.h>
26 
27 #define DEFAULT_CREST_API_VERSION "/api-v5.0"
28 
29 namespace Crest
30 {
31 
32 class CrestApiBase {
33 
34 private:
35 
36  inline static const std::string s_CREST_CLIENT_VERSION = "5.0";
37 
38 protected:
39 
45  std::string getHash(std::string_view str);
46 
52  std::string getHashForFile(const std::string &file);
53 
58  const std::string& getClientVersion();
59 
60 
61 public:
62  virtual ~CrestApiBase() = default;
63  // GlobaTag methods
64 
93 
94 
101  virtual GlobalTagDto findGlobalTag(const std::string& name) = 0;
102 
111  virtual GlobalTagSetDto listGlobalTags(const std::string& name, int size, int page, const std::string& sort) = 0;
112 
118  virtual void removeGlobalTag(const std::string& name) = 0;
119 
120  // Tag methods
121 
150  virtual void createTag(TagDto& tag) = 0;
151 
158  virtual TagDto findTag(const std::string& name) = 0;
159 
169  virtual TagSetDto listTags(const std::string& name, int size, int page, const std::string& sort) = 0;
170 
176  virtual void removeTag(const std::string& name) = 0;
177 
184  virtual int getSize(const std::string& tagname) = 0;
185 
186  // Tag Meta Info methods
187 
220  virtual void createTagMeta(TagMetaDto& tag) = 0;
221 
226  virtual void updateTagMeta(TagMetaDto& tag) = 0;
227 
233  virtual TagMetaDto findTagMeta(const std::string& name) = 0;
234 
235 
236  // IOV methods
237 
250  virtual IovSetDto selectIovs(const std::string& name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string& sort) = 0;
251 
262  virtual IovSetDto selectGroups(const std::string& name, long snapshot, int size, int page, const std::string& sort) = 0;
263 
264  // GlobalTagMap methods
265 
287  virtual void createGlobalTagMap(GlobalTagMapDto& globalTagMap) = 0;
288 
296  virtual GlobalTagMapSetDto findGlobalTagMap(const std::string& name, const std::string& xCrestMapMode) = 0;
297 
304  virtual void removeGlobalTagMap(const std::string& name, const std::string& record, const std::string& label, const std::string& tagname) = 0;
305 
306  // Payload methods
307 
332  virtual void storeData(const std::string& tag,
333  const StoreSetDto& storeSetJson,
334  const std::string& payloadFormat,
335  const std::string& objectType,
336  const std::string& compressionType,
337  const std::string& version,
338  uint64_t endTime) = 0;
339 
340 
341  // Payload retrieval methods
342 
349  virtual std::string getPayload(const std::string& hash) = 0;
350 
357  virtual PayloadDto getPayloadMeta(const std::string& hash) = 0;
358 
363  virtual std::string getCrestVersion() = 0;
364 
365 
366 };
367 
368 } // namespace Crest
369 
370 #endif // CRESTAPI_CRESTCLIENT_H
Crest::CrestApiBase::listTags
virtual TagSetDto listTags(const std::string &name, int size, int page, const std::string &sort)=0
This method returns the tag list as TagSetDto.
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
CrestModel.h
Crest::CrestApiBase::~CrestApiBase
virtual ~CrestApiBase()=default
Crest::CrestApiBase::getCrestVersion
virtual std::string getCrestVersion()=0
This method returns the full CREST Server version.
Crest::CrestApiBase::createTagMeta
virtual void createTagMeta(TagMetaDto &tag)=0
This method creates a tag meta info.
TagSetDto
Definition: CrestModel.h:126
Crest::CrestApiBase::removeGlobalTagMap
virtual void removeGlobalTagMap(const std::string &name, const std::string &record, const std::string &label, const std::string &tagname)=0
This method removes a global tag map.
GlobalTagSetDto
Definition: CrestModel.h:81
Crest
Definition: CrestApi.h:30
Crest::CrestApiBase::createTag
virtual void createTag(TagDto &tag)=0
This method creates a tag.
Crest::CrestApiBase::getHash
std::string getHash(std::string_view str)
This method method calculates the hash for string.
Definition: CrestApiBase.cxx:32
makeDTCalibBlob_pickPhase.globalTag
globalTag
Definition: makeDTCalibBlob_pickPhase.py:398
TagMetaDto
Definition: CrestModel.h:238
hotSpotInTAG.objectType
objectType
Definition: hotSpotInTAG.py:107
PayloadDto
Definition: CrestModel.h:345
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
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::CrestApiBase::listGlobalTags
virtual GlobalTagSetDto listGlobalTags(const std::string &name, int size, int page, const std::string &sort)=0
This method finds the global tags.
Crest::CrestApiBase::findGlobalTag
virtual GlobalTagDto findGlobalTag(const std::string &name)=0
This method finds a global tag by name.
Crest::CrestApiBase::removeTag
virtual void removeTag(const std::string &name)=0
This method removes a tag.
GlobalTagDto
Definition: CrestModel.h:55
Crest::CrestApiBase::updateTagMeta
virtual void updateTagMeta(TagMetaDto &tag)=0
This method updates a tag meta info.
Crest::CrestApiBase::createGlobalTag
virtual void createGlobalTag(GlobalTagDto &globalTag)=0
This method creates a global tag.
TagDto
The TagDto class It contains all fields of the TagDto class from the CREST API.
Definition: CrestModel.h:98
Crest::CrestApiBase::findTag
virtual TagDto findTag(const std::string &name)=0
This method finds a tag by the name.
file
TFile * file
Definition: tile_monitor.h:29
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
Crest::CrestApiBase
Definition: CrestApiBase.h:32
Crest::CrestApiBase::createGlobalTagMap
virtual void createGlobalTagMap(GlobalTagMapDto &globalTagMap)=0
This method creates a global tag map.
GlobalTagMapSetDto
Definition: CrestModel.h:160
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MyPlots.page
page
Definition: MyPlots.py:234
get_generator_info.version
version
Definition: get_generator_info.py:33
Crest::CrestApiBase::findTagMeta
virtual TagMetaDto findTagMeta(const std::string &name)=0
This method gets a tag meta info by the tag name.
Crest::CrestApiBase::selectGroups
virtual IovSetDto selectGroups(const std::string &name, long snapshot, int size, int page, const std::string &sort)=0
This method returns IOV groups for a given tagname.
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
IovSetDto
Definition: CrestModel.h:287
Crest::CrestApiBase::getClientVersion
const std::string & getClientVersion()
This method returns the full CrestApi version.
Definition: CrestApiBase.cxx:38
Crest::CrestApiBase::getPayloadMeta
virtual PayloadDto getPayloadMeta(const std::string &hash)=0
This method finds a payload meta info for the hash.
tagname
Definition: tagname.h:29
Crest::CrestApiBase::storeData
virtual void storeData(const std::string &tag, const StoreSetDto &storeSetJson, const std::string &payloadFormat, const std::string &objectType, const std::string &compressionType, const std::string &version, uint64_t endTime)=0
This method stores several payloads in batch mode.
str
Definition: BTagTrackIpAccessor.cxx:11
Crest::CrestApiBase::getHashForFile
std::string getHashForFile(const std::string &file)
This method method calculates the hash for a file.
Definition: CrestApiBase.cxx:8
Crest::CrestApiBase::getPayload
virtual std::string getPayload(const std::string &hash)=0
This method finds a payload resource associated to the hash.
Crest::CrestApiBase::getSize
virtual int getSize(const std::string &tagname)=0
This method gets the number of IOVs for the given tag.
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
StoreSetDto
Definition: CrestModel.h:331
Crest::CrestApiBase::s_CREST_CLIENT_VERSION
static const std::string s_CREST_CLIENT_VERSION
Definition: CrestApiBase.h:36
Crest::CrestApiBase::findGlobalTagMap
virtual GlobalTagMapSetDto findGlobalTagMap(const std::string &name, const std::string &xCrestMapMode)=0
This method searches for tag mappings using the global tag name or tag name .
Crest::CrestApiBase::removeGlobalTag
virtual void removeGlobalTag(const std::string &name)=0
This method removes a global tag.
GlobalTagMapDto
Definition: CrestModel.h:139
lumiFormat.endTime
endTime
Definition: lumiFormat.py:100
Crest::CrestApiBase::selectIovs
virtual IovSetDto selectIovs(const std::string &name, uint64_t since, uint64_t until, long snapshot, int size, int page, const std::string &sort)=0
This method selects IOVs for a given tagname.