Tasks

Resources related to tasks.

CronJob

The CronJob resource represents cron(8) to execute scheduled commands.

List resource

GET /api/v1.0/tasks/cronjob/

Returns a list of all cronjobs.

Example request:

GET /api/v1.0/tasks/cronjob/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
          "cron_command": "touch /tmp/xx",
          "cron_daymonth": "*",
          "cron_dayweek": "*",
          "cron_description": "",
          "cron_enabled": true,
          "cron_hour": "*",
          "cron_minute": "*",
          "cron_month": "1,2,3,4,6,7,8,9,10,11,12",
          "cron_stderr": false,
          "cron_stdout": true,
          "cron_user": "root",
          "id": 1
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/tasks/cronjob/

Creates a new cronjob and returns the new cronjob object.

Example request:

POST /api/v1.0/tasks/cronjob/ HTTP/1.1
Content-Type: application/json

  {
          "cron_user": "root",
          "cron_command": "/data/myscript.sh",
          "cron_minute": "*/20",
          "cron_hour": "*",
          "cron_daymonth": "*",
          "cron_month": "*",
          "cron_dayweek": "*",
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
          "cron_command": "/data/myscript.sh",
          "cron_daymonth": "*",
          "cron_dayweek": "*",
          "cron_description": "",
          "cron_enabled": true,
          "cron_hour": "*",
          "cron_minute": "*/20",
          "cron_month": "*",
          "cron_stderr": false,
          "cron_stdout": true,
          "cron_user": "root",
          "id": 2
  }
JSON Parameters:
 
  • cron_command (string) – command to execute
  • cron_daymonth (string) – days of the month to run
  • cron_dayweek (string) – days of the week to run
  • cron_description (string) – description of the job
  • cron_enabled (boolean) – job enabled?
  • cron_hour (string) – hours to run
  • cron_minute (string) – minutes to run
  • cron_month (string) – months to run
  • cron_user (string) – user to run
  • cron_stderr (boolean) – redirect stderr to /dev/null
  • cron_stdout (boolean) – redirect stdout to /dev/null
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Update resource

PUT /api/v1.0/tasks/cronjob/(int: id)/

Update cronjob id.

Example request:

PUT /api/v1.0/tasks/cronjob/2/ HTTP/1.1
Content-Type: application/json

  {
          "cron_enabled": false,
          "cron_stderr": true
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
          "cron_command": "/data/myscript.sh",
          "cron_daymonth": "*",
          "cron_dayweek": "*",
          "cron_description": "",
          "cron_enabled": false,
          "cron_hour": "*",
          "cron_minute": "*/20",
          "cron_month": "*",
          "cron_stderr": true,
          "cron_stdout": true,
          "cron_user": "root",
          "id": 2
  }
JSON Parameters:
 
  • cron_command (string) – command to execute
  • cron_daymonth (string) – days of the month to run
  • cron_dayweek (string) – days of the week to run
  • cron_description (string) – description of the job
  • cron_enabled (boolean) – job enabled?
  • cron_hour (string) – hours to run
  • cron_minute (string) – minutes to run
  • cron_month (string) – months to run
  • cron_user (string) – user to run
  • cron_stderr (boolean) – redirect stderr to /dev/null
  • cron_stdout (boolean) – redirect stdout to /dev/null
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 200 – no error

Delete resource

DELETE /api/v1.0/tasks/cronjob/(int: id)/

Delete cronjob id.

Example request:

DELETE /api/v1.0/tasks/cronjob/2/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error

Run

POST /api/v1.0/tasks/cronjob/(int: id)/run/

Start cron job of id.

Example request:

POST /api/v1.0/tasks/cronjob/1/run/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 202 Accepted
Vary: Accept
Content-Type: application/json

Cron job started.
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 202 – no error

InitShutdown

The InitShutdown resource represents Init and Shutdown scripts.

List resource

GET /api/v1.0/tasks/initshutdown/

Returns a list of all init shutdown scripts.

Example request:

GET /api/v1.0/tasks/initshutdown/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
          "id": 1
          "ini_type": "command",
          "ini_command": "rm /mnt/tank/temp*",
          "ini_when": "postinit"
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/tasks/initshutdown/

Creates a new initshutdown and returns the new initshutdown object.

Example request:

POST /api/v1.0/tasks/initshutdown/ HTTP/1.1
Content-Type: application/json

  {
          "ini_type": "command",
          "ini_command": "rm /mnt/tank/temp*",
          "ini_when": "postinit"
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
          "id": 1,
          "ini_command": "rm /mnt/tank/temp*",
          "ini_script": null,
          "ini_type": "command",
          "ini_when": "postinit"
  }
JSON Parameters:
 
  • ini_command (string) – command to execute
  • ini_script (string) – path to script to execute
  • ini_type (string) – run a command (“command”) or a script (“script”)
  • ini_when (string) – preinit, postinit, shutdown
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Update resource

PUT /api/v1.0/tasks/initshutdown/(int: id)/

Update initshutdown id.

Example request:

