cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
10037
Views
0
Helpful
10
Replies

Using Cisco Tidal REST APIs

santoshtupe1
Level 1
Level 1

Hi,

 

I want to get job status using Tidal REST API, so we are using JobRun.get API as below:

https://servername/api/sname/JobRun.get/111111111

where 111111111 is job number. Using this we are getting required information.

But problem is job number is dynamic and we are manually getting it from Tidal Web UI.

Question is how to get job status using Job name instead of Job number? Or is there any way to get dynamic job number using job name?

 

regards

Santosh.

10 Replies 10

rosaho
Level 3
Level 3

This discussion has been reposted from Additional Communities to the Tidal Enterprise Scheduler community.

Marc Clasby
Level 1
Level 1

Here's 2 examples

  1. one to grab select columns by jobmst_alias
  2. one to grab everything by jobmst_id

one special thing to note is that you don't need to tag items in query conditions.

I'm working on a more comprehensive guide as  I think I have finally figured all this out...

Marc

 

Assumptions

Given a jobrun in the schedule

jobmst_id = 19990

jobmst_alias='REST1'

 

select columns rundate, alias by jobmst_alias

<entry xmlns="http://purl.org/atom/ns#">
 <tes:JobRun.get xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">
  <id></id>
  <selectColumns>rundate, alias</selectColumns>
  <queryCondition>alias='REST1'</queryCondition>
 </tes:JobRun.get>
</entry>

 

one to grab everything by jobmst_id

<entry xmlns="http://purl.org/atom/ns#">
 <tes:JobRun.get xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">
  <id></id>
  <selectColumns></selectColumns>
  <queryCondition>jobid=19990</queryCondition>
 </tes:JobRun.get>
</entry>

Hi Marc - I am very interested in your guide if you are willing to share when you get it completed. 

 

I currently have a requirement that our ticketing system (ServiceNow) connect to Tidal and issue a reboot set of jobs.  What needs to happen is the Agent on the group job changes to the one passed by ServiceNow, but since a job action doesn't allow a variable in the agent field, I'm stumped.

 

Thank you!

Michelle Morris

 

Nice Challenge.... well you can't do it with 1 step... at least not without a script or workflow in servicenow... which when you get that far... let me know as I am interested in the servicenow integration down the road ... we are just starting to implement here (my new job).

 

In the use case you outlined you have to take a multiple step approach (could possibly be scripted with something like PowerShell, ServiceNow Workflow, etc.).

I executed this and it does work manually

Marc

 

Requirements

  1. Need to know jobmst_id of target job/jobgroup in this case 20072

  2. Must add “require operator release” setting

  3. Must be able to query for latest jobrun_id and use in downstream REST calls

Desired Outcomes

  1. I want to force a run on Agent XYZ nodmst_id = 117 for this particular run

  2. I want to add different parameters for override (add a variable)

  3. I want to execute with the changes above automatically

 

  1. Caveat: you can’t change the agent on insert via GUI, this make the job/jobgroup have to have “require operator release” setting

  2. Caveat: you have to specify all parameters as it will put in a blank parameter screen by default… this seems like a defect to me (GUIs will insert the params from the definition and allow you to override but not REST job.insert method)

 

Step 1 insert the job on operator release

 

<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://purl.org/atom/ns#">

           <tes:Job.insert xmlns:tes="http://www.tidalsoftware.com/client/teservlet">

                     <tes:id>20072</tes:id>

                     <tes:params>Write-Output &apos;&lt;JobParent&gt;\&lt;JobName&gt; runs on &lt;ALIAS_TidalSql.118&gt; my new Params&apos;</tes:params>

                     <tes:startdate>20150910</tes:startdate>

           </tes:Job.insert>

</entry>

 

Step 2 Obtain the latest jobrun_id for target jobmst_id

 

Must get jobrun_id to manipulate the job using REST here’s where the process might break for you  unless you can write a query to get the “max” run :  SELECT MAX(jobrun_id) FROM jobrun WHERE jobmst_id = 20072

In this case the jobrunid/id =  669920

 

Step 3 Modify job in job activity and switch agents

 

In this case say I wanted to Switch Agent List (definition) to Specific Agent 117 so I have to run a jobrun.update method

 

<?xml version="1.0" encoding="UTF-8" ?>

