Manage job schedules
Use schedule management methods to schedule certain types of periodic operations that run in your cluster.
Job schedule
A job schedule describes the interval at which to run a job, the type of job, and the parameters defining the job scope.
A job schedule has the following form:
{
"first_run_date": FIRST_RUN_DATE,
"first_run_time": FIRST_RUN_TIME,
"timezone": TIMEZONE,
"interval": INTERVAL,
"interval_unit": INTERVAL_UNIT,
"job_params": {
type: backup | best-practice,
JOB_PARAMS,
},
"id": ID,
"next_run": NEXT_RUN,
"last_run": LAST_RUN
}
The job schedule fields are:
| Field | Type | Description |
|---|---|---|
|
string |
The first date on which to run the job in |
|
string |
The first time on which to run the job in |
|
string |
The time zone, listed in the OpsCenter |
|
integer |
Sets the frequency at which the job runs. Specifies the number of time units ( |
|
string |
The unit of time for |
|
dict |
A dictionary that describes the job. The If
If
|
|
string |
A unique ID that references a job schedule. When creating a job schedule, omit this field. The system assigns an ID when the job schedule is created. When you |
|
string |
The date and time of the next scheduled run. This field is always system-defined.
Omit this field from your |
|
string |
The date and time of the last successful run. This field is always system-defined.
Omit this field from your |
GET /{cluster_id}/job-schedules
Retrieve a list of jobs scheduled to run in OpsCenter. Currently the only types of jobs are a scheduled backup or a best practice rule.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
Returns a list of job-schedule objects.
Example:
curl http://127.0.0.1:8888/Test_Cluster/job-schedules
Output:
[
{
"first_run_date": "2012-04-19",
"first_run_time": "18:00:00",
"id": "19119720-115a-4f2c-862f-e10e1fb90eed",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"last_run": "2012-04-20 18:00:00 GMT",
"next_run": "2012-04-21 18:00:00 GMT",
"timezone": "GMT"
},
...
]
GET /{cluster_id}/job-schedules/{schedule_id}
Get the description of a scheduled job.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
schedule_id: A unique ID of the scheduled job that matches the id of a
job-scheduleobject.
Returns a Job Schedule object.
POST /{cluster_id}/job-schedules
Create a new scheduled job. You can create a scheduled job to run one time in the future by specifying an interval of -1 and interval_unit of null.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
Body: A dictionary in the format of a Job Schedule describing the scheduled job to create.
Don’t include the id, last_run, and next_run fields; these are set by the system when the job schedule is created and triggered.
Returns 201 response code and the ID of the newly created job if successful.
Example:
curl -X POST
http://127.0.0.1:8888/Test_Cluster/job-schedules/
-d
'{
"first_run_date": "2012-05-03",
"first_run_time": "18:00:00",
"interval": 1,
"interval_unit": "days",
"job_params": {
"cleanup_age": 30,
"cleanup_age_unit": "days",
"keyspaces": [],
"type": "backup"
},
"timezone": "GMT"
}'
Output:
"905391b7-1920-486d-a633-282f22dce604"
PUT /{cluster_id}/job-schedules/{schedule_id}
Update a scheduled job.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
schedule_id: A unique ID identifying the schedule job to update.
Body: A dictionary with fields from the job-schedule object that you want to update.
Returns 200 response code and a null message if the schedule was updated successfully.
Example:
curl -X PUT
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22 dce604
-d
'{
"interval": "12",
"interval_unit": "hours"
}'
DELETE /{cluster_id}/job-schedules/{schedule_id}
Delete a scheduled job.
Path arguments:
-
cluster_id: The ID of a cluster returned from GET /cluster-configs.
-
schedule_id: A unique ID identifying the schedule job to delete.
Returns 200 response code and a null message if the schedule was deleted successfully.
Example:
curl -X DELETE
http://127.0.0.1:8888/Test_Cluster/job-schedules/905391b7-1920-486d-a633-282f22 dce604