Skip to content

REST: Scheduled jobs management

ddurnev edited this page May 31, 2013 · 9 revisions

List systems jobs stat

Path:/rest/jobs-stat

Type: GET

Example results:

{"links":[],
 "items": [
     {
        "projectId":1,
        "scheduledJobs":2,
        "failedJobs":1,
        "links":
           [{"href":"http://localhost:8080/rest/projects/1/jobs",
             "rel":"self",
             "type":"application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
             "methods":["get"]}]
     }
  ]
}

List project jobs

Path:/rest/projects/(projectId)/jobs

Type: GET

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to

Example results:

{
    "failed": [{
            "item": {
                "id": "1",
                "projectId": 1,
                "envId": 1,
                "date": 1363763640000,
                "workflow": "another",
                "variables": {
                    "count": "1"
                },
                "scheduledBy": "Scheduler / genesis",
                "failureDescription": "Workflow execution failed",
                "workflowId": 2
            },
            "links": [{
                    "href": "http://localhost:8080/rest/projects/1/envs/1/failedJobs/1",
                    "rel": "self",
                    "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
                    "methods": ["delete"]
                }
            ]
        }
    ],
    "requested": [{
            "item": {
                "id": "execution-destroy-env-1",
                "projectId": 1,
                "envId": 1,
                "date": 1364368327497,
                "workflow": "destroy",
                "variables": {},
                "scheduledBy": "genesis"
            },
            "links": [{
                    "href": "http://localhost:8080/rest/projects/1/envs/1/jobs/execution-destroy-env-1",
                    "rel": "self",
                    "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
                    "methods": ["put", "delete"]
                }
            ]
        }, {
            "item": {
                "id": "execution-destroy-env-2",
                "projectId": 1,
                "envId": 2,
                "date": 1364373126772,
                "workflow": "destroy",
                "variables": {},
                "scheduledBy": "genesis"
            },
            "links": [{
                    "href": "http://localhost:8080/rest/projects/1/envs/2/jobs/execution-destroy-env-2",
                    "rel": "self",
                    "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
                    "methods": ["put", "delete"]
                }
            ]
        }
    ]
}

List environment requested jobs

Path:/rest/projects/(projectId)/envs/(envId)/jobs

Type: GET

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to
envId Number id of the environment

Example results:

{
    "links": [{
            "href": "http://localhost:8080/rest/projects/1/envs/2/jobs",
            "rel": "self",
            "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
            "methods": ["get", "post"]
        }
    ],
    "items": [{
            "id": "execution-destroy-env-2",
            "projectId": 1,
            "envId": 2,
            "date": 1364373126772,
            "workflow": "destroy",
            "variables": {},
            "scheduledBy": "genesis",
            "links": [{
                    "href": "http://localhost:8080/rest/projects/1/envs/2/jobs/execution-destroy-env-2",
                    "rel": "self",
                    "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
                    "methods": ["put", "delete"]
                }
            ]
        }
    ]
}

Delete environment requested jobs

Path:/rest/projects/(projectId)/jobs/(jobId)

Type: DELETE

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to
envId Number id of the environemnt
jobId String id of the job to be removed (can be obtained from list env jobs request)

Example results:

{"result":"execution-another-env-1","isSuccess":true}

List environment failed jobs (failed jobs log)

Path:/rest/projects/(projectId)/envs/(envId)/failedJobs

Type: GET

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to
envId Number id of the environment

Example results:

{
    "links": [{
            "href": "http://localhost:8080/rest/projects/1/envs/1/failedJobs",
            "rel": "self",
            "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
            "methods": ["get"]
        }
    ],
    "items": [{
            "id": "1",
            "projectId": 1,
            "envId": 1,
            "date": 1363763640000,
            "workflow": "another",
            "variables": {
                "count": "1"
            },
            "scheduledBy": "Scheduler / genesis",
            "failureDescription": "Workflow execution failed",
            "workflowId": 2,
            "links": [{
                    "href": "http://localhost:8080/rest/projects/1/envs/1/failedJobs/1",
                    "rel": "self",
                    "type": "application/vnd.griddynamics.genesis.ScheduledJobDetails+json",
                    "methods": ["delete"]
                }
            ]
        }
    ]
}

Delete failed job log record

Path:/rest/projects/(projectId)/failedJobs/(jobId)

Type: DELETE

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to
envId Number id of the environemnt
jobId String id of the job to be removed (can be obtained from list env jobs request)

Example results:

{"result":"1","isSuccess":true}

Schedule workflow execution for environment

Path:/rest/projects/(projectId)/envs/(envId)/jobs

Type: POST

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to
envId Number id of the environment

**Request body structure**

Request body consists form a single JSON map contains the following entries:

Entry name Entry predefined value Type Description
parameters В  JSON object parameters used by execution action

Parameters JSON object structure:

Entry name Type Description
workflow String Name of the workflow to be executed
parameters Map of String pairs Workflow variable values customized by user
executionDate Number execution date timestamp
schedule String (Optional) Expression describing job execution schedule. Could be either full unix-like cron expression(see Quartz cron expressions) or duration interval expression. If not specified then job is run only once at executionDate

Request example

{ 
  "workflow":"another",
  "executionDate":1364642100000,
  "schedule": "0 0 14-6 ? * FRI-MON",
  "parameters":{"count":"1"}}

Response example

{"result":"2013-03-30T11:15:00Z","isSuccess":true}

Update schedule workflow execution job parameters

Path:/rest/projects/(projectId)/envs/(envId)/jobs/(jobId)

Type: PUT

Path parameters

Parameter Type Description
projectId Number id of the project credentials belong to
envId Number id of the environment
jobId String id of the job

Request body structure

Request body consists form a single JSON map contains the following entries:

Entry name Entry predefined value Type Description
parameters В  JSON object parameters used by execution action

Parameters JSON object structure:

Entry name Type Description
workflow String Name of the workflow to be executed
parameters Map of String pairs Workflow variable values customized by user
executionDate Number execution date timestamp. In case of no schedule or interval schedule job is (first) executed at specified time. In case of cron schedule - the timestamp specifies when the schedule first comes into affect
schedule String (Optional) Expression describing job execution schedule. Could be either full unix-like cron expression(see Quartz cron expressions) or duration interval expression. If not specified then job is run only once at executionDate

Interval expression syntax

Duration syntax is N followed by one of the characters 'm', 'h', 'd', 'w'. Where

  • N is positive integer value specifying number of units.

Final letter specifies unit:

  • m - minute
  • h - hour
  • d - day
  • w - week.

For example: to execute job weekly(starting at start date) specify:

 1w

Request example

{ 
  "workflow":"another",
  "executionDate":1364642100000,
  "schedule": "1d",
  "parameters":{"count":"1"}}

Response example

{"result":"2013-03-30T11:15:00Z","isSuccess":true}
Clone this wiki locally