PUT /api/v1.0/tasks/initshutdown/1/ HTTP/1.1
Content-Type: application/json

  {
          "ini_when": "preinit"
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
          "id": 1,
          "ini_command": "rm /mnt/tank/temp*",
          "ini_script": null,
          "ini_type": "command",
          "ini_when": "preinit"
  }
JSON Parameters:
 
  • ini_command (string) – command to execute
  • ini_script (string) – path to script to execute
  • ini_type (string) – run a command (“command”) or a script (“script”)
  • ini_when (string) – preinit, postinit, shutdown
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 200 – no error

Delete resource

DELETE /api/v1.0/tasks/initshutdown/(int: id)/

Delete initshutdown id.

Example request:

DELETE /api/v1.0/tasks/initshutdown/1/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error

Rsync

The Rsync resource represents rsync(1) to execute scheduled commands.

List resource

GET /api/v1.0/tasks/rsync/

Returns a list of all rsyncs.

Example request:

GET /api/v1.0/tasks/rsync/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
          "rsync_user": "root",
          "rsync_minute": "*/20",
          "rsync_enabled": true,
          "rsync_daymonth": "*",
          "rsync_path": "/mnt/tank",
          "rsync_delete": false,
          "rsync_hour": "*",
          "id": 1,
          "rsync_extra": "",
          "rsync_archive": false,
          "rsync_compress": true,
          "rsync_dayweek": "*",
          "rsync_desc": "",
          "rsync_direction": "push",
          "rsync_times": true,
          "rsync_preserveattr": false,
          "rsync_remotehost": "testhost",
          "rsync_mode": "module",
          "rsync_remotemodule": "testmodule",
          "rsync_remotepath": "",
          "rsync_quiet": false,
          "rsync_recursive": true,
          "rsync_month": "*",
          "rsync_preserveperm": false,
          "rsync_remoteport": 22
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/tasks/rsync/

Creates a new rsync and returns the new rsync object.

Example request:

POST /api/v1.0/tasks/rsync/ HTTP/1.1
Content-Type: application/json

  {
          "rsync_path": "/mnt/tank",
          "rsync_user": "root",
          "rsync_mode": "module",
          "rsync_remotemodule": "testmodule",
          "rsync_remotehost": "testhost",
          "rsync_direction": "push",
          "rsync_minute": "*/20",
          "rsync_hour": "*",
          "rsync_daymonth": "*",
          "rsync_month": "*",
          "rsync_dayweek": "*",
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
          "rsync_user": "root",
          "rsync_minute": "*/20",
          "rsync_enabled": true,
          "rsync_daymonth": "*",
          "rsync_path": "/mnt/tank",
          "rsync_delete": false,
          "rsync_hour": "*",
          "id": 1,
          "rsync_extra": "",
          "rsync_archive": false,
          "rsync_compress": true,
          "rsync_dayweek": "*",
          "rsync_desc": "",
          "rsync_direction": "push",
          "rsync_times": true,
          "rsync_preserveattr": false,
          "rsync_remotehost": "testhost",
          "rsync_mode": "module",
          "rsync_remotemodule": "testmodule",
          "rsync_remotepath": "",
          "rsync_quiet": false,
          "rsync_recursive": true,
          "rsync_month": "*",
          "rsync_preserveperm": false,
          "rsync_remoteport": 22
  }
JSON Parameters:
 
  • rsync_path (string) – path to rsync
  • rsync_user (string) – user to run rsync(1)
  • rsync_mode (string) – module, ssh
  • rsync_remotemodule (string) – module of remote side
  • rsync_remotehost (string) – host of remote side
  • rsync_remoteport (string) – port of remote side
  • rsync_remotepath (string) – path of remote side
  • rsync_direction (string) – push, pull
  • rsync_minute (string) – minutes to run
  • rsync_hour (string) – hours to run
  • rsync_daymonth (string) – days of month to run
  • rsync_month (string) – months to run
  • rsync_dayweek (string) – days of week to run
  • rsync_archive (boolean) – archive mode
  • rsync_compress (boolean) – compress the stream
  • rsync_times (boolean) – preserve times
  • rsync_preserveattr (boolean) – preserve file attributes
  • rsync_quiet (boolean) – run quietly
  • rsync_recursive (boolean) – recursive
  • rsync_preserveperm (boolean) – preserve permissions
  • extra (string) – extra arguments to rsync(1)
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Update resource

PUT /api/v1.0/tasks/rsync/(int: id)/

Update rsync id.

Example request:

PUT /api/v1.0/tasks/rsync/1/ HTTP/1.1
Content-Type: application/json

  {
          "rsync_archive": true
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
          "rsync_user": "root",
          "rsync_minute": "*/20",
          "rsync_enabled": true,
          "rsync_daymonth": "*",
          "rsync_path": "/mnt/tank",
          "rsync_delete": false,
          "rsync_hour": "*",
          "id": 1,
          "rsync_extra": "",
          "rsync_archive": true,
          "rsync_compress": true,
          "rsync_dayweek": "*",
          "rsync_desc": "",
          "rsync_direction": "push",
          "rsync_times": true,
          "rsync_preserveattr": false,
          "rsync_remotehost": "testhost",
          "rsync_mode": "module",
          "rsync_remotemodule": "testmodule",
          "rsync_remotepath": "",
          "rsync_quiet": false,
          "rsync_recursive": true,
          "rsync_month": "*",
          "rsync_preserveperm": false,
          "rsync_remoteport": 22
  }
