Skip to content

Latest commit

 

History

History
603 lines (376 loc) · 11.2 KB

File metadata and controls

603 lines (376 loc) · 11.2 KB

Create Job

This API creates a job by accepting one or more job schedules to be created.

Note:

You cannot create CF tasks using the REST API because they are bound to a specific application. For more information, see Can I create a CF task using the REST API?.

Routes

POST /scheduler/jobs

Request Parameters

BODY

Parameter

Required

Data Type

Description

name

Yes

string

Name of the job. Name must not contain special characters or only numbers.

Note:

The job creation request fails if a job with the same name already exists for the technical user.

description

Yes

string

Provides more details about a job.

action

Yes

string

The fully qualified URL endpoint to be called when the job runs.

Note:

Relevant for your production scenario: To encrypt data during the communication between the SAP Job Scheduling service and the application, make sure that you use HTTPS in the URL for the action endpoint to be called when the job runs.

active

Yes

boolean

Activation status of the job (default value is false).

httpMethod

Yes

string

The HTTP method to be used to call the job action endpoint URL. Allowed values are “GET”, “POST” , “PUT”, and “DELETE”.

startTime

No

string/object/null

Start time for the job. The scheduler respects the start time of both the schedule and the job. For more information about the supported formats, see Date and Time Format.

endTime

Yes

string/object/null

End time for the job. The scheduler respects the end time of both the schedule and the job. For more information about the supported formats, see Date and Time Format.

ansConfig

No

object

The ansConfig object has two boolean keys:

  • onSuccess: On true, a success alert notification is sent to the SAP Alert Notification Service. On false, no notification is sent.
  • onError: On true, an error alert notification is sent to the SAP Alert Notification Service. On false, no notification is sent.

Restriction:

This feature is only available in the Cloud Foundry environment.

schedules

Yes

array

Contains one or more job schedules to be created.

The schedules array can be used to create job schedules. Each job schedule is composed of the following parameters:

data

No

object

Data value is passed to the job action endpoint when invoked by Job Scheduler. For the HTTP method “PUT” or “POST”, the data parameters are sent in the request body while invoking the endpoint. For the HTTP method “GET” or “DELETE”, the data parameters are sent as query strings.

description

No

string

Provides more details about a schedule.

active

Yes

boolean

Activation status of the job schedule. The allowed values are true or false.

startTime

No

string/object

Start time for the job schedule. For information about the supported formats, see the section on Date and Time Format.

endTime

No

string/object

End time for the job schedule. For information about the supported formats, see the section on Date and Time Format.

cron, time, repeatInterval, and repeatAt are the different scheduling options available. Use any one of the option that suits your requirement.

Remember:

You must specify at most one scheduling mode.

cron

-

string

Crontab pattern for triggering the schedule. For more information, see the section on Cron Format.

time

-

string/object

Human-Readable Date Formats .

If an object is used, you must specify the date and time formats as strings. For information about the supported formats, see the section on Date and Time Format.

repeatInterval

-

string

Used to run schedules repeatedly at some interval. Human-readable texts must comply with the rules outlined for human readable dates. For information about the supported formats, see the section on For one-time schedules, this denotes the task execution time. You can use human-readable text to denote a specific time. Example: "3.30pm", "tomorrow at 2am". For information about human readable dates and the supported readable strings, see the section on Date and Time Format.

repeatAt

-

string

For recurring schedules, this denotes the exact time when the job schedule must run. The human readable strings must comply with the rules outlined in the section Human Readable Dates. For information about human readable dates and the supported readable strings, see the section on Date and Time Format.

Example

POST /scheduler/jobs

For one-time schedules, this denotes the task execution time. 

{
  "name": "validateSalesOrder",
  "description": "cron job that validates sales order requests",
  "action": "http://salesOrderApp.hana.ondemand.com:40023/salesOrders/validate",
  "active": true,
  "httpMethod": "PUT",
  "ansConfig": {
     "onError": false,
     "onSuccess": false
      },
  "schedules": [
    {
      "cron": "* * * * * */10 0",
      "description": "this schedule runs every 10 minutes",
      "data": {
        "salesOrderId": "1234"
      },
      "active": true,
      "startTime": {
        "date": "2015-10-20 04:30 +0000",
        "format": "YYYY-MM-DD HH:mm Z"
      }
    }
  ]
}

Responses

Status Code 201

The call was successful and the Job has been created. The API responds with a Location header which represents the relative resource URI for finding the job details.

Example

{
  "name": "validateSalesOrder",
  "action": "http://<application-url>/action",
  "active": true,
  "httpMethod": "PUT",
  "description": "cron job that validates sales order requests",
  "startTime": null,
  "endTime": null,
  "signatureVersion": 0,
  "schedules": [
    {
      "active": true,
      "startTime": "2015-10-20 04:30:00",
      "endTime": null,
      "description": "every 10 seconds, every 2 minutes",
      "data": "{\"salesOrderId\":\"1234\"}",
      "cron": "* * * * * * */10",
      "type": "recurring",
      "scheduleId": "schedule ID details"
    }
  ],
  "_id": 3
}

Status Code 400

The API was unable to process the request due to invalid data provided.

Related Information

Configure Job (Using ID)

Configure Job (Using Name)

Delete Job

Retrieve Job Details

Retrieve All Jobs

Retrieve Job Run Logs

Retrieve Job Run Log Details

Update Job Run Log

Create Job Schedule

Configure Job Schedule

Delete Job Schedule

Activate or Deactivate All Job Schedules

Delete All Job Schedules

Retrieve Job Schedule Details

Retrieve Job Schedules

SAP Alert Notification service for SAP BTP