VMware Cloud Community
jmedd
Enthusiast
Enthusiast
Jump to solution

vRO REST API: querying workflows by categoryID

In PowervRO we have a function Get-vROWorkflow which uses the vRO REST API to query workflows:

PowervRO/Get-vROWorkflow.ps1 at master · jakkulabs/PowervRO · GitHub

One of the options is to query by categoryName using the following URL:

"/vco/api/workflows/?conditions=categoryName=$($Category)"

We have a request to enhance this function to instead be able to query by categoryID. I tried the following, but it did not work and also could not find any documentation on how to discover what other 'conditions' are available:

"/vco/api/workflows/?conditions=categoryId=$($CategoryId)"

Is it possible to query the workflows API using a categoryId as a condition? If so, how should it be formed?

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Jonathan,

Workflow's properties that could be used in this conditional filtering are id, name, description, categoryName and version. So currently it is not possible to use categoryId in a condition, unless we add some code to do so on vRO server side (feel free to open a PR about it).

There is a workaround, though. You can get the same result in two steps:

1) Make a GET request to fetch the category with the given categoryId. It could be something like:

GET /vco/api/catalog/System/WorkflowCategory?conditions=id=ff80808165ed93fd0165ed955493000f

The returned response content should contain a href to the category object. Look for a link element that looks similar to:

<link href="https://10.20.30.50:8281/vco/api/catalog/System/WorkflowCategory/ff80808165ed93fd0165ed955493000f/" rel="down">

2) Using the value of this href element, append workflows at its end (that's the name of the relation from the category to its child workflows). The URL should look like:

https://10.20.30.50:8281/vco/api/catalog/System/WorkflowCategory/ff80808165ed93fd0165ed955493000f/wo...

Now, if you make GET request with this URL, you'll get the list of workflows that are within this category.

Hope the above makes sense.

View solution in original post

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Jonathan,

Workflow's properties that could be used in this conditional filtering are id, name, description, categoryName and version. So currently it is not possible to use categoryId in a condition, unless we add some code to do so on vRO server side (feel free to open a PR about it).

There is a workaround, though. You can get the same result in two steps:

1) Make a GET request to fetch the category with the given categoryId. It could be something like:

GET /vco/api/catalog/System/WorkflowCategory?conditions=id=ff80808165ed93fd0165ed955493000f

The returned response content should contain a href to the category object. Look for a link element that looks similar to:

<link href="https://10.20.30.50:8281/vco/api/catalog/System/WorkflowCategory/ff80808165ed93fd0165ed955493000f/" rel="down">

2) Using the value of this href element, append workflows at its end (that's the name of the relation from the category to its child workflows). The URL should look like:

https://10.20.30.50:8281/vco/api/catalog/System/WorkflowCategory/ff80808165ed93fd0165ed955493000f/wo...

Now, if you make GET request with this URL, you'll get the list of workflows that are within this category.

Hope the above makes sense.

Reply
0 Kudos
jmedd
Enthusiast
Enthusiast
Jump to solution

Excellent, that works great - thanks a lot!

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
Reply
0 Kudos