Scheduler API
- Manage Schedules: List, Create, Update, Delete
- Stop or List Running Scheduled Jobs
- Get Job History
- Schedule Definition Properties
- Examples
The scheduler REST API is used to define a schedule for system activities and manage the jobs that result from the schedule.
All of the Fusion services are available for scheduling, as are any Solr activities and any other HTTP-based URI.
See Schedules for more information about all of the options available for scheduling, and instructions for configuring scheduler jobs using the Fusion UI.
Manage Schedules: List, Create, Update, Delete
The path for this request is:
/api/apollo/scheduler/schedules/<id>
where <id> is the name of a specific schedule.
-
GET - returns the definition of a specific schedule, or all defined schedules, if the schedule name is omitted.
-
POST - creates a new schedule. The schedule name is included in the definition in the request body.
-
PUT - modifies an existing schedule.
-
DELETE - removes the schedule.
Stop or List Running Scheduled Jobs
The path for this request is:
/api/apollo/scheduler/jobs/<id>
where <id> is the name of a specific schedule.
A GET request will list the specified job, or all jobs if the ID is omitted.
A DELETE will stop the defined job, or all jobs if the ID is omitted.
Get Job History
This is a request to the History API. The path for this request is:
/api/apollo/history/scheduler/items/<id>
where <id> is the name of a scheduled job.
A GET request will list the history of 50 runs of the specified job. If the job is omitted, this will return a list of the IDs for all scheduled jobs.
To see a history of past jobs, you can use the History API.
Schedule Definition Properties
Parameter | Description |
---|---|
id |
The ID of the schedule. This is required when creating a schedule with a POST request. |
creatorType |
The type of user that created the schedule. If you have resources creating schedules programmatically, you could define a type that helps distinguish those schedules from others created by people. |
creatorId |
An ID for the user that created the schedule. |
startTime |
A time when the schedule should be started. If this is not set, it will be set to the date/time when the schedule was created. |
endTime |
A time when the schedule should be terminated, i.e., when it will not run any more in the future. If not set, the schedule will run until it is disabled (i.e., "active" is set to false) or deleted. |
repeatUnit |
A unit of time that when combined with the interval property defines how often the schedule will run. Allowed values are:
These time units are not case sensitive. |
interval |
An integer that when combined with the repeatUnit property defines how often the schedule will run. If this is not set, or set to a number lower than '1' (i.e., '0'), the schedule will only be run once. |
active |
If true, the schedule will be executed according to the defined interval. If false, the schedule will be disabled and will not run at the defined time. |
callParams |
The callParams define the API call to execute at the defined time intervals. It allows several properties:
|
Examples
Run a crawl of the datasource "LocalDocs2" every day:
REQUEST
curl -u user:pass -X POST -H 'Content-Type: application/json' -d '{"id":"1", "creatorType":"human", "creatorId":"admin1", "repeatUnit":"DAY", "interval":1, "active":true, "callParams":{"uri":"service://connectors/jobs/LocalDocs2", "method":"POST"}}' http://localhost:8764/api/apollo/scheduler/schedules
RESPONSE
{ "id" : "1", "trigger" : "1_1400007488512_-9223372036854775808", "schedule" : { "id" : "1", "creatorType" : "human", "creatorId" : "admin1", "createTime" : "2014-05-13T18:58:08.512Z", "startTime" : "2014-05-13T18:58:08.512Z", "endTime" : null, "repeatUnit" : "DAY", "interval" : 1, "active" : true, "callParams" : { "uri" : "service://connectors/jobs/LocalDocs2", "method" : "POST", "queryParams" : { }, "headers" : { }, "entity" : null } } }
Issue a commit to the SolrCloud collection "demo" every hour:
REQUEST
curl-u user:pass -X POST -H 'Content-Type: application/json' -d '{"id":"2", "creatorType":"human", "creatorId":"admin1", "repeatUnit":"HOUR", "interval":1, "active":true, "callParams":{"uri":"solr://demo/update", "method":"GET", "queryParams":{"stream.body":"<commit/>"}}}' http://localhost:8764/api/apollo/scheduler/schedules
RESPONSE
{ "id" : "2", "trigger" : "2_1400011854443_-9223372036854775807", "schedule" : { "id" : "2", "creatorType" : "human", "creatorId" : "admin1", "createTime" : "2014-05-13T20:10:54.443Z", "startTime" : "2014-05-13T20:10:54.443Z", "endTime" : null, "repeatUnit" : "HOUR", "interval" : 1, "active" : true, "callParams" : { "uri" : "solr://demo/update", "method" : "GET", "queryParams" : { "stream.body" : "<commit/>" }, "headers" : { }, "entity" : null } } }
Set schedule "2" to inactive:
REQUEST
curl -u user:pass -X PUT -H 'Content-Type: application/json' -d '{"creatorType":"human", "creatorId":"admin1", "repeatUnit":"HOUR", "interval":1, "active":false, "callParams":{"uri":"solr://demo/update", "method":"GET", "queryParams":{"stream.body":"<commit/>"}}}' http://localhost:8764/api/apollo/scheduler/schedules/2
There will be no response if the PUT request was successful.
List all scheduled jobs:
REQUEST
curl -u user:pass http://localhost:8764/api/apollo/scheduler/jobs
RESPONSE
[ { "id" : "2", "trigger" : "2_1400011854443_-9223372036854775807", "schedule" : { "id" : "2", "creatorType" : "human", "creatorId" : "admin1", "createTime" : "2014-05-13T20:10:54.443Z", "startTime" : "2014-05-13T20:10:54.443Z", "endTime" : null, "repeatUnit" : "HOUR", "interval" : 1, "active" : true, "callParams" : { "uri" : "solr://demo/update", "method" : "GET", "queryParams" : { "stream.body" : "<commit/>" }, "headers" : { }, "entity" : null } } }, { "id" : "1", "trigger" : "1_1400007488512_-9223372036854775808", "schedule" : { "id" : "1", "creatorType" : "human", "creatorId" : "admin1", "createTime" : "2014-05-13T18:58:08.512Z", "startTime" : "2014-05-13T18:58:08.512Z", "endTime" : null, "repeatUnit" : "DAY", "interval" : 1, "active" : true, "callParams" : { "uri" : "service://connectors/jobs/LocalDocs2", "method" : "POST", "queryParams" : { }, "headers" : { }, "entity" : null } } } ]
List the history of job ID '1':
REQUEST
curl -u user:pass http://localhost:8764/api/apollo/history/scheduler/items/1
RESPONSE
{ "events" : [ { "start" : "2014-05-16T15:34:49.008Z", "end" : "2014-05-16T15:34:49.435Z", "source" : "scheduler", "type" : "execute", "status" : "ok", "details" : { "status" : 200, "entity" : "{\n \"id\" : \"TwitterSearch\",\n \"dataSourceId\" : \"TwitterSearch\",\n \"state\" : \"RUNNING\",\n \"message\" : null,\n \"startTime\" : 1400254489000,\n \"endTime\" : -1,\n \"finished\" : false,\n \"counters\" : { },\n \"exception\" : null,\n \"running\" : true\n}" }, "error" : null }, { "start" : "2014-05-16T15:38:32.536Z", "end" : "2014-05-16T15:38:32.559Z", "source" : "scheduler", "type" : "execute", "status" : "ok", "details" : { "status" : 200, "entity" : "{\n \"id\" : \"TwitterSearch\",\n \"dataSourceId\" : \"TwitterSearch\",\n \"state\" : \"RUNNING\",\n \"message\" : null,\n \"startTime\" : 1400254712000,\n \"endTime\" : -1,\n \"finished\" : false,\n \"counters\" : { },\n \"exception\" : null,\n \"running\" : true\n}" } ] }