Adding operator tables.

This commit is contained in:
stephb9959
2022-04-07 19:52:36 -07:00
parent 4c7d2bff28
commit 1b853b385d
26 changed files with 1432 additions and 47 deletions

View File

@@ -136,7 +136,7 @@ add_executable(owprov
src/storage/storage_variables.cpp src/storage/storage_variables.h
src/RESTAPI/RESTAPI_variables_handler.cpp src/RESTAPI/RESTAPI_variables_handler.h
src/RESTAPI/RESTAPI_variables_list_handler.cpp src/RESTAPI/RESTAPI_variables_list_handler.h
src/FileDownloader.cpp src/FileDownloader.h src/Tasks/VenueConfigUpdater.cpp src/Tasks/VenueConfigUpdater.h src/Kafka_ProvUpdater.cpp src/Kafka_ProvUpdater.h src/storage/storage_operataor.cpp src/storage/storage_operataor.h src/storage/storage_sub_devices.cpp src/storage/storage_sub_devices.h src/storage/storage_service_class.cpp src/storage/storage_service_class.h src/RESTAPI/RESTAPI_sub_devices_list_handler.cpp src/RESTAPI/RESTAPI_sub_devices_list_handler.h src/RESTAPI/RESTAPI_sub_devices_handler.cpp src/RESTAPI/RESTAPI_sub_devices_handler.h src/RESTAPI/RESTAPI_service_class_list_handler.cpp src/RESTAPI/RESTAPI_service_class_list_handler.h src/RESTAPI/RESTAPI_service_class_handler.cpp src/RESTAPI/RESTAPI_service_class_handler.h src/RESTAPI/RESTAPI_operators_list_handler.cpp src/RESTAPI/RESTAPI_operators_list_handler.h src/RESTAPI/RESTAPI_operators_handler.cpp src/RESTAPI/RESTAPI_operators_handler.h)
src/FileDownloader.cpp src/FileDownloader.h src/Tasks/VenueConfigUpdater.cpp src/Tasks/VenueConfigUpdater.h src/Kafka_ProvUpdater.cpp src/Kafka_ProvUpdater.h src/storage/storage_operataor.cpp src/storage/storage_operataor.h src/storage/storage_sub_devices.cpp src/storage/storage_sub_devices.h src/storage/storage_service_class.cpp src/storage/storage_service_class.h src/RESTAPI/RESTAPI_sub_devices_list_handler.cpp src/RESTAPI/RESTAPI_sub_devices_list_handler.h src/RESTAPI/RESTAPI_sub_devices_handler.cpp src/RESTAPI/RESTAPI_sub_devices_handler.h src/RESTAPI/RESTAPI_service_class_list_handler.cpp src/RESTAPI/RESTAPI_service_class_list_handler.h src/RESTAPI/RESTAPI_service_class_handler.cpp src/RESTAPI/RESTAPI_service_class_handler.h src/RESTAPI/RESTAPI_operators_list_handler.cpp src/RESTAPI/RESTAPI_operators_list_handler.h src/RESTAPI/RESTAPI_operators_handler.cpp src/RESTAPI/RESTAPI_operators_handler.h src/storage/storage_op_contacts.cpp src/storage/storage_op_contacts.h src/storage/storage_op_locations.cpp src/storage/storage_op_locations.h src/RESTAPI/RESTAPI_op_contact_list_handler.cpp src/RESTAPI/RESTAPI_op_contact_list_handler.h src/RESTAPI/RESTAPI_op_contact_handler.cpp src/RESTAPI/RESTAPI_op_contact_handler.h src/RESTAPI/RESTAPI_op_location_list_handler.cpp src/RESTAPI/RESTAPI_op_location_list_handler.h src/RESTAPI/RESTAPI_op_location_handler.cpp src/RESTAPI/RESTAPI_op_location_handler.h)
target_link_libraries(owprov PUBLIC
${Poco_LIBRARIES}

2
build
View File

@@ -1 +1 @@
91
92

View File

@@ -496,6 +496,60 @@ components:
items:
$ref: '#/components/schemas/Location'
OperatorLocation:
type: object
properties:
allOf:
$ref: '#/components/schemas/ObjectInfo'
type:
type: string
enum:
- SERVICE
- EQUIPMENT
- AUTO
- MANUAL
- SPECIAL
- UNKNOWN
- CORPORATE
buildingName:
type: string
addressLines:
type: array
items:
type: string
city:
type: string
state:
type: string
postal:
type: string
country:
type: string
phones:
type: array
items:
type: string
mobiles:
type: array
items:
type: string
operatorId:
type: string
format: uuid
subscriberId:
type: string
format: uuid
geoCode:
type: string
OperatorLocationList:
type: object
properties:
locations:
type: array
items:
$ref: '#/components/schemas/OperatorLocation'
# uuids: con:<uuid>
Contact:
type: object
@@ -559,6 +613,63 @@ components:
items:
$ref: '#/components/schemas/Contact'
OperatorContact:
type: object
properties:
allOf:
$ref: '#/components/schemas/ObjectInfo'
type:
type: string
enum:
- SUBSCRIBER
- USER
- INSTALLER
- CSR
- MANAGER
- BUSINESSOWNER
- TECHNICIAN
- CORPORATE
title:
type: string
salutation:
type: string
firstname:
type: string
lastname:
type: string
initials:
type: string
visual:
type: string
phones:
type: array
items:
type: string
mobiles:
type: array
items:
type: string
primaryEmail:
type: string
secondaryEmail:
type: string
accessPIN:
type: string
operatorId:
type: string
format: uuid
subscriberId:
type: string
format: uuid
OperatorContactList:
type: object
properties:
contacts:
type: array
items:
$ref: '#/components/schemas/OperatorContact'
DeviceConfigurationElement:
type: object
properties:
@@ -3779,6 +3890,348 @@ paths:
404:
$ref: '#/components/responses/NotFound'
/operatorLocation:
get:
tags:
- Operator Locations
operationId: getOperatorLocations
summary: Retrieve a list of locations.
parameters:
- in: query
name: operatorId
schema:
type: string
format: uuid
required: true
- 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
- in: query
description: Supply a list of Locations comma separated
name: select
schema:
type: string
example: uuid1,uuid2,uuid3
required: false
- in: query
description: return the number of Locations
name: countOnly
schema:
type: boolean
required: false
- in: query
description: return only the UUIDs of Locations
name: uuidOnly
schema:
type: boolean
required: false
responses:
200:
description: Return a list of Locations
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/OperatorLocationList'
- $ref: '#/components/schemas/CountAnswer'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/operatorLocations/{uuid}:
get:
tags:
- Operator Locations
operationId: getOperatorLocation
summary: Retrieve a specific location.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
responses:
200:
$ref: '#/components/schemas/OperatorLocation'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
post:
tags:
- Operator Locations
operationId: createOperatorLocation
summary: Create a specific location.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
requestBody:
description: Information used to create the new location
content:
application/json:
schema:
$ref: '#/components/schemas/OperatorLocation'
responses:
200:
$ref: '#/components/schemas/OperatorLocation'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
put:
tags:
- Operator Locations
operationId: modifyOperatorLocation
summary: Modify a specific location.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
requestBody:
description: Information used to modify the new location
content:
application/json:
schema:
$ref: '#/components/schemas/OperatorLocation'
responses:
200:
$ref: '#/components/schemas/OperatorLocation'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
delete:
tags:
- Operator Locations
operationId: deleteOperatorLocation
summary: Delete a specific location.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
- in: query
name: force
schema:
type: boolean
required: true
responses:
204:
$ref: '#/components/responses/Success'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/operatorContact:
get:
tags:
- Operator Contacts
operationId: getOperatorContacts
summary: Retrieve a list of operator contacts.
parameters:
- in: query
name: operatorId
schema:
type: string
format: uuid
required: true
- 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
- in: query
description: Supply a list of operator contacts comma separated
name: select
schema:
type: string
example: uuid1,uuid2,uuid3
required: false
- in: query
description: return the number of operator contacts
name: countOnly
schema:
type: boolean
required: false
- in: query
description: return only the UUIDs of operator contacts
name: uuidOnly
schema:
type: boolean
required: false
responses:
200:
description: Return a list of operator contacts
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/OperatorContactList'
- $ref: '#/components/schemas/CountAnswer'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/operatorContacts/{uuid}:
get:
tags:
- Operator Contacts
operationId: getOperatorContact
summary: Retrieve a specific operator contact.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
responses:
200:
$ref: '#/components/schemas/OperatorContact'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
post:
tags:
- Operator Contacts
operationId: createOperatorContact
summary: Create a specific operator contact.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
requestBody:
description: Information used to create the new entity
content:
application/json:
schema:
$ref: '#/components/schemas/OperatorContact'
responses:
200:
$ref: '#/components/schemas/OperatorContact'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
put:
tags:
- Operator Contacts
operationId: modifyOperatorContact
summary: Modify a specific operator contact.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
requestBody:
description: Information used to modify the new entity
content:
application/json:
schema:
$ref: '#/components/schemas/OperatorContact'
responses:
200:
$ref: '#/components/schemas/OperatorContact'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
delete:
tags:
- Operator Contacts
operationId: deleteOperatorContact
summary: Delete a specific operator contact.
parameters:
- in: path
name: uuid
schema:
type: string
format: uuid
required: true
- in: query
name: force
schema:
type: boolean
required: true
responses:
204:
$ref: '#/components/responses/Success'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
#########################################################################################
##

View File

@@ -530,4 +530,17 @@ namespace OpenWifi {
P=="quarterly" || P=="lifetime" || P=="custom1" ||
P=="custom2"|| P=="custom3"|| P=="custom4");
}
inline bool ValidContactType(const std::string &contact) {
auto C = Poco::toLower(contact);
return (C=="subscriber" || C=="user" || C=="installer" || C=="csr" ||
C=="manager" || C=="businessowner" || C=="technician" ||
C=="corporate");
}
inline bool ValidLocationType(const std::string &location) {
auto C = Poco::toLower(location);
return (C=="service" || C=="equipment" || C=="auto" || C=="manual" ||
C=="special" || C=="unknown" || C=="corporate");
}
}

