Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Scheduled Jobs

 

 

Executing Jobs 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

Item

Value

HTTP Method

POST

URI

/scheduled-jobs/{jobId}/runs

Body

 

{ "args": "<space separated list of arguments to the job>" }

Response

Details of the scheduled job that was queued for execution.

Parameters

Parameter

Description

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

 

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

Item

Value

HTTP Method

GET

URI

/scheduled-jobs/{jobId}/runs?fromDate=<fromDate>&toDate=<toDate>&status=<status>

Response

Details of the job runs that satisfy the request criteria.

Parameters

Parameter

Description

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) 20220221 (only date - 21st Feb 2022)

b) 20220221T061500 (date and time - 21st Feb 2022 6:15 am)

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.

IN_PROGRESS: Job runs that are still executing. At any given point in time, a job should have a single IN_PROGRESS job run!

SUCCEEDED: Job runs that completed without any errors.

FAILED: Job runs that completed with one or more errors.

Download the 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

Item

Value

HTTP Method

GET

URI

/scheduled-jobs/{jobId}/runs/{runId}/result-file

Response

Contents of the files/results created by the scheduled job run/execution

Parameters

Parameter

Value

Parameter

Value

jobId

Scheduled Job ID

runId

Scheduled Job run or execution ID

 

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com