diff --git a/openapi/owgw.yaml b/openapi/owgw.yaml index 588337a8..0f0cee91 100644 --- a/openapi/owgw.yaml +++ b/openapi/owgw.yaml @@ -554,7 +554,7 @@ components: enum: - ap - switch - default: AP + default: ap DefaultConfigurationList: properties: diff --git a/src/RESTAPI/RESTAPI_default_configuration.cpp b/src/RESTAPI/RESTAPI_default_configuration.cpp index 2f8ddc17..33b605a3 100644 --- a/src/RESTAPI/RESTAPI_default_configuration.cpp +++ b/src/RESTAPI/RESTAPI_default_configuration.cpp @@ -56,23 +56,23 @@ namespace OpenWifi { return BadRequest(RESTAPI::Errors::InvalidJSONDocument); } - if (DefConfig.Models.empty()) { + if (DefConfig.models.empty()) { return BadRequest(RESTAPI::Errors::ModelIDListCannotBeEmpty); } - DefConfig.Platform = DefConfig.Platform.empty() ? Platforms::AP : DefConfig.Platform; - if(DefConfig.Platform != Platforms::AP && DefConfig.Platform != Platforms::SWITCH) { + DefConfig.platform = DefConfig.platform.empty() ? Platforms::AP : DefConfig.platform; + if(DefConfig.platform != Platforms::AP && DefConfig.platform != Platforms::SWITCH) { return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters); } std::string Error; - if (!ValidateUCentralConfiguration(ConfigurationValidator::GetType(DefConfig.Platform), - DefConfig.Configuration, Error, + if (!ValidateUCentralConfiguration(ConfigurationValidator::GetType(DefConfig.platform), + DefConfig.configuration, Error, GetBoolParameter("strict", false))) { return BadRequest(RESTAPI::Errors::ConfigBlockInvalid, Error); } - DefConfig.Created = DefConfig.LastModified = Utils::Now(); + DefConfig.created = DefConfig.lastModified = Utils::Now(); if (StorageService()->CreateDefaultConfiguration(Name, DefConfig)) { return OK(); } @@ -94,31 +94,31 @@ namespace OpenWifi { return NotFound(); } - if(Existing.Platform.empty()) { - Existing.Platform = Platforms::AP; + if(Existing.platform.empty()) { + Existing.platform = Platforms::AP; } if(ParsedBody_->has("platform")) { - if(NewConfig.Platform.empty() || (NewConfig.Platform != Platforms::AP && NewConfig.Platform != Platforms::SWITCH)) { + if(NewConfig.platform.empty() || (NewConfig.platform != Platforms::AP && NewConfig.platform != Platforms::SWITCH)) { return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters); } - Existing.Platform = NewConfig.Platform; + Existing.platform = NewConfig.platform; } - if (!NewConfig.Configuration.empty()) { + if (!NewConfig.configuration.empty()) { std::string Error; - if (!ValidateUCentralConfiguration(ConfigurationValidator::GetType(Existing.Platform), - NewConfig.Configuration, Error, + if (!ValidateUCentralConfiguration(ConfigurationValidator::GetType(Existing.platform), + NewConfig.configuration, Error, GetBoolParameter("strict", false))) { return BadRequest(RESTAPI::Errors::ConfigBlockInvalid, Error); } - Existing.Configuration = NewConfig.Configuration; + Existing.configuration = NewConfig.configuration; } - Existing.LastModified = Utils::Now(); - AssignIfPresent(Obj, "description", Existing.Description); + Existing.lastModified = Utils::Now(); + AssignIfPresent(Obj, "description", Existing.description); if (Obj->has("modelIds")) - Existing.Models = NewConfig.Models; + Existing.models = NewConfig.models; if (StorageService()->UpdateDefaultConfiguration(Name, Existing)) { GWObjects::DefaultConfiguration ModifiedConfig; diff --git a/src/RESTObjects/RESTAPI_GWobjects.cpp b/src/RESTObjects/RESTAPI_GWobjects.cpp index c796c4bb..adabb0d6 100644 --- a/src/RESTObjects/RESTAPI_GWobjects.cpp +++ b/src/RESTObjects/RESTAPI_GWobjects.cpp @@ -232,24 +232,24 @@ namespace OpenWifi::GWObjects { } void DefaultConfiguration::to_json(Poco::JSON::Object &Obj) const { - EmbedDocument("configuration", Obj, Configuration); - field_to_json(Obj, "name", Name); - field_to_json(Obj, "modelIds", Models); - field_to_json(Obj, "description", Description); - field_to_json(Obj, "created", Created); - field_to_json(Obj, "lastModified", LastModified); - field_to_json(Obj, "Platform", Platform); + EmbedDocument("configuration", Obj, configuration); + field_to_json(Obj, "name", name); + field_to_json(Obj, "modelIds", models); + field_to_json(Obj, "description", description); + field_to_json(Obj, "created", created); + field_to_json(Obj, "lastModified", lastModified); + field_to_json(Obj, "platform", platform); } bool DefaultConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) { try { - field_from_json(Obj, "configuration", Configuration); - field_from_json(Obj, "name", Name); - field_from_json(Obj, "modelIds", Models); - field_from_json(Obj, "description", Description); - field_from_json(Obj, "created", Created); - field_from_json(Obj, "lastModified", LastModified); - field_from_json(Obj, "Platform", Platform); + field_from_json(Obj, "configuration", configuration); + field_from_json(Obj, "name", name); + field_from_json(Obj, "modelIds", models); + field_from_json(Obj, "description", description); + field_from_json(Obj, "created", created); + field_from_json(Obj, "lastModified", lastModified); + field_from_json(Obj, "Platform", platform); return true; } catch (const Poco::Exception &E) { } diff --git a/src/RESTObjects/RESTAPI_GWobjects.h b/src/RESTObjects/RESTAPI_GWobjects.h index f7a77275..ed17aba7 100644 --- a/src/RESTObjects/RESTAPI_GWobjects.h +++ b/src/RESTObjects/RESTAPI_GWobjects.h @@ -180,13 +180,13 @@ namespace OpenWifi::GWObjects { }; struct DefaultConfiguration { - std::string Name; - std::string Configuration; - Types::StringVec Models; - std::string Description; - uint64_t Created; - uint64_t LastModified; - std::string Platform; + std::string name; + std::string configuration; + Types::StringVec models; + std::string description; + uint64_t created; + uint64_t lastModified; + std::string platform; void to_json(Poco::JSON::Object &Obj) const; bool from_json(const Poco::JSON::Object::Ptr &Obj); }; diff --git a/src/storage/storage_defconfig.cpp b/src/storage/storage_defconfig.cpp index ef7d2c44..e38e4ae8 100644 --- a/src/storage/storage_defconfig.cpp +++ b/src/storage/storage_defconfig.cpp @@ -35,23 +35,23 @@ namespace OpenWifi { typedef std::vector DefConfigRecordList; void Convert(const DefConfigRecordTuple &R, GWObjects::DefaultConfiguration &T) { - T.Name = R.get<0>(); - T.Configuration = R.get<1>(); - T.Models = RESTAPI_utils::to_object_array(R.get<2>()); - T.Description = R.get<3>(); - T.Created = R.get<4>(); - T.LastModified = R.get<5>(); - T.Platform = R.get<6>(); + T.name = R.get<0>(); + T.configuration = R.get<1>(); + T.models = RESTAPI_utils::to_object_array(R.get<2>()); + T.description = R.get<3>(); + T.created = R.get<4>(); + T.lastModified = R.get<5>(); + T.platform = R.get<6>(); } void Convert(const GWObjects::DefaultConfiguration &R, DefConfigRecordTuple &T) { - T.set<0>(R.Name); - T.set<1>(R.Configuration); - T.set<2>(RESTAPI_utils::to_string(R.Models)); - T.set<3>(R.Description); - T.set<4>(R.Created); - T.set<5>(R.LastModified); - T.set<6>(R.Platform); + T.set<0>(R.name); + T.set<1>(R.configuration); + T.set<2>(RESTAPI_utils::to_string(R.models)); + T.set<3>(R.description); + T.set<4>(R.created); + T.set<5>(R.lastModified); + T.set<6>(R.platform); } bool Storage::CreateDefaultConfiguration(std::string &Name, @@ -71,7 +71,7 @@ namespace OpenWifi { if (!TmpName.empty()) return false; - Config::Config Cfg(DefConfig.Configuration); + Config::Config Cfg(DefConfig.configuration); if (Cfg.Valid()) { Sess.begin(); @@ -126,7 +126,7 @@ namespace OpenWifi { Poco::Data::Session Sess = Pool_->get(); Sess.begin(); Poco::Data::Statement Update(Sess); - DefConfig.LastModified = Now; + DefConfig.lastModified = Now; std::string St{"UPDATE DefaultConfigs SET Name=?, Configuration=?, Models=?, " "Description=?, Created=? , LastModified=? , Platform=? WHERE Name=?"}; @@ -236,8 +236,8 @@ namespace OpenWifi { for (const auto &DefConfig : DefConfigs) { GWObjects::DefaultConfiguration C; Convert(DefConfig, C); - for (const auto &Model : C.Models) { - if ((Model == "*" || Model == DeviceModel) && (Config.Platform == Platform)){ + for (const auto &Model : C.models) { + if ((Model == "*" || Model == DeviceModel) && (Config.platform == Platform)){ Config = C; return true; } diff --git a/src/storage/storage_device.cpp b/src/storage/storage_device.cpp index bdc71448..5f39aa8b 100644 --- a/src/storage/storage_device.cpp +++ b/src/storage/storage_device.cpp @@ -579,7 +579,7 @@ namespace OpenWifi { if (!Found && AP_WS_Server()->UseDefaults() && FindDefaultConfigurationForModel(Caps.Compatible(), Caps.Platform(), DefConfig)) { - Config::Config NewConfig(DefConfig.Configuration); + Config::Config NewConfig(DefConfig.configuration); NewConfig.SetUUID(Now); D.Configuration = NewConfig.get(); } else if (!Found) {