Fixing uptime.

This commit is contained in:
stephb9959
2021-07-27 15:42:12 -07:00
parent 660570df44
commit d0df73fa86
3 changed files with 47 additions and 47 deletions

2
build
View File

@@ -1 +1 @@
134
135

View File

@@ -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

View File

@@ -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;
}