mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Adding venue device retrieval.
This commit is contained in:
@@ -668,6 +668,21 @@ components:
|
||||
minLength: 2
|
||||
maxLength: 2
|
||||
|
||||
VenueDeviceList:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
devices:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
|
||||
InventoryTagList:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1932,7 +1947,20 @@ paths:
|
||||
schema:
|
||||
type: boolean
|
||||
required: false
|
||||
|
||||
- in: query
|
||||
description: return the devices under a venue
|
||||
name: getDevices
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
- in: query
|
||||
description: return the devices under a venue and its children. Must select getDevices=true as well.
|
||||
name: getChildren
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
responses:
|
||||
200:
|
||||
description: Return a list of venues.
|
||||
@@ -1942,6 +1970,7 @@ paths:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/VenueList'
|
||||
- $ref: '#/components/schemas/CountAnswer'
|
||||
- $ref: '#/components/schemas/VenueDeviceList'
|
||||
403:
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
404:
|
||||
|
||||
@@ -15,6 +15,24 @@
|
||||
|
||||
namespace OpenWifi{
|
||||
|
||||
static Types::UUIDvec_t GetDevices(const ProvObjects::Venue &V, bool GetChildren) {
|
||||
Types::UUIDvec_t R;
|
||||
std::copy(V.devices.begin(),V.devices.end(),std::back_inserter(R));
|
||||
if(GetChildren) {
|
||||
for (const auto &i: V.children) {
|
||||
ProvObjects::Venue V2;
|
||||
if (StorageService()->VenueDB().GetRecord("id", i, V2)) {
|
||||
auto LowerDevs = GetDevices(V2, GetChildren);
|
||||
std::copy(LowerDevs.begin(), LowerDevs.end(), std::back_inserter(R));
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(R.begin(),R.end());
|
||||
auto Last = std::unique(R.begin(),R.end());
|
||||
R.erase(Last,R.end());
|
||||
return R;
|
||||
}
|
||||
|
||||
void RESTAPI_venue_handler::DoGet() {
|
||||
std::string UUID = GetBinding("uuid", "");
|
||||
ProvObjects::Venue Existing;
|
||||
@@ -22,6 +40,20 @@ namespace OpenWifi{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if(GetBoolParameter("getDevices")) {
|
||||
auto GetChildren = GetBoolParameter("getChildren");
|
||||
Types::UUIDvec_t 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);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
if(QB_.AdditionalInfo)
|
||||
AddExtendedInfo(Existing, Answer);
|
||||
|
||||
Reference in New Issue
Block a user