WORKLOAD AUTOMATION COMMUNITY
  • Home
  • Blogs
  • Forum
  • Resources
  • Events
    • IWA 9.5 Roadshows
  • About
  • Contact
  • What's new

How to make the most out of REST APIs in  Workload Automation

5/22/2020

0 Comments

 
Picture
REST API’s in WA have been around since long, but their Usage is still not clear amongst most WA Admins using the product since long , this Blog aims to provide an Introduction to WA REST API’s and attempts to clear some doubts in regards to their Usage . 
The REST API is executed using the curl binary. The Curl binary executing the REST API hits a Service URL and passes a JSON Input to the Service.  
The Service URL varies depending on the operation performed using REST. 

It could either be a REST POST Request, a REST GET Request or a REST PUT Request. 

The response from a REST request is also in the form of a JSON Response. 

REST API Calls in Workload Automation are made through a GUI and the GUI URL can be accessed using the following link     https://FullyQualifiedNameofMDM/twsd . 

The UI looks as below , the classification of REST operations is done interms of engine , eventrule, model(DB) , plan and security . 
Picture
Running a Job Query to get the Plan Job ID : 

Plan Job ID can be used in many plan related operations for a Job . Extracting plan Job ID is of importance and is the first step in all such Operations . 

To Extract the Plan Job ID for a Job named TESTJOB the below JSON query can be executed : 
 
{ 
 
   "filters": { 
 
      "jobInPlanFilter": { 
 
      "actualKey": "S_MDM;JOBS;TESTJOB" 
 
       } 
 
      } 
 
     }, 
 
      "sorters": { 
 
       "jobInPlanSorter": { 
 
        "jobstreamScheduledTime": { 
 
        "descending": false, 
 
        "priority": 1 
 
        } 
 
       } 
 
      } 
 
} 
 
The “How Many” Field is also to be set, to receive the appropriate response. ​
Picture
The Output returned is in the form of a JSON Response as follows , the output response includes the id field which is the Plan Job ID (in alphanumeric) . In this case the ID returned is “27371e93-9112-3798-a8fe-10f44473190a”. ​
Picture
Extrapolating the Scenario to confirm the Job to SUCCESS : 

The job when viewed from conman “sj S_MDM#JOBS.TESTJOB” would be as follows , this is a job submitted with confirmed option , so that the true Status can be managed by the Operator post checks. ​
Picture
The Confirm Success REST API Query can be executed by easily passing the planid which is current alongwith the jobid which is Plan Job ID returned from previous Step : “27371e93-9112-3798-a8fe-10f44473190a”. ​
Picture
The response returned is as below and the Success return code in this case is 202. ​
Picture
The Output when verified through conman “sj @#@.TESTJOB” shows that the Job was marked to SUCCESS . ​
Picture
Submitting a Jobstream through REST API : 

While Submitting a jobstream through REST API the Model ID of the Jobstream is to be fetched  
from GET /model/Jobstream : ​
Picture
The Jobstream Name and the Workstation Name are supplied as input to the REST Call : ​
Picture
The Output returned is a JSON Response , the JSON Response includes an ID in the Header section which is the Jobstream ID of the Jobstream , in this case this is 94938606-bdeb-b5cc-53816b8eea04. ​
Picture
Next a make_Jobstream function is to be executed to create a Make_Jobstream instance in plan Object , the input parameters in this case is the DB Jobstream ID , plan ID which is current plan and a JSON input supplying input arrival time : ​
Picture
This returns a JSON Response which is the make Jobstream in plan Object to be supplied as input to the Submit Jobstream REST API Query .
Picture
Picture
JSON Response retrieved : 

The Json response received is to be modified to include the input arrival time field and the same can then be used for submission : 
 
