3 #include <nopayloadclient/exception.hpp>
4 #include <nopayloadclient/nopayloadclient.hpp>
6 #include <nlohmann/json.hpp>
12 : nopayloadclient::NoPayloadClient(gt_name)
13 , m_CachedGlobalTag(gt_name)
19 return nopayloadclient::NoPayloadClient::getPayloadIOVs(0, iov);
25 if (resp[
"code"] != 0)
29 nlohmann::json payload_iovs = resp[
"msg"];
30 if (!payload_iovs.contains(pl_type))
32 return nopayloadclient::DataBaseException(
"No valid payload with type " + pl_type).jsonify();
34 nlohmann::json payload_iov = payload_iovs[pl_type];
37 std::cout <<
"pl_type: " << pl_type
39 <<
", minor_iov_start: " << payload_iov[
"minor_iov_start"]
40 <<
", minor_iov_end: " << payload_iov[
"minor_iov_end"]
43 if (payload_iov[
"minor_iov_end"] <= iov)
45 return nopayloadclient::DataBaseException(
"No valid payload with type " + pl_type).jsonify();
47 return makeResp(payload_iov[
"payload_url"]);
53 if (resp[
"code"] != 0)
57 for (
auto it = resp[
"msg"].
begin();
it != resp[
"msg"].end();)
59 if (
it.value()[
"minor_iov_end"] < iov)
61 it = resp[
"msg"].erase(
it);
68 for (
auto& piov : resp[
"msg"].
items())
70 piov.value() = piov.value()[
"payload_url"];
87 nlohmann::json resp =
getUrl(pl_type, iov);
88 if (resp[
"code"] != 0)
92 std::cout << resp << std::endl;
106 return {{
"code", -1}, {
"msg", message}};
116 return {{
"code", -1}, {
"msg", message}};
126 long long iov_start,
long long iov_end)
136 return {{
"code", 0}, {
"msg", message}};
146 return {{
"code", -1}, {
"msg", message}};
158 bool found_gt =
false;
159 nlohmann::json resp = nopayloadclient::NoPayloadClient::getGlobalTags();
160 nlohmann::json msgcont = resp[
"msg"];
161 for (
auto&
it : msgcont.items())
164 std::cout <<
"global tag: " << exist_gt << std::endl;
165 if (exist_gt == tagname)
177 std::cout <<
"Error creating global tag, msg: " << resp[
"msg"] << std::endl;
181 std::cout <<
"SphenixClient: Created new global tag " << tagname << std::endl;
193 resp = nopayloadclient::NoPayloadClient::getPayloadTypes();
194 nlohmann::json msgcont = resp[
"msg"];
195 for (
auto&
it : msgcont.items())
232 nlohmann::json resp = nopayloadclient::NoPayloadClient::getGlobalTags();
233 nlohmann::json msgcont = resp[
"msg"];
234 for (
auto&
it : msgcont.items())
238 if (exist_gt == tagname)