From d0df73fa86f96865f2448dd31b59fcdc7bd74104 Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Tue, 27 Jul 2021 15:42:12 -0700 Subject: [PATCH] Fixing uptime. --- build | 2 +- src/RESTAPI_protocol.h | 38 ++++++++++++++++++++++-- src/RESTAPI_system_command.cpp | 54 +++++++--------------------------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/build b/build index fa59ff27..50f0bcd3 100644 --- a/build +++ b/build @@ -1 +1 @@ -134 \ No newline at end of file +135 \ No newline at end of file diff --git a/src/RESTAPI_protocol.h b/src/RESTAPI_protocol.h index c3a12942..c7c8d49e 100644 --- a/src/RESTAPI_protocol.h +++ b/src/RESTAPI_protocol.h @@ -72,9 +72,7 @@ namespace uCentral::RESTAPI::Protocol { static const char * REASON = "reason"; static const char * FILEUUID = "uuid"; static const char * USERID = "userId"; - static const char * USERS = "users"; static const char * PASSWORD = "password"; - static const char * NEWPASSWORD = "newPassword"; static const char * TOKEN = "token"; static const char * SETLOGLEVEL = "setloglevel"; static const char * GETLOGLEVELS = "getloglevels"; @@ -89,6 +87,42 @@ namespace uCentral::RESTAPI::Protocol { static const char * LIST = "list"; static const char * TAG = "tag"; static const char * TAGLIST = "tagList"; + static const char * DESCRIPTION = "description"; + static const char * NOTES = "notes"; + static const char * DEVICETYPE = "deviceType"; + static const char * REVISION = "revision"; + static const char * AGES = "ages"; + static const char * REVISIONS = "revisions"; + static const char * DEVICETYPES = "deviceTypes"; + static const char * LATESTONLY = "latestOnly"; + static const char * IDONLY = "idOnly"; + static const char * REVISIONSET = "revisionSet"; + static const char * DEVICESET = "deviceSet"; + static const char * HISTORY = "history"; + static const char * ID = "id"; + static const char * VERSION = "version"; + static const char * TIMES = "times"; + static const char * UPTIME = "uptime"; + static const char * START = "start"; + + static const char * NEWPASSWORD = "newPassword"; + static const char * USERS = "users"; + + static const char * ERRORTEXT = "errorText"; + static const char * ERRORCODE = "errorCode"; + static const char * AVATARID = "avatarId"; + static const char * UNNAMED = "(unnamed)"; + static const char * UNSPECIFIED = "(unspecified)"; + static const char * CONTENTDISPOSITION = "Content-Disposition"; + static const char * CONTENTTYPE = "Content-Type"; + + static const char * REQUIREMENTS = "requirements"; + static const char * PASSWORDPATTERN = "passwordPattern"; + static const char * ACCESSPOLICY = "accessPolicy"; + static const char * PASSWORDPOLICY = "passwordPolicy"; + static const char * FORGOTPASSWORD = "forgotPassword"; + static const char * ME = "me"; + } #endif // UCENTRALGW_RESTAPI_PROTOCOL_H diff --git a/src/RESTAPI_system_command.cpp b/src/RESTAPI_system_command.cpp index a29ca17c..23b84678 100644 --- a/src/RESTAPI_system_command.cpp +++ b/src/RESTAPI_system_command.cpp @@ -13,40 +13,6 @@ #include "Daemon.h" #include "RESTAPI_protocol.h" -/* - - SystemCommandDetails: - type: object - properties: - command: - type: string - enum: - - setloglevel - - getloglevel - - stats - parameters: - type: array - items: - properties: - name: - type: string - value: - type: string - - SystemCommandResults: - type: object - properties: - command: - type: string - result: - type: integer - resultTxt: - type: array - items: - type: string - - */ - namespace uCentral { void RESTAPI_system_command::handleRequest(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) { @@ -134,26 +100,26 @@ namespace uCentral { void RESTAPI_system_command::DoGet(Poco::Net::HTTPServerRequest &Request, Poco::Net::HTTPServerResponse &Response) { try { ParseParameters(Request); - auto Command = GetParameter("command", ""); - if (!Poco::icompare(Command, "version")) { + auto Command = GetParameter(RESTAPI::Protocol::COMMAND, ""); + if (!Poco::icompare(Command, RESTAPI::Protocol::VERSION)) { Poco::JSON::Object Answer; - Answer.set("tag", "version"); - Answer.set("value", Daemon()->Version()); + Answer.set(RESTAPI::Protocol::TAG, RESTAPI::Protocol::VERSION); + Answer.set(RESTAPI::Protocol::VALUE, Daemon()->Version()); ReturnObject(Request, Answer, Response); return; } - if (!Poco::icompare(Command, "times")) { + if (!Poco::icompare(Command, RESTAPI::Protocol::TIMES)) { Poco::JSON::Array Array; Poco::JSON::Object Answer; Poco::JSON::Object UpTimeObj; - UpTimeObj.set("tag","uptime"); - UpTimeObj.set("value", Daemon()->uptime().totalSeconds()); + UpTimeObj.set(RESTAPI::Protocol::TAG,RESTAPI::Protocol::UPTIME); + UpTimeObj.set(RESTAPI::Protocol::VALUE, Daemon()->uptime().totalSeconds()); Poco::JSON::Object StartObj; - StartObj.set("tag","start"); - StartObj.set("value", Daemon()->startTime().epochTime()); + StartObj.set(RESTAPI::Protocol::TAG,RESTAPI::Protocol::START); + StartObj.set(RESTAPI::Protocol::VALUE, Daemon()->startTime().epochTime()); Array.add(UpTimeObj); Array.add(StartObj); - Answer.set("times", Array); + Answer.set(RESTAPI::Protocol::TIMES, Array); ReturnObject(Request, Answer, Response); return; }