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

Driving Workload Scheduler with Rest APIs is super simple with the Swagger UI!

1/11/2018

2 Comments

 
Picture
Starting from version 9.3 FP2, Workload Scheduler provides a set of fully functional APIs that are implemented based on Representational State Transfer (REST) services. The REST APIs are based on the same APIs used by the product user interface and provide full access to all the Workload Scheduler features, which is great!

With this blog I want to show you how simple it is to access the REST APIs with the Swagger UI.

Once you have installed your master domain manager or backup master domain manager, you can access the Swagger UI at the following url: https://<TWS_HOST>:<port_number>/twsd where:

  • TWS_HOST: Is the hostname of the master domain manager or backup master domain manager
  • port_number: Is the HTTPS port number of the master domain manager or backup master domain manager. The default is 31116

The REST APIs provide services grouped in five main categories: engine, event rules, workload modelling, plans, and security. For each category you can find a list of operations that you can perform. You can also see details about the REST APIs on https://start.wa.ibmserviceengage.com/twsd/.
Add Unix job to the model

    
Let’s start using the REST APIs with a simple example: adding the following Unix job to the model. 

As first step, we can list the model operations and search for one suitable for our purposes:
Picture
The POST /model/jobdefinition operation is exactly what we are looking for.
Picture
The only required parameter is the jobDefinition parameter. As we can see from the model schema, through this operation we have full access to the creation of all kinds of jobs.

Before starting to write the code, we can try to use the REST APIs to become familiar with the many exposed parameters. A good starting point is the template that we can copy and paste by clicking on the model schema. Once pasted, we can click on the Model tab where we can find information about the optionality of the various parameters and, when necessary, a small explanation of each single parameter. Once removed the not necessary options, we can try the REST call via the button “Try it out!”

Starting from the above job definition, here’s how to map the job definition with the object properties from the model schema:

Picture
Here is how the object appears once the parameters have been replaced:
Picture
And now let’s “Try it out!”
Picture
Finally, the job is added to the model. Now we are ready to write our first shell script:

    
Now that we have understood how to do, let's see briefly how to do a job rerun, a job stream submission, and a job submission.

Rerun a job in the plan

To do the job rerun, we must act on the plan, then open the list of operations related to the plan and look for the rerun:
Picture
As we can see, we have only two required parameters, the plan jobid: <WORKSTATION_NAME>;<JOB_STREAM_ID>;<JOB_NAME> (you can check the job stream id via conman thru the SHOWID option) and the planid. We have just to enter these two parameters:
Picture
And now let’s “Try it out!”
Picture
Once we have the curl call, the shell script creation is super simple!

Submit a job stream in the plan

To submit a job stream we must act on the plan, then open the list of operations related to the plan and look for the job stream submission:
Picture
The operation has three required parameters: the jobstreamid that is the job stream internal id (we will see how to get it soon), the planId and the SubmitJobStreamInfo that allow to specify how the job stream should be submitted. In our example, we can simply add the input arrival time and the job stream alias:
Job Stream

    
To get the jobstreamId we must run an operation on the model:
Picture
This operation has only one required parameter: How-Many that indicates how many object to retrieve. We set this parameter to one and add the optional parameter body to be sure to get just one result:
Picture
We can use the following statements to filter out the unwanted job streams:
Job Stream

    
If needed, we can also add validFrom, validTo or validInRange options. And now let’s “Try it out!”
Picture
Finally, with the job stream id we can now call the job stream submission operation:
Picture
And now let’s “Try it out!”
Picture
As a further automation step we can add a webhook to our job stream via a REST job.

Submit a job in plan

As the last example, we’ll see the job submission. This will require the use of three operations: first, we have to get the job id from the model; then, we need to get an instance of “job in plan”; finally, we can submit the job.

To get the job id we need to perform an operation on the model:
Picture
As we have already seen for the job stream, this operation has only one required parameter: How-Many that indicates how many objects to retrieve. We set this parameter to one and add the optional parameter body to be sure to get just one result:
Picture
We can use the following statements to filter out the unwanted job streams:
Job Stream

    
And now let’s “Try it out!”
Picture
Now that we have the job id, we can get an instance of the job in plan through a plan operation:
Picture
This operation has three required parameters, the jobstreamId:
<WORKSTATION_NAME>;<JOB_STREAM_ID>, the planId and the SubmitJobIntoJobStreamInfo needed to identify the job to submit. For this simple example we can use the following:
Job Stream

    
And now let’s “Try it out!”
Picture
Now that we have the job in plan instance (the entire response body) we can finally submit the job. For the job submission, we must act on the plan, so let’s look in the plan to find the right operation:
Picture
For this operation, we have two required parameters, the planId and the SubmitJobInfo, namely the job in plan instance we found in the previous step:
Picture
So, we can simply copy the entire response body of the previous step and paste it in the SubmitJobInfo field:
Job Stream

    
And now let’s “Try it out!”
Picture
REST APIs easily integrate workload scheduling capabilities with external products and solutions. By using the Swagger UI you can find the best suitable APIs, simply and quickly. Then, you can try and test the selected REST APIs before using them into your application code.

All the REST APIs examples you’ve seen in this blog can be found here: https://github.com/WAdev0/TWS_REST_API_samples

If you have any feedback on this article, you can contact Gianluca Salce at gianluca.salce@hcl.com

Gianluca Salce
Test Lead at HCL

Gianluca works as a Test Lead at HCL Products and Platforms in Rome software development laboratory.

2 Comments
Andy1st link
3/3/2018 05:43:11 pm

Courtesy means 'an act of politeness' or 'something given for free.' Courtesy s are those schools which provide driving education at a minimal rate, teaching all the basics of driving, which includes showing courteousness towards others on the road.

Reply
driving lessons bolton link
7/31/2018 11:30:24 am

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.

Reply

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