Jobs APIManaged Fusion Admin APIs
The Jobs API allows you to define schedules for objects that perform work. You can schedule datasources and Spark jobs.
This topic explains how to format requests to the Jobs API. To learn how to work with jobs and schedules in the Managed Fusion UI, see Jobs and Schedules.
For more information, view the API specification.
Job runtime configuration
In order to see this object within the Managed Fusion UI, it must be associated with an app. To do this, create the object using the /apps endpoint.
|
Job configuration requests have these parameters:
-
<type>:<id>
path parameter (required)The resource identifier takes the form
<type>:<id>
, such asdatasource:movie-db
,spark:dailyMetricsRollup-counters
, ortask:delete-old-system-logs
.See Job types below.
-
enabled
body parameter"True" or "false" to enable or disable the job.
-
triggers
body parameterThis parameter defines one or more conditions that trigger the job. See Job triggers below.
Below is an example request that configures a job:
PUT /jobs/datasource:movie-db/schedule
{
"enabled": true,
"triggers": [
{"type": "cron", "enabled": true, "value": "0 */10 * * * *"}
]
}
Job types
The job type must be specified as part of the resource identifier in PUT
, POST
, and DELETE
calls. These are the possible job types:
|
A job to ingest data according to the specified datasource configuration, such as See Datasource Jobs. |
|
A Spark job to process data, such as See Spark Jobs. |
Job triggers
Each job can have multiple triggers, and each trigger configuration requires enabled
and type
parameters.
Additional parameters are required by each trigger type, described below:
Trigger type | Parameters |
---|---|
Run the job at a regular interval over some time range. |
|
Run the job on a cron-style schedule. |
A cron string. |
Run the job after another job succeeds or fails. |
|
Examples
Get all datasource jobs
Input
curl -u USERNAME:PASSWORD https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/jobs?type=datasource
Output
[ {
"resource" : "datasource:ratings-db",
"enabled" : true,
"startedBy" : "acb38917-611a-46e1-a3cf-4ed46a30fd24"
}, {
"resource" : "datasource:movies-db",
"enabled" : true,
"startedBy" : "acb38917-611a-46e1-a3cf-4ed46a30fd24",
"status" : "success",
"lastStartTime" : "2017-05-17T20:58:10.503Z",
"lastEndTime" : "2017-05-17T20:58:42.020Z"
} ]
Start a datasource job now
Input
curl -u USERNAME:PASSWORD -X POST -H "Content-Type: application/json" https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/jobs/datasource:movies-db/actions -d '{"action": "start"}'
Output
{
"resource" : "datasource:movies-db",
"action" : "start",
"accepted" : true,
"message" : "Started job datasource:movies-db"
}
Get the job history for a datasource
Input
curl -u USERNAME:PASSWORD https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/jobs/datasource:movies-db/history
Output
[ {
"resource" : "datasource:movies-db",
"startTime" : "2017-05-17T21:01:46.743Z",
"endTime" : "2017-05-17T21:02:05.720Z",
"status" : "success"
}, {
"resource" : "datasource:movies-db",
"startTime" : "2017-05-17T20:58:10.503Z",
"endTime" : "2017-05-17T20:58:42.020Z",
"status" : "success"
} ]
Define a trigger for a datasource job
Input
curl -u USERNAME:PASSWORD -X PUT -H "Content-Type: application/json" https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/jobs/datasource:ratings-db/schedule -d '{"triggers": [{"type": "cron", "enabled": "true", "expression": "0 15 10 ? * MON-FRI"}]}'
Output
{
"resource" : "datasource:ratings-db",
"triggers" : [ {
"type" : "cron",
"enabled" : true,
"expression" : "0 15 10 ? * MON-FRI",
"type" : "cron"
} ]
}