From 5e33881a4e6d261d32bf27de189aec746cd65d51 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Sat, 18 Sep 2021 22:18:00 -0700 Subject: [PATCH] Adding system reload --- build | 2 +- openapi/ucentralfws.yaml | 118 ++++++++++++++++++++++++--------- src/RESTAPI_system_command.cpp | 6 +- 3 files changed, 92 insertions(+), 34 deletions(-) diff --git a/build b/build index 8580e7b..1758ddd 100644 --- a/build +++ b/build @@ -1 +1 @@ -30 \ No newline at end of file +32 \ No newline at end of file diff --git a/openapi/ucentralfws.yaml b/openapi/ucentralfws.yaml index f81a57a..bf15b85 100644 --- a/openapi/ucentralfws.yaml +++ b/openapi/ucentralfws.yaml @@ -294,28 +294,6 @@ components: items: $ref: '#/components/schemas/TagIntPair' - SystemCommandDetails: - type: object - properties: - command: - type: string - enum: - - setloglevels - - getloglevels - - getSubSystemNames - - getLogLevelNames - - stats - parameters: - oneOf: - - $ref: '#/components/schemas/StringList' - - $ref: '#/components/schemas/TagValuePairList' - - SystemCommandResults: - type: object - oneOf: - - $ref: '#/components/schemas/StringList' - - $ref: '#/components/schemas/TagValuePairList' - NoteInfo: type: object properties: @@ -345,12 +323,84 @@ components: hostname: type: string -######################################################################################### -## -## End of uCentral system wide values -## -######################################################################################### + SystemCommandSetLogLevel: + type: object + properties: + command: + type: string + enum: + - setloglevel + subsystems: + type: array + items: + $ref: '#/components/schemas/TagValuePair' + SystemCommandReload: + type: object + properties: + command: + type: string + enum: + - reload + subsystems: + type: array + items: + type: string + example: these are the SubSystems names retrieve with the GetSubSystemsNamesResult. + + SystemCommandGetLogLevels: + type: object + properties: + command: + type: string + enum: + - getloglevels + + SystemGetLogLevelsResult: + type: object + properties: + taglist: + type: array + items: + $ref: '#/components/schemas/TagValuePair' + + SystemCommandGetLogLevelNames: + type: object + properties: + command: + type: string + enum: + - getloglevelnames + + SystemCommandGetSubsystemNames: + type: object + properties: + command: + type: string + enum: + - getsubsystemnames + + SystemCommandGetLogLevelNamesResult: + type: object + properties: + list: + type: array + items: + type: string + + SystemGetSubSystemNemesResult: + type: object + properties: + taglist: + type: array + items: + $ref: '#/components/schemas/TagValuePair' + +######################################################################################### +## +## End of uCentral system-wide values +## +######################################################################################### paths: /firmwares: get: @@ -722,21 +772,29 @@ paths: post: tags: - System Commands - summary: Perform some systeme wide commands + summary: Perform some system wide commands operationId: systemCommand requestBody: description: Command details content: application/json: schema: - $ref: '#/components/schemas/SystemCommandDetails' + oneOf: + - $ref: '#/components/schemas/SystemCommandSetLogLevel' + - $ref: '#/components/schemas/SystemCommandReload' + - $ref: '#/components/schemas/SystemCommandGetLogLevels' + - $ref: '#/components/schemas/SystemCommandGetLogLevelNames' + - $ref: '#/components/schemas/SystemCommandGetSubsystemNames' responses: 200: description: Successfull command execution content: application/json: schema: - $ref: '#/components/schemas/SystemCommandResults' + oneOf: + - $ref: '#/components/schemas/SystemGetLogLevelsResult' + - $ref: '#/components/schemas/SystemCommandGetLogLevelNamesResult' + - $ref: '#/components/schemas/SystemGetSubSystemNemesResult' 403: $ref: '#/components/responses/Unauthorized' 404: diff --git a/src/RESTAPI_system_command.cpp b/src/RESTAPI_system_command.cpp index 947d28d..cacc94a 100644 --- a/src/RESTAPI_system_command.cpp +++ b/src/RESTAPI_system_command.cpp @@ -24,9 +24,9 @@ namespace OpenWifi { if (Obj->has(RESTAPI::Protocol::COMMAND)) { auto Command = Poco::toLower(Obj->get(RESTAPI::Protocol::COMMAND).toString()); if (Command == RESTAPI::Protocol::SETLOGLEVEL) { - if (Obj->has(RESTAPI::Protocol::PARAMETERS) && - Obj->isArray(RESTAPI::Protocol::PARAMETERS)) { - auto ParametersBlock = Obj->getArray(RESTAPI::Protocol::PARAMETERS); + if (Obj->has(RESTAPI::Protocol::SUBSYSTEMS) && + Obj->isArray(RESTAPI::Protocol::SUBSYSTEMS)) { + auto ParametersBlock = Obj->getArray(RESTAPI::Protocol::SUBSYSTEMS); for (const auto &i : *ParametersBlock) { Poco::JSON::Parser pp; auto InnerObj = pp.parse(i).extract();