I decided to open-source the code of my previous projects and tools I built. Since I’m using GitHub more and more to help me with current projects I felt it unfair that I kept all my code to myself without sharing so I started uploading past projects into my GitHub. So amongst others you’ll find the code for:
and Vdisk Informer
In my GitHub repository found >HERE<
Most of these tools are legacy now but someone might find something useful in them….ENJOY….
If you wanted to get started with VMware vSphere APIs watch my UK VMware User Group session last month. Its a refresh of an older session I use to deliver. I focus less now on the SOAP based API and more on the REST based API.
A colleague of mine (@peteroudman )asked me how to grab a parameter through filtering a JSON response generated from the vRA REST API after he had tried several times. The parameter in question was workItem number. The purpose of this was to automate a catalog item request that has an approval request attached to it. To achieve this we need to compare the response from a few different API calls. We ran into an issue doing what we need purely with REST calls but let me explain from the beginning so you learn something:
- We want to automate the request of a catalog item from outside of vRA
- Using the catalogItemId we make a request call using a predefined payload (JSON entry) using the catalog-service API request function
- The response header from the above call informs us of a parameter known as the requestId
- Because the catalog item as an approval request waiting for someone to accept or reject this request we need to programmatically handle this.
- When there is some action needed by the user a workitem request is generated.
- We noticed that when you list all workitems there was a parameter in the JSON response called requestInstanceId which was identical to the requestID. This is the key to how we associate the original request to which workitem needs action.
- So the plan is to filter all the workitems expect the one relevant to our catalog request
- The API has a filter function when you make a GET request
- The problem is that requestInstanceId parameter is not filterable because its an inner-feed in the JSON response and not a JSON element.
- We tried every possibility to format the filter sting and some examples look like this:
- $filter=(workItemRequest/itemData/entries(6)/value/value eq ’18f71a3a-34c1-4624-9e20-11f4666a6b4a’)
- ?$filter=(workItemRequest/itemData(6)/value eq ‘7990b2ce-0497-4a5a-9c40-060350086078’)
The conclusion is that we have to filter the workitem response outside of the API call in code. Not difficult but would have been nice to have that feature in the filter. I realise this is a high-level explanation but if you want to discuss this problem in detail reach out to me. Like to thank @grantorchard for trying his best to fix this for us.