View File

@@ -0,0 +1,155 @@
//
// Created by stephane bourque on 2022-04-07.
//
#include "RESTAPI_op_contact_handler.h"
#include "RESTAPI_db_helpers.h"
#include "sdks/SDK_sec.h"
namespace OpenWifi {
void RESTAPI_op_contact_handler::DoGet() {
auto uuid = GetBinding("uuid","");
if(uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
OpContactDB::RecordName Existing;
if(!DB_.GetRecord("id",uuid,Existing)) {
return NotFound();
}
Poco::JSON::Object Answer;
Existing.to_json(Answer);
return ReturnObject(Answer);
}
void RESTAPI_op_contact_handler::DoDelete() {
auto uuid = GetBinding("uuid","");
if(uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
OpContactDB::RecordName Existing;
if(!DB_.GetRecord("id",uuid,Existing)) {
return NotFound();
}
// see if anyone is still using this thing
if(!Existing.subscriberId.empty()){
return BadRequest(RESTAPI::Errors::StillInUse);
}
DB_.DeleteRecord("id", uuid);
return OK();
}
void RESTAPI_op_contact_handler::DoPost() {
auto RawObject = ParseStream();
OpContactDB::RecordName NewObject;
if(!NewObject.from_json(RawObject)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
if(RawObject->has("type")) {
if(!NewObject.type.empty()) {
if (ValidContactType(NewObject.type)) {
return BadRequest(RESTAPI::Errors::InvalidContactType);
}
NewObject.type = Poco::toLower(NewObject.type);
} else {
NewObject.type.clear();
}
}
if(NewObject.operatorId.empty() || !StorageService()->OperatorDB().Exists("id",NewObject.operatorId)) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
if(!NewObject.subscriberId.empty()) {
SecurityObjects::UserInfo NewSubInfo;
if(!SDK::Sec::Subscriber::Get(this, NewObject.subscriberId, NewSubInfo)) {
return BadRequest(RESTAPI::Errors::InvalidSubscriberId);
}
NewObject.primaryEmail = NewSubInfo.email;
} else {
NewObject.primaryEmail.clear();
}
if(RawObject->has("managementPolicy") && !StorageService()->PolicyDB().Exists("id",NewObject.managementPolicy)) {
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
}
ProvObjects::CreateObjectInfo(RawObject, UserInfo_.userinfo, NewObject.info);
if(DB_.CreateRecord(NewObject)) {
OpContactDB::RecordName New;
StorageService()->OpContactDB().GetRecord("id", NewObject.info.id, New);
Poco::JSON::Object Answer;
New.to_json(Answer);
return ReturnObject(Answer);
}
return InternalError("Contact could not be created.");
}
void RESTAPI_op_contact_handler::DoPut() {
auto uuid = GetBinding("uuid","");
OpContactDB::RecordName Existing;
if(uuid.empty() || DB_.GetRecord("id",uuid,Existing)) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
auto RawObject = ParseStream();
OpContactDB::RecordName UpdateObj;
if(!UpdateObj.from_json(RawObject)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
if(RawObject->has("managementPolicy") && !StorageService()->PolicyDB().Exists("id",UpdateObj.managementPolicy)) {
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
}
if(!UpdateObj.subscriberId.empty()) {
SecurityObjects::UserInfo NewSubInfo;
if(!SDK::Sec::Subscriber::Get(this, UpdateObj.subscriberId, NewSubInfo)) {
return BadRequest(RESTAPI::Errors::InvalidSubscriberId);
}
UpdateObj.primaryEmail = NewSubInfo.email;
} else {
UpdateObj.primaryEmail.clear();
}
if(RawObject->has("type")) {
if(!UpdateObj.type.empty()) {
if (ValidContactType(UpdateObj.type)) {
return BadRequest(RESTAPI::Errors::InvalidContactType);
}
Existing.type = Poco::toLower(UpdateObj.type);
} else {
Existing.type.clear();
}
}
ProvObjects::UpdateObjectInfo(RawObject, UserInfo_.userinfo, Existing.info);
AssignIfPresent(RawObject,"type",Existing.type);
AssignIfPresent(RawObject,"title",Existing.title);
AssignIfPresent(RawObject,"salutation",Existing.salutation);
AssignIfPresent(RawObject,"firstname",Existing.firstname);
AssignIfPresent(RawObject,"lastname",Existing.lastname);
AssignIfPresent(RawObject,"initials",Existing.initials);
AssignIfPresent(RawObject,"visual",Existing.visual);
AssignIfPresent(RawObject,"mobiles",Existing.mobiles);
AssignIfPresent(RawObject,"phones",Existing.phones);
AssignIfPresent(RawObject,"accessPIN",Existing.accessPIN);
AssignIfPresent(RawObject,"secondaryEmail",Existing.secondaryEmail);
if(DB_.UpdateRecord("id",uuid,Existing)) {
OpContactDB::RecordName New;
StorageService()->OpContactDB().GetRecord("id", Existing.info.id, New);
Poco::JSON::Object Answer;
New.to_json(Answer);
return ReturnObject(Answer);
}
return InternalError("Contact could not be updated.");
}
}

View File

@@ -0,0 +1,30 @@
//
// Created by stephane bourque on 2022-04-07.
//
#pragma once
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_contact_handler : public RESTAPIHandler {
public:
RESTAPI_op_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, 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,
TransactionId,
Internal){}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/operatorContact/{uuid}"}; };
private:
OpContactDB &DB_=StorageService()->OpContactDB();
void DoGet() final ;
void DoPost() final ;
void DoPut() final ;
void DoDelete() final ;
};
}

View File

@@ -0,0 +1,18 @@
//
// Created by stephane bourque on 2022-04-07.
//
#include "RESTAPI_op_contact_list_handler.h"
#include "RESTAPI_db_helpers.h"
namespace OpenWifi {
void RESTAPI_op_contact_list_handler::DoGet() {
auto operatorId= GetParameter("operatorId");
if(operatorId.empty() || !StorageService()->OperatorDB().Exists("id",operatorId)) {
return BadRequest(RESTAPI::Errors::OperatorIdMustExist);
}
return ListHandlerForOperator<OpContactDB>("contacts", DB_, *this,operatorId);
}
}

View File

@@ -0,0 +1,30 @@
//
// Created by stephane bourque on 2022-04-07.
//
#pragma once
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_contact_list_handler : public RESTAPIHandler {
public:
RESTAPI_op_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
TransactionId,
Internal) {
}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/operatorLocation"}; };
private:
OpContactDB &DB_=StorageService()->OpContactDB();
void DoGet() final;
void DoPost() final {};
void DoPut() final {};
void DoDelete() final {};
};
}

