diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-06-04 12:46:15 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-06-10 17:00:01 +0200 |
commit | 1fdb7e6d1cf0709b1079b2d9990c0d53d8740461 (patch) | |
tree | e13f19f28e2ee379150171bad00fecec59168901 /src/json.h | |
parent | 893101ffc6162d64cfbe5827c32d4e6de5e35f42 (diff) |
#915 Add commands and procedures to procedure creation
Adds the possibility to create a procedure with commands and other
procedures integrated as steps.
Note: "steps" parameter is optional and "steps" array object order
defines execution order.
Request:
POST /procedure/add
{
"center": "1",
"name": "procedure",
"description": "My procedure",
"steps": [
{
"command": "wol",
"params": { "type": "broadcast" }
},
{
"procedure": 22
},
{
"command": "poweroff",
"params": {}
}
]
}
Response:
200 OK
This commit also updates unit tests for /procedure/add POST method to
include steps.
Diffstat (limited to 'src/json.h')
-rw-r--r-- | src/json.h | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -98,4 +98,31 @@ struct og_cmd_json { uint32_t flags; }; +enum og_procedure_step_type { + OG_STEP_COMMAND = 0, + OG_STEP_PROCEDURE, +}; + +#define OG_PROCEDURE_STEPS_MAX 256 + +struct og_procedure_step { + enum og_procedure_step_type type; + uint32_t position; + + union { + struct og_cmd_json cmd; + struct { + uint64_t id; + } procedure; + }; +}; + +struct og_procedure { + uint64_t id; + struct og_procedure_step steps[OG_PROCEDURE_STEPS_MAX]; + uint32_t num_steps; +}; + +int og_json_parse_procedure(json_t *element, struct og_procedure *proc); + #endif |