JSON Parameters:
 
  • rsync_path (string) – path to rsync
  • rsync_user (string) – user to run rsync(1)
  • rsync_mode (string) – module, ssh
  • rsync_remotemodule (string) – module of remote side
  • rsync_remotehost (string) – host of remote side
  • rsync_remoteport (string) – port of remote side
  • rsync_remotepath (string) – path of remote side
  • rsync_direction (string) – push, pull
  • rsync_minute (string) – minutes to run
  • rsync_hour (string) – hours to run
  • rsync_daymonth (string) – days of month to run
  • rsync_month (string) – months to run
  • rsync_dayweek (string) – days of week to run
  • rsync_archive (boolean) – archive mode
  • rsync_compress (boolean) – compress the stream
  • rsync_times (boolean) – preserve times
  • rsync_preserveattr (boolean) – preserve file attributes
  • rsync_quiet (boolean) – run quietly
  • rsync_recursive (boolean) – recursive
  • rsync_preserveperm (boolean) – preserve permissions
  • extra (string) – extra arguments to rsync(1)
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 200 – no error

Delete resource

DELETE /api/v1.0/tasks/rsync/(int: id)/

Delete rsync id.

Example request:

DELETE /api/v1.0/tasks/rsync/1/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error

Run

POST /api/v1.0/tasks/rsync/(int: id)/run/

Start rsync job of id.

Example request:

POST /api/v1.0/tasks/rsync/1/run/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 202 Accepted
Vary: Accept
Content-Type: application/json

Rsync job started.
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 202 – no error

SMARTTest

The SMARTTest resource represents schedule of SMART tests using smartd(8).

List resource

GET /api/v1.0/tasks/smarttest/

Returns a list of all smarttests.

Example request:

GET /api/v1.0/tasks/smarttest/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
          "smarttest_dayweek": "*",
          "smarttest_daymonth": "*",
          "smarttest_disks": [
                  2,
                  3
          ],
          "smarttest_month": "*",
          "smarttest_type": "L",
          "id": 1,
          "smarttest_hour": "*",
          "smarttest_desc": ""
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/tasks/smarttest/

Creates a new smarttest and returns the new smarttest object.

Example request:

POST /api/v1.0/tasks/smarttest/ HTTP/1.1
Content-Type: application/json

  {
          "smarttest_disks": [2, 3],
          "smarttest_type": "L",
          "smarttest_hour": "*",
          "smarttest_daymonth": "*",
          "smarttest_month": "*",
          "smarttest_dayweek": "*",
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
          "smarttest_dayweek": "*",
          "smarttest_daymonth": "*",
          "smarttest_disks": [
                  2,
                  3
          ],
          "smarttest_month": "*",
          "smarttest_type": "L",
          "id": 1,
          "smarttest_hour": "*",
          "smarttest_desc": ""
  }
JSON Parameters:
 
  • smarttest_dayweek (string) – days of the week to run
  • smarttest_daymonth (string) – days of the month to run
  • smarttest_hour (string) – hours to run
  • smarttest_month (string) – months to run
  • smarttest_disks (string) – list of ids of “storage/disk” resource
  • smarttest_type (string) – L (Long Self-Test), S (Short Self-Test), C (Conveyance Self-Test (ATA only)), O (Offline Immediate Test (ATA only))
  • smarttest_desc (string) – user description of the test
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Update resource

PUT /api/v1.0/tasks/smarttest/(int: id)/

Update smarttest id.

Example request:

PUT /api/v1.0/tasks/smarttest/1/ HTTP/1.1
Content-Type: application/json

  {
          "smarttest_type": "S",
          "smarttest_disks": [2, 3]
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
          "smarttest_dayweek": "*",
          "smarttest_daymonth": "*",
          "smarttest_disks": [
                  2,
                  3
          ],
          "smarttest_month": "*",
          "smarttest_type": "L",
          "id": 1,
          "smarttest_hour": "*",
          "smarttest_desc": ""
  }
JSON Parameters:
 
  • smarttest_dayweek (string) – days of the week to run
  • smarttest_daymonth (string) – days of the month to run
  • smarttest_hour (string) – hours to run
  • smarttest_month (string) – months to run
  • smarttest_disks (string) – list of ids of “storage/disk” resource
  • smarttest_type (string) – L (Long Self-Test), S (Short Self-Test), C (Conveyance Self-Test (ATA only)), O (Offline Immediate Test (ATA only))
  • smarttest_desc (string) – user description of the test
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 200 – no error

Delete resource

DELETE /api/v1.0/tasks/smarttest/(int: id)/

Delete smarttest id.

Example request:

DELETE /api/v1.0/tasks/smarttest/1/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error