Schedule

Schedule is a specification of a Task and is used to finetune Task args. A Schedule is identified by it’s id, the scheduled time of execution crontime, and it’s description. A Schedule can be active or not based on the value of active.

We are using cron format for time scheduling. For more information on how this works refer to various online resources, like this one

Scheme:

{
  "id": "UUID",
  "task_id": "UUID",
  "description": "String",
  "args": "JSON",
  "crontime": "String",
  "active": "Boolean"
}

Example:

{
  "id": "986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02",
  "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
  "description": "run every 8 hours",
  "args": {
    "part_id": "1"
  },
  "crontime": "0 0/8 * * *",
  "active": true
}

GET methods

GET /api/v1/schedules

Returns all schedules with their relative information if at least one resource exists, otherwise returns an empty collection. Request can contain a page parameter that returns a specific page, additionally total number of pages, next page, previous page and other information are described in the response header.

Example request:

GET /api/v1/schedules HTTP/1.1
Host: https://scheduler.hid.facts4.work

Example response:

HTTP/1.1 200 OK
Content-type: application/json

[
  {
    "id": "986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02",
    "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
    "description": "run every 8 hours",
    "args": {
      "part_id": "1"
    },
    "crontime": "0 0/8 * * *",
    "active": true
  }
]
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Response JSON Array of Objects:
 
  • id (string) – id of the schedule
  • task_id (string) – id of the task relative to schedule
  • description (string) – description of the schedule
  • args (json) – argument values of arguments required by task
  • crontime (string) – scheduled time of execution
  • active (boolean) – wether the schedule will execute or not
Status Codes:
GET /api/v1/schedules/:id

Returns a specific schedule with :id and the rest of its parameters if it exists, otherwise returns 404 error.

Example request:

GET /api/v1/schedule/986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02 HTTP/1.1
Host: https://scheduler.hid.facts4.work

Example response:

HTTP/1.1 200 OK
Content-type: application/json

{
  "id": "986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02",
  "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
  "description": "run every 8 hours",
  "args": {
    "part_id": "1"
  },
  "crontime": "0 0/8 * * *",
  "active": true
}
Parameters:
  • id (string) – schedule’s unique id
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Response JSON Object:
 
  • id (string) – id of the schedule
  • task_id (string) – id of the task relative to schedule
  • description (string) – description of the schedule
  • args (json) – argument values of arguments required by task
  • crontime (string) – scheduled time of execution
  • active (boolean) – wether the schedule will execute or not
Status Codes:

POST methods

POST /api/v1/schedules

Adds a new schedule. id is generated server-side. Returns the new resource or error message.

Note: Do not execute twice the same POST request for it will create two resources with the same information.

Example request:

POST /api/v1/schedules HTTP/1.1
Host: https://scheduler.hid.facts4.work
Content-Type: application/json

{
  "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
  "description": "run every 8 hours",
  "args": {
    "part_id": "1"
  },
  "crontime": "0 0/8 * * *",
}

Example response:

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

{
  "id": "986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02",
  "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
  "description": "run every 8 hours",
  "args": {
    "part_id": "1"
  },
  "crontime": "0 0/8 * * *",
  "active": true
}
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Request JSON Object:
 
  • task_id (string) – id of the task relative to schedule
  • description (string) – description of the schedule
  • args (json) – argument values of arguments required by task
  • crontime (string) – scheduled time of execution
  • active (boolean) – active status, defaults to true
Response JSON Object:
 
  • id (string) – id of the schedule
  • task_id (string) – id of the task relative to schedule
  • description (string) – description of the schedule
  • args (json) – argument values of arguments required by task
  • crontime (string) – scheduled time of execution
  • active (boolean) – wether the schedule will execute or not
Status Codes:

PUT methods

PUT /api/v1/schedules/:id

Updates an existing schedule with new information. Returns the new resource or error message.

Note: All parameters must be defined with the PUT request, ie. PUT request replaces the existing resource with the modified one if it exists, or creates a new one.

Example request:

PUT /api/v1/schedules/986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02 HTTP/1.1
Host: https://scheduler.hid.facts4.work
Content-Type: application/json

{
  "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
  "description": "run every 8 hours - DISABLED",
  "args": {
    "part_id": "1"
  },
  "crontime": "0 0/8 * * *",
  "active": false
}

Example response:

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

{
  "id": "986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02",
  "task_id": "5880f2f1-e548-4db5-9ef3-3e23954689f4",
  "description": "run every 8 hours - DISABLED",
  "args": {
    "part_id": "1"
  },
  "crontime": "0 0/8 * * *",
  "active": false
}
Parameters:
  • id (string) – schedule’s unique id
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Request JSON Object:
 
  • task_id (string) – id of the task relative to schedule
  • description (string) – description of the schedule
  • args (json) – argument values of arguments required by task
  • crontime (string) – scheduled time of execution
  • active (boolean) – active status, defaults to true
Response JSON Object:
 
  • id (string) – id of the schedule
  • task_id (string) – id of the task relative to schedule
  • description (string) – description of the schedule
  • args (json) – argument values of arguments required by task
  • crontime (string) – scheduled time of execution
  • active (boolean) – wether the schedule will execute or not
Status Codes:

DELETE methods

DELETE /api/v1/schedules/:id

Delete an existing schedule, responds with the confirmation or error. Can only delete one resource at a time, to remove a collection of machines call the DELETE method for each element.

Example request:

DELETE /api/v1/schedules/986c6f2e-7c49-4c0b-9bb3-9566ea3e9b02 HTTP/1.1
Host: https://scheduler.hid.facts4.work

Example response:

HTTP/1.1 200 OK
Parameters:
  • id (string) – schedule’s unique id
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Status Codes: