Executing any Scheduled Job On Demand:
The purpose of scheduled jobs is to perform a task at predetermined schedule like once in a week, every night at 11 pm or every minute. However, at times, you would like to trigger the scheduled job execution on demand especially when using the jobs to retrieve the data for integration with the other external systems.
The API given below can be used to queue a pre-created scheduled job for execution at any time of the day.
Item | Value |
---|---|
HTTP Method |
|
URI |
|
Body | { "args": "<space separated list of arguments to the job>" } |
Response | Details of the scheduled job that was queued for execution. |
Parameters
Parameter | Description |
---|---|
jobId | ID of the scheduled job to run / queue for execution. Scheduled Job ID is a unique identifier assigned to every scheduled job in OpenSpecimen. This ID can be obtained from Jobs view UI. |
args | Space separated list of input arguments to the job. This can be empty if the job has no run time arguments as the input |
Scheduled Job Runs
Whenever a scheduled job is executed, it creates scheduled job run. The idea of a run record is to capture the details of execution like when the job was executed, who executed it, and output of the execution, if any.
The below API can be used to list the runs / executions of a scheduled job.
Item | Value |
---|---|
HTTP Method |
|
URI |
|
Response | Details of the job runs that satisfy the request criteria. |
Parameters
Parameter | Description |
---|---|
jobId | Scheduled Job ID whose run records are required. This is a required parameter. |
fromDate | Specifies the date/time after which the scheduled job run was created. This is an optional parameter. When not specified, it defaults to the earliest date/time known to the mankind. Example: a) b) |
toDate | Specifies the date/time before which the scheduled job run was created. This is an optional parameter. When not specified, it defaults to the current date/time. Follows the same format as fromDate. |
status | One of the 3 values given below. This is an optional parameter. When not specified, it is assumed job runs of all statuses are required.
|
Download the Schedule Job Run Output
Some scheduled jobs like the saved query jobs created an output CSV file. The resultant CSV file can be downloaded using the API given below:
Item | Value |
---|---|
HTTP Method | GET |
URI |
|
Response | Contents of the files/results created by the scheduled job run/execution |
Parameters
Parameter | Value |
---|---|
jobId | Scheduled Job ID |
runId | Scheduled Job run or execution ID |