From 6219929cd5fd3d42ee0f1a1d22f282c87bb77c6d Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 2 Feb 2024 20:05:45 -0500 Subject: [PATCH] preliminary support for management APIs RID (Query/Add/Delete/Commit), TGID (Query/Add/Delete/Commit) [note: commit doesn't work pending modification to RadioIdLookup and TalkgroupRulesLookup to implement commit/saving to disk]; --- src/common/lookups/RadioIdLookup.cpp | 26 + src/common/lookups/RadioIdLookup.h | 5 + src/common/lookups/TalkgroupRulesLookup.cpp | 8 + src/common/lookups/TalkgroupRulesLookup.h | 5 +- src/fne/network/RESTAPI.cpp | 562 +++++++++++++++++--- src/fne/network/RESTAPI.h | 21 +- src/fne/network/RESTDefines.h | 13 +- src/remote/RESTClientMain.cpp | 4 +- 8 files changed, 570 insertions(+), 74 deletions(-) diff --git a/src/common/lookups/RadioIdLookup.cpp b/src/common/lookups/RadioIdLookup.cpp index 5868776b..c75a975b 100644 --- a/src/common/lookups/RadioIdLookup.cpp +++ b/src/common/lookups/RadioIdLookup.cpp @@ -98,6 +98,24 @@ void RadioIdLookup::addEntry(uint32_t id, bool enabled) m_mutex.unlock(); } +/// +/// Erases an existing entry from the lookup table by the specified unique ID. +/// +/// Unique ID to erase. +void RadioIdLookup::eraseEntry(uint32_t id) +{ + m_mutex.lock(); + { + try { + m_table.at(id); + m_table.erase(id); + } catch (...) { + /* stub */ + } + } + m_mutex.unlock(); +} + /// /// Finds a table entry in this lookup table. /// @@ -124,6 +142,14 @@ RadioId RadioIdLookup::find(uint32_t id) return entry; } +/// +/// Saves loaded talkgroup rules. +/// +void RadioIdLookup::commit() +{ + // bryanb: TODO TODO TODO +} + /// /// Flag indicating whether radio ID access control is enabled or not. /// diff --git a/src/common/lookups/RadioIdLookup.h b/src/common/lookups/RadioIdLookup.h index 2b845338..f8ee427c 100644 --- a/src/common/lookups/RadioIdLookup.h +++ b/src/common/lookups/RadioIdLookup.h @@ -90,9 +90,14 @@ namespace lookups /// Adds a new entry to the lookup table by the specified unique ID. void addEntry(uint32_t id, bool enabled); + /// Erases an existing entry from the lookup table by the specified unique ID. + void eraseEntry(uint32_t id); /// Finds a table entry in this lookup table. RadioId find(uint32_t id) override; + /// Saves loaded radio ID lookups. + void commit(); + /// Flag indicating whether radio ID access control is enabled or not. bool getACL(); diff --git a/src/common/lookups/TalkgroupRulesLookup.cpp b/src/common/lookups/TalkgroupRulesLookup.cpp index 9ad4b4a2..ac059cfa 100644 --- a/src/common/lookups/TalkgroupRulesLookup.cpp +++ b/src/common/lookups/TalkgroupRulesLookup.cpp @@ -288,6 +288,14 @@ TalkgroupRuleGroupVoice TalkgroupRulesLookup::findByRewrite(uint32_t peerId, uin return entry; } +/// +/// Saves loaded talkgroup rules. +/// +void TalkgroupRulesLookup::commit() +{ + // bryanb: TODO TODO TODO +} + /// /// Flag indicating whether talkgroup ID access control is enabled or not. /// diff --git a/src/common/lookups/TalkgroupRulesLookup.h b/src/common/lookups/TalkgroupRulesLookup.h index 430bf9b8..b56f948a 100644 --- a/src/common/lookups/TalkgroupRulesLookup.h +++ b/src/common/lookups/TalkgroupRulesLookup.h @@ -275,13 +275,16 @@ namespace lookups void addEntry(uint32_t id, uint8_t slot, bool enabled); /// Adds a new entry to the lookup table. void addEntry(TalkgroupRuleGroupVoice groupVoice); - /// Adds a new entry to the lookup table. + /// Erases an existing entry from the lookup table by the specified unique ID. void eraseEntry(uint32_t id, uint8_t slot); /// Finds a table entry in this lookup table. virtual TalkgroupRuleGroupVoice find(uint32_t id, uint8_t slot = 0U); /// Finds a table entry in this lookup table by rewrite. virtual TalkgroupRuleGroupVoice findByRewrite(uint32_t peerId, uint32_t id, uint8_t slot = 0U); + /// Saves loaded talkgroup rules. + void commit(); + /// Flag indicating whether talkgroup ID access control is enabled or not. bool getACL(); diff --git a/src/fne/network/RESTAPI.cpp b/src/fne/network/RESTAPI.cpp index 7ffb7026..42833118 100644 --- a/src/fne/network/RESTAPI.cpp +++ b/src/fne/network/RESTAPI.cpp @@ -23,6 +23,8 @@ using namespace network; using namespace network::rest; using namespace network::rest::http; +using namespace lookups; + #include #include #include @@ -119,6 +121,237 @@ bool parseRequestBody(const HTTPPayload& request, HTTPPayload& reply, json::obje return true; } +/// +/// Helper to convert a to JSON. +/// +/// +/// +json::object tgToJson(const TalkgroupRuleGroupVoice& groupVoice) +{ + json::object tg = json::object(); + + std::string tgName = groupVoice.name(); + tg["name"].set(tgName); + bool invalid = groupVoice.isInvalid(); + tg["invalid"].set(invalid); + + // source stanza + { + json::object source = json::object(); + uint32_t tgId = groupVoice.source().tgId(); + source["tgid"].set(tgId); + uint8_t tgSlot = groupVoice.source().tgSlot(); + source["slot"].set(tgSlot); + tg["source"].set(source); + } + + // config stanza + { + json::object config = json::object(); + bool active = groupVoice.config().active(); + config["active"].set(active); + bool affiliated = groupVoice.config().affiliated(); + config["affiliated"].set(affiliated); + bool parrot = groupVoice.config().parrot(); + config["parrot"].set(parrot); + + json::array inclusions = json::array(); + std::vector inclusion = groupVoice.config().inclusion(); + if (inclusion.size() > 0) { + for (auto inclEntry : inclusion) { + uint32_t peerId = inclEntry; + inclusions.push_back(json::value((double)peerId)); + } + } + config["inclusion"].set(inclusions); + + json::array exclusions = json::array(); + std::vector exclusion = groupVoice.config().exclusion(); + if (exclusion.size() > 0) { + for (auto exclEntry : exclusion) { + uint32_t peerId = exclEntry; + exclusions.push_back(json::value((double)peerId)); + } + } + config["exclusion"].set(exclusions); + + json::array rewrites = json::array(); + std::vector rewrite = groupVoice.config().rewrite(); + if (rewrite.size() > 0) { + for (auto rewrEntry : rewrite) { + json::object rewrite = json::object(); + uint32_t peerId = rewrEntry.peerId(); + rewrite["peerid"].set(peerId); + uint32_t tgId = rewrEntry.tgId(); + rewrite["tgid"].set(tgId); + uint8_t tgSlot = rewrEntry.tgSlot(); + rewrite["slot"].set(tgSlot); + + exclusions.push_back(json::value(rewrite)); + } + } + config["rewrite"].set(rewrites); + tg["config"].set(config); + } + + return tg; +} + +/// +/// Helper to convert JSON to a . +/// +/// +/// +TalkgroupRuleGroupVoice jsonToTG(json::object& req, HTTPPayload& reply) +{ + TalkgroupRuleGroupVoice groupVoice = TalkgroupRuleGroupVoice(); + + // validate parameters + if (!req["name"].is()) { + errorPayload(reply, "TG \"name\" was not a valid string"); + return TalkgroupRuleGroupVoice(); + } + + groupVoice.name(req["name"].get()); + + // source stanza + { + if (!req["source"].is()) { + errorPayload(reply, "TG \"source\" was not a valid JSON object"); + return TalkgroupRuleGroupVoice(); + } + json::object sourceObj = req["source"].get(); + + if (!sourceObj["tgid"].is()) { + errorPayload(reply, "TG source \"tgid\" was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + if (!sourceObj["slot"].is()) { + errorPayload(reply, "TG source \"slot\" was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + TalkgroupRuleGroupVoiceSource source = groupVoice.source(); + source.tgId(sourceObj["tgid"].get()); + source.tgSlot(sourceObj["slot"].get()); + + groupVoice.source(source); + } + + // config stanza + { + if (!req["config"].is()) { + errorPayload(reply, "TG \"config\" was not a valid JSON object"); + return TalkgroupRuleGroupVoice(); + } + json::object configObj = req["config"].get(); + + if (!configObj["active"].is()) { + errorPayload(reply, "TG configuration \"active\" was not a valid boolean"); + return TalkgroupRuleGroupVoice(); + } + + if (!configObj["affiliated"].is()) { + errorPayload(reply, "TG configuration \"affiliated\" was not a valid boolean"); + return TalkgroupRuleGroupVoice(); + } + + if (!configObj["parrot"].is()) { + errorPayload(reply, "TG configuration \"parrot\" slot was not a valid boolean"); + return TalkgroupRuleGroupVoice(); + } + + TalkgroupRuleConfig config = groupVoice.config(); + config.active(configObj["active"].get()); + config.affiliated(configObj["affiliated"].get()); + config.parrot(configObj["parrot"].get()); + + if (!req["inclusion"].is()) { + errorPayload(reply, "TG \"inclusion\" was not a valid JSON array"); + return TalkgroupRuleGroupVoice(); + } + json::array inclusions = req["inclusion"].get(); + + std::vector inclusion = groupVoice.config().inclusion(); + if (inclusions.size() > 0) { + for (auto inclEntry : inclusions) { + if (!inclEntry.is()) { + errorPayload(reply, "TG inclusion value was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + inclusion.push_back(inclEntry.get()); + } + config.inclusion(inclusion); + } + + if (!req["exclusion"].is()) { + errorPayload(reply, "TG \"exclusion\" was not a valid JSON array"); + return TalkgroupRuleGroupVoice(); + } + json::array exclusions = req["exclusion"].get(); + + std::vector exclusion = groupVoice.config().exclusion(); + if (exclusions.size() > 0) { + for (auto exclEntry : exclusions) { + if (!exclEntry.is()) { + errorPayload(reply, "TG exclusion value was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + exclusion.push_back(exclEntry.get()); + } + config.exclusion(exclusion); + } + + if (!req["rewrites"].is()) { + errorPayload(reply, "TG \"rewrites\" was not a valid JSON array"); + return TalkgroupRuleGroupVoice(); + } + json::array rewrites = req["rewrites"].get(); + + std::vector rewrite = groupVoice.config().rewrite(); + if (rewrites.size() > 0) { + for (auto rewrEntry : rewrites) { + if (!rewrEntry.is()) { + errorPayload(reply, "TG rewrite value was not a valid JSON object"); + return TalkgroupRuleGroupVoice(); + } + json::object rewriteObj = rewrEntry.get(); + + TalkgroupRuleRewrite rewriteRule = TalkgroupRuleRewrite(); + + if (!rewriteObj["peerid"].is()) { + errorPayload(reply, "TG rewrite rule \"peerid\" was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + if (!rewriteObj["tgid"].is()) { + errorPayload(reply, "TG rewrite rule \"tgid\" was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + if (!rewriteObj["slot"].is()) { + errorPayload(reply, "TG rewrite rule \"slot\" was not a valid number"); + return TalkgroupRuleGroupVoice(); + } + + rewriteRule.peerId(rewriteObj["peerid"].get()); + rewriteRule.tgId(rewriteObj["tgid"].get()); + rewriteRule.tgSlot(rewriteObj["slot"].get()); + + rewrite.push_back(rewriteRule); + } + config.rewrite(rewrite); + } + + groupVoice.config(config); + } + + return groupVoice; +} + // --------------------------------------------------------------------------- // Public Class Members // --------------------------------------------------------------------------- @@ -238,8 +471,18 @@ void RESTAPI::initializeEndpoints() m_dispatcher.match(GET_VERSION).get(REST_API_BIND(RESTAPI::restAPI_GetVersion, this)); m_dispatcher.match(GET_STATUS).get(REST_API_BIND(RESTAPI::restAPI_GetStatus, this)); - m_dispatcher.match(FNE_GET_PEERLIST).get(REST_API_BIND(RESTAPI::restAPI_GetPeerList, this)); - m_dispatcher.match(FNE_GET_TGID_LIST).get(REST_API_BIND(RESTAPI::restAPI_GetTGIDList, this)); + + m_dispatcher.match(FNE_GET_PEER_QUERY).get(REST_API_BIND(RESTAPI::restAPI_GetPeerQuery, this)); + + m_dispatcher.match(FNE_GET_RID_QUERY).get(REST_API_BIND(RESTAPI::restAPI_GetRIDQuery, this)); + m_dispatcher.match(FNE_PUT_RID_ADD).put(REST_API_BIND(RESTAPI::restAPI_PutRIDAdd, this)); + m_dispatcher.match(FNE_PUT_RID_DELETE).put(REST_API_BIND(RESTAPI::restAPI_PutRIDDelete, this)); + m_dispatcher.match(FNE_GET_RID_COMMIT).get(REST_API_BIND(RESTAPI::restAPI_GetRIDCommit, this)); + + m_dispatcher.match(FNE_GET_TGID_QUERY).get(REST_API_BIND(RESTAPI::restAPI_GetTGQuery, this)); + m_dispatcher.match(FNE_PUT_TGID_ADD).put(REST_API_BIND(RESTAPI::restAPI_PutTGAdd, this)); + m_dispatcher.match(FNE_PUT_TGID_DELETE).put(REST_API_BIND(RESTAPI::restAPI_PutTGDelete, this)); + m_dispatcher.match(FNE_GET_TGID_COMMIT).get(REST_API_BIND(RESTAPI::restAPI_GetTGCommit, this)); m_dispatcher.match(FNE_GET_FORCE_UPDATE).get(REST_API_BIND(RESTAPI::restAPI_GetForceUpdate, this)); @@ -431,7 +674,7 @@ void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, /// /// /// -void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +void RESTAPI::restAPI_GetPeerQuery(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { return; @@ -484,7 +727,147 @@ void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply /// /// /// -void RESTAPI::restAPI_GetTGIDList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +void RESTAPI::restAPI_GetRIDQuery(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object response = json::object(); + setResponseDefaultStatus(response); + + json::array rids = json::array(); + if (m_ridLookup != nullptr) { + if (m_ridLookup->table().size() > 0) { + for (auto entry : m_ridLookup->table()) { + json::object ridObj = json::object(); + + uint32_t rid = entry.first; + ridObj["id"].set(rid); + bool enabled = entry.second.radioEnabled(); + ridObj["enabled"].set(enabled); + + rids.push_back(json::value(ridObj)); + } + } + } + + response["rids"].set(rids); + reply.payload(response); +} + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_PutRIDAdd(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object req = json::object(); + if (!parseRequestBody(request, reply, req)) { + return; + } + + errorPayload(reply, "OK", HTTPPayload::OK); + + if (!req["rid"].is()) { + errorPayload(reply, "rid was not a valid integer"); + return; + } + + uint32_t rid = req["rid"].get(); + + if (!req["enabled"].is()) { + errorPayload(reply, "enabled was not a valid boolean"); + return; + } + + bool enabled = req["enabled"].get(); + + RadioId radioId = m_ridLookup->find(rid); + if (radioId.radioDefault()) { + m_ridLookup->addEntry(rid, enabled); + } + else { + m_ridLookup->toggleEntry(rid, enabled); + } + + if (m_network != nullptr) { + m_network->m_forceListUpdate = true; + } +} + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_PutRIDDelete(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object req = json::object(); + if (!parseRequestBody(request, reply, req)) { + return; + } + + errorPayload(reply, "OK", HTTPPayload::OK); + + if (!req["rid"].is()) { + errorPayload(reply, "rid was not a valid integer"); + return; + } + + uint32_t rid = req["rid"].get(); + + RadioId radioId = m_ridLookup->find(rid); + if (radioId.radioDefault()) { + errorPayload(reply, "failed to find specified RID to delete"); + return; + } + + m_ridLookup->eraseEntry(rid); + + if (m_network != nullptr) { + m_network->m_forceListUpdate = true; + } +} + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_GetRIDCommit(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object response = json::object(); + setResponseDefaultStatus(response); + + m_ridLookup->commit(); + + reply.payload(response); +} + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_GetTGQuery(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { return; @@ -497,68 +880,7 @@ void RESTAPI::restAPI_GetTGIDList(const HTTPPayload& request, HTTPPayload& reply if (m_tidLookup != nullptr) { if (m_tidLookup->groupVoice().size() > 0) { for (auto entry : m_tidLookup->groupVoice()) { - json::object tg = json::object(); - - std::string tgName = entry.name(); - tg["name"].set(tgName); - bool invalid = entry.isInvalid(); - tg["invalid"].set(invalid); - - { - json::object source = json::object(); - uint32_t tgId = entry.source().tgId(); - source["tgid"].set(tgId); - uint8_t tgSlot = entry.source().tgSlot(); - source["slot"].set(tgSlot); - tg["source"].set(source); - } - - { - json::object config = json::object(); - bool active = entry.config().active(); - config["active"].set(active); - bool parrot = entry.config().parrot(); - config["parrot"].set(parrot); - - json::array inclusions = json::array(); - std::vector inclusion = entry.config().inclusion(); - if (inclusion.size() > 0) { - for (auto inclEntry : inclusion) { - uint32_t peerId = inclEntry; - inclusions.push_back(json::value((double)peerId)); - } - } - config["inclusion"].set(inclusions); - - json::array exclusions = json::array(); - std::vector exclusion = entry.config().exclusion(); - if (exclusion.size() > 0) { - for (auto exclEntry : exclusion) { - uint32_t peerId = exclEntry; - exclusions.push_back(json::value((double)peerId)); - } - } - config["exclusion"].set(exclusions); - - json::array rewrites = json::array(); - std::vector rewrite = entry.config().rewrite(); - if (rewrite.size() > 0) { - for (auto rewrEntry : rewrite) { - json::object rewrite = json::object(); - uint32_t peerId = rewrEntry.peerId(); - rewrite["peerId"].set(peerId); - uint32_t tgId = rewrEntry.tgId(); - rewrite["tgid"].set(tgId); - uint8_t tgSlot = rewrEntry.tgSlot(); - rewrite["slot"].set(tgSlot); - - exclusions.push_back(json::value(rewrite)); - } - } - config["rewrite"].set(rewrites); - tg["config"].set(config); - } - + json::object tg = tgToJson(entry); tgs.push_back(json::value(tg)); } } @@ -568,6 +890,113 @@ void RESTAPI::restAPI_GetTGIDList(const HTTPPayload& request, HTTPPayload& reply reply.payload(response); } +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_PutTGAdd(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object req = json::object(); + if (!parseRequestBody(request, reply, req)) { + return; + } + + errorPayload(reply, "OK", HTTPPayload::OK); + + TalkgroupRuleGroupVoice groupVoice = jsonToTG(req, reply); + if (groupVoice.isInvalid()) { + return; + } + + std::string groupName = groupVoice.name(); + uint32_t tgId = groupVoice.source().tgId(); + uint8_t tgSlot = groupVoice.source().tgSlot(); + bool active = groupVoice.config().active(); + bool parrot = groupVoice.config().parrot(); + + uint32_t incCount = groupVoice.config().inclusion().size(); + uint32_t excCount = groupVoice.config().exclusion().size(); + uint32_t rewrCount = groupVoice.config().rewrite().size(); + + if (incCount > 0 && excCount > 0) { + ::LogWarning(LOG_REST, "Talkgroup (%s) defines both inclusions and exclusions! Inclusions take precedence and exclusions will be ignored.", groupName.c_str()); + } + + ::LogInfoEx(LOG_REST, "Talkgroup NAME: %s SRC_TGID: %u SRC_TS: %u ACTIVE: %u PARROT: %u INCLUSIONS: %u EXCLUSIONS: %u REWRITES: %u", groupName.c_str(), tgId, tgSlot, active, parrot, incCount, excCount, rewrCount); + + m_tidLookup->addEntry(groupVoice); + + if (m_network != nullptr) { + m_network->m_forceListUpdate = true; + } +} + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_PutTGDelete(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object req = json::object(); + if (!parseRequestBody(request, reply, req)) { + return; + } + + errorPayload(reply, "OK", HTTPPayload::OK); + + // validate state is a string within the JSON blob + if (!req["tgid"].is()) { + errorPayload(reply, "tgid was not a valid integer"); + return; + } + + uint32_t tgid = req["tgid"].get(); + + TalkgroupRuleGroupVoice groupVoice = m_tidLookup->find(tgid); + if (groupVoice.isInvalid()) { + errorPayload(reply, "failed to find specified TGID to delete"); + return; + } + + m_tidLookup->eraseEntry(groupVoice.source().tgId(), groupVoice.source().tgSlot()); + + if (m_network != nullptr) { + m_network->m_forceListUpdate = true; + } +} + +/// +/// +/// +/// +/// +/// +void RESTAPI::restAPI_GetTGCommit(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) +{ + if (!validateAuth(request, reply)) { + return; + } + + json::object response = json::object(); + setResponseDefaultStatus(response); + + m_tidLookup->commit(); + + reply.payload(response); +} + /// /// /// @@ -589,7 +1018,6 @@ void RESTAPI::restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& re reply.payload(response); } - /// /// /// diff --git a/src/fne/network/RESTAPI.h b/src/fne/network/RESTAPI.h index 8ba496a4..a17e2e02 100644 --- a/src/fne/network/RESTAPI.h +++ b/src/fne/network/RESTAPI.h @@ -94,10 +94,27 @@ private: void restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /// void restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + /// - void restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + void restAPI_GetPeerQuery(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + + /// + void restAPI_GetRIDQuery(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + /// + void restAPI_PutRIDAdd(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + /// + void restAPI_PutRIDDelete(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + /// + void restAPI_GetRIDCommit(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + + /// + void restAPI_GetTGQuery(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + /// + void restAPI_PutTGAdd(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + /// + void restAPI_PutTGDelete(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /// - void restAPI_GetTGIDList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); + void restAPI_GetTGCommit(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /// void restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); diff --git a/src/fne/network/RESTDefines.h b/src/fne/network/RESTDefines.h index c9c9d393..46e1bbe2 100644 --- a/src/fne/network/RESTDefines.h +++ b/src/fne/network/RESTDefines.h @@ -20,8 +20,17 @@ // Constants // --------------------------------------------------------------------------- -#define FNE_GET_PEERLIST "/peerlist" -#define FNE_GET_TGID_LIST "/tgidlist" +#define FNE_GET_PEER_QUERY "/peer/query" + +#define FNE_GET_RID_QUERY "/rid/query" +#define FNE_PUT_RID_ADD "/rid/add" +#define FNE_PUT_RID_DELETE "/rid/delete" +#define FNE_GET_RID_COMMIT "/rid/commit" + +#define FNE_GET_TGID_QUERY "/tg/query" +#define FNE_PUT_TGID_ADD "/tg/add" +#define FNE_PUT_TGID_DELETE "/tg/delete" +#define FNE_GET_TGID_COMMIT "/tg/commit" #define FNE_GET_FORCE_UPDATE "/force-update" diff --git a/src/remote/RESTClientMain.cpp b/src/remote/RESTClientMain.cpp index bb087ad7..bc02c990 100644 --- a/src/remote/RESTClientMain.cpp +++ b/src/remote/RESTClientMain.cpp @@ -728,10 +728,10 @@ int main(int argc, char** argv) ** Fixed Network Equipment */ else if (rcom == RCD_FNE_GET_PEERLIST) { - retCode = client->send(HTTP_GET, FNE_GET_PEERLIST, json::object(), response); + retCode = client->send(HTTP_GET, FNE_GET_PEER_QUERY, json::object(), response); } else if (rcom == RCD_FNE_GET_TGIDLIST) { - retCode = client->send(HTTP_GET, FNE_GET_TGID_LIST, json::object(), response); + retCode = client->send(HTTP_GET, FNE_GET_TGID_QUERY, json::object(), response); } else if (rcom == RCD_FNE_GET_FORCEUPDATE) { retCode = client->send(HTTP_GET, FNE_GET_FORCE_UPDATE, json::object(), response);