Steps required to make Autosys Rest API calls using Curl
search cancel

Steps required to make Autosys Rest API calls using Curl

book

Article ID: 253211

calendar_today

Updated On:

Products

Autosys Workload Automation

Issue/Introduction

Documenting the steps required to use a third party tool, CURL, to make Autosys REST API calls.

Environment

Autosys 12.x

Resolution

Below are the examples in the documentation that can be used to create a curl command.
Example 1:
example from the documentation:

 -- request --
GET https://WSServer:9443/AEWS/job/sleep1
 -- response --
200 OK
Server:  Apache-Coyote/1.1
Cache-Control:  private
Expires:  Wed, 31 Dec 1969 19:00:00 EST
Content-Type:  application/json
Transfer-Encoding:  chunked
Content-Encoding:  gzip
Vary:  Accept-Encoding
Date:  Wed, 01 Feb 2012 20:27:14 GMT
{"name":"sleep1","jobType":"CMD","machine":"WSServer","self":{"@rel":"self","@href":"https://WSServer:9443/AEWS/job/sleep1"},"status":"4"}

example curl command
curl -v -k --user "ejmcommander:ejmcommander" -X GET https://WSServer.example.com :9443/AEWS/job/mark1

example job definition that shows service desk configurations:
curl -v -k --user "ejmcommander:ejmcommander" -X GET https://WSServer.example.com :9443/AEWS/jil/job?name=mark1

* Server auth using Basic with user 'ejmcommander'
> GET /AEWS/jil/job?name=mark1 HTTP/1.1
> Host: WSServer.example.com :9443
> Authorization: Basic ZWptY29tbWFuZGVyOmVqbWNvbW1hbmRlcg==
> User-Agent: curl/7.61.1
> Accept: */*

< HTTP/1.1 200 
< Cache-Control: private
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Date: Tue, 25 Oct 2022 19:19:21 GMT


/* ----------------- mark1 ----------------- */ 

insert_job: mark1   job_type: CMD 
command: echo 123
machine: WSServer.example.com
owner: [email protected]
permission: 
date_conditions: 0
std_out_file: "/tmp/$AUTO_JOB_NAME.$AUTORUN.out"
std_err_file: "/tmp/$AUTO_JOB_NAME.$AUTORUN.err"
alarm_if_fail: 1
alarm_if_terminated: 1
service_desk: 1
svcdesk_desc: "test"
svcdesk_pri: 5
svcdesk_imp: 4
svcdesk_sev: 4
* Connection #0 to host WSServer.example.com left intact

Example 2:
You can pull the job information using a filter on box name
example:
curl -v -k --user "ejmcommander:ejmcommander" -X GET https://WSServer.example.com :9443/AEWS/job?filter=boxname==Mark_Box


Sample response
{
    "job": [{
            "boxName": "Mark_Box",
            "name": "mark1",
            "jobType": "CMD",
            "machine": "WSServer.example.com ",
            "self": {
                "@href": "https://WSServer.example.com :9443/AEWS/job/mark1",
                "@rel": "self"
            },
            "status": "4"
        }, {
            "boxName": "Mark_Box",
            "name": "mark2",
            "jobType": "CMD",
            "machine": "WSServer.example.com ",
            "self": {
                "@href": "https://WSServer.example.com :9443/AEWS/job/mark2",
                "@rel": "self"
            },
            "status": "4"
        }, {
            "boxName": "Mark_Box",
            "name": "mark3",
            "jobType": "CMD",
            "machine": "WSServer.example.com ",
            "self": {
                "@href": "https://WSServer.example.com :9443/AEWS/job/mark3",
                "@rel": "self"
            },
            "status": "4"
        }
    ],
    "self": {
        "@href": "https://WSServer.example.com :9443/AEWS/job?filter=boxname==Mark_Box",
        "@rel": "self"
    }
}

Example 3:

Below is an example of pulling a list of jobs that all have the service_desk field set to true or 1.

curl -v -k --user "ejmcommander:ejmcommander" -X GET https://WSServer.example.com :9443/AEWS/jil/job?name=ALL  | egrep "insert_job|service_desk: 1" | grep -B 1 "service_desk: 1" | grep insert_job | awk '{ print $2 }' | xargs -n 1 autorep -q -J

This same thing can be done with the autorep command as well.
autorep -J % -q | egrep "insert_job|service_desk: 1" | grep -B 1 "service_desk: 1" | grep insert_job | awk '{ print $2 }'| xargs -n 1 autorep -q -J

 

Additional Information

Please review the Autosys documentation on using web services:
AutoSys Workload Automation 12.0.01

To get information about a job/box definition you would use the below call:
GET AEWS/job/jobname method-- Retrieve Information of a Specific Job

 

To review the job run information please use the below call:
GET AEWS/job-run-info method -- Retrieve Job Run Information of a Single or Multiple Jobs