summaryrefslogtreecommitdiffstats
path: root/src/rest.h
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-05-10 17:18:15 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-05-18 16:50:14 +0200
commitdf5161ebc351df35504bd6366526a544ff6a96da (patch)
tree4ced41a36a5219a32dc41459258be9852a4f9094 /src/rest.h
parentf03425e6aeb95fe25253ed541565378c78b6eea1 (diff)
#915 Add last_cmd to GET /clients API
"last_cmd" json object contains information of the last command executed by the correspondent client. For now, it only includes "result" string property, which stores "success" if the last command finished correctly or "failure" on the contrary. To populate "result" property, this commit also adds "last_cmd_result" enum attribute to og_client struct. Client response processing fills this attribute according to its success. Clients in WOL_SENT state always have last_cmd->result = "unknown". Request: GET /clients Response: 200 OK { "clients": [ { "addr": "10.141.10.102", "state": "WOL_SENT", "last_cmd": { "result": "unknown" } }, { "addr": "10.141.10.101", "state": "OPG", "speed": 1000, "last_cmd": { "result": "success" } }, { "addr": "10.141.10.100", "state": "OPG", "speed": 1000, "last_cmd": { "result": "failure" } } ] }
Diffstat (limited to 'src/rest.h')
-rw-r--r--src/rest.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/rest.h b/src/rest.h
index d586ef6..df6b225 100644
--- a/src/rest.h
+++ b/src/rest.h
@@ -42,6 +42,12 @@ enum og_cmd_type {
OG_CMD_MAX
};
+enum og_cmd_result {
+ OG_UNKNOWN = 0,
+ OG_FAILURE = 1,
+ OG_SUCCESS = 2,
+};
+
#define OG_MSG_REQUEST_MAXLEN 131072
struct og_client {
@@ -59,6 +65,7 @@ struct og_client {
enum og_client_status status;
enum og_cmd_type last_cmd;
unsigned int last_cmd_id;
+ enum og_cmd_result last_cmd_result;
bool autorun;
uint32_t speed;
const char *shell_output;