View File

@@ -0,0 +1,149 @@
//
// Created by stephane bourque on 2022-04-07.
//
#include "RESTAPI_op_location_handler.h"
#include "sdks/SDK_sec.h"
#include "RESTAPI/RESTAPI_db_helpers.h"
namespace OpenWifi {
void RESTAPI_op_location_handler::DoGet() {
auto uuid = GetBinding("uuid","");
if(uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
OpLocationDB::RecordName Existing;
if(!DB_.GetRecord("id",uuid,Existing)) {
return NotFound();
}
Poco::JSON::Object Answer;
Existing.to_json(Answer);
return ReturnObject(Answer);
}
void RESTAPI_op_location_handler::DoDelete() {
auto uuid = GetBinding("uuid","");
if(uuid.empty()) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
OpLocationDB::RecordName Existing;
if(!DB_.GetRecord("id",uuid,Existing)) {
return NotFound();
}
// see if anyone is still using this thing
if(!Existing.subscriberId.empty()){
return BadRequest(RESTAPI::Errors::StillInUse);
}
DB_.DeleteRecord("id", uuid);
return OK();
}
void RESTAPI_op_location_handler::DoPost() {
auto RawObject = ParseStream();
OpLocationDB::RecordName NewObject;
if(!NewObject.from_json(RawObject)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
if(RawObject->has("type")) {
if(!NewObject.type.empty()) {
if (ValidLocationType(NewObject.type)) {
return BadRequest(RESTAPI::Errors::InvalidLocationType);
}
NewObject.type = Poco::toLower(NewObject.type);
} else {
NewObject.type.clear();
}
}
if(NewObject.operatorId.empty() || !StorageService()->OperatorDB().Exists("id",NewObject.operatorId)) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
if(!NewObject.subscriberId.empty()) {
SecurityObjects::UserInfo NewSubInfo;
if(!SDK::Sec::Subscriber::Get(this, NewObject.subscriberId, NewSubInfo)) {
return BadRequest(RESTAPI::Errors::InvalidSubscriberId);
}
}
if(RawObject->has("managementPolicy") && !StorageService()->PolicyDB().Exists("id",NewObject.managementPolicy)) {
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
}
ProvObjects::CreateObjectInfo(RawObject, UserInfo_.userinfo, NewObject.info);
if(DB_.CreateRecord(NewObject)) {
OpLocationDB::RecordName New;
StorageService()->OpLocationDB().GetRecord("id", NewObject.info.id, New);
Poco::JSON::Object Answer;
New.to_json(Answer);
return ReturnObject(Answer);
}
return InternalError("Location could not be created.");
}
void RESTAPI_op_location_handler::DoPut() {
auto uuid = GetBinding("uuid","");
OpLocationDB::RecordName Existing;
if(uuid.empty() || DB_.GetRecord("id",uuid,Existing)) {
return BadRequest(RESTAPI::Errors::MissingUUID);
}
auto RawObject = ParseStream();
OpLocationDB::RecordName UpdateObj;
if(!UpdateObj.from_json(RawObject)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
if(RawObject->has("type")) {
if(!UpdateObj.type.empty()) {
if (ValidLocationType(UpdateObj.type)) {
return BadRequest(RESTAPI::Errors::InvalidLocationType);
}
Existing.type = Poco::toLower(UpdateObj.type);
} else {
Existing.type.clear();
}
}
if(RawObject->has("managementPolicy") && !StorageService()->PolicyDB().Exists("id",UpdateObj.managementPolicy)) {
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
}
if(!UpdateObj.subscriberId.empty()) {
SecurityObjects::UserInfo NewSubInfo;
if(!SDK::Sec::Subscriber::Get(this, UpdateObj.subscriberId, NewSubInfo)) {
return BadRequest(RESTAPI::Errors::InvalidSubscriberId);
}
} else {
if(RawObject->has("subscriberId") && UpdateObj.subscriberId.empty())
Existing.subscriberId.clear();
}
ProvObjects::UpdateObjectInfo(RawObject, UserInfo_.userinfo, Existing.info);
AssignIfPresent(RawObject,"buildingName",Existing.buildingName);
AssignIfPresent(RawObject,"addressLines",Existing.addressLines);
AssignIfPresent(RawObject,"city",Existing.city);
AssignIfPresent(RawObject,"state",Existing.state);
AssignIfPresent(RawObject,"postal",Existing.postal);
AssignIfPresent(RawObject,"country",Existing.country);
AssignIfPresent(RawObject,"mobiles",Existing.mobiles);
AssignIfPresent(RawObject,"phones",Existing.phones);
AssignIfPresent(RawObject,"geoCode",Existing.geoCode);
if(DB_.UpdateRecord("id",uuid,Existing)) {
OpLocationDB::RecordName New;
StorageService()->OpLocationDB().GetRecord("id", Existing.info.id, New);
Poco::JSON::Object Answer;
New.to_json(Answer);
return ReturnObject(Answer);
}
return InternalError("Location could not be updated.");
}
}

View File

@@ -0,0 +1,30 @@
//
// Created by stephane bourque on 2022-04-07.
//
#pragma once
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_location_handler : public RESTAPIHandler {
public:
RESTAPI_op_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, 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,
TransactionId,
Internal){}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/operatorLocation/{uuid}"}; };
private:
OpLocationDB &DB_=StorageService()->OpLocationDB();
void DoGet() final ;
void DoPost() final ;
void DoPut() final ;
void DoDelete() final ;
};
}

View File

@@ -0,0 +1,18 @@
//
// Created by stephane bourque on 2022-04-07.
//
#include "RESTAPI_op_location_list_handler.h"
#include "RESTAPI_db_helpers.h"
namespace OpenWifi {
void RESTAPI_op_location_list_handler::DoGet() {
auto operatorId= GetParameter("operatorId");
if(operatorId.empty() || !StorageService()->OperatorDB().Exists("id",operatorId)) {
return BadRequest(RESTAPI::Errors::OperatorIdMustExist);
}
return ListHandlerForOperator<OpLocationDB>("locations", DB_, *this,operatorId);
}
}

View File

@@ -0,0 +1,31 @@
//
// Created by stephane bourque on 2022-04-07.
//
#pragma once
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_location_list_handler : public RESTAPIHandler {
public:
RESTAPI_op_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
TransactionId,
Internal) {
}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/operatorLocation"}; };
private:
OpLocationDB &DB_=StorageService()->OpLocationDB();
void DoGet() final;
void DoPost() final {};
void DoPut() final {};
void DoDelete() final {};
};
}

