Framework update

This commit is contained in:
stephb9959
2022-04-22 14:29:11 -07:00
parent ea0caa0815
commit 2d3717bb98
5 changed files with 681 additions and 139 deletions

View File

@@ -193,6 +193,91 @@ namespace OpenWifi::ProvObjects {
return false;
}
void Operator::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"managementPolicy",managementPolicy);
field_to_json( Obj,"managementRoles",managementRoles);
field_to_json( Obj,"rrm",rrm);
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
field_to_json( Obj,"variables",variables);
field_to_json( Obj,"defaultOperator",defaultOperator);
field_to_json( Obj,"sourceIP",sourceIP);
}
bool Operator::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"managementPolicy",managementPolicy);
field_from_json( Obj,"managementRoles",managementRoles);
field_from_json( Obj,"rrm",rrm);
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
field_from_json( Obj,"variables",variables);
field_from_json( Obj,"defaultOperator",defaultOperator);
field_from_json( Obj,"sourceIP",sourceIP);
return true;
} catch(...) {
}
return false;
}
void OperatorList::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj,"operators",operators);
}
bool OperatorList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json( Obj,"operators",operators);
return true;
} catch(...) {
}
return false;
}
void ServiceClass::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"operatorId",operatorId);
field_to_json( Obj,"managementPolicy",managementPolicy);
field_to_json( Obj,"cost",cost);
field_to_json( Obj,"currency",currency);
field_to_json( Obj,"period",period);
field_to_json( Obj,"billingCode",billingCode);
field_to_json( Obj,"variables",variables);
field_to_json( Obj,"defaultService",defaultService);
}
bool ServiceClass::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"operatorId",operatorId);
field_from_json( Obj,"managementPolicy",managementPolicy);
field_from_json( Obj,"cost",cost);
field_from_json( Obj,"currency",currency);
field_from_json( Obj,"period",period);
field_from_json( Obj,"billingCode",billingCode);
field_from_json( Obj,"variables",variables);
field_from_json( Obj,"defaultService",defaultService);
return true;
} catch(...) {
}
return false;
}
void ServiceClassList::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj,"serviceClasses",serviceClasses);
}
bool ServiceClassList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json( Obj,"serviceClasses",serviceClasses);
return true;
} catch(...) {
}
return false;
}
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj,"id",id);
field_to_json( Obj,"entity",loginId);
@@ -273,6 +358,92 @@ 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,"subscriberDeviceId",subscriberDeviceId);
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,"subscriberDeviceId",subscriberDeviceId);
field_from_json( Obj,"managementPolicy",managementPolicy);
return true;
} catch (...) {
}
return false;
}
void SubLocation::to_json(Poco::JSON::Object &Obj) const {
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);
}
bool SubLocation::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
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);
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));
@@ -319,6 +490,100 @@ 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,"subscriberDeviceId",subscriberDeviceId);
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,"subscriberDeviceId",subscriberDeviceId);
field_from_json( Obj,"managementPolicy",managementPolicy);
return true;
} catch (...) {
}
return false;
}
void SubContact::to_json(Poco::JSON::Object &Obj) const {
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);
}
bool SubContact::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
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);
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);
@@ -528,46 +793,16 @@ namespace OpenWifi::ProvObjects {
return false;
}
void field_to_json(Poco::JSON::Object &Obj, const char * FieldName, ACLACCESS A) {
switch(A) {
case READ: Obj.set(FieldName,"read"); break;
case MODIFY: Obj.set(FieldName,"modify"); break;
case CREATE: Obj.set(FieldName,"create"); break;
case DELETE: Obj.set(FieldName,"delete"); break;
case NONE:
default:
Obj.set(FieldName,"none");
}
}
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char * FieldName, ACLACCESS &A) {
if(Obj->has(FieldName)) {
auto V = Obj->getValue<std::string>(FieldName);
if(V=="read")
A = READ;
else if(V=="modify")
A = MODIFY;
else if(V=="create")
A = CREATE;
else if(V=="delete")
A = DELETE;
else if(V=="none")
A = NONE;
else
throw Poco::Exception("invalid JSON");
}
}
void ObjectACL::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj, "users", users);
RESTAPI_utils::field_to_json(Obj, "roles", roles);
field_to_json(Obj, "users", users);
field_to_json(Obj, "roles", roles);
field_to_json(Obj, "access", access);
}
bool ObjectACL::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj, "users", users);
RESTAPI_utils::field_from_json(Obj, "roles", roles);
field_from_json(Obj, "users", users);
field_from_json(Obj, "roles", roles);
field_from_json(Obj, "access", access);
return true;
} catch(...) {
@@ -577,12 +812,12 @@ namespace OpenWifi::ProvObjects {
}
void ObjectACLList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj, "list", list);
field_to_json(Obj, "list", list);
}
bool ObjectACLList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj, "list", list);
field_from_json(Obj, "list", list);
return true;
} catch(...) {
@@ -590,46 +825,15 @@ namespace OpenWifi::ProvObjects {
return false;
}
std::string to_string(VISIBILITY A) {
switch(A) {
case PUBLIC: return "public";
case SELECT: return "select";
case PRIVATE:
default:
return "private";
}
}
void field_to_json(Poco::JSON::Object &Obj, const char * FieldName, VISIBILITY A) {
Obj.set(FieldName,to_string(A));
}
VISIBILITY visibility_from_string(const std::string &V) {
if(V=="public")
return PUBLIC;
else if(V=="select")
return SELECT;
else if(V=="private")
return PRIVATE;
throw Poco::Exception("invalid json");
}
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char * FieldName, VISIBILITY &A) {
if(Obj->has(FieldName)) {
auto V = Obj->getValue<std::string>(FieldName);
A = visibility_from_string(V);
}
}
void Map::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
RESTAPI_utils::field_to_json( Obj,"data",data);
RESTAPI_utils::field_to_json( Obj,"entity",entity);
RESTAPI_utils::field_to_json( Obj,"creator",creator);
RESTAPI_utils::field_to_json( Obj,"visibility",visibility);
RESTAPI_utils::field_to_json( Obj,"access",access);
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
RESTAPI_utils::field_to_json( Obj,"venue", venue);
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);
field_to_json( Obj,"managementPolicy", managementPolicy);
field_to_json( Obj,"venue", venue);
}
bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -649,6 +853,20 @@ namespace OpenWifi::ProvObjects {
return false;
}
void SerialNumberList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json( Obj,"serialNumbers",serialNumbers);
}
bool SerialNumberList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json( Obj,"serialNumbers",serialNumbers);
return true;
} catch(...) {
}
return false;
}
void MapList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json( Obj,"list",list);
}
@@ -665,31 +883,31 @@ namespace OpenWifi::ProvObjects {
void SignupEntry::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
RESTAPI_utils::field_to_json( Obj,"email", email);
RESTAPI_utils::field_to_json( Obj,"userId", userId);
RESTAPI_utils::field_to_json( Obj,"macAddress", macAddress);
RESTAPI_utils::field_to_json( Obj,"serialNumber", serialNumber);
RESTAPI_utils::field_to_json( Obj,"submitted", submitted);
RESTAPI_utils::field_to_json( Obj,"completed", completed);
RESTAPI_utils::field_to_json( Obj,"status", status);
RESTAPI_utils::field_to_json( Obj,"error", error);
RESTAPI_utils::field_to_json( Obj,"statusCode", statusCode);
RESTAPI_utils::field_to_json( Obj,"deviceID", deviceID);
field_to_json( Obj,"email", email);
field_to_json( Obj,"userId", userId);
field_to_json( Obj,"macAddress", macAddress);
field_to_json( Obj,"serialNumber", serialNumber);
field_to_json( Obj,"submitted", submitted);
field_to_json( Obj,"completed", completed);
field_to_json( Obj,"status", status);
field_to_json( Obj,"error", error);
field_to_json( Obj,"statusCode", statusCode);
field_to_json( Obj,"deviceID", deviceID);
}
bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
RESTAPI_utils::field_from_json( Obj,"email", email);
RESTAPI_utils::field_from_json( Obj,"userId", userId);
RESTAPI_utils::field_from_json( Obj,"macAddress", macAddress);
RESTAPI_utils::field_from_json( Obj,"serialNumber", serialNumber);
RESTAPI_utils::field_from_json( Obj,"submitted", submitted);
RESTAPI_utils::field_from_json( Obj,"completed", completed);
RESTAPI_utils::field_from_json( Obj,"status", status);
RESTAPI_utils::field_from_json( Obj,"error", error);
RESTAPI_utils::field_from_json( Obj,"statusCode", statusCode);
RESTAPI_utils::field_from_json( Obj,"deviceID", deviceID);
field_from_json( Obj,"email", email);
field_from_json( Obj,"userId", userId);
field_from_json( Obj,"macAddress", macAddress);
field_from_json( Obj,"serialNumber", serialNumber);
field_from_json( Obj,"submitted", submitted);
field_from_json( Obj,"completed", completed);
field_from_json( Obj,"status", status);
field_from_json( Obj,"error", error);
field_from_json( Obj,"statusCode", statusCode);
field_from_json( Obj,"deviceID", deviceID);
return true;
} catch(...) {
@@ -698,18 +916,18 @@ namespace OpenWifi::ProvObjects {
}
void Variable::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json( Obj,"type", type);
RESTAPI_utils::field_to_json( Obj,"weight", weight);
RESTAPI_utils::field_to_json( Obj,"prefix", prefix);
RESTAPI_utils::field_to_json( Obj,"value", value);
field_to_json( Obj,"type", type);
field_to_json( Obj,"weight", weight);
field_to_json( Obj,"prefix", prefix);
field_to_json( Obj,"value", value);
}
bool Variable::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json( Obj,"type", type);
RESTAPI_utils::field_from_json( Obj,"weight", weight);
RESTAPI_utils::field_from_json( Obj,"prefix", prefix);
RESTAPI_utils::field_from_json( Obj,"value", value);
field_from_json( Obj,"type", type);
field_from_json( Obj,"weight", weight);
field_from_json( Obj,"prefix", prefix);
field_from_json( Obj,"value", value);
return true;
} catch(...) {
@@ -718,12 +936,12 @@ namespace OpenWifi::ProvObjects {
}
void VariableList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json( Obj,"variables", variables);
field_to_json( Obj,"variables", variables);
}
bool VariableList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json( Obj,"variables", variables);
field_from_json( Obj,"variables", variables);
return true;
} catch(...) {
@@ -733,25 +951,25 @@ namespace OpenWifi::ProvObjects {
void VariableBlock::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
RESTAPI_utils::field_to_json( Obj,"variables", variables);
RESTAPI_utils::field_to_json( Obj,"entity", entity);
RESTAPI_utils::field_to_json( Obj,"venue", venue);
RESTAPI_utils::field_to_json( Obj,"subscriber", subscriber);
RESTAPI_utils::field_to_json( Obj,"inventory", inventory);
RESTAPI_utils::field_to_json( Obj,"configurations", configurations);
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
field_to_json( Obj,"variables", variables);
field_to_json( Obj,"entity", entity);
field_to_json( Obj,"venue", venue);
field_to_json( Obj,"subscriber", subscriber);
field_to_json( Obj,"inventory", inventory);
field_to_json( Obj,"configurations", configurations);
field_to_json( Obj,"managementPolicy", managementPolicy);
}
bool VariableBlock::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
RESTAPI_utils::field_from_json( Obj,"variables", variables);
RESTAPI_utils::field_from_json( Obj,"entity", entity);
RESTAPI_utils::field_from_json( Obj,"venue", venue);
RESTAPI_utils::field_from_json( Obj,"subscriber", subscriber);
RESTAPI_utils::field_from_json( Obj,"inventory", inventory);
RESTAPI_utils::field_from_json( Obj,"configurations", configurations);
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
field_from_json( Obj,"variables", variables);
field_from_json( Obj,"entity", entity);
field_from_json( Obj,"venue", venue);
field_from_json( Obj,"subscriber", subscriber);
field_from_json( Obj,"inventory", inventory);
field_from_json( Obj,"configurations", configurations);
field_from_json( Obj,"managementPolicy", managementPolicy);
return true;
} catch(...) {
}
@@ -759,12 +977,74 @@ namespace OpenWifi::ProvObjects {
}
void VariableBlockList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json( Obj,"variableBlocks", variableBlocks);
field_to_json( Obj,"variableBlocks", variableBlocks);
}
bool VariableBlockList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json( Obj,"variableBlocks", variableBlocks);
field_from_json( Obj,"variableBlocks", variableBlocks);
return true;
} catch(...) {
}
return false;
}
void SubscriberDevice::to_json(Poco::JSON::Object &Obj) const {
info.to_json(Obj);
field_to_json( Obj,"serialNumber", serialNumber);
field_to_json( Obj,"deviceType", deviceType);
field_to_json( Obj,"operatorId", operatorId);
field_to_json( Obj,"subscriberId", subscriberId);
field_to_json( Obj,"location", location);
field_to_json( Obj,"contact", contact);
field_to_json( Obj,"managementPolicy", managementPolicy);
field_to_json( Obj,"serviceClass", serviceClass);
field_to_json( Obj,"qrCode", qrCode);
field_to_json( Obj,"geoCode", geoCode);
field_to_json( Obj,"rrm", rrm);
field_to_json( Obj,"state", state);
field_to_json( Obj,"locale", locale);
field_to_json( Obj,"billingCode", billingCode);
field_to_json( Obj,"configuration", configuration);
field_to_json( Obj,"suspended", suspended);
field_to_json( Obj,"realMacAddress", realMacAddress);
}
bool SubscriberDevice::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
info.from_json(Obj);
field_from_json( Obj,"serialNumber", serialNumber);
field_from_json( Obj,"deviceType", deviceType);
field_from_json( Obj,"operatorId", operatorId);
field_from_json( Obj,"subscriberId", subscriberId);
field_from_json( Obj,"location", location);
field_from_json( Obj,"contact", contact);
field_from_json( Obj,"managementPolicy", managementPolicy);
field_from_json( Obj,"serviceClass", serviceClass);
field_from_json( Obj,"qrCode", qrCode);
field_from_json( Obj,"geoCode", geoCode);
field_from_json( Obj,"rrm", rrm);
field_from_json( Obj,"state", state);
field_from_json( Obj,"locale", locale);
field_from_json( Obj,"billingCode", billingCode);
field_from_json( Obj,"configuration", configuration);
field_from_json( Obj,"suspended", suspended);
field_from_json( Obj,"realMacAddress", realMacAddress);
return true;
} catch(...) {
}
return false;
}
void SubscriberDeviceList::to_json(Poco::JSON::Object &Obj) const {
field_to_json( Obj,"subscriberDevices", subscriberDevices);
}
bool SubscriberDeviceList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json( Obj,"subscriberDevices", subscriberDevices);
return true;
} catch(...) {
@@ -773,18 +1053,18 @@ namespace OpenWifi::ProvObjects {
}
void VenueDeviceList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj,"id",id);
RESTAPI_utils::field_to_json(Obj,"name",name);
RESTAPI_utils::field_to_json(Obj,"description",description);
RESTAPI_utils::field_to_json(Obj,"devices",devices);
field_to_json(Obj,"id",id);
field_to_json(Obj,"name",name);
field_to_json(Obj,"description",description);
field_to_json(Obj,"devices",devices);
}
bool VenueDeviceList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj,"id",id);
RESTAPI_utils::field_from_json(Obj,"name",name);
RESTAPI_utils::field_from_json(Obj,"description",description);
RESTAPI_utils::field_from_json(Obj,"devices",devices);
field_from_json(Obj,"id",id);
field_from_json(Obj,"name",name);
field_from_json(Obj,"description",description);
field_from_json(Obj,"devices",devices);
return true;
} catch(...) {
@@ -843,5 +1123,47 @@ namespace OpenWifi::ProvObjects {
return true;
}
void WebSocketNotificationContent::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"title",title);
field_to_json(Obj,"type",type);
field_to_json(Obj,"success",success);
field_to_json(Obj,"errors",errors);
field_to_json(Obj,"warnings",warnings);
field_to_json(Obj,"timeStamp",timeStamp);
field_to_json(Obj,"details",details);
}
bool WebSocketNotificationContent::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"title",title);
field_from_json(Obj,"type",type);
field_from_json(Obj,"success",success);
field_from_json(Obj,"errors",errors);
field_from_json(Obj,"warnings",warnings);
field_from_json(Obj,"timeStamp",timeStamp);
field_from_json(Obj,"details",details);
return true;
} catch(...) {
}
return false;
}
void WebSocketNotification::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"notification_id",notification_id);
field_to_json(Obj,"content",content);
}
bool WebSocketNotification::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"notification_id",notification_id);
field_from_json(Obj,"content",content);
return true;
} catch(...) {
}
return false;
}
}

