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 . 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. 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”. 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. 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”. The response returned is as below and the Success return code in this case is 202. The Output when verified through conman “sj @#@.TESTJOB” shows that the Job was marked to SUCCESS . 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 : The Jobstream Name and the Workstation Name are supplied as input to the REST Call : 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. 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 : 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 . 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 : The Jobstream submission post REST API Submit shows the UNSIONSCHEDID of the Jobstream in the response : The conman output post submission shows the UNSIONSCHEDID in the conman “sj @#TESTJOB” output : 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
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
Archives
October 2024
Categories
All
|