summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/includes/restfunctions.php
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2020-01-30 12:22:55 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-02 12:32:36 +0200
commit77c09c6b7d6f4d613c7d550d727466d2d11ff3bd (patch)
treee5837ca361e46ae69bfaa6c0d12646125a689ceb /admin/WebConsole/includes/restfunctions.php
parent5a9ed93cd193065c4476c2af566d21f146f9397d (diff)
#942 add create/delete schedule api to web (web)
Web updates for #942 Add support for scheduled tasks and commands
Diffstat (limited to 'admin/WebConsole/includes/restfunctions.php')
-rw-r--r--admin/WebConsole/includes/restfunctions.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index 4813c010..828a2bef 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -27,6 +27,8 @@ define('OG_REST_CMD_RESTORE_BASIC_IMAGE', 'image/restore/basic');
define('OG_REST_CMD_RESTORE_INCREMENTAL_IMAGE', 'image/restore/incremental');
define('OG_REST_CMD_RUN_SCHEDULE', 'run/schedule');
define('OG_REST_CMD_RUN_TASK', 'task/run');
+define('OG_REST_CMD_CREATE_SCHEDULE', 'schedule/create');
+define('OG_REST_CMD_DELETE_SCHEDULE', 'schedule/delete');
define('OG_REST_PARAM_CLIENTS', 'clients');
define('OG_REST_PARAM_ADDR', 'addr');
@@ -61,6 +63,13 @@ define('OG_REST_PARAM_DIFF_NAME', 'diff_name');
define('OG_REST_PARAM_METHOD', 'method');
define('OG_REST_PARAM_ECHO', 'echo');
define('OG_REST_PARAM_TASK', 'task');
+define('OG_REST_PARAM_TIME_PARAMS', 'time_params');
+define('OG_REST_PARAM_YEARS', 'years');
+define('OG_REST_PARAM_MONTHS', 'months');
+define('OG_REST_PARAM_DAYS', 'days');
+define('OG_REST_PARAM_HOURS', 'hours');
+define('OG_REST_PARAM_AM_PM', 'am_pm');
+define('OG_REST_PARAM_MINUTES', 'minutes');
$conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmServer.cfg');
define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['APITOKEN']);
@@ -551,6 +560,34 @@ function run_task($task_id) {
return common_request(OG_REST_CMD_RUN_TASK, POST, $data);
}
+function create_schedule($task_id, $name, $years, $months, $days, $hours,
+ $am_pm, $minutes) {
+
+ $data = array (
+ OG_REST_PARAM_TASK => $task_id,
+ OG_REST_PARAM_NAME => $name,
+ OG_REST_PARAM_TIME_PARAMS => array (
+ OG_REST_PARAM_YEARS => intval($years),
+ OG_REST_PARAM_MONTHS => intval($months),
+ OG_REST_PARAM_DAYS => intval($days),
+ OG_REST_PARAM_HOURS => intval($hours),
+ OG_REST_PARAM_AM_PM => intval($am_pm),
+ OG_REST_PARAM_MINUTES => intval($minutes)
+ )
+ );
+
+ return common_request(OG_REST_CMD_CREATE_SCHEDULE, POST, $data);
+}
+
+function delete_schedule($schedule_id) {
+
+ $data = array (
+ OG_REST_PARAM_ID => $schedule_id,
+ );
+
+ return common_request(OG_REST_CMD_DELETE_SCHEDULE, POST, $data);
+}
+
/*
* @function multiRequest.
* @param URLs array (may include header and POST data), cURL options array.