View File

@@ -33,6 +33,13 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct SerialNumberList {
Types::UUIDvec_t serialNumbers;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ManagementPolicyEntry {
Types::UUIDvec_t users;
Types::UUIDvec_t resources;
@@ -193,6 +200,51 @@ 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 subscriberDeviceId;
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 SubLocation {
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;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
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
@@ -256,6 +308,55 @@ 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 subscriberDeviceId;
Types::UUID_t managementPolicy;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct SubContact {
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;
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;
@@ -268,7 +369,7 @@ namespace OpenWifi::ProvObjects {
typedef std::vector<DeviceConfigurationElement> DeviceConfigurationElementVec;
struct DeviceConfiguration {
ObjectInfo info;
ObjectInfo info;
Types::UUID_t managementPolicy;
Types::StringVec deviceTypes;
DeviceConfigurationElementVec configuration;
@@ -287,6 +388,7 @@ namespace OpenWifi::ProvObjects {
};
typedef std::vector<DeviceConfiguration> DeviceConfigurationVec;
struct InventoryTag {
ObjectInfo info;
std::string serialNumber;
@@ -362,20 +464,20 @@ namespace OpenWifi::ProvObjects {
};
struct UuidList {
std::vector<std::string> list;
Types::UUIDvec_t list;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
enum ACLACCESS {
NONE, READ, MODIFY, CREATE, DELETE
NONE = 0, READ=1, MODIFY=2, CREATE=3, DELETE=4
};
struct ObjectACL {
UuidList users;
UuidList roles;
ACLACCESS access = NONE;
uint64_t access = (uint64_t) NONE;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -388,13 +490,6 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
enum VISIBILITY {
PUBLIC, PRIVATE, SELECT
};
std::string to_string(VISIBILITY A);
VISIBILITY visibility_from_string(const std::string &V);
struct Map {
ObjectInfo info;
std::string data;
@@ -481,6 +576,28 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct Operator {
ObjectInfo info;
Types::UUID_t managementPolicy;
Types::UUIDvec_t managementRoles;
std::string rrm;
std::string firmwareUpgrade;
bool firmwareRCOnly=true;
std::vector<Variable> variables;
bool defaultOperator=false;
Types::StringVec sourceIP;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct OperatorList {
std::vector<Operator> operators;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct VenueDeviceList {
std::string id;
std::string name;
@@ -491,6 +608,80 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ServiceClass {
ObjectInfo info;
Types::UUID_t operatorId;
Types::UUID_t managementPolicy;
double cost=0.0;
std::string currency;
std::string period;
std::string billingCode;
std::vector<Variable> variables;
bool defaultService=false;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ServiceClassList {
std::vector<ServiceClass> serviceClasses;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct SubscriberDevice {
ObjectInfo info;
std::string serialNumber;
std::string deviceType;
Types::UUID_t operatorId;
Types::UUID_t subscriberId;
SubLocation location;
SubContact contact;
Types::UUID_t managementPolicy;
Types::UUID_t serviceClass;
std::string qrCode;
std::string geoCode;
std::string rrm;
std::string state;
std::string locale;
std::string billingCode;
DeviceConfigurationElementVec configuration;
bool suspended=false;
std::string realMacAddress;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct SubscriberDeviceList {
std::vector<SubscriberDevice> subscriberDevices;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct WebSocketNotificationContent {
std::string title,
type,
details;
std::vector<std::string> success,
errors,
warnings;
uint64_t timeStamp=std::time(nullptr);
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct WebSocketNotification {
inline static uint64_t xid=1;
uint64_t notification_id=++xid;
WebSocketNotificationContent content;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);

View File

@@ -301,6 +301,20 @@ namespace OpenWifi::SecurityObjects {
return false;
};
void UserInfoList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"users",users);
}
bool UserInfoList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"users",users);
return true;
} catch (...) {
std::cout << "Cannot parse: InternalServiceInfo" << std::endl;
}
return false;
}
void InternalServiceInfo::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"privateURI",privateURI);
field_to_json(Obj,"publicURI",publicURI);

View File

@@ -146,6 +146,13 @@ namespace OpenWifi {
};
typedef std::vector<UserInfo> UserInfoVec;
struct UserInfoList {
std::vector<UserInfo> users;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
// bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
bool MergeNotes(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes);

View File

@@ -1994,6 +1994,14 @@ namespace OpenWifi {
return false;
}
template <typename T> bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, const T &value, T & assignee) {
if(O->has(Field)) {
assignee = value;
return true;
}
return false;
}
inline void AddCORS() {
auto Origin = Request->find("Origin");
if (Origin != Request->end()) {