Skip to content

Commit

Permalink
Enable Aviso+Mirror on REST API
Browse files Browse the repository at this point in the history
Re ECFLOW-1931
  • Loading branch information
marcosbento committed Jun 17, 2024
1 parent 8f19f48 commit 655043e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libs/rest/src/ecflow/http/ApiV1Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ ojson get_node_attributes(const std::string& path) {
j["autocancel"] = node->get_autocancel();
j["autoarchive"] = node->get_autoarchive();
j["autorestore"] = node->get_autorestore();
j["avisos"] = node->avisos();
j["mirrors"] = node->mirrors();

{
// Collect 'normal' variables
Expand Down Expand Up @@ -612,6 +614,14 @@ ojson add_node_attribute(const httplib::Request& request) {
std::string value_ = (value == "true" || value == "set") ? "set" : "clear";
client->alter(path, "change", "event", name, value_);
}
else if (type == "aviso") {
const std::string name = payload.at("name");
client->alter(path, "add", "aviso", name, value);
}
else if (type == "mirror") {
const std::string name = payload.at("name");
client->alter(path, "add", "mirror", name, value);
}
else if (type == "cron") {
add_attribute_to_path(ecf::CronAttr::create(value), request);
}
Expand Down Expand Up @@ -729,6 +739,10 @@ ojson update_node_attribute_by_user(const httplib::Request& request) {
client->alter(path, "delete", type, old_value);
client->alter(path, "add", type, value);
}
else if (type == "aviso" || type == "mirror") {
const std::string value = json_type_to_string(payload.at("value"));
client->alter(path, "change", type, value);
}
else if (type == "autocancel") {
const std::string value = json_type_to_string(payload.at("value"));
update_attribute_in_path(create_from_text<ecf::AutoCancelAttr>(value), type, request);
Expand Down
7 changes: 7 additions & 0 deletions libs/rest/src/ecflow/http/TreeGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ struct FullTree
if (auto flag = node.get_flag(); flag.flag()) {
array.emplace_back(publish_atribute(flag, "flag"));
}

for (const auto& aviso : node.avisos()) {
array.emplace_back(publish_atribute(aviso, "aviso"));
}
for (const auto& mirror : node.mirrors()) {
array.emplace_back(publish_atribute(mirror, "mirror"));
}
}

private:
Expand Down
17 changes: 17 additions & 0 deletions libs/rest/src/ecflow/http/TypeToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,21 @@ void to_json(ojson& j, const ecf::AutoArchiveAttr& a) {
j["value"] = value;
}

void to_json(ojson& j, const ecf::AvisoAttr& a) {
j["name"] = a.name();
j["listener"] = a.listener();
j["url"] = a.url();
j["schema"] = a.schema();
j["polling"] = a.polling();
}

void to_json(ojson& j, const ecf::MirrorAttr& a) {
j["name"] = a.name();
j["remote_path"] = a.remote_path();
j["remote_host"] = a.remote_host();
j["remote_port"] = a.remote_port();
j["polling"] = a.polling();
j["ssl"] = a.ssl();
}

} // namespace ecf
4 changes: 4 additions & 0 deletions libs/rest/src/ecflow/http/TypeToJson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
#include "ecflow/core/TimeSlot.hpp"
#include "ecflow/http/JSON.hpp"
#include "ecflow/node/AutoRestoreAttr.hpp"
#include "ecflow/node/AvisoAttr.hpp"
#include "ecflow/node/Expression.hpp"
#include "ecflow/node/Flag.hpp"
#include "ecflow/node/InLimit.hpp"
#include "ecflow/node/Limit.hpp"
#include "ecflow/node/LimitFwd.hpp"
#include "ecflow/node/MirrorAttr.hpp"

/**
* IMPORTANT
Expand Down Expand Up @@ -82,6 +84,8 @@ void to_json(ecf::http::ojson&, const ecf::AutoArchiveAttr*);
void to_json(ecf::http::ojson&, const ecf::AutoArchiveAttr&);
void to_json(ecf::http::ojson&, const ecf::AutoRestoreAttr*);
void to_json(ecf::http::ojson&, const ecf::AutoRestoreAttr&);
void to_json(ecf::http::ojson&, const ecf::AvisoAttr&);
void to_json(ecf::http::ojson&, const ecf::MirrorAttr&);
} // namespace ecf

#endif /* ecflow_http_TypeToJson_HPP */

0 comments on commit 655043e

Please sign in to comment.