{ 
  "key": { 
    "name": "TESTJOB", 
    "startTime": "2019-10-25T07:38:49", 
    "workstationKey": { 
      "name": "S_MDM" 
    } 
  }, 
  "jobStreamDbIdentifier": "94938606-bdeb-3504-b5cc-538a6b8eea04", 
  "workstation": { 
    "name": "S_MDM" 
  }, 
  "inputArrivalTime": "2019-10-25T07:38:49", 
  "productionDate": "2019-10-25T10:48:03", 
  "scheduledDate": "2019-10-25T00:00:00", 
  "jobStreamStats": { 
    "numberOfJob": 0, 
    "numberOfCurrentNodes": 0, 
    "numberOfSuccessfullJob": 0, 
    "numberOfDeltaJob": 0, 
    "numberOfDeltaSuccJob": 0, 
    "numberOfNotRunningJob": 0, 
    "numberOfExecutingJob": 0, 
    "numberOfAbendedJob": 0, 
    "numberOfFailedJob": 0, 
    "numberOfSkelJob": 0, 
    "numberOfUndecidedJob": 0 
  }, 
  "limit": -1, 
  "resDepSequenceNum": -1, 
  "followsDepSequenceNum": -1, 
  "inOrder": false, 
  "replicated": false, 
  "carriedForward": false, 
  "carryForward": false, 
  "dontTouch": false, 
  "userJobs": false, 
  "thisCpu": false, 
  "external": false, 
  "needResources": false, 
  "hasResources": false, 
  "released": false, 
  "pendingCancellation": false, 
  "aliased": false, 
  "every": false, 
  "hasInternetworkDependencies": false, 
  "heldByUser": false, 
  "lateJobStream": false, 
  "pendingPredecessor": false, 
  "zombie": false, 
  "jobs": [ 
    { 
      "name": "TESTJOB", 
      "jobDefinition": { 
        "jobDefinitionInPlanKey": { 
          "name": "TESTJOB", 
          "workstationInPlanKey": { 
            "name": "S_MDM" 
          } 
        }, 
        "description": "Sleep Job", 
        "taskType": "UNIX", 
        "command": false, 
        "definedByJsdl": false, 
        "taskString": "sleep 200", 
        "taskStringInfo": "sleep 2", 
        "returnCode": 0, 
        "interactive": false, 
        "userLogin": "twsadmin", 
        "recoveryOption": "STOP", 
        "estimatedDuration": 201000, 
        "recoveryRepeatInterval": 0, 
        "recoveryRepeatAffinity": false 
      }, 
      "workstationInPlan": { 
        "name": "S_MDM" 
      }, 
      "jobStreamInPlan": { 
        "name": "TESTJOB", 
        "id": "94938606-bdeb-3504-b5cc-538a6b8eea04", 
        "startTime": "2019-10-25T07:38:49", 
        "workstationKey": { 
          "name": "S_MDM" 
        } 
      }, 
      "dependencies": {}, 
      "priority": 10, 
      "originalPriority": 10, 
      "repeatInterval": -1, 
      "cpuTime": 0, 
      "timeInfo": { 
        "estimatedDuration": 0, 
        "elapsedTime": 0 
      }, 
      "timeRestriction": { 
        "timeDependent": false 
      }, 
      "jobNumber": 0, 
      "headRecordNumber": 0, 
      "status": { 
        "canceled": false 
      }, 
      "rerunInstancesNumber": 0, 
      "lastInRerunChain": false, 
      "dependenciesStats": { 
        "numberOfDependencies": 0, 
        "numberOfJobDependencies": 0, 
        "numberOfJobStreamDependencies": 0, 
        "numberOfInternetworkDependencies": 0, 
        "numberOfPromptDependencies": 0, 
        "numberOfResourceDependencies": 0, 
        "numberOfFileDependencies": 0, 
        "numberOfUnresolvedDependencies": 0, 
        "numberOfNonResourceUnresolvedDependencies": 0 
      }, 
      "criticalNetworkInfo": { 
        "critical": false, 
        "onCriticalPath": false, 
        "late": false, 
        "longRunning": false, 
        "promotedToUrgentQueue": false, 
        "riskForJobStreamLimit": false, 
        "riskForJobStreamPriority": false, 
        "riskForJobStreamFence": false, 
        "riskForJobStreamSuppressed": false, 
        "riskForJobPriority": false, 
        "riskForJobFence": false, 
        "riskForStartTime": false, 
        "riskForWorkStationIgnore": false, 
        "plannedRestriction": { 
          "timeDependent": false, 
          "minDuration": -1, 
          "maxDuration": -1 
        }, 
        "every": false, 
        "restarted": false 
      }, 
      "sigma": 0, 
      "estimatedEndSigma": -1, 
      "recordNumber": 0, 
      "monitored": false, 
      "aliased": false, 
      "buckujob": false, 
      "centralized": false, 
      "centralizedSatisfied": false, 
      "dontTouch": false, 
      "every": false, 
      "external": false, 
      "hasResource": false, 
      "heldByUser": false, 
      "jobLate": false, 
      "needMessage": false, 
      "needResource": false, 
      "pendingCancellation": false, 
      "programmatic": false, 
      "recoveryRerunJob": false, 
      "released": false, 
      "replicated": false, 
      "rerunJob": false, 
      "restarted": false, 
      "running": false, 
      "successPending": false, 
      "untilGone": false, 
      "userJob": false, 
      "userRerunAgain": false, 
      "wildcarded": false, 
      "requiresConfirmation": false, 
      "minDurationNotReached": false, 
      "maxDurationGone": false, 
      "position": 0, 
      "dependencySequenceNumber": -1, 
      "noOperation": false, 
      "recoveryDefinition": false, 
      "everyRerun": false, 
      "rerunStep": false, 
      "recoveryRepeatIterations": 0, 
      "delayRerun": false, 
      "autogenerated": false, 
      "pollingJobUsed": false, 
      "pendingPredecessor": false, 
      "altJobIssue": false, 
      "interactive": false, 
      "definedByJsdl": false, 
      "ignoreFlags": false, 
      "canceledInSuccStatus": false, 
      "msgGenerated": false 
    } 
  ], 
  "priority": 10, 
  "origPriority": 10, 
  "monitored": false, 
  "status": { 
    "canceled": false 
  }, 
  "timeRestriction": { 
    "untilTime": "2019-11-24T07:38:49", 
    "timeDependent": false, 
    "untilAction": "SUPPRESS", 
    "minDuration": -1, 
    "maxDuration": -1 
  }, 
  "timeInfo": { 
    "estimatedDuration": -1, 
    "elapsedTime": 0 
  }, 
  "timeZone": "America/Chicago", 
  "cpuTime": 0, 
  "recordNumber": 0, 
  "dependenciesStats": { 
    "numberOfDependencies": 0, 
    "numberOfJobDependencies": 0, 
    "numberOfJobStreamDependencies": 0, 
    "numberOfInternetworkDependencies": 0, 
    "numberOfPromptDependencies": 0, 
    "numberOfResourceDependencies": 0, 
    "numberOfFileDependencies": 0, 
    "numberOfUnresolvedDependencies": 0, 
    "numberOfNonResourceUnresolvedDependencies": 0 
  }, 
  "sigma": -1, 
  "estimatedEndSigma": -1, 
  "dependencies": {}, 
  "zosSpecificAttributes": { 
    "rerunRequested": false, 
    "addedToCurrentPlan": false, 
    "latestOutPassed": false, 
    "remainingDurationCriticalPath": 0, 
    "remainingOperationsCriticalPath": 0 
  } 
} 
 
 
The Jobstream can be submitted by using the Jobstream ID , plan ID and using the JSON Response within the SubmitJobstreamInfo Field : 
Picture
Picture
The Jobstream submission post REST API Submit shows the UNSIONSCHEDID of the Jobstream in the response : ​
Picture
Picture
The conman output post submission shows the UNSIONSCHEDID in the conman “sj @#TESTJOB” output : ​
Picture
REST API’s is most useful while working on Integration with external Products which donot have ready made plugin for available for Integration . ​