View File

@@ -78,6 +78,19 @@ namespace OpenWifi {
ProvObjects::CreateObjectInfo(RawObject, UserInfo_.userinfo, NewObject.info);
if(DB_.CreateRecord(NewObject)) {
// Create the default service...
ProvObjects::ServiceClass DefSer;
DefSer.info.id = MicroService::CreateUUID();
DefSer.info.name = "Default Service Class";
DefSer.defaultService = true;
DefSer.info.created = DefSer.info.modified = OpenWifi::Now();
DefSer.operatorId = NewObject.info.id;
DefSer.period = "monthly";
DefSer.billingCode = "basic";
StorageService()->ServiceClassDB().CreateRecord(DefSer);
ProvObjects::Operator New;
DB_.GetRecord("id",NewObject.info.id,New);
Poco::JSON::Object Answer;

View File

@@ -33,6 +33,11 @@
#include "RESTAPI/RESTAPI_operators_list_handler.h"
#include "RESTAPI/RESTAPI_sub_devices_handler.h"
#include "RESTAPI/RESTAPI_sub_devices_list_handler.h"
#include "RESTAPI/RESTAPI_op_contact_handler.h"
#include "RESTAPI/RESTAPI_op_contact_list_handler.h"
#include "RESTAPI/RESTAPI_op_location_handler.h"
#include "RESTAPI/RESTAPI_op_location_list_handler.h"
namespace OpenWifi {
@@ -68,6 +73,10 @@ namespace OpenWifi {
RESTAPI_operators_list_handler,
RESTAPI_service_class_handler,
RESTAPI_service_class_list_handler,
RESTAPI_op_contact_handler,
RESTAPI_op_contact_list_handler,
RESTAPI_op_location_handler,
RESTAPI_op_location_list_handler,
RESTAPI_asset_server
>(Path,Bindings,L, S, TransactionId);
}
@@ -103,7 +112,11 @@ namespace OpenWifi {
RESTAPI_operators_handler,
RESTAPI_operators_list_handler,
RESTAPI_service_class_handler,
RESTAPI_service_class_list_handler
RESTAPI_service_class_list_handler,
RESTAPI_op_contact_handler,
RESTAPI_op_contact_list_handler,
RESTAPI_op_location_handler,
RESTAPI_op_location_list_handler
>(Path, Bindings, L, S, TransactionId);
}
}

View File

@@ -2,17 +2,6 @@
// Created by stephane bourque on 2022-04-06.
//
#ifndef OWPROV_RESTAPI_SERVICE_CLASS_LIST_HANDLER_H
#define OWPROV_RESTAPI_SERVICE_CLASS_LIST_HANDLER_H
class RESTAPI_service_class_list_handler {
};
#endif //OWPROV_RESTAPI_SERVICE_CLASS_LIST_HANDLER_H
#pragma once
#include "framework/MicroService.h"
@@ -31,7 +20,7 @@ namespace OpenWifi {
TransactionId,
Internal) {
}
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/serviceClasses"}; };
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/operatorLocations"}; };
private:
ServiceClassDB &DB_=StorageService()->ServiceClassDB();
void DoGet() final;

View File

@@ -195,8 +195,6 @@ namespace OpenWifi::ProvObjects {
void Operator::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"contacts",contacts);
field_to_json( Obj,"locations",locations);
field_to_json( Obj,"managementPolicy",managementPolicy);
field_to_json( Obj,"managementRoles",managementRoles);
field_to_json( Obj,"rrm",rrm);
@@ -210,8 +208,6 @@ namespace OpenWifi::ProvObjects {
bool Operator::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"contacts",contacts);
field_from_json( Obj,"locations",locations);
field_from_json( Obj,"managementPolicy",managementPolicy);
field_from_json( Obj,"managementRoles",managementRoles);
field_from_json( Obj,"rrm",rrm);
@@ -362,6 +358,60 @@ namespace OpenWifi::ProvObjects {
return false;
}
void OperatorLocation::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"type",type);
field_to_json( Obj,"buildingName",buildingName);
field_to_json( Obj,"addressLines",addressLines);
field_to_json( Obj,"city",city);
field_to_json( Obj,"state",state);
field_to_json( Obj,"postal",postal);
field_to_json( Obj,"country",country);
field_to_json( Obj,"phones",phones);
field_to_json( Obj,"mobiles",mobiles);
field_to_json( Obj,"geoCode",geoCode);
field_to_json( Obj,"operatorId",operatorId);
field_to_json( Obj,"subscriberId",subscriberId);
field_to_json( Obj,"managementPolicy",managementPolicy);
}
bool OperatorLocation::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"type", type);
field_from_json( Obj,"buildingName",buildingName);
field_from_json( Obj,"addressLines",addressLines);
field_from_json( Obj,"city",city);
field_from_json( Obj,"state",state);
field_from_json( Obj,"postal",postal);
field_from_json( Obj,"country",country);
field_from_json( Obj,"phones",phones);
field_from_json( Obj,"mobiles",mobiles);
field_from_json( Obj,"geoCode",geoCode);
field_from_json( Obj,"operatorId",operatorId);
field_from_json( Obj,"subscriberId",subscriberId);
field_from_json( Obj,"managementPolicy",managementPolicy);
return true;
} catch (...) {
}
return false;
}
void OperatorLocationList::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj, "locations", locations);
}
bool OperatorLocationList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json( Obj, "locations", locations);
return true;
} catch(...) {
}
return false;
}
void Contact::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"type", to_string(type));
@@ -408,6 +458,64 @@ namespace OpenWifi::ProvObjects {
return false;
}
void OperatorContact::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"type", type);
field_to_json( Obj,"title",title);
field_to_json( Obj,"salutation",salutation);
field_to_json( Obj,"firstname",firstname);
field_to_json( Obj,"lastname",lastname);
field_to_json( Obj,"initials",initials);
field_to_json( Obj,"visual",visual);
field_to_json( Obj,"mobiles",mobiles);
field_to_json( Obj,"phones",phones);
field_to_json( Obj,"primaryEmail",primaryEmail);
field_to_json( Obj,"secondaryEmail",secondaryEmail);
field_to_json( Obj,"accessPIN",accessPIN);
field_to_json( Obj,"operatorId",operatorId);
field_to_json( Obj,"subscriberId",subscriberId);
field_to_json( Obj,"managementPolicy",managementPolicy);
}
bool OperatorContact::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"type", type);
field_from_json( Obj,"title",title);
field_from_json( Obj,"salutation",salutation);
field_from_json( Obj,"firstname",firstname);
field_from_json( Obj,"lastname",lastname);
field_from_json( Obj,"initials",initials);
field_from_json( Obj,"visual",visual);
field_from_json( Obj,"mobiles",mobiles);
field_from_json( Obj,"phones",phones);
field_from_json( Obj,"primaryEmail",primaryEmail);
field_from_json( Obj,"secondaryEmail",secondaryEmail);
field_from_json( Obj,"accessPIN",accessPIN);
field_from_json( Obj,"operatorId",operatorId);
field_from_json( Obj,"subscriberId",subscriberId);
field_from_json( Obj,"managementPolicy",managementPolicy);
return true;
} catch (...) {
}
return false;
}
void OperatorContactList::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj, "contacts", contacts);
}
bool OperatorContactList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json( Obj, "contacts", contacts);
return true;
} catch(...) {
}
return false;
}
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj, "serialNumber", serialNumber);

