Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:33

0001 #pragma once
0002 
0003 #include <iostream>
0004 #include <memory>
0005 #include <nlohmann/json.hpp>
0006 
0007 #include <nopayloadclient/curlwrapper.hpp>
0008 #include <nopayloadclient/realwrapper.hpp>
0009 #include <nopayloadclient/fakewrapper.hpp>
0010 #include <nopayloadclient/cache.hpp>
0011 #include <nopayloadclient/payload.hpp>
0012 #include <nopayloadclient/iov.hpp>
0013 #include <nopayloadclient/moment.hpp>
0014 #include <nopayloadclient/payloadiov.hpp>
0015 #include <nopayloadclient/exception.hpp>
0016 
0017 
0018 namespace nopayloadclient {
0019 
0020 using nlohmann::json;
0021 using std::string;
0022 
0023 class RESTHandler {
0024 public:
0025     RESTHandler() {};
0026     RESTHandler(const json& config);
0027 
0028     // Configuring
0029     void clearCache();
0030 
0031     // Reading
0032     json getGlobalTags();
0033     json getGlobalTagStatuses();
0034     json getPayloadTypes();
0035     json getPayloadLists(const string& global_tag);
0036     json getPayloadIOVs(const string& global_tag, Moment& mom);
0037 
0038     // Writing
0039     void createGlobalTagStatus(const string& name);
0040     void createGlobalTagObject(const string& name, const string& status);
0041     void createPayloadType(const string& name);
0042     void deletePayloadType(const string& name);
0043     void attachPayloadList(const string& global_tag, const string& pl_name);
0044     void lockGlobalTag(const string& name);
0045     void unlockGlobalTag(const string& name);
0046     void deleteGlobalTag(const string& name);
0047     void cloneGlobalTag(const string& source, const string& target);
0048     void deletePayloadIOV(const string& gt_name, const string& pll_name, IOV& iov);
0049     void attachPayloadIOV(const string& pll_name, long long piov_id);
0050     string createPayloadList(const string& type);
0051     void deletePayloadList(const string& type);
0052     long long createPayloadIOV(const Payload& pl, IOV& iov);
0053 
0054 private:
0055     //CurlWrapper curlwrapper_;
0056     std::unique_ptr<CurlWrapper> curlwrapper_;
0057     Cache cache_;
0058     bool use_cache_;
0059 
0060     json get(const string& url);
0061     json del(const string& url, bool trash_cache=true);
0062     json put(const string& url, bool trash_cache=true);
0063     json put(const string& url, const json& data, bool trash_cache=true);
0064     json post(const string& url, const json& data, bool trash_cache=true);
0065 
0066     //json get_piov_array(const json& raw_response);
0067     json get_piov_dict(const json& raw_response);
0068 
0069 };
0070 
0071 }