- Print
- PDF
Manage Tasks
- Print
- PDF
The Task Scheduler API helps you to manage scheduling of tasks and related operations in the Britive system.
1. Details of Task Scheduler Service
The GET method retrieves details of the task scheduler service by retrieving the task scheduler service object.
GET | {{url}}/api/tasks/services?name=environmentScanner&appId={{appId}} |
Request Example
An example GET request for retrieving the details of task scheduler service is shown here.
curl --location --request GET '{{url}}/api/tasks/services?name=environmentScanner&appId={{appId}}' \
--header 'Authorization: TOKEN {{apiToken}}'
Response Example
An example response of the GET request for retrieving the details of the task scheduler service is shown here.
Status: 200 OK |
{
"taskServiceId": "kyf2y23x0bapf06755h8",
"name": "environmentScanner",
"tenantNamespace": "tmslocal",
"appId": "omz5z2r6l934yu1xhddj",
"enabled": false,
"queueId": "ed-scheduledTaskEnvScanQueue",
"taskType": "ApplicationScanner"
}
2. Create a Task
The POST method creates a new task in the system, as indicated by the taskServiceId provided in the request path.
POST | {{url}}/api/tasks/services/{{taskServiceId}}/tasks |
Request Example
An example POST request for creating a task is shown here.
curl --location --request POST '{{url}}/api/tasks/services/{{taskServiceId}}/tasks' \
--header 'Content-Type: application/json' \
--header 'Authorization: TOKEN {{apiToken}}' \
--data-raw '{
"name": "Daily Scan All 2",
"startTime": "12:00",
"frequencyType": "Daily",
"properties": {
"appId": "omz5z2r6l934yu1xhddj",
"scope": [
{
"type": "EnvironmentGroup",
"value": "r-pak3"
}
],
"orgScan": true
}
}'
An example response of the POST request for creating a task is shown here.
Status: 200 OK |
{
"taskId": "8jsmh3b5a887swsti7q8",
"taskServiceId": "kyf2y23x0bapf06755h8",
"tenantNamespace": "tmslocal",
"name": "Daily Scan All 2",
"description": null,
"properties": {
"appId": "omz5z2r6l934yu1xhddj",
"scope": [
{
"type": "EnvironmentGroup",
"value": "r-pak3"
}
],
"orgScan": true
},
"startTime": "12:00:00",
"frequencyType": "Daily",
"frequencyInterval": null,
"createdBy": "bob@tms.com",
"created": "2020-10-02T06:13:47Z",
"modified": null,
"modifiedBy": null,
"nextRun": "2020-10-02T12:00:00Z"
}
3. Enable a Task Service
The POST method enables the task service in the system, as indicated by the taskServiceId provided in the request path.
POST | {{url}}/api/tasks/services/{{taskServiceId}}/enabled-statuses |
Request Example
An example POST request for enabling the task service is shown here.
curl --location --request POST '{{url}}/api/tasks/services/{{taskServiceId}}/enabled-statuses' \
--header 'Authorization: TOKEN {{apiToken}}'
Response Example
An example response of the POST request for enabling the task service is shown here.
Status: 200 OK |
{
"taskServiceId": "kyf2y23x0bapf06755h8",
"name": "environmentScanner",
"tenantNamespace": "tmslocal",
"appId": "omz5z2r6l934yu1xhddj",
"enabled": true,
"queueId": "ed-scheduledTaskEnvScanQueue",
"taskType": "ApplicationScanner"
}
4. Details of Task Status
The GET method returns an array of task statuses ordered by the sentTime descending, as indicated by the taskId provided in the request path.
Note: sentTime is a parameter as part of the response object.
GET | {{url}}/api/tasks/services/{{taskServiceId}}/tasks/statuses |
Request Example
An example GET request for retrieving the list of task statuses is shown here.
curl --location --request GET '{{url}}/api/tasks/services/{{taskServiceId}}/tasks/statuses' \
--header 'Authorization: TOKEN {{apiToken}}'
Response Example
An example response of the GET request for retrieving the list of task statuses is shown here.
Status: 200 OK |
[
{
"taskStatusId": "npog83u08fzsrx5fbxo3t3bbj66nnogl",
"taskId": "of5XmWPzdGmZiTRdrE1A",
"tenantNamespace": "tmslocal",
"plannedTime": "2020-07-21T09:43:00Z",
"sentTime": null,
"endTime": null,
"condition": "Planned",
"message": null,
"conditionDisplayName": "Planned"
},
{
"taskStatusId": "sLShQnXaNRIclQycfc74PJbxRc334OJQ",
"taskId": "of5XmWPzdGmZiTRdrE1A",
"tenantNamespace": "tmslocal",
"plannedTime": "2020-05-08T09:43:00Z",
"sentTime": "2020-07-21T03:06:54Z",
"endTime": null,
"condition": "Sent",
"message": null,
"conditionDisplayName": "Submitted"
},
{
"taskStatusId": "pCAVSUfbAoTusAMtao5jbmvbNwR2dEdh",
"taskId": "of5XmWPzdGmZiTRdrE1A",
"tenantNamespace": "tmslocal",
"plannedTime": "2020-03-03T09:43:00Z",
"sentTime": "2020-05-08T08:06:01Z",
"endTime": null,
"condition": "Sent",
"message": null,
"conditionDisplayName": "Submitted"
},
{
"taskStatusId": "Nym2iXQ1JFsRD9Ns2mdD7sROCpjqibh7",
"taskId": "of5XmWPzdGmZiTRdrE1A",
"tenantNamespace": "tmslocal",
"plannedTime": "2020-03-03T09:40:00Z",
"sentTime": "2020-03-03T09:40:18Z",
"endTime": null,
"condition": "Finished",
"message": "Finished",
"conditionDisplayName": "Executed"
},
{
"taskStatusId": "eDvjmbqm5WKlSJgzNGViSwdI6rlBexJI",
"taskId": "of5XmWPzdGmZiTRdrE1A",
"tenantNamespace": "tmslocal",
"plannedTime": "2020-03-03T09:32:00Z",
"sentTime": "2020-03-03T09:32:15Z",
"endTime": null,
"condition": "Finished",
"message": "Finished",
"conditionDisplayName": "Executed"
}
]
5. Disable a Service
The POST method disables the task service in the system, as indicated by the taskServiceId provided in the request path.
POST | {{url}}/api/tasks/services/{{taskServiceId}}/disabled-statuses |
Request Example
An example POST request for disabling a task is shown here.
curl --location --request POST '{{ptsUrl}}/api/tasks/services/{{taskServiceId}}/disabled-statuses' \
--header 'Content-Type: application/json' \
--header 'Authorization: TOKEN {{apiToken}}' \
--data-raw ''
Response Example
An example response of the POST request for disabling a task is shown here.
Status: 200 OK |
{ "taskServiceId": "kyf2y23x0bapf06755h8",
"name": "environmentScanner",
"tenantNamespace": "tmslocal",
"appId": "omz5z2r6l934yu1xhddj",
"enabled": false,
"queueId": "ed-scheduledTaskEnvScanQueue",
"taskType": "ApplicationScanner"
}
6. Details of a Task
The GET method returns the details of a task, as indicated by the taskId provided in the request path.
GET | {{url}}/api/tasks/services/{{taskServiceId}}/tasks/{{taskId}} |
Request Example
An example GET request for retrieving the details of a task is shown here.
curl --location --request GET '{{url}}/api/tasks/services/{{taskServiceId}}/tasks/{{taskId}}' \
--header 'Authorization: TOKEN {{apiToken}}'
Response Example
An example response of the GET request for retrieving the details of a task is shown here.
Status: 200 OK |
[
{
"taskId": "8jsmh3b5a887swsti7q8",
"taskServiceId": "kyf2y23x0bapf06755h8",
"tenantNamespace": "tmslocal",
"name": "Daily Scan All 3",
"description": null,
"properties": {
"appId": "omz5z2r6l934yu1xhddj",
"scope": [
{
"type": "EnvironmentGroup",
"value": "r-pak3"
}
],
"orgScan": true
},
"startTime": "13:00:00",
"frequencyType": "Daily",
"frequencyInterval": null,
"createdBy": "bob@tms.com",
"created": "2020-10-02T06:13:48Z",
"modified": "2020-10-02T06:23:40Z",
"modifiedBy": "bob@tms.com",
"nextRun": "2020-10-02T13:00:00Z"
}
]
7. Details of Tasks
The GET method returns an array of tasks, as indicated by the taskServiceId provided in the request path.
GET | {{url}}/api/tasks/services/{{taskServiceId}}/tasks |
Request Example
An example GET request for retrieving a list of tasks is shown here.
curl --location --request GET '{{url}}/api/tasks/services/{{taskServiceId}}/tasks' \
--header 'Authorization: TOKEN {{apiToken}}'
Response Example
An example response of the GET request for retrieving a list of tasks is shown here.
Status: 200 OK |
[
{
"taskId": "3yvgdj0a2woomcu9v6dx",
"taskServiceId": "kyf2y23x0bapf06755h8",
"tenantNamespace": "tmslocal",
"name": "Daily Scan All",
"description": null,
"properties": {
"appId": "omz5z2r6l934yu1xhddj",
"scope": [
{
"type": "EnvironmentGroup",
"value": "r-pak3"
}
],
"orgScan": true
},
"startTime": "17:00:00",
"frequencyType": "Daily",
"frequencyInterval": null,
"createdBy": "bob@tms.com",
"created": "2020-10-02T05:38:01Z",
"modified": null,
"modifiedBy": null,
"nextRun": "2020-10-02T17:00:00Z"
}
]
8. Update a Task
The PATCH method updates a task, as indicated by the taskServiceId and taskId provided in the request path.
PATCH | {{url}}/api/tasks/services/{{taskServiceId}}/tasks/{{taskId}} |
Request Example
An example PATCH request for updating a task is shown here.
curl --location --request PATCH '{{url}}/api/tasks/services/{{taskServiceId}}/tasks/{{taskId}}' \
--header 'Content-Type: application/json' \
--header 'Authorization: TOKEN {{apiToken}}' \
--data-raw '{
"name": "Daily Scan All 3",
"startTime": "13:00"
}'
An example response of the PATCH request for updating a task is shown here.
Status: 200 OK |
[
{
"taskId": "3yvgdj0a2woomcu9v6dx",
"taskServiceId": "kyf2y23x0bapf06755h8",
"tenantNamespace": "tmslocal",
"name": "Daily Scan All",
"description": null,
"properties": {
"appId": "omz5z2r6l934yu1xhddj",
"scope": [
{
"type": "EnvironmentGroup",
"value": "r-pak3"
}
],
"orgScan": true
},
"startTime": "17:00:00",
"frequencyType": "Daily",
"frequencyInterval": null,
"createdBy": "bob@tms.com",
"created": "2020-10-02T05:38:01Z",
"modified": null,
"modifiedBy": null,
"nextRun": "2020-10-02T17:00:00Z"
}
]
9. Delete Task
The DELETE method deletes a task in the system, as indicated by the taskId provided in the request path. When a task is deleted, all the associated tasks are also deleted.
DELETE | {{url}}/api/tasks/services/{{taskServiceId}}/tasks/{{taskId}} |
An example DELETE request for deleting a task is shown here.
curl --location --request DELETE '{{url}}/api/tasks/services/{{taskServiceId}}/tasks/{{taskId}}' \
--header 'Authorization: TOKEN {{apiToken}}'
Status: 200 OK |
The response only has headers.
Note:
This request does not return a response body.