EventScheduler
Overview
Event Scheduler API implementation.
This API provides functionality solely related to Event Tasks. For scheduled tasks, check TaskScheduler
.
Supported methods
- Getters :
- Get task results
- Get result output
- Setters :
- Set task settings
- Actions :
- Enable task
- Disable task
- Run task
- Delete task
- Create task
Methods
get_task_results
Retrieve the results list for a specific task.
Internal API
SYNO.Core.EventScheduler
Parameters
task_name str
Name of the Event task to enable/disable.
Returns
dict[str, object]
A dictionary containing the task results.
Example return
Click to expand
{
"data": [
{
"event_fire_time": "2024-09-13 03:17:47",
"exit_info": {
"exit_code": 0,
"exit_type": "stop"
},
"extra": {},
"pid": 16058,
"result_id": 115,
"run_time_env": {},
"start_time": "2024-09-13 03:17:47",
"stop_time": "2024-09-13 03:17:47",
"task_name": "asd",
"trigger_event": "on_demand"
}
],
"success": true
}
get_result_output
Retrieve the output for a given result.
Parameters
task_name : str
Name of the Event task to enable/disable.
result_id : int
ID of the result to retrieve. From get_task_results()
.
Returns
dict[str, object]
A dictionary containing the result output.
Example return
{
"data": {
"script_in": "hello",
"script_out": "/volume3/datastore/scripts_output/asd/1726190267/script.log: line 1: hello: command not found
"
},
"success": true
}
Internal API
SYNO.Core.EventScheduler
task_set_enable
Enable or disable Event task.
Internal API
SYNO.Core.EventScheduler
Parameters
task_name str
Name of the Event task to enable/disable.
enable (bool) ``
Wheter to enable (True
) or disable (False
) the task.
Returns
dict[str, object]
A dictionary containing the result of the action.
Example return
Click to expand
{
"success": true
}
task_run
Run a specific Event task.
Internal API
SYNO.Core.EventScheduler
Parameters
task_name str
Name of the Event task to run.
Returns
dict[str, object]
A dictionary containing the result of the task execution.
Example return
Click to expand
{
"success": true
}
task_delete
Delete a specific Event task.
Internal API
SYNO.Core.EventScheduler
Parameters
task_name str
Name of the Event task to run.
Returns
dict[str, object]
A dictionary containing the result of the task deletion.
task_create_or_set
Create or modify an event-based task.
Internal API
SYNO.Core.EventScheduler
Parameters
action str
Action to perform on the task.
Possible values:
create
-> Creates a new task.set
-> Modify an existing task.
task_name str
The name of the task.
owner dict[str, str]
Dictionary containing the owner's ID and name (e.g., {"1026": "user1"}
).
You can get the user UID by running synouser --get your_user
in your NAS CLI.
For root privileges, pass {"0":"root"}
.
trigger_event str
The event that triggers the task.
Possible values:
shutdown
bootup
script str
The script to be executed when the task is triggered.
depend_on_task list[str]
A list of event triggered task names that this task depends on (i.e., tasks that will be run before this one). Defaults to []
.
enable bool
Whether to enable the task. Defaults to True
.
notify_email str
Email address to send notifications to. Defaults to ""
, thus disabling the notification feature.
notify_only_on_error bool
If True
, notifications are only sent when an error occurs. Defaults to False
.
Returns
dict[str, object]
A dictionary containing the result of the task creation or modification, or a strnig in case of an error.
Example return
Click to expand
{
"success": true
}