Author's BIO
Picture
Sriram V 

I’ve been working with Workload Automation for the last 11 years in various capacities like WA Administrator , SME , India-SME , later joined the Product team supporting Workload Automation on SaaS, recently moved to Tech Sales and Lab Services of Workload Automation. ​
View my profile on LinkedIn
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Archives

    March 2023
    February 2023
    January 2023
    December 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2020
    March 2020
    January 2020
    December 2019
    November 2019
    October 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    August 2017
    July 2017
    June 2017
    May 2017

    Categories

    All
    Analytics
    Azure
    Business Applications
    Cloud
    Data Storage
    DevOps
    Monitoring & Reporting

    RSS Feed

www.hcltechsw.com
About HCL Software 
HCL Software is a division of HCL Technologies (HCL) that operates its primary software business. It develops, markets, sells, and supports over 20 product families in the areas of DevSecOps, Automation, Digital Solutions, Data Management, Marketing and Commerce, and Mainframes. HCL Software has offices and labs around the world to serve thousands of customers. Its mission is to drive ultimate customer success with their IT investments through relentless innovation of its products. For more information, To know more  please visit www.hcltechsw.com.  Copyright © 2019 HCL Technologies Limited
  • Home
  • Blogs
  • Forum
  • Resources
  • Events
    • IWA 9.5 Roadshows
  • About
  • Contact
  • What's new