diff --git a/src/RESTObjects/RESTAPI_FMSObjects.cpp b/src/RESTObjects/RESTAPI_FMSObjects.cpp index 78d0062..7d40630 100644 --- a/src/RESTObjects/RESTAPI_FMSObjects.cpp +++ b/src/RESTObjects/RESTAPI_FMSObjects.cpp @@ -245,4 +245,30 @@ namespace OpenWifi::FMSObjects { } return false; } + + void DeviceInformation::to_json(Poco::JSON::Object &Obj) const { + field_to_json(Obj, "serialNumber",serialNumber); + field_to_json(Obj, "history", history); + field_to_json(Obj, "currentFirmware", currentFirmware); + field_to_json(Obj, "currentFirmwareDate", currentFirmwareDate); + field_to_json(Obj, "latestFirmware", latestFirmware); + field_to_json(Obj, "latestFirmwareDate", latestFirmwareDate); + field_to_json(Obj, "latestFirmwareAvailable",latestFirmwareAvailable); + } + + bool DeviceInformation::from_json(const Poco::JSON::Object::Ptr &Obj) { + try { + field_from_json(Obj, "serialNumber",serialNumber); + field_from_json(Obj, "history", history); + field_from_json(Obj, "currentFirmware", currentFirmware); + field_from_json(Obj, "currentFirmwareDate", currentFirmwareDate); + field_from_json(Obj, "latestFirmware", latestFirmware); + field_from_json(Obj, "latestFirmwareDate", latestFirmwareDate); + field_from_json(Obj, "latestFirmwareAvailable",latestFirmwareAvailable); + return true; + } catch(...) { + + } + return false; + } } diff --git a/src/RESTObjects/RESTAPI_FMSObjects.h b/src/RESTObjects/RESTAPI_FMSObjects.h index 366523e..954992e 100644 --- a/src/RESTObjects/RESTAPI_FMSObjects.h +++ b/src/RESTObjects/RESTAPI_FMSObjects.h @@ -127,6 +127,19 @@ namespace OpenWifi::FMSObjects { void reset(); bool from_json(const Poco::JSON::Object::Ptr &Obj); }; + + struct DeviceInformation { + std::string serialNumber; + RevisionHistoryEntryList history; + std::string currentFirmware; + uint64_t currentFirmwareDate=0; + std::string latestFirmware; + uint64_t latestFirmwareDate=0; + bool latestFirmwareAvailable; + + void to_json(Poco::JSON::Object &Obj) const; + bool from_json(const Poco::JSON::Object::Ptr &Obj); + }; } diff --git a/src/RESTObjects/RESTAPI_ProvObjects.cpp b/src/RESTObjects/RESTAPI_ProvObjects.cpp index f5dc093..66df8eb 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.cpp +++ b/src/RESTObjects/RESTAPI_ProvObjects.cpp @@ -93,6 +93,11 @@ namespace OpenWifi::ProvObjects { field_to_json( Obj,"devices",devices); field_to_json( Obj,"rrm",rrm); field_to_json( Obj,"sourceIP",sourceIP); + field_to_json( Obj,"variables", variables); + field_to_json( Obj,"managementPolicies", managementPolicies); + field_to_json( Obj,"managementRoles", managementRoles); + field_to_json( Obj,"maps", maps); + field_to_json( Obj,"configurations", configurations); } bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -108,6 +113,11 @@ namespace OpenWifi::ProvObjects { field_from_json( Obj,"devices",devices); field_from_json( Obj,"rrm",rrm); field_from_json( Obj,"sourceIP",sourceIP); + field_from_json( Obj,"variables", variables); + field_from_json( Obj,"managementPolicies", managementPolicies); + field_from_json( Obj,"managementRoles", managementRoles); + field_from_json( Obj,"maps", maps); + field_from_json( Obj,"configurations", configurations); return true; } catch(...) { @@ -142,10 +152,15 @@ namespace OpenWifi::ProvObjects { field_to_json( Obj,"design",design); field_to_json( Obj,"managementPolicy",managementPolicy); field_to_json( Obj,"deviceConfiguration",deviceConfiguration); - field_to_json( Obj,"contact",contact); + field_to_json( Obj,"contacts",contacts); field_to_json( Obj,"location",location); field_to_json( Obj,"rrm",rrm); field_to_json( Obj,"sourceIP",sourceIP); + field_to_json( Obj,"variables", variables); + field_to_json( Obj,"managementPolicies", managementPolicies); + field_to_json( Obj,"managementRoles", managementRoles); + field_to_json( Obj,"maps", maps); + field_to_json( Obj,"configurations", configurations); } bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -160,10 +175,15 @@ namespace OpenWifi::ProvObjects { field_from_json( Obj,"design",design); field_from_json( Obj,"managementPolicy",managementPolicy); field_from_json( Obj,"deviceConfiguration",deviceConfiguration); - field_from_json( Obj,"contact",contact); + field_from_json( Obj,"contacts",contacts); field_from_json( Obj,"location",location); field_from_json( Obj,"rrm",rrm); field_from_json( Obj,"sourceIP",sourceIP); + field_from_json( Obj,"variables", variables); + field_from_json( Obj,"managementPolicies", managementPolicies); + field_from_json( Obj,"managementRoles", managementRoles); + field_from_json( Obj,"maps", maps); + field_from_json( Obj,"configurations", configurations); return true; } catch (...) { @@ -193,6 +213,7 @@ namespace OpenWifi::ProvObjects { field_to_json( Obj,"managementPolicy",managementPolicy); field_to_json( Obj,"users",users); field_to_json( Obj,"entity",entity); + field_to_json( Obj,"venue",venue); } bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -201,6 +222,7 @@ namespace OpenWifi::ProvObjects { field_from_json( Obj,"managementPolicy",managementPolicy); field_from_json( Obj,"users",users); field_from_json( Obj,"entity",entity); + field_from_json( Obj,"venue",venue); return true; } catch(...) { } @@ -312,6 +334,7 @@ namespace OpenWifi::ProvObjects { field_to_json( Obj,"state",state); field_to_json( Obj,"devClass",devClass); field_to_json( Obj,"locale",locale); + field_to_json( Obj,"realMacAddress",realMacAddress); } bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -332,6 +355,7 @@ namespace OpenWifi::ProvObjects { field_from_json( Obj,"state",state); field_from_json( Obj,"devClass",devClass); field_from_json( Obj,"locale",locale); + field_from_json( Obj,"realMacAddress",realMacAddress); return true; } catch(...) { @@ -404,6 +428,10 @@ namespace OpenWifi::ProvObjects { field_to_json( Obj,"rrm",rrm); field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade); field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly); + field_to_json( Obj,"subscriberOnly",subscriberOnly); + field_to_json( Obj,"entity", entity); + field_to_json( Obj,"venue", venue); + field_to_json( Obj,"subscriber", subscriber); } bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -417,6 +445,10 @@ namespace OpenWifi::ProvObjects { field_from_json( Obj,"rrm",rrm); field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade); field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly); + field_from_json( Obj,"subscriberOnly",subscriberOnly); + field_from_json( Obj,"entity", entity); + field_from_json( Obj,"venue", venue); + field_from_json( Obj,"subscriber", subscriber); return true; } catch(...) { @@ -595,6 +627,8 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_to_json( Obj,"creator",creator); field_to_json( Obj,"visibility",visibility); RESTAPI_utils::field_to_json( Obj,"access",access); + RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy); + RESTAPI_utils::field_to_json( Obj,"venue", venue); } bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -605,6 +639,8 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_from_json( Obj,"creator",creator); field_from_json( Obj,"visibility",visibility); RESTAPI_utils::field_from_json( Obj,"access",access); + RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy); + RESTAPI_utils::field_from_json( Obj,"venue", venue); return true; } catch(...) { @@ -630,11 +666,14 @@ namespace OpenWifi::ProvObjects { info.to_json(Obj); RESTAPI_utils::field_to_json( Obj,"email", email); RESTAPI_utils::field_to_json( Obj,"userId", userId); + RESTAPI_utils::field_to_json( Obj,"macAddress", macAddress); RESTAPI_utils::field_to_json( Obj,"serialNumber", serialNumber); RESTAPI_utils::field_to_json( Obj,"submitted", submitted); RESTAPI_utils::field_to_json( Obj,"completed", completed); RESTAPI_utils::field_to_json( Obj,"status", status); RESTAPI_utils::field_to_json( Obj,"error", error); + RESTAPI_utils::field_to_json( Obj,"statusCode", statusCode); + RESTAPI_utils::field_to_json( Obj,"deviceID", deviceID); } bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -642,11 +681,14 @@ namespace OpenWifi::ProvObjects { info.from_json(Obj); RESTAPI_utils::field_from_json( Obj,"email", email); RESTAPI_utils::field_from_json( Obj,"userId", userId); + RESTAPI_utils::field_from_json( Obj,"macAddress", macAddress); RESTAPI_utils::field_from_json( Obj,"serialNumber", serialNumber); RESTAPI_utils::field_from_json( Obj,"submitted", submitted); RESTAPI_utils::field_from_json( Obj,"completed", completed); RESTAPI_utils::field_from_json( Obj,"status", status); RESTAPI_utils::field_from_json( Obj,"error", error); + RESTAPI_utils::field_from_json( Obj,"statusCode", statusCode); + RESTAPI_utils::field_from_json( Obj,"deviceID", deviceID); return true; } catch(...) { @@ -695,7 +737,8 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_to_json( Obj,"venue", venue); RESTAPI_utils::field_to_json( Obj,"subscriber", subscriber); RESTAPI_utils::field_to_json( Obj,"inventory", inventory); - RESTAPI_utils::field_to_json( Obj,"inUse", inUse); + RESTAPI_utils::field_to_json( Obj,"configurations", configurations); + RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy); } bool VariableBlock::from_json(const Poco::JSON::Object::Ptr &Obj) { @@ -706,7 +749,8 @@ namespace OpenWifi::ProvObjects { RESTAPI_utils::field_from_json( Obj,"venue", venue); RESTAPI_utils::field_from_json( Obj,"subscriber", subscriber); RESTAPI_utils::field_from_json( Obj,"inventory", inventory); - RESTAPI_utils::field_from_json( Obj,"inUse", inUse); + RESTAPI_utils::field_from_json( Obj,"configurations", configurations); + RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy); return true; } catch(...) { } @@ -750,7 +794,7 @@ namespace OpenWifi::ProvObjects { } bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) { - uint64_t Now = std::time(nullptr); + uint64_t Now = OpenWifi::Now(); if(O->has("name")) I.name = O->get("name").toString(); @@ -772,5 +816,12 @@ namespace OpenWifi::ProvObjects { return true; } + + bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I) { + I.modified = I.created = OpenWifi::Now(); + I.id = MicroService::CreateUUID(); + return true; + } + } diff --git a/src/RESTObjects/RESTAPI_ProvObjects.h b/src/RESTObjects/RESTAPI_ProvObjects.h index 28bbd54..5839221 100644 --- a/src/RESTObjects/RESTAPI_ProvObjects.h +++ b/src/RESTObjects/RESTAPI_ProvObjects.h @@ -48,6 +48,7 @@ namespace OpenWifi::ProvObjects { std::vector entries; Types::StringVec inUse; Types::UUID_t entity; + Types::UUID_t venue; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -66,6 +67,11 @@ namespace OpenWifi::ProvObjects { Types::UUIDvec_t devices; std::string rrm; Types::StringVec sourceIP; + Types::UUIDvec_t variables; + Types::UUIDvec_t managementPolicies; + Types::UUIDvec_t managementRoles; + Types::UUIDvec_t maps; + Types::UUIDvec_t configurations; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -92,10 +98,15 @@ namespace OpenWifi::ProvObjects { DiGraph topology; std::string design; Types::UUIDvec_t deviceConfiguration; - std::string contact; + Types::UUIDvec_t contacts; std::string location; std::string rrm; Types::StringVec sourceIP; + Types::UUIDvec_t variables; + Types::UUIDvec_t configurations; + Types::UUIDvec_t maps; + Types::UUIDvec_t managementPolicies; + Types::UUIDvec_t managementRoles; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -117,6 +128,7 @@ namespace OpenWifi::ProvObjects { Types::UUIDvec_t users; Types::StringVec inUse; Types::UUID_t entity; + Types::UUID_t venue; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -260,10 +272,14 @@ namespace OpenWifi::ProvObjects { Types::StringVec deviceTypes; DeviceConfigurationElementVec configuration; Types::StringVec inUse; - Types::StringPairVec variables; + Types::UUIDvec_t variables; std::string rrm; std::string firmwareUpgrade; bool firmwareRCOnly=false; + bool subscriberOnly=false; + std::string venue; + std::string entity; + std::string subscriber; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -287,6 +303,7 @@ namespace OpenWifi::ProvObjects { std::string state; std::string devClass; std::string locale; + std::string realMacAddress; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -384,6 +401,8 @@ namespace OpenWifi::ProvObjects { std::string creator; VISIBILITY visibility = PRIVATE; ObjectACLList access; + Types::UUID_t managementPolicy; + std::string venue; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -396,15 +415,28 @@ namespace OpenWifi::ProvObjects { bool from_json(const Poco::JSON::Object::Ptr &Obj); }; + enum SignupStatusCodes { + SignupCreated = 0 , + SignupWaitingForEmail, + SignupWaitingForDevice, + SignupSuccess, + SignupFailure, + SignupCanceled, + SignupTimedOut + }; + struct SignupEntry { ObjectInfo info; std::string email; std::string userId; + std::string macAddress; std::string serialNumber; uint64_t submitted = 0 ; uint64_t completed = 0 ; std::string status; uint64_t error=0; + uint64_t statusCode=0; + std::string deviceID; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -434,7 +466,8 @@ namespace OpenWifi::ProvObjects { std::string venue; std::string subscriber; std::string inventory; - std::vector inUse; + Types::UUIDvec_t configurations; + Types::UUID_t managementPolicy; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); @@ -449,4 +482,5 @@ namespace OpenWifi::ProvObjects { bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I); bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I); + bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I); }; diff --git a/src/framework/MicroService.h b/src/framework/MicroService.h index 8d6cd96..9dc0201 100644 --- a/src/framework/MicroService.h +++ b/src/framework/MicroService.h @@ -83,7 +83,7 @@ using namespace std::chrono_literals; #include "ow_version.h" #define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl; - +// #define _OWDEBUG_ Logger().debug(Poco::format("%s: %lu",__FILE__,__LINE__)); namespace OpenWifi { inline uint64_t Now() { return std::time(nullptr); }; @@ -1679,7 +1679,7 @@ namespace OpenWifi { std::vector Methods, RESTAPI_GenericServer & Server, uint64_t TransactionId, - bool Internal=false, + bool Internal, bool AlwaysAuthorize=true, bool RateLimited=false, const RateLimit & Profile = RateLimit{.Interval=1000,.MaxCalls=100}, @@ -1858,7 +1858,17 @@ namespace OpenWifi { return Return; } - static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, std::string &Value) { + static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, Types::UUIDvec_t & Value) { + if(O->has(Field) && O->isArray(Field)) { + auto Arr = O->getArray(Field); + for(const auto &i:*Arr) + Value.emplace_back(i.toString()); + return true; + } + return false; + } + + static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, std::string &Value) { if(O->has(Field)) { Value = O->get(Field).toString(); return true; @@ -2209,8 +2219,8 @@ namespace OpenWifi { class RESTAPI_UnknownRequestHandler : public RESTAPIHandler { public: - RESTAPI_UnknownRequestHandler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId) - : RESTAPIHandler(bindings, L, std::vector{}, Server, TransactionId) {} + RESTAPI_UnknownRequestHandler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal) + : RESTAPIHandler(bindings, L, std::vector{}, Server, TransactionId, Internal) {} inline void DoGet() override {}; inline void DoPost() override {}; inline void DoPut() override {}; @@ -2233,11 +2243,11 @@ namespace OpenWifi { Poco::Logger & Logger, RESTAPI_GenericServer & Server, uint64_t TransactionId) { static_assert(test_has_PathName_method((T*)nullptr), "Class must have a static PathName() method."); if(RESTAPIHandler::ParseBindings(RequestedPath,T::PathName(),Bindings)) { - return new T(Bindings, Logger, Server, false, TransactionId); + return new T(Bindings, Logger, Server, TransactionId, false); } if constexpr (sizeof...(Args) == 0) { - return new RESTAPI_UnknownRequestHandler(Bindings,Logger, Server, TransactionId); + return new RESTAPI_UnknownRequestHandler(Bindings,Logger, Server, TransactionId, false); } else { return RESTAPI_Router(RequestedPath, Bindings, Logger, Server, TransactionId); } @@ -2248,11 +2258,11 @@ namespace OpenWifi { Poco::Logger & Logger, RESTAPI_GenericServer & Server, uint64_t TransactionId) { static_assert(test_has_PathName_method((T*)nullptr), "Class must have a static PathName() method."); if(RESTAPIHandler::ParseBindings(RequestedPath,T::PathName(),Bindings)) { - return new T(Bindings, Logger, Server, true, TransactionId); + return new T(Bindings, Logger, Server, TransactionId, true ); } if constexpr (sizeof...(Args) == 0) { - return new RESTAPI_UnknownRequestHandler(Bindings,Logger, Server, TransactionId); + return new RESTAPI_UnknownRequestHandler(Bindings,Logger, Server, TransactionId, true); } else { return RESTAPI_Router_I(RequestedPath, Bindings, Logger, Server, TransactionId); } @@ -3066,10 +3076,10 @@ namespace OpenWifi { } inline Poco::Logger & GetLogger(const std::string &Name) { - static auto initilized = false; + static auto initialized = false; - if(!initilized) { - initilized = true; + if(!initialized) { + initialized = true; InitializeLoggingSystem(); } return Poco::Logger::get(Name); @@ -3227,9 +3237,9 @@ namespace OpenWifi { } auto i=Services_.begin(); - auto Now = (uint64_t )std::time(nullptr); + auto now = OpenWifi::Now(); for(;i!=Services_.end();) { - if((Now - i->second.LastUpdate)>60) { + if((now - i->second.LastUpdate)>60) { i = Services_.erase(i); } else ++i; @@ -4292,12 +4302,6 @@ namespace OpenWifi { Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_DELETE, Path, Poco::Net::HTTPMessage::HTTP_1_1); - std::ostringstream obody; - Poco::JSON::Stringifier::stringify(Body_,obody); - - Request.setContentType("application/json"); - Request.setContentLength(obody.str().size()); - if(BearerToken.empty()) { Request.add("X-API-KEY", Svc.AccessKey); Request.add("X-INTERNAL-NAME", MicroService::instance().PublicEndPoint()); @@ -4306,9 +4310,7 @@ namespace OpenWifi { Request.add("Authorization", "Bearer " + BearerToken); } - std::ostream & os = Session.sendRequest(Request); - os << obody.str(); - + Session.sendRequest(Request); Poco::Net::HTTPResponse Response; Session.receiveResponse(Response); return Response.getStatus(); diff --git a/src/framework/orm.h b/src/framework/orm.h index 0f5fad9..4ffa5b5 100644 --- a/src/framework/orm.h +++ b/src/framework/orm.h @@ -667,9 +667,6 @@ namespace ORM { if(!ItemList.empty()) { OrderByString = " ORDER BY " + ItemList; } - - std::cout << OrderByString << std::endl; - return true; } @@ -730,11 +727,11 @@ namespace ORM { try { Command << i, Poco::Data::Keywords::now; } catch (const Poco::Exception &E) { - Logger_.log(E); - Logger_.error(Poco::format("The following statement '%s' generated an exception during a table upgrade. This maya or may not be a problem.", i)); - } - if(!IgnoreExceptions) { - return false; + // Logger_.log(E); + // Logger_.error(Poco::format("The following statement '%s' generated an exception during a table upgrade. This may or may not be a problem.", i)); + if(!IgnoreExceptions) { + return false; + } } Command.reset(Session); } @@ -810,32 +807,32 @@ namespace ORM { return ManipulateVectorMember(&RecordType::users, FieldName, ParentUUID, ChildUUID, false); } - inline bool AddInUse(field_name_t FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) { + inline bool AddConfiguration(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) { + return ManipulateVectorMember(&RecordType::deviceConfiguration, FieldName, ParentUUID, ChildUUID, true); + } + + inline bool DelConfiguration(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) { + return ManipulateVectorMember(&RecordType::deviceConfiguration, FieldName, ParentUUID, ChildUUID, false); + } + + inline bool AddVariable(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) { + return ManipulateVectorMember(&RecordType::variables, FieldName, ParentUUID, ChildUUID, true); + } + + inline bool DelVariable(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) { + return ManipulateVectorMember(&RecordType::variables, FieldName, ParentUUID, ChildUUID, false); + } + + inline bool AddInUse(field_name_t FieldName, const std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) { std::string FakeUUID{ Prefix + ":" + ChildUUID}; return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, true); } - inline bool DeleteInUse(field_name_t FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) { + inline bool DeleteInUse(field_name_t FieldName, const std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) { std::string FakeUUID{ Prefix + ":" + ChildUUID}; return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, false); } - inline bool DeleteContact(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) { - return ManipulateVectorMember(&RecordType::contacts,FieldName, ParentUUID, ChildUUID, false); - } - - inline bool AddContact(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) { - return ManipulateVectorMember(&RecordType::contacts,FieldName, ParentUUID, ChildUUID, true); - } - - inline bool DeleteLocation(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) { - return ManipulateVectorMember(&RecordType::locations,FieldName, ParentUUID, ChildUUID, false); - } - - inline bool AddLocation(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) { - return ManipulateVectorMember(&RecordType::locations,FieldName, ParentUUID, ChildUUID, true); - } - inline bool GetInUse(field_name_t FieldName, const std::string & UUID, std::vector & UUIDs ) { RecordType R; if(GetRecord(FieldName,UUID,R)) { diff --git a/src/framework/ow_constants.h b/src/framework/ow_constants.h index f827809..d9833e0 100644 --- a/src/framework/ow_constants.h +++ b/src/framework/ow_constants.h @@ -71,6 +71,7 @@ namespace OpenWifi::RESTAPI::Errors { static const std::string SerialNumberNotTheProperClass{"Device is not available to subscribers. It ahs been assigned to another class of devices."}; static const std::string UserAlreadyExists{"Username already exists."}; static const std::string NotImplemented{"Function not implemented."}; + static const std::string VariableMustExist{"Specified variable does not exist."}; } namespace OpenWifi::RESTAPI::Protocol {