<entry xmlns="http://purl.org/atom/ns#">

           <tes:JobRun.update xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">

                     <object>

                                <tes:id>669920</tes:id>

                                <tes:nodeid>117</tes:nodeid>

                     </object>

           </tes:JobRun.update>

</entry>

 

Step 3 Release job

<?xml version="1.0" encoding="UTF-8" ?>

<entry xmlns="http://purl.org/atom/ns#">

           <tes:JobRun.release xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">

                     <id>669920</id>

           </tes:JobRun.release>

</entry>

 

That's it..

Marc - It appears there is not an update method for the JobRun:

Method [update] does not exist for type [com.tidalsoft.scheduler.api.objects.impl.JobRun].

 

but...

 

If I wrap my job in a job group, I can edit the agent at the group level.  Then, with the agent inherited in the job I can insert the group and the job runs on the correct agent!

 

Thank you so much for helping me get started on this.  I will definitely let you know how we end up integrating this.

 

Here are the two steps:

Edit the agent at the group level:

<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://purl.org/atom/ns#">

<id>3</id>

<tes:JobGroup.update xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">

<tes:jobgroup>

<tes:id>20185</tes:id>

<tes:type>1</tes:type>

<tes:agentid>1660</tes:agentid>

</tes:jobgroup>

</tes:JobGroup.update>

</entry>

 

 

Insert job group

<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://purl.org/atom/ns#">

           <tes:Job.insert xmlns:tes="http://www.tidalsoftware.com/client/teservlet">

                     <tes:id>20185</tes:id>

                     <tes:startdate>20150911</tes:startdate>

           </tes:Job.insert>

</entry>

 

Hi,

Is there a way to update the command parameter in job activity after the job is inserted through API?

 

I tried something like this below. Nothing worked.

 

<?xml version="1.0" encoding="UTF-8" ?>
<entry xmlns="http://purl.org/atom/ns#">
<tes:JobRun.update xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">
<object>
<tes:id>3374762</tes:id>

--<tes:parameters>test johnny</tes:parameters>

--<tes:parameter>test johnny</tes:parameter>

--<tes:params>test johnny</tes:params>

--<tes:param>test johnny</tes:param>
</object>
</tes:JobRun.update>
</entry>

chinmayiinjam
Level 1
Level 1

@santoshtupe1 Did u get to solve  this. I am facing the same issue.

What Tidal product are you referring to?

If it's Cisco Process Orchestrator, I might be able to help.  What issue did you run into?

Hi @Tuan Tran,

                       I am trying to use  API for Tidal Enterprise Scheduler version 6.0 Web API. I was able to insert a job into schedule. But, I couldn't pull the jobrunid of the running job to pull its status. How can I pull the status of the running job.

Thank you.

Best,

Chinmayi Injam. 

        

eao72
Level 1
Level 1

How to use Cisco Tidal REST APIs to get job status

 

Below are two approaches to get this data: first, using the job number and, second, using the job name. I've included a URL and XML example of each. Btw, these examples are really getting ALL the job data for you, including status. You should be able to parse out the status from what's returned.

 

Prep:

This is the base of the URL request: http://hostname:port/api/DSP-Name/

where 'DSP Name' is 'Demand Side Platform Name' (I think? It’s just how they write it in the Tidal API Reference Guide). For tidal, this is 'tes-6.X' which is your Tidal Enterprise Scheduler version (ex: tes-6.2)

 

Get status using Job Number (abbreviated Job No. on the Tidal application):

 

     <?xml version="1.0" encoding="UTF-8" ?>

     <entry xmlns="http://purl.org/atom/ns#">

         <tes:JobRun.get xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">

             <id>11111111</id>

             <selectColumns></selectColumns>

             <queryCondition></queryCondition>

         </tes:JobRun.get>

     </entry>

 

Get status using Job Name:

 

     <?xml version="1.0" encoding="UTF-8" ?>

     <entry xmlns="http://purl.org/atom/ns#">

         <tes:JobRun.get xmlns:tes="http://www.tidalsoftware.com/client/tesservlet">

             <id></id>

             <selectColumns></selectColumns>

             <queryCondition>name='Job Name'</queryCondition>

         </tes:JobRun.get>

     </entry>

 

The unused tags in the XML (id, selectColumns, queryCondition) can be removed-- I just left them in to make clear they can all be used in the query.