Adding venue device retrieval.

This commit is contained in:
stephb9959
2022-03-11 11:01:03 -08:00
parent 2aba988dba
commit e04988fcac
3 changed files with 36 additions and 8 deletions

View File

@@ -41,16 +41,14 @@ namespace OpenWifi{
}
if(GetBoolParameter("getDevices")) {
ProvObjects::VenueDeviceList VDL;
VDL.id = Existing.info.id;
VDL.name = Existing.info.name;
VDL.description = Existing.info.description;
auto GetChildren = GetBoolParameter("getChildren");
Types::UUIDvec_t Devices = GetDevices(Existing,GetChildren);
VDL.devices = GetDevices(Existing,GetChildren);
Poco::JSON::Object Answer;
Answer.set("id", Existing.info.id);
Answer.set("name",Existing.info.name);
Answer.set("description", Existing.info.description);
Poco::JSON::Array SerialNumbers;
for(const auto &i:Devices)
SerialNumbers.add(i);
Answer.set("devices", Devices);
VDL.to_json(Answer);
return ReturnObject(Answer);
}

View File

@@ -770,6 +770,25 @@ namespace OpenWifi::ProvObjects {
return false;
}
void VenueDeviceList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj,"id",id);
RESTAPI_utils::field_to_json(Obj,"name",name);
RESTAPI_utils::field_to_json(Obj,"description",description);
RESTAPI_utils::field_to_json(Obj,"devices",devices);
}
bool VenueDeviceList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj,"id",id);
RESTAPI_utils::field_from_json(Obj,"name",name);
RESTAPI_utils::field_from_json(Obj,"description",description);
RESTAPI_utils::field_from_json(Obj,"devices",devices);
return true;
} catch(...) {
}
return false;
}
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = std::time(nullptr);

View File

@@ -480,6 +480,17 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct VenueDeviceList {
std::string id;
std::string name;
std::string description;
Types::UUIDvec_t devices;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
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);