View File

@@ -200,6 +200,35 @@ namespace OpenWifi::ProvObjects {
};
typedef std::vector<Location> LocationVec;
struct OperatorLocation {
ObjectInfo info;
std::string type;
std::string buildingName;
Types::StringVec addressLines;
std::string city;
std::string state;
std::string postal;
std::string country;
Types::StringVec phones;
Types::StringVec mobiles;
std::string geoCode;
Types::UUID_t operatorId;
Types::UUID_t subscriberId;
Types::UUID_t managementPolicy;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
typedef std::vector<Location> LocationVec;
struct OperatorLocationList {
std::vector<OperatorLocation> locations;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
enum ContactType {
CT_SUBSCRIBER, CT_USER, CT_INSTALLER, CT_CSR, CT_MANAGER,
CT_BUSINESSOWNER, CT_TECHNICIAN, CT_CORPORATE, CT_UNKNOWN
@@ -263,6 +292,37 @@ namespace OpenWifi::ProvObjects {
};
typedef std::vector<Contact> ContactVec;
struct OperatorContact {
ObjectInfo info;
std::string type;
std::string title;
std::string salutation;
std::string firstname;
std::string lastname;
std::string initials;
std::string visual;
Types::StringVec mobiles;
Types::StringVec phones;
std::string primaryEmail;
std::string secondaryEmail;
std::string accessPIN;
Types::UUID_t operatorId;
Types::UUID_t subscriberId;
Types::UUID_t managementPolicy;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct OperatorContactList {
std::vector<OperatorContact> contacts;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
typedef std::vector<OperatorContact> OperatorContactVec;
struct DeviceConfigurationElement {
std::string name;
std::string description;
@@ -484,8 +544,6 @@ namespace OpenWifi::ProvObjects {
struct Operator {
ObjectInfo info;
Types::UUIDvec_t contacts;
Types::UUIDvec_t locations;
Types::UUID_t managementPolicy;
Types::UUIDvec_t managementRoles;
std::string rrm;

View File

@@ -32,6 +32,8 @@ namespace OpenWifi {
OperatorDB_ = std::make_unique<OpenWifi::OperatorDB>(dbType_, *Pool_, Logger());
ServiceClassDB_ = std::make_unique<OpenWifi::ServiceClassDB>(dbType_, *Pool_, Logger());
SubscriberDeviceDB_ = std::make_unique<OpenWifi::SubscriberDeviceDB>(dbType_, *Pool_, Logger());
OpLocationDB_ = std::make_unique<OpenWifi::OpLocationDB>(dbType_, *Pool_, Logger());
OpContactDB_ = std::make_unique<OpenWifi::OpContactDB>(dbType_, *Pool_, Logger());
EntityDB_->Create();
PolicyDB_->Create();
@@ -49,6 +51,8 @@ namespace OpenWifi {
OperatorDB_->Create();
ServiceClassDB_->Create();
SubscriberDeviceDB_->Create();
OpLocationDB_->Create();
OpContactDB_->Create();
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); };
@@ -66,6 +70,8 @@ namespace OpenWifi {
ExistFunc_[OperatorDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return OperatorDB_->Exists(F,V); };
ExistFunc_[ServiceClassDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return ServiceClassDB_->Exists(F,V); };
ExistFunc_[SubscriberDeviceDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return SubscriberDeviceDB_->Exists(F,V); };
ExistFunc_[OpLocationDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return OpLocationDB_->Exists(F,V); };
ExistFunc_[OpContactDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return OpContactDB_->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_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return PolicyDB_->GetNameAndDescription(F,V, Name, Description); };
@@ -83,6 +89,8 @@ namespace OpenWifi {
ExpandFunc_[OperatorDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return OperatorDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[ServiceClassDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return ServiceClassDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[SubscriberDeviceDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return SubscriberDeviceDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[OpLocationDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return OpLocationDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[OpContactDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return OpContactDB_->GetNameAndDescription(F,V, Name, Description); };
InventoryDB_->InitializeSerialCache();
@@ -257,7 +265,7 @@ namespace OpenWifi {
ProvObjects::ServiceClass DefSer;
DefSer.info.id = MicroService::CreateUUID();
DefSer.info.name = "Default Operator";
DefSer.info.name = "Default Service Class";
DefSer.defaultService = true;
DefSer.info.created = DefSer.info.modified = OpenWifi::Now();
DefSer.operatorId = DefOp.info.id;

View File

@@ -15,7 +15,9 @@
#include "storage/storage_policies.h"
#include "storage/storage_venue.h"
#include "storage/storage_location.h"
#include "storage/storage_op_locations.h"
#include "storage/storage_contact.h"
#include "storage/storage_op_contacts.h"
#include "storage/storage_inventory.h"
#include "storage/storage_management_roles.h"
#include "storage/storage_configurations.h"
@@ -58,6 +60,8 @@ namespace OpenWifi {
OpenWifi::OperatorDB & OperatorDB() { return *OperatorDB_; };
OpenWifi::ServiceClassDB & ServiceClassDB() { return *ServiceClassDB_; };
OpenWifi::SubscriberDeviceDB & SubscriberDeviceDB() { return *SubscriberDeviceDB_; };
OpenWifi::OpLocationDB & OpLocationDB() { return *OpLocationDB_; };
OpenWifi::OpContactDB & OpContactDB() { return *OpContactDB_; };
bool Validate(const Poco::URI::QueryParameters &P, std::string &Error);
bool Validate(const Types::StringVec &P, std::string &Error);
@@ -87,6 +91,8 @@ namespace OpenWifi {
std::unique_ptr<OpenWifi::OperatorDB> OperatorDB_;
std::unique_ptr<OpenWifi::ServiceClassDB> ServiceClassDB_;
std::unique_ptr<OpenWifi::SubscriberDeviceDB> SubscriberDeviceDB_;
std::unique_ptr<OpenWifi::OpLocationDB> OpLocationDB_;
std::unique_ptr<OpenWifi::OpContactDB> OpContactDB_;
std::string DefaultOperator_;

View File

@@ -91,7 +91,9 @@ namespace OpenWifi::RESTAPI::Errors {
static const std::string InvalidIPAddresses{"Invalid IP addresses."};
static const std::string InvalidBillingCode{"Empty of invalid billing code."};
static const std::string InvalidBillingPeriod{"Invalid billing period."};
static const std::string InvalidSubscriberId{"Invalid subscriber ID"};
static const std::string InvalidContactType{"Invalid contact type"};
static const std::string InvalidLocationType{"Invalid location type"};
}
namespace OpenWifi::RESTAPI::Protocol {

View File

@@ -0,0 +1,99 @@
//
// Created by stephane bourque on 2022-04-07.
//
#include "storage_op_contacts.h"
#include "framework/OpenWifiTypes.h"
#include "framework/MicroService.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h"
namespace OpenWifi {
static ORM::FieldVec OpContactDB_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{"type",ORM::FieldType::FT_TEXT},
ORM::Field{"title",ORM::FieldType::FT_TEXT},
ORM::Field{"salutation",ORM::FieldType::FT_TEXT},
ORM::Field{"firstname",ORM::FieldType::FT_TEXT},
ORM::Field{"lastname",ORM::FieldType::FT_TEXT},
ORM::Field{"initials",ORM::FieldType::FT_TEXT},
ORM::Field{"visual",ORM::FieldType::FT_TEXT},
ORM::Field{"mobiles",ORM::FieldType::FT_TEXT},
ORM::Field{"phones",ORM::FieldType::FT_TEXT},
ORM::Field{"primaryEmail",ORM::FieldType::FT_TEXT},
ORM::Field{"secondaryEmail",ORM::FieldType::FT_TEXT},
ORM::Field{"accessPIN",ORM::FieldType::FT_TEXT},
ORM::Field{"operatorId",ORM::FieldType::FT_TEXT},
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT},
ORM::Field{"subscriberId",ORM::FieldType::FT_TEXT}
};
static ORM::IndexVec OpContactDB_Indexes{
{ std::string("op_contact_name_index"),
ORM::IndexEntryVec{
{std::string("name"),
ORM::Indextype::ASC} } }
};
OpContactDB::OpContactDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
DB(T, "op_contacts", OpContactDB_Fields, OpContactDB_Indexes, P, L, "ocn") {}
}
template<> void ORM::DB<OpenWifi::OpContactDBRecordType, OpenWifi::ProvObjects::OperatorContact>::Convert(const OpenWifi::OpContactDBRecordType &In, OpenWifi::ProvObjects::OperatorContact &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.type = In.get<6>();
Out.title = In.get<7>();
Out.salutation = In.get<8>();
Out.firstname = In.get<9>();
Out.lastname = In.get<10>();
Out.initials = In.get<11>();
Out.visual = In.get<12>();
Out.mobiles = OpenWifi::RESTAPI_utils::to_object_array(In.get<13>());
Out.phones = OpenWifi::RESTAPI_utils::to_object_array(In.get<14>());
Out.primaryEmail = In.get<15>();
Out.secondaryEmail = In.get<16>();
Out.accessPIN = In.get<17>();
Out.operatorId = In.get<18>();
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<19>());
Out.managementPolicy = In.get<20>();
Out.subscriberId = In.get<21>();
}
template<> void ORM::DB<OpenWifi::OpContactDBRecordType, OpenWifi::ProvObjects::OperatorContact>::Convert(const OpenWifi::ProvObjects::OperatorContact &In, OpenWifi::OpContactDBRecordType &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>(In.type);
Out.set<7>(In.title);
Out.set<8>(In.salutation);
Out.set<9>(In.firstname);
Out.set<10>(In.lastname);
Out.set<11>(In.initials);
Out.set<12>(In.visual);
Out.set<13>(OpenWifi::RESTAPI_utils::to_string(In.mobiles));
Out.set<14>(OpenWifi::RESTAPI_utils::to_string(In.phones));
Out.set<15>(In.primaryEmail);
Out.set<16>(In.secondaryEmail);
Out.set<17>(In.accessPIN);
Out.set<18>(In.operatorId);
Out.set<19>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
Out.set<20>(In.managementPolicy);
Out.set<21>(In.subscriberId);
}

View File

@@ -0,0 +1,40 @@
//
// Created by stephane bourque on 2022-04-07.
//
#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,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string
> OpContactDBRecordType;
class OpContactDB : public ORM::DB<OpContactDBRecordType, ProvObjects::OperatorContact> {
public:
OpContactDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~OpContactDB() {};
private:
};
}

View File

@@ -0,0 +1,92 @@
//
// Created by stephane bourque on 2022-04-07.
//
#include "storage_op_locations.h"
#include "framework/OpenWifiTypes.h"
#include "framework/MicroService.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h"
namespace OpenWifi {
static ORM::FieldVec OpLocationDB_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{"type",ORM::FieldType::FT_TEXT},
ORM::Field{"buildingName",ORM::FieldType::FT_TEXT},
ORM::Field{"addressLines",ORM::FieldType::FT_TEXT},
ORM::Field{"city",ORM::FieldType::FT_TEXT},
ORM::Field{"state",ORM::FieldType::FT_TEXT},
ORM::Field{"postal",ORM::FieldType::FT_TEXT},
ORM::Field{"country",ORM::FieldType::FT_TEXT},
ORM::Field{"phones",ORM::FieldType::FT_TEXT},
ORM::Field{"mobiles",ORM::FieldType::FT_TEXT},
ORM::Field{"geoCode",ORM::FieldType::FT_TEXT},
ORM::Field{"operatorId",ORM::FieldType::FT_TEXT},
ORM::Field{"tags",ORM::FieldType::FT_TEXT},
ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT},
ORM::Field{"subscriberId",ORM::FieldType::FT_TEXT}
};
static ORM::IndexVec OpLocationDB_Indexes{
{ std::string("op_location_name_index"),
ORM::IndexEntryVec{
{std::string("name"),
ORM::Indextype::ASC} } }
};
OpLocationDB::OpLocationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
DB(T, "op_locations", OpLocationDB_Fields, OpLocationDB_Indexes, P, L, "olc") {}
}
template<> void ORM::DB<OpenWifi::OpLocationDBRecordType , OpenWifi::ProvObjects::OperatorLocation>::Convert(const OpenWifi::OpLocationDBRecordType &In, OpenWifi::ProvObjects::OperatorLocation &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.type = In.get<6>();
Out.buildingName = In.get<7>();
Out.addressLines = OpenWifi::RESTAPI_utils::to_object_array(In.get<8>());
Out.city = In.get<9>();
Out.state = In.get<10>();
Out.postal = In.get<11>();
Out.country = In.get<12>();
Out.phones = OpenWifi::RESTAPI_utils::to_object_array(In.get<13>());
Out.mobiles = OpenWifi::RESTAPI_utils::to_object_array(In.get<14>());
Out.geoCode = In.get<15>();
Out.operatorId = In.get<16>();
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<17>());
Out.managementPolicy = In.get<18>();
Out.subscriberId = In.get<19>();
}
template<> void ORM::DB<OpenWifi::OpLocationDBRecordType, OpenWifi::ProvObjects::OperatorLocation>::Convert(const OpenWifi::ProvObjects::OperatorLocation &In, OpenWifi::OpLocationDBRecordType &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>(In.type);
Out.set<7>(In.buildingName);
Out.set<8>(OpenWifi::RESTAPI_utils::to_string(In.addressLines));
Out.set<9>(In.city);
Out.set<10>(In.state);
Out.set<11>(In.postal);
Out.set<12>(In.country);
Out.set<13>(OpenWifi::RESTAPI_utils::to_string(In.phones));
Out.set<14>(OpenWifi::RESTAPI_utils::to_string(In.mobiles));
Out.set<15>(In.geoCode);
Out.set<16>(In.operatorId);
Out.set<17>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
Out.set<18>(In.managementPolicy);
Out.set<19>(In.subscriberId);
}

View File

@@ -0,0 +1,38 @@
//
// Created by stephane bourque on 2022-04-07.
//
#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,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string,
std::string
> OpLocationDBRecordType;
class OpLocationDB : public ORM::DB<OpLocationDBRecordType, ProvObjects::OperatorLocation> {
public:
OpLocationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~OpLocationDB() {};
private:
};
}

View File

@@ -18,8 +18,6 @@ namespace OpenWifi {
ORM::Field{"notes",ORM::FieldType::FT_TEXT},
ORM::Field{"created",ORM::FieldType::FT_BIGINT},
ORM::Field{"modified",ORM::FieldType::FT_BIGINT},
ORM::Field{"contacts",ORM::FieldType::FT_TEXT},
ORM::Field{"locations",ORM::FieldType::FT_TEXT},
ORM::Field{"managementPolicy",ORM::FieldType::FT_TEXT},
ORM::Field{"managementRoles",ORM::FieldType::FT_TEXT},
ORM::Field{"rrm",ORM::FieldType::FT_TEXT},
@@ -79,16 +77,14 @@ template<> void ORM::DB< OpenWifi::OperatorDBRecordType, OpenWifi::ProvObject
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.contacts = OpenWifi::RESTAPI_utils::to_object_array(In.get<6>());
Out.locations = OpenWifi::RESTAPI_utils::to_object_array(In.get<7>());
Out.managementPolicy = In.get<8>();
Out.managementRoles = OpenWifi::RESTAPI_utils::to_object_array(In.get<9>());
Out.rrm = In.get<10>();
Out.firmwareUpgrade = In.get<11>();
Out.firmwareRCOnly = In.get<12>();
Out.variables = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::Variable>(In.get<13>());
Out.defaultOperator = In.get<14>();
Out.sourceIP = OpenWifi::RESTAPI_utils::to_object_array(In.get<15>());
Out.managementPolicy = In.get<6>();
Out.managementRoles = OpenWifi::RESTAPI_utils::to_object_array(In.get<7>());
Out.rrm = In.get<8>();
Out.firmwareUpgrade = In.get<9>();
Out.firmwareRCOnly = In.get<10>();
Out.variables = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::Variable>(In.get<11>());
Out.defaultOperator = In.get<12>();
Out.sourceIP = OpenWifi::RESTAPI_utils::to_object_array(In.get<13>());
}
template<> void ORM::DB< OpenWifi::OperatorDBRecordType, OpenWifi::ProvObjects::Operator>::Convert(const OpenWifi::ProvObjects::Operator &In, OpenWifi::OperatorDBRecordType &Out) {
@@ -98,14 +94,12 @@ template<> void ORM::DB< OpenWifi::OperatorDBRecordType, OpenWifi::ProvObject
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.contacts));
Out.set<7>(OpenWifi::RESTAPI_utils::to_string(In.locations));
Out.set<8>(In.managementPolicy);
Out.set<9>(OpenWifi::RESTAPI_utils::to_string(In.managementRoles));
Out.set<10>(In.rrm);
Out.set<11>(In.firmwareUpgrade);
Out.set<12>(In.firmwareRCOnly);
Out.set<13>(OpenWifi::RESTAPI_utils::to_string(In.variables));
Out.set<14>(In.defaultOperator);
Out.set<15>(OpenWifi::RESTAPI_utils::to_string(In.sourceIP));
Out.set<6>(In.managementPolicy);
Out.set<7>(OpenWifi::RESTAPI_utils::to_string(In.managementRoles));
Out.set<8>(In.rrm);
Out.set<9>(In.firmwareUpgrade);
Out.set<10>(In.firmwareRCOnly);
Out.set<11>(OpenWifi::RESTAPI_utils::to_string(In.variables));
Out.set<12>(In.defaultOperator);
Out.set<13>(OpenWifi::RESTAPI_utils::to_string(In.sourceIP));
}

View File

@@ -20,8 +20,6 @@ namespace OpenWifi {
std::string,
std::string,
std::string,
std::string,
std::string,
bool,
std::string,
bool,