mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 19:48:03 +00:00
Adding MAP API.
This commit is contained in:
@@ -107,7 +107,7 @@ add_executable(owprov
|
|||||||
src/RESTAPI/RESTAPI_db_helpers.h
|
src/RESTAPI/RESTAPI_db_helpers.h
|
||||||
src/JobController.cpp src/JobController.h
|
src/JobController.cpp src/JobController.h
|
||||||
src/JobRegistrations.cpp
|
src/JobRegistrations.cpp
|
||||||
src/storage/storage_jobs.cpp src/storage/storage_jobs.h src/WebSocketClientServer.cpp src/WebSocketClientServer.h)
|
src/storage/storage_jobs.cpp src/storage/storage_jobs.h src/WebSocketClientServer.cpp src/WebSocketClientServer.h src/storage/storage_maps.cpp src/storage/storage_maps.h src/RESTAPI/RESTAPI_map_handler.cpp src/RESTAPI/RESTAPI_map_handler.h src/RESTAPI/RESTAPI_map_list_handler.cpp src/RESTAPI/RESTAPI_map_list_handler.h)
|
||||||
|
|
||||||
target_link_libraries(owprov PUBLIC
|
target_link_libraries(owprov PUBLIC
|
||||||
${Poco_LIBRARIES} ${MySQL_LIBRARIES}
|
${Poco_LIBRARIES} ${MySQL_LIBRARIES}
|
||||||
|
|||||||
@@ -616,6 +616,66 @@ components:
|
|||||||
errorCode:
|
errorCode:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
||||||
|
UserList:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
list:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
|
||||||
|
ObjectACL:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
users:
|
||||||
|
$ref: '#/components/schemas/UserList'
|
||||||
|
access:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- none
|
||||||
|
- read
|
||||||
|
- readwrite
|
||||||
|
- readwritedelete
|
||||||
|
|
||||||
|
ObjectACLList:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
list:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/ObjectACL'
|
||||||
|
|
||||||
|
Map:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
allOf:
|
||||||
|
$ref: '#/components/schemas/ObjectInfo'
|
||||||
|
entity:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
data:
|
||||||
|
type: string
|
||||||
|
visibility:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- private
|
||||||
|
- public
|
||||||
|
- select
|
||||||
|
creator:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
access:
|
||||||
|
$ref: '#/components/schemas/ObjectACLList'
|
||||||
|
|
||||||
|
MapList:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
list:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Map'
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
##
|
##
|
||||||
## These are endpoints that all services in the OPenWiFI stack must provide
|
## These are endpoints that all services in the OPenWiFI stack must provide
|
||||||
@@ -1710,6 +1770,144 @@ paths:
|
|||||||
404:
|
404:
|
||||||
$ref: '#/components/responses/NotFound'
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
/map:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- Maps
|
||||||
|
operationId: getMapList
|
||||||
|
summary: Retrieve the list of maps
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
description: Pagination start (starts at 1. If not specified, 1 is assumed)
|
||||||
|
name: offset
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
description: Maximum number of entries to return (if absent, no limit is assumed)
|
||||||
|
name: limit
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
description: Filter the results
|
||||||
|
name: filter
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Return a list of Venues
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/MapList'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
/map/{uuid}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- Maps
|
||||||
|
operationId: getMap
|
||||||
|
summary: Retrieve a specific map.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
required: true
|
||||||
|
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Successfull retrieval of a map
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Map'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- Maps
|
||||||
|
operationId: createMap
|
||||||
|
summary: Create a specific map.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
required: true
|
||||||
|
requestBody:
|
||||||
|
description: Information used to create the new policy
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Map'
|
||||||
|
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/schemas/Map'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- Maps
|
||||||
|
operationId: modifyMap
|
||||||
|
summary: Modify a specific map.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
required: true
|
||||||
|
requestBody:
|
||||||
|
description: Information used to modify a map
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Map'
|
||||||
|
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/schemas/ManagementPolicy'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- Maps
|
||||||
|
operationId: deleteMap
|
||||||
|
summary: Delete a specific map.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: uuid
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
204:
|
||||||
|
$ref: '#/components/responses/Success'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
/managementPolicy:
|
/managementPolicy:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "RESTAPI/RESTAPI_location_list_handler.h"
|
#include "RESTAPI/RESTAPI_location_list_handler.h"
|
||||||
#include "RESTAPI/RESTAPI_venue_list_handler.h"
|
#include "RESTAPI/RESTAPI_venue_list_handler.h"
|
||||||
#include "RESTAPI/RESTAPI_managementRole_list_handler.h"
|
#include "RESTAPI/RESTAPI_managementRole_list_handler.h"
|
||||||
|
#include "RESTAPI/RESTAPI_map_handler.h"
|
||||||
|
#include "RESTAPI/RESTAPI_map_list_handler.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -42,6 +44,8 @@ namespace OpenWifi {
|
|||||||
RESTAPI_managementRole_list_handler,
|
RESTAPI_managementRole_list_handler,
|
||||||
RESTAPI_configurations_handler,
|
RESTAPI_configurations_handler,
|
||||||
RESTAPI_configurations_list_handler,
|
RESTAPI_configurations_list_handler,
|
||||||
|
RESTAPI_map_handler,
|
||||||
|
RESTAPI_map_list_handler,
|
||||||
RESTAPI_webSocketServer
|
RESTAPI_webSocketServer
|
||||||
>(Path,Bindings,L, S);
|
>(Path,Bindings,L, S);
|
||||||
}
|
}
|
||||||
|
|||||||
126
src/RESTAPI/RESTAPI_map_handler.cpp
Normal file
126
src/RESTAPI/RESTAPI_map_handler.cpp
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-11-09.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RESTAPI_map_handler.h"
|
||||||
|
|
||||||
|
#include "framework/RESTAPI_protocol.h"
|
||||||
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
|
#include "StorageService.h"
|
||||||
|
#include "Poco/JSON/Parser.h"
|
||||||
|
#include "Poco/StringTokenizer.h"
|
||||||
|
#include "framework/RESTAPI_errors.h"
|
||||||
|
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||||
|
|
||||||
|
namespace OpenWifi{
|
||||||
|
|
||||||
|
void RESTAPI_map_handler::DoGet() {
|
||||||
|
|
||||||
|
ProvObjects::Map Existing;
|
||||||
|
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
|
||||||
|
if(UUID.empty() || !DB_.GetRecord(RESTAPI::Protocol::ID,UUID,Existing)) {
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
if(QB_.AdditionalInfo)
|
||||||
|
AddExtendedInfo(Existing,Answer);
|
||||||
|
Existing.to_json(Answer);
|
||||||
|
ReturnObject(Answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RESTAPI_map_handler::DoDelete() {
|
||||||
|
ProvObjects::Map Existing;
|
||||||
|
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
|
||||||
|
if(UUID.empty() || !DB_.GetRecord(RESTAPI::Protocol::ID,UUID,Existing)) {
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(UserInfo_.userinfo.email!=Existing.creator) {
|
||||||
|
return UnAuthorized("You must be the creator of the map to delete it");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DB_.DeleteRecord("id", Existing.info.id)) {
|
||||||
|
return OK();
|
||||||
|
}
|
||||||
|
InternalError(RESTAPI::Errors::CouldNotBeDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
static auto ValidateVisibility(const std::string &V) {
|
||||||
|
return (V=="private" || V=="public" || V=="select");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RESTAPI_map_handler::DoPost() {
|
||||||
|
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
|
||||||
|
if(UUID.empty()) {
|
||||||
|
return BadRequest(RESTAPI::Errors::MissingUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Obj = ParseStream();
|
||||||
|
ProvObjects::Map NewObject;
|
||||||
|
if (!NewObject.from_json(Obj)) {
|
||||||
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!CreateObjectInfo(Obj, UserInfo_.userinfo, NewObject.info)) {
|
||||||
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ValidateVisibility(NewObject.visibility)) {
|
||||||
|
return BadRequest("Invalid visibility parameter.");
|
||||||
|
}
|
||||||
|
|
||||||
|
NewObject.creator = UserInfo_.userinfo.email;
|
||||||
|
|
||||||
|
if(DB_.CreateRecord(NewObject)) {
|
||||||
|
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
ProvObjects::Map M;
|
||||||
|
DB_.GetRecord("id", NewObject.info.id,M);
|
||||||
|
M.to_json(Answer);
|
||||||
|
return ReturnObject(Answer);
|
||||||
|
}
|
||||||
|
InternalError(RESTAPI::Errors::RecordNotCreated);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RESTAPI_map_handler::DoPut() {
|
||||||
|
ProvObjects::Map Existing;
|
||||||
|
std::string UUID = GetBinding(RESTAPI::Protocol::ID,"");
|
||||||
|
if(UUID.empty() || !DB_.GetRecord(RESTAPI::Protocol::ID,UUID,Existing)) {
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto RawObject = ParseStream();
|
||||||
|
ProvObjects::Map NewObject;
|
||||||
|
if(!NewObject.from_json(RawObject)) {
|
||||||
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!UpdateObjectInfo(RawObject, UserInfo_.userinfo, Existing.info)) {
|
||||||
|
return BadRequest( RESTAPI::Errors::NameMustBeSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RawObject->has("entity") && !StorageService()->EntityDB().Exists("id",NewObject.entity)) {
|
||||||
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssignIfPresent(RawObject,"entity",Existing.entity);
|
||||||
|
AssignIfPresent(RawObject,"data", Existing.data);
|
||||||
|
AssignIfPresent(RawObject,"visibility", Existing.visibility);
|
||||||
|
|
||||||
|
if(RawObject->has("visibility") && !ValidateVisibility(NewObject.visibility)) {
|
||||||
|
return BadRequest("Invalid visibility parameter.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DB_.UpdateRecord("id",UUID,Existing)) {
|
||||||
|
|
||||||
|
ProvObjects::Map NewRecord;
|
||||||
|
|
||||||
|
DB_.GetRecord("id", UUID, NewRecord);
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
NewRecord.to_json(Answer);
|
||||||
|
return ReturnObject(Answer);
|
||||||
|
}
|
||||||
|
InternalError(RESTAPI::Errors::RecordNotUpdated);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/RESTAPI/RESTAPI_map_handler.h
Normal file
34
src/RESTAPI/RESTAPI_map_handler.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-11-09.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OWPROV_RESTAPI_MAP_HANDLER_H
|
||||||
|
#define OWPROV_RESTAPI_MAP_HANDLER_H
|
||||||
|
|
||||||
|
#include "framework/MicroService.h"
|
||||||
|
#include "StorageService.h"
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
class RESTAPI_map_handler : public RESTAPIHandler {
|
||||||
|
public:
|
||||||
|
RESTAPI_map_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal)
|
||||||
|
: RESTAPIHandler(bindings, L,
|
||||||
|
std::vector<std::string>{
|
||||||
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
Poco::Net::HTTPRequest::HTTP_PUT, Poco::Net::HTTPRequest::HTTP_DELETE,
|
||||||
|
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||||
|
Server,
|
||||||
|
Internal),
|
||||||
|
DB_(StorageService()->MapDB()){}
|
||||||
|
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/map/{uuid}"}; };
|
||||||
|
private:
|
||||||
|
MapDB &DB_;
|
||||||
|
void DoGet() final ;
|
||||||
|
void DoPost() final ;
|
||||||
|
void DoPut() final ;
|
||||||
|
void DoDelete() final ;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //OWPROV_RESTAPI_MAP_HANDLER_H
|
||||||
25
src/RESTAPI/RESTAPI_map_list_handler.cpp
Normal file
25
src/RESTAPI/RESTAPI_map_list_handler.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-11-09.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RESTAPI_map_list_handler.h"
|
||||||
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
|
#include "StorageService.h"
|
||||||
|
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||||
|
|
||||||
|
namespace OpenWifi{
|
||||||
|
void RESTAPI_map_list_handler::DoGet() {
|
||||||
|
if(!QB_.Select.empty()) {
|
||||||
|
return ReturnRecordList<decltype(StorageService()->MapDB()),
|
||||||
|
ProvObjects::Map>("list",StorageService()->MapDB(),*this );
|
||||||
|
} else if(QB_.CountOnly) {
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
auto C = StorageService()->MapDB().Count();
|
||||||
|
return ReturnCountOnly(C);
|
||||||
|
} else {
|
||||||
|
std::vector<ProvObjects::Map> Maps;
|
||||||
|
StorageService()->MapDB().GetRecords(QB_.Offset,QB_.Limit,Maps);
|
||||||
|
return MakeJSONObjectArray("list", Maps, *this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/RESTAPI/RESTAPI_map_list_handler.h
Normal file
30
src/RESTAPI/RESTAPI_map_list_handler.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-11-09.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OWPROV_RESTAPI_MAP_LIST_HANDLER_H
|
||||||
|
#define OWPROV_RESTAPI_MAP_LIST_HANDLER_H
|
||||||
|
|
||||||
|
#include "framework/MicroService.h"
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
class RESTAPI_map_list_handler : public RESTAPIHandler {
|
||||||
|
public:
|
||||||
|
RESTAPI_map_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, bool Internal)
|
||||||
|
: RESTAPIHandler(bindings, L,
|
||||||
|
std::vector<std::string>{
|
||||||
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||||
|
Server,
|
||||||
|
Internal) {}
|
||||||
|
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/map"}; };
|
||||||
|
|
||||||
|
void DoGet() final;
|
||||||
|
void DoPost() final {};
|
||||||
|
void DoPut() final {};
|
||||||
|
void DoDelete() final {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OWPROV_RESTAPI_MAP_LIST_HANDLER_H
|
||||||
@@ -10,27 +10,30 @@
|
|||||||
#include "RESTAPI_ProvObjects.h"
|
#include "RESTAPI_ProvObjects.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/MicroService.h"
|
||||||
|
|
||||||
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
|
|
||||||
namespace OpenWifi::ProvObjects {
|
namespace OpenWifi::ProvObjects {
|
||||||
|
|
||||||
void ObjectInfo::to_json(Poco::JSON::Object &Obj) const {
|
void ObjectInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json(Obj,"id",id);
|
field_to_json(Obj,"id",id);
|
||||||
RESTAPI_utils::field_to_json(Obj,"name",name);
|
field_to_json(Obj,"name",name);
|
||||||
RESTAPI_utils::field_to_json(Obj,"description",description);
|
field_to_json(Obj,"description",description);
|
||||||
RESTAPI_utils::field_to_json(Obj,"created",created);
|
field_to_json(Obj,"created",created);
|
||||||
RESTAPI_utils::field_to_json(Obj,"modified",modified);
|
field_to_json(Obj,"modified",modified);
|
||||||
RESTAPI_utils::field_to_json(Obj,"notes",notes);
|
field_to_json(Obj,"notes",notes);
|
||||||
RESTAPI_utils::field_to_json(Obj,"tags",tags);
|
field_to_json(Obj,"tags",tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ObjectInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json(Obj,"id",id);
|
field_from_json(Obj,"id",id);
|
||||||
RESTAPI_utils::field_from_json(Obj,"name",name);
|
field_from_json(Obj,"name",name);
|
||||||
RESTAPI_utils::field_from_json(Obj,"description",description);
|
field_from_json(Obj,"description",description);
|
||||||
RESTAPI_utils::field_from_json(Obj,"created",created);
|
field_from_json(Obj,"created",created);
|
||||||
RESTAPI_utils::field_from_json(Obj,"modified",modified);
|
field_from_json(Obj,"modified",modified);
|
||||||
RESTAPI_utils::field_from_json(Obj,"notes",notes);
|
field_from_json(Obj,"notes",notes);
|
||||||
RESTAPI_utils::field_from_json(Obj,"tags",tags);
|
field_from_json(Obj,"tags",tags);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -39,18 +42,18 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ManagementPolicyEntry::to_json(Poco::JSON::Object &Obj) const {
|
void ManagementPolicyEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json( Obj,"users",users);
|
field_to_json( Obj,"users",users);
|
||||||
RESTAPI_utils::field_to_json( Obj,"resources",resources);
|
field_to_json( Obj,"resources",resources);
|
||||||
RESTAPI_utils::field_to_json( Obj,"access",access);
|
field_to_json( Obj,"access",access);
|
||||||
RESTAPI_utils::field_to_json( Obj,"policy",policy);
|
field_to_json( Obj,"policy",policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManagementPolicyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ManagementPolicyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"users",users);
|
field_from_json( Obj,"users",users);
|
||||||
RESTAPI_utils::field_from_json( Obj,"resources",resources);
|
field_from_json( Obj,"resources",resources);
|
||||||
RESTAPI_utils::field_from_json( Obj,"access",access);
|
field_from_json( Obj,"access",access);
|
||||||
RESTAPI_utils::field_from_json( Obj,"policy",policy);
|
field_from_json( Obj,"policy",policy);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -60,17 +63,17 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void ManagementPolicy::to_json(Poco::JSON::Object &Obj) const {
|
void ManagementPolicy::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json(Obj, "entries", entries);
|
field_to_json(Obj, "entries", entries);
|
||||||
RESTAPI_utils::field_to_json(Obj, "inUse", inUse);
|
field_to_json(Obj, "inUse", inUse);
|
||||||
RESTAPI_utils::field_to_json(Obj, "entity", entity);
|
field_to_json(Obj, "entity", entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManagementPolicy::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ManagementPolicy::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
RESTAPI_utils::field_from_json(Obj, "entries", entries);
|
field_from_json(Obj, "entries", entries);
|
||||||
RESTAPI_utils::field_from_json(Obj, "inUse", inUse);
|
field_from_json(Obj, "inUse", inUse);
|
||||||
RESTAPI_utils::field_from_json(Obj, "entity", entity);
|
field_from_json(Obj, "entity", entity);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -80,31 +83,31 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Entity::to_json(Poco::JSON::Object &Obj) const {
|
void Entity::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
field_to_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_to_json( Obj,"venues",venues);
|
field_to_json( Obj,"venues",venues);
|
||||||
RESTAPI_utils::field_to_json( Obj,"children",children);
|
field_to_json( Obj,"children",children);
|
||||||
RESTAPI_utils::field_to_json( Obj,"contacts",contacts);
|
field_to_json( Obj,"contacts",contacts);
|
||||||
RESTAPI_utils::field_to_json( Obj,"locations",locations);
|
field_to_json( Obj,"locations",locations);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||||
RESTAPI_utils::field_to_json( Obj,"devices",devices);
|
field_to_json( Obj,"devices",devices);
|
||||||
RESTAPI_utils::field_to_json( Obj,"rrm",rrm);
|
field_to_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_to_json( Obj,"sourceIP",sourceIP);
|
field_to_json( Obj,"sourceIP",sourceIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
field_from_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_from_json( Obj,"venues",venues);
|
field_from_json( Obj,"venues",venues);
|
||||||
RESTAPI_utils::field_from_json( Obj,"children",children);
|
field_from_json( Obj,"children",children);
|
||||||
RESTAPI_utils::field_from_json( Obj,"contacts",contacts);
|
field_from_json( Obj,"contacts",contacts);
|
||||||
RESTAPI_utils::field_from_json( Obj,"locations",locations);
|
field_from_json( Obj,"locations",locations);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||||
RESTAPI_utils::field_from_json( Obj,"devices",devices);
|
field_from_json( Obj,"devices",devices);
|
||||||
RESTAPI_utils::field_from_json( Obj,"rrm",rrm);
|
field_from_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_from_json( Obj,"sourceIP",sourceIP);
|
field_from_json( Obj,"sourceIP",sourceIP);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -113,14 +116,14 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DiGraphEntry::to_json(Poco::JSON::Object &Obj) const {
|
void DiGraphEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
field_to_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_to_json( Obj,"child",child);
|
field_to_json( Obj,"child",child);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiGraphEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DiGraphEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
field_from_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_from_json( Obj,"child",child);
|
field_from_json( Obj,"child",child);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -130,37 +133,37 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Venue::to_json(Poco::JSON::Object &Obj) const {
|
void Venue::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
field_to_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
field_to_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_to_json( Obj,"children",children);
|
field_to_json( Obj,"children",children);
|
||||||
RESTAPI_utils::field_to_json( Obj,"devices",devices);
|
field_to_json( Obj,"devices",devices);
|
||||||
RESTAPI_utils::field_to_json( Obj,"topology",topology);
|
field_to_json( Obj,"topology",topology);
|
||||||
RESTAPI_utils::field_to_json( Obj,"parent",parent);
|
field_to_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_to_json( Obj,"design",design);
|
field_to_json( Obj,"design",design);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||||
RESTAPI_utils::field_to_json( Obj,"contact",contact);
|
field_to_json( Obj,"contact",contact);
|
||||||
RESTAPI_utils::field_to_json( Obj,"location",location);
|
field_to_json( Obj,"location",location);
|
||||||
RESTAPI_utils::field_to_json( Obj,"rrm",rrm);
|
field_to_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_to_json( Obj,"sourceIP",sourceIP);
|
field_to_json( Obj,"sourceIP",sourceIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
field_from_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
field_from_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_from_json( Obj,"children",children);
|
field_from_json( Obj,"children",children);
|
||||||
RESTAPI_utils::field_from_json( Obj,"devices",devices);
|
field_from_json( Obj,"devices",devices);
|
||||||
RESTAPI_utils::field_from_json( Obj,"topology",topology);
|
field_from_json( Obj,"topology",topology);
|
||||||
RESTAPI_utils::field_from_json( Obj,"parent",parent);
|
field_from_json( Obj,"parent",parent);
|
||||||
RESTAPI_utils::field_from_json( Obj,"design",design);
|
field_from_json( Obj,"design",design);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||||
RESTAPI_utils::field_from_json( Obj,"contact",contact);
|
field_from_json( Obj,"contact",contact);
|
||||||
RESTAPI_utils::field_from_json( Obj,"location",location);
|
field_from_json( Obj,"location",location);
|
||||||
RESTAPI_utils::field_from_json( Obj,"rrm",rrm);
|
field_from_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_from_json( Obj,"sourceIP",sourceIP);
|
field_from_json( Obj,"sourceIP",sourceIP);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -169,16 +172,16 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
|
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json( Obj,"id",id);
|
field_to_json( Obj,"id",id);
|
||||||
RESTAPI_utils::field_to_json( Obj,"entity",loginId);
|
field_to_json( Obj,"entity",loginId);
|
||||||
RESTAPI_utils::field_to_json( Obj,"children",userType);
|
field_to_json( Obj,"children",userType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserInfoDigest::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool UserInfoDigest::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"id",id);
|
field_from_json( Obj,"id",id);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",loginId);
|
field_from_json( Obj,"entity",loginId);
|
||||||
RESTAPI_utils::field_from_json( Obj,"children",userType);
|
field_from_json( Obj,"children",userType);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
@@ -187,17 +190,17 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void ManagementRole::to_json(Poco::JSON::Object &Obj) const {
|
void ManagementRole::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_to_json( Obj,"users",users);
|
field_to_json( Obj,"users",users);
|
||||||
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
field_to_json( Obj,"entity",entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_from_json( Obj,"users",users);
|
field_from_json( Obj,"users",users);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
field_from_json( Obj,"entity",entity);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
}
|
}
|
||||||
@@ -206,39 +209,39 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Location::to_json(Poco::JSON::Object &Obj) const {
|
void Location::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json( Obj,"type",OpenWifi::ProvObjects::to_string(type));
|
field_to_json( Obj,"type",OpenWifi::ProvObjects::to_string(type));
|
||||||
RESTAPI_utils::field_to_json( Obj,"buildingName",buildingName);
|
field_to_json( Obj,"buildingName",buildingName);
|
||||||
RESTAPI_utils::field_to_json( Obj,"addressLines",addressLines);
|
field_to_json( Obj,"addressLines",addressLines);
|
||||||
RESTAPI_utils::field_to_json( Obj,"city",city);
|
field_to_json( Obj,"city",city);
|
||||||
RESTAPI_utils::field_to_json( Obj,"state",state);
|
field_to_json( Obj,"state",state);
|
||||||
RESTAPI_utils::field_to_json( Obj,"postal",postal);
|
field_to_json( Obj,"postal",postal);
|
||||||
RESTAPI_utils::field_to_json( Obj,"country",country);
|
field_to_json( Obj,"country",country);
|
||||||
RESTAPI_utils::field_to_json( Obj,"phones",phones);
|
field_to_json( Obj,"phones",phones);
|
||||||
RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
|
field_to_json( Obj,"mobiles",mobiles);
|
||||||
RESTAPI_utils::field_to_json( Obj,"geoCode",geoCode);
|
field_to_json( Obj,"geoCode",geoCode);
|
||||||
RESTAPI_utils::field_to_json( Obj,"inUse",inUse);
|
field_to_json( Obj,"inUse",inUse);
|
||||||
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
field_to_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Location::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Location::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
std::string tmp_type;
|
std::string tmp_type;
|
||||||
RESTAPI_utils::field_from_json( Obj,"type", tmp_type);
|
field_from_json( Obj,"type", tmp_type);
|
||||||
type = location_from_string(tmp_type);
|
type = location_from_string(tmp_type);
|
||||||
RESTAPI_utils::field_from_json( Obj,"buildingName",buildingName);
|
field_from_json( Obj,"buildingName",buildingName);
|
||||||
RESTAPI_utils::field_from_json( Obj,"addressLines",addressLines);
|
field_from_json( Obj,"addressLines",addressLines);
|
||||||
RESTAPI_utils::field_from_json( Obj,"city",city);
|
field_from_json( Obj,"city",city);
|
||||||
RESTAPI_utils::field_from_json( Obj,"state",state);
|
field_from_json( Obj,"state",state);
|
||||||
RESTAPI_utils::field_from_json( Obj,"postal",postal);
|
field_from_json( Obj,"postal",postal);
|
||||||
RESTAPI_utils::field_from_json( Obj,"country",country);
|
field_from_json( Obj,"country",country);
|
||||||
RESTAPI_utils::field_from_json( Obj,"phones",phones);
|
field_from_json( Obj,"phones",phones);
|
||||||
RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
|
field_from_json( Obj,"mobiles",mobiles);
|
||||||
RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
|
field_from_json( Obj,"geoCode",geoCode);
|
||||||
RESTAPI_utils::field_from_json( Obj,"inUse",inUse);
|
field_from_json( Obj,"inUse",inUse);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
field_from_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -248,43 +251,43 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void Contact::to_json(Poco::JSON::Object &Obj) const {
|
void Contact::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json( Obj,"type", to_string(type));
|
field_to_json( Obj,"type", to_string(type));
|
||||||
RESTAPI_utils::field_to_json( Obj,"title",title);
|
field_to_json( Obj,"title",title);
|
||||||
RESTAPI_utils::field_to_json( Obj,"salutation",salutation);
|
field_to_json( Obj,"salutation",salutation);
|
||||||
RESTAPI_utils::field_to_json( Obj,"firstname",firstname);
|
field_to_json( Obj,"firstname",firstname);
|
||||||
RESTAPI_utils::field_to_json( Obj,"lastname",lastname);
|
field_to_json( Obj,"lastname",lastname);
|
||||||
RESTAPI_utils::field_to_json( Obj,"initials",initials);
|
field_to_json( Obj,"initials",initials);
|
||||||
RESTAPI_utils::field_to_json( Obj,"visual",visual);
|
field_to_json( Obj,"visual",visual);
|
||||||
RESTAPI_utils::field_to_json( Obj,"mobiles",mobiles);
|
field_to_json( Obj,"mobiles",mobiles);
|
||||||
RESTAPI_utils::field_to_json( Obj,"phones",phones);
|
field_to_json( Obj,"phones",phones);
|
||||||
RESTAPI_utils::field_to_json( Obj,"primaryEmail",primaryEmail);
|
field_to_json( Obj,"primaryEmail",primaryEmail);
|
||||||
RESTAPI_utils::field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
||||||
RESTAPI_utils::field_to_json( Obj,"accessPIN",accessPIN);
|
field_to_json( Obj,"accessPIN",accessPIN);
|
||||||
RESTAPI_utils::field_to_json( Obj,"inUse",inUse);
|
field_to_json( Obj,"inUse",inUse);
|
||||||
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
field_to_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Contact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool Contact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
std::string tmp_type;
|
std::string tmp_type;
|
||||||
RESTAPI_utils::field_from_json( Obj,"type", tmp_type);
|
field_from_json( Obj,"type", tmp_type);
|
||||||
type = contact_from_string(tmp_type);
|
type = contact_from_string(tmp_type);
|
||||||
RESTAPI_utils::field_from_json( Obj,"title",title);
|
field_from_json( Obj,"title",title);
|
||||||
RESTAPI_utils::field_from_json( Obj,"salutation",salutation);
|
field_from_json( Obj,"salutation",salutation);
|
||||||
RESTAPI_utils::field_from_json( Obj,"firstname",firstname);
|
field_from_json( Obj,"firstname",firstname);
|
||||||
RESTAPI_utils::field_from_json( Obj,"lastname",lastname);
|
field_from_json( Obj,"lastname",lastname);
|
||||||
RESTAPI_utils::field_from_json( Obj,"initials",initials);
|
field_from_json( Obj,"initials",initials);
|
||||||
RESTAPI_utils::field_from_json( Obj,"visual",visual);
|
field_from_json( Obj,"visual",visual);
|
||||||
RESTAPI_utils::field_from_json( Obj,"mobiles",mobiles);
|
field_from_json( Obj,"mobiles",mobiles);
|
||||||
RESTAPI_utils::field_from_json( Obj,"phones",phones);
|
field_from_json( Obj,"phones",phones);
|
||||||
RESTAPI_utils::field_from_json( Obj,"primaryEmail",primaryEmail);
|
field_from_json( Obj,"primaryEmail",primaryEmail);
|
||||||
RESTAPI_utils::field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
||||||
RESTAPI_utils::field_from_json( Obj,"accessPIN",accessPIN);
|
field_from_json( Obj,"accessPIN",accessPIN);
|
||||||
RESTAPI_utils::field_from_json( Obj,"inUse",inUse);
|
field_from_json( Obj,"inUse",inUse);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
field_from_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
||||||
@@ -294,35 +297,35 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
|
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json(Obj, "serialNumber", serialNumber);
|
field_to_json(Obj, "serialNumber", serialNumber);
|
||||||
RESTAPI_utils::field_to_json(Obj, "venue", venue);
|
field_to_json(Obj, "venue", venue);
|
||||||
RESTAPI_utils::field_to_json(Obj, "entity", entity);
|
field_to_json(Obj, "entity", entity);
|
||||||
RESTAPI_utils::field_to_json(Obj, "subscriber", subscriber);
|
field_to_json(Obj, "subscriber", subscriber);
|
||||||
RESTAPI_utils::field_to_json(Obj, "deviceType", deviceType);
|
field_to_json(Obj, "deviceType", deviceType);
|
||||||
RESTAPI_utils::field_to_json(Obj, "qrCode", qrCode);
|
field_to_json(Obj, "qrCode", qrCode);
|
||||||
RESTAPI_utils::field_to_json(Obj, "geoCode", geoCode);
|
field_to_json(Obj, "geoCode", geoCode);
|
||||||
RESTAPI_utils::field_to_json(Obj, "location", location);
|
field_to_json(Obj, "location", location);
|
||||||
RESTAPI_utils::field_to_json(Obj, "contact", contact);
|
field_to_json(Obj, "contact", contact);
|
||||||
RESTAPI_utils::field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||||
RESTAPI_utils::field_to_json( Obj,"rrm",rrm);
|
field_to_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
RESTAPI_utils::field_from_json( Obj,"serialNumber",serialNumber);
|
field_from_json( Obj,"serialNumber",serialNumber);
|
||||||
RESTAPI_utils::field_from_json( Obj,"venue",venue);
|
field_from_json( Obj,"venue",venue);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
field_from_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_from_json( Obj,"subscriber",subscriber);
|
field_from_json( Obj,"subscriber",subscriber);
|
||||||
RESTAPI_utils::field_from_json( Obj,"deviceType",deviceType);
|
field_from_json( Obj,"deviceType",deviceType);
|
||||||
RESTAPI_utils::field_from_json(Obj, "qrCode", qrCode);
|
field_from_json(Obj, "qrCode", qrCode);
|
||||||
RESTAPI_utils::field_from_json( Obj,"geoCode",geoCode);
|
field_from_json( Obj,"geoCode",geoCode);
|
||||||
RESTAPI_utils::field_from_json( Obj,"location",location);
|
field_from_json( Obj,"location",location);
|
||||||
RESTAPI_utils::field_from_json( Obj,"contact",contact);
|
field_from_json( Obj,"contact",contact);
|
||||||
RESTAPI_utils::field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||||
RESTAPI_utils::field_from_json( Obj,"rrm",rrm);
|
field_from_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -331,18 +334,18 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceConfigurationElement::to_json(Poco::JSON::Object &Obj) const {
|
void DeviceConfigurationElement::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json( Obj,"name", name);
|
field_to_json( Obj,"name", name);
|
||||||
RESTAPI_utils::field_to_json( Obj,"description", description);
|
field_to_json( Obj,"description", description);
|
||||||
RESTAPI_utils::field_to_json( Obj,"weight", weight);
|
field_to_json( Obj,"weight", weight);
|
||||||
RESTAPI_utils::field_to_json( Obj,"configuration", configuration);
|
field_to_json( Obj,"configuration", configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceConfigurationElement::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DeviceConfigurationElement::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"name",name);
|
field_from_json( Obj,"name",name);
|
||||||
RESTAPI_utils::field_from_json( Obj,"description",description);
|
field_from_json( Obj,"description",description);
|
||||||
RESTAPI_utils::field_from_json( Obj,"weight",weight);
|
field_from_json( Obj,"weight",weight);
|
||||||
RESTAPI_utils::field_from_json( Obj,"configuration",configuration);
|
field_from_json( Obj,"configuration",configuration);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -352,27 +355,27 @@ namespace OpenWifi::ProvObjects {
|
|||||||
|
|
||||||
void DeviceConfiguration::to_json(Poco::JSON::Object &Obj) const {
|
void DeviceConfiguration::to_json(Poco::JSON::Object &Obj) const {
|
||||||
info.to_json(Obj);
|
info.to_json(Obj);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy",managementPolicy);
|
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_to_json( Obj,"deviceTypes",deviceTypes);
|
field_to_json( Obj,"deviceTypes",deviceTypes);
|
||||||
RESTAPI_utils::field_to_json( Obj,"configuration",configuration);
|
field_to_json( Obj,"configuration",configuration);
|
||||||
RESTAPI_utils::field_to_json( Obj,"inUse",inUse);
|
field_to_json( Obj,"inUse",inUse);
|
||||||
RESTAPI_utils::field_to_json( Obj,"variables",variables);
|
field_to_json( Obj,"variables",variables);
|
||||||
RESTAPI_utils::field_to_json( Obj,"rrm",rrm);
|
field_to_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||||
RESTAPI_utils::field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
info.from_json(Obj);
|
info.from_json(Obj);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy",managementPolicy);
|
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||||
RESTAPI_utils::field_from_json( Obj,"deviceTypes",deviceTypes);
|
field_from_json( Obj,"deviceTypes",deviceTypes);
|
||||||
RESTAPI_utils::field_from_json( Obj,"configuration",configuration);
|
field_from_json( Obj,"configuration",configuration);
|
||||||
RESTAPI_utils::field_from_json( Obj,"inUse",inUse);
|
field_from_json( Obj,"inUse",inUse);
|
||||||
RESTAPI_utils::field_from_json( Obj,"variables",variables);
|
field_from_json( Obj,"variables",variables);
|
||||||
RESTAPI_utils::field_from_json( Obj,"rrm",rrm);
|
field_from_json( Obj,"rrm",rrm);
|
||||||
RESTAPI_utils::field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||||
RESTAPI_utils::field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -381,8 +384,8 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Report::to_json(Poco::JSON::Object &Obj) const {
|
void Report::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json(Obj, "snapshot", snapShot);
|
field_to_json(Obj, "snapshot", snapShot);
|
||||||
RESTAPI_utils::field_to_json(Obj, "devices", tenants);
|
field_to_json(Obj, "devices", tenants);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Report::reset() {
|
void Report::reset() {
|
||||||
@@ -390,16 +393,16 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExpandedUseEntry::to_json(Poco::JSON::Object &Obj) const {
|
void ExpandedUseEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json(Obj, "uuid", uuid);
|
field_to_json(Obj, "uuid", uuid);
|
||||||
RESTAPI_utils::field_to_json(Obj, "name", name);
|
field_to_json(Obj, "name", name);
|
||||||
RESTAPI_utils::field_to_json(Obj, "description", description);
|
field_to_json(Obj, "description", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExpandedUseEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ExpandedUseEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"uuid",uuid);
|
field_from_json( Obj,"uuid",uuid);
|
||||||
RESTAPI_utils::field_from_json( Obj,"name",name);
|
field_from_json( Obj,"name",name);
|
||||||
RESTAPI_utils::field_from_json( Obj,"description",description);
|
field_from_json( Obj,"description",description);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -408,14 +411,14 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExpandedUseEntryList::to_json(Poco::JSON::Object &Obj) const {
|
void ExpandedUseEntryList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json(Obj, "type", type);
|
field_to_json(Obj, "type", type);
|
||||||
RESTAPI_utils::field_to_json(Obj, "entries", entries);
|
field_to_json(Obj, "entries", entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExpandedUseEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ExpandedUseEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"type",type);
|
field_from_json( Obj,"type",type);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entries",entries);
|
field_from_json( Obj,"entries",entries);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -424,12 +427,94 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExpandedUseEntryMapList::to_json(Poco::JSON::Object &Obj) const {
|
void ExpandedUseEntryMapList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
RESTAPI_utils::field_to_json(Obj, "entries", entries);
|
field_to_json(Obj, "entries", entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExpandedUseEntryMapList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool ExpandedUseEntryMapList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
RESTAPI_utils::field_from_json( Obj,"entries",entries);
|
field_from_json( Obj,"entries",entries);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "list", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UserList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "list", list);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectACL::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "users", users);
|
||||||
|
field_to_json(Obj, "access", access);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjectACL::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "users", users);
|
||||||
|
field_from_json(Obj, "access", access);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectACLList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "list", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjectACLList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "list", list);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Map::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
info.to_json(Obj);
|
||||||
|
field_to_json( Obj,"data",data);
|
||||||
|
field_to_json( Obj,"entity",entity);
|
||||||
|
field_to_json( Obj,"creator",creator);
|
||||||
|
field_to_json( Obj,"visibility",visibility);
|
||||||
|
field_to_json( Obj,"access",access);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
info.from_json(Obj);
|
||||||
|
field_from_json( Obj,"data",data);
|
||||||
|
field_from_json( Obj,"entity",entity);
|
||||||
|
field_from_json( Obj,"creator",creator);
|
||||||
|
field_from_json( Obj,"visibility",visibility);
|
||||||
|
field_from_json( Obj,"access",access);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json( Obj,"list",list);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json( Obj,"list",list);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
|
|||||||
@@ -324,6 +324,47 @@ namespace OpenWifi::ProvObjects {
|
|||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct UserList {
|
||||||
|
std::vector<std::string> list;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObjectACL {
|
||||||
|
UserList users;
|
||||||
|
std::string access;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObjectACLList {
|
||||||
|
std::vector<ObjectACL> list;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Map {
|
||||||
|
ObjectInfo info;
|
||||||
|
std::string data;
|
||||||
|
std::string entity;
|
||||||
|
std::string creator;
|
||||||
|
std::string visibility;
|
||||||
|
ObjectACLList access;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MapList {
|
||||||
|
std::vector<Map> list;
|
||||||
|
|
||||||
|
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 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 Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace OpenWifi {
|
|||||||
ConfigurationDB_ = std::make_unique<OpenWifi::ConfigurationDB>(dbType_, *Pool_, Logger_);
|
ConfigurationDB_ = std::make_unique<OpenWifi::ConfigurationDB>(dbType_, *Pool_, Logger_);
|
||||||
TagsDictionaryDB_ = std::make_unique<OpenWifi::TagsDictionaryDB>(dbType_, *Pool_, Logger_);
|
TagsDictionaryDB_ = std::make_unique<OpenWifi::TagsDictionaryDB>(dbType_, *Pool_, Logger_);
|
||||||
TagsObjectDB_ = std::make_unique<OpenWifi::TagsObjectDB>(dbType_, *Pool_, Logger_);
|
TagsObjectDB_ = std::make_unique<OpenWifi::TagsObjectDB>(dbType_, *Pool_, Logger_);
|
||||||
|
MapDB_ = std::make_unique<OpenWifi::MapDB>(dbType_, *Pool_, Logger_);
|
||||||
|
|
||||||
EntityDB_->Create();
|
EntityDB_->Create();
|
||||||
PolicyDB_->Create();
|
PolicyDB_->Create();
|
||||||
@@ -39,6 +40,7 @@ namespace OpenWifi {
|
|||||||
ConfigurationDB_->Create();
|
ConfigurationDB_->Create();
|
||||||
TagsDictionaryDB_->Create();
|
TagsDictionaryDB_->Create();
|
||||||
TagsObjectDB_->Create();
|
TagsObjectDB_->Create();
|
||||||
|
MapDB_->Create();
|
||||||
|
|
||||||
ExistFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V) -> bool { return EntityDB_->Exists(F,V); };
|
ExistFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V) -> bool { return EntityDB_->Exists(F,V); };
|
||||||
ExistFunc_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V) -> bool { return PolicyDB_->Exists(F,V); };
|
ExistFunc_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V) -> bool { return PolicyDB_->Exists(F,V); };
|
||||||
@@ -51,6 +53,7 @@ namespace OpenWifi {
|
|||||||
ExistFunc_[SecurityDBProxy()->Prefix()] = [=](const char *F, std::string &V) ->bool { return SecurityDBProxy()->Exists(F,V); };
|
ExistFunc_[SecurityDBProxy()->Prefix()] = [=](const char *F, std::string &V) ->bool { return SecurityDBProxy()->Exists(F,V); };
|
||||||
ExistFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return TagsDictionaryDB_->Exists(F,V); };
|
ExistFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return TagsDictionaryDB_->Exists(F,V); };
|
||||||
ExistFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return TagsObjectDB_->Exists(F,V); };
|
ExistFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return TagsObjectDB_->Exists(F,V); };
|
||||||
|
ExistFunc_[MapDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return MapDB_->Exists(F,V); };
|
||||||
|
|
||||||
ExpandFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return EntityDB_->GetNameAndDescription(F,V, Name, Description); };
|
ExpandFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return EntityDB_->GetNameAndDescription(F,V, Name, Description); };
|
||||||
ExpandFunc_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return PolicyDB_->GetNameAndDescription(F,V, Name, Description); };
|
ExpandFunc_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return PolicyDB_->GetNameAndDescription(F,V, Name, Description); };
|
||||||
@@ -63,6 +66,7 @@ namespace OpenWifi {
|
|||||||
ExpandFunc_[SecurityDBProxy()->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return SecurityDBProxy()->Exists(F,V); };
|
ExpandFunc_[SecurityDBProxy()->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return SecurityDBProxy()->Exists(F,V); };
|
||||||
ExpandFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsDictionaryDB_->Exists(F,V); };
|
ExpandFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsDictionaryDB_->Exists(F,V); };
|
||||||
ExpandFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsObjectDB_->Exists(F,V);; };
|
ExpandFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsObjectDB_->Exists(F,V);; };
|
||||||
|
ExpandFunc_[MapDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return MapDB_->Exists(F,V);; };
|
||||||
|
|
||||||
EntityDB_->CheckForRoot();
|
EntityDB_->CheckForRoot();
|
||||||
InventoryDB_->InitializeSerialCache();
|
InventoryDB_->InitializeSerialCache();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "storage/storage_management_roles.h"
|
#include "storage/storage_management_roles.h"
|
||||||
#include "storage/storage_configurations.h"
|
#include "storage/storage_configurations.h"
|
||||||
#include "storage/storage_tags.h"
|
#include "storage/storage_tags.h"
|
||||||
|
#include "storage/storage_maps.h"
|
||||||
#include "SecurityDBProxy.h"
|
#include "SecurityDBProxy.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
@@ -51,6 +51,7 @@ namespace OpenWifi {
|
|||||||
OpenWifi::ConfigurationDB & ConfigurationDB() { return *ConfigurationDB_; };
|
OpenWifi::ConfigurationDB & ConfigurationDB() { return *ConfigurationDB_; };
|
||||||
OpenWifi::TagsDictionaryDB & TagsDictionaryDB() { return *TagsDictionaryDB_; };
|
OpenWifi::TagsDictionaryDB & TagsDictionaryDB() { return *TagsDictionaryDB_; };
|
||||||
OpenWifi::TagsObjectDB & TagsObjectDB() { return *TagsObjectDB_; };
|
OpenWifi::TagsObjectDB & TagsObjectDB() { return *TagsObjectDB_; };
|
||||||
|
OpenWifi::MapDB & MapDB() { return *MapDB_; };
|
||||||
|
|
||||||
bool Validate(const Poco::URI::QueryParameters &P, std::string &Error);
|
bool Validate(const Poco::URI::QueryParameters &P, std::string &Error);
|
||||||
bool Validate(const Types::StringVec &P, std::string &Error);
|
bool Validate(const Types::StringVec &P, std::string &Error);
|
||||||
@@ -86,6 +87,8 @@ namespace OpenWifi {
|
|||||||
std::unique_ptr<OpenWifi::ConfigurationDB> ConfigurationDB_;
|
std::unique_ptr<OpenWifi::ConfigurationDB> ConfigurationDB_;
|
||||||
std::unique_ptr<OpenWifi::TagsDictionaryDB> TagsDictionaryDB_;
|
std::unique_ptr<OpenWifi::TagsDictionaryDB> TagsDictionaryDB_;
|
||||||
std::unique_ptr<OpenWifi::TagsObjectDB> TagsObjectDB_;
|
std::unique_ptr<OpenWifi::TagsObjectDB> TagsObjectDB_;
|
||||||
|
std::unique_ptr<OpenWifi::MapDB> MapDB_;
|
||||||
|
|
||||||
|
|
||||||
typedef std::function<bool(const char *FieldName, std::string &Value)> exist_func;
|
typedef std::function<bool(const char *FieldName, std::string &Value)> exist_func;
|
||||||
typedef std::function<bool(const char *FieldName, std::string &Value, std::string &Name, std::string &Description)> expand_func;
|
typedef std::function<bool(const char *FieldName, std::string &Value, std::string &Name, std::string &Description)> expand_func;
|
||||||
|
|||||||
65
src/storage/storage_maps.cpp
Normal file
65
src/storage/storage_maps.cpp
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-11-09.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "storage_maps.h"
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
static ORM::FieldVec MapsDB_Fields{
|
||||||
|
// object info
|
||||||
|
ORM::Field{"id",64, true},
|
||||||
|
ORM::Field{"name",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"description",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"notes",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"created",ORM::FieldType::FT_BIGINT},
|
||||||
|
ORM::Field{"modified",ORM::FieldType::FT_BIGINT},
|
||||||
|
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"data",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"creator",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"visibility",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"access",ORM::FieldType::FT_TEXT},
|
||||||
|
ORM::Field{"entity",ORM::FieldType::FT_TEXT}
|
||||||
|
};
|
||||||
|
|
||||||
|
static ORM::IndexVec MapsDB_Indexes{
|
||||||
|
{ std::string("maps_name_index"),
|
||||||
|
ORM::IndexEntryVec{
|
||||||
|
{std::string("name"),
|
||||||
|
ORM::Indextype::ASC} } }
|
||||||
|
};
|
||||||
|
|
||||||
|
MapDB::MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||||
|
DB(T, "maps", MapsDB_Fields, MapsDB_Indexes, P, L, "map") {}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Map>::Convert(OpenWifi::MapDBRecordType &In, OpenWifi::ProvObjects::Map &Out) {
|
||||||
|
Out.info.id = In.get<0>();
|
||||||
|
Out.info.name = In.get<1>();
|
||||||
|
Out.info.description = In.get<2>();
|
||||||
|
Out.info.notes = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::SecurityObjects::NoteInfo>(In.get<3>());
|
||||||
|
Out.info.created = In.get<4>();
|
||||||
|
Out.info.modified = In.get<5>();
|
||||||
|
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<6>());
|
||||||
|
Out.data = In.get<7>();
|
||||||
|
Out.creator = In.get<8>();
|
||||||
|
Out.visibility = In.get<9>();
|
||||||
|
Out.access = OpenWifi::RESTAPI_utils::to_object<OpenWifi::ProvObjects::ObjectACLList>(In.get<10>());
|
||||||
|
Out.entity = In.get<11>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Map>::Convert(OpenWifi::ProvObjects::Map &In, OpenWifi::MapDBRecordType &Out) {
|
||||||
|
Out.set<0>(In.info.id);
|
||||||
|
Out.set<1>(In.info.name);
|
||||||
|
Out.set<2>(In.info.description);
|
||||||
|
Out.set<3>(OpenWifi::RESTAPI_utils::to_string(In.info.notes));
|
||||||
|
Out.set<4>(In.info.created);
|
||||||
|
Out.set<5>(In.info.modified);
|
||||||
|
Out.set<6>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
|
||||||
|
Out.set<7>(In.data);
|
||||||
|
Out.set<8>(In.creator);
|
||||||
|
Out.set<9>(In.visibility);
|
||||||
|
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.access));
|
||||||
|
Out.set<11>(In.entity);
|
||||||
|
}
|
||||||
35
src/storage/storage_maps.h
Normal file
35
src/storage/storage_maps.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-11-09.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OWPROV_STORAGE_MAPS_H
|
||||||
|
#define OWPROV_STORAGE_MAPS_H
|
||||||
|
|
||||||
|
#include "framework/orm.h"
|
||||||
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
typedef Poco::Tuple<
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
uint64_t,
|
||||||
|
uint64_t,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string,
|
||||||
|
std::string
|
||||||
|
> MapDBRecordType;
|
||||||
|
|
||||||
|
class MapDB : public ORM::DB<MapDBRecordType, ProvObjects::Map> {
|
||||||
|
public:
|
||||||
|
MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //OWPROV_STORAGE_MAPS_H
|
||||||
Reference in New Issue
Block a user