vRealize Operations's Manager API is becoming rich version by version. One of the good introduction, starting version 6.1 is support for Reporting. So now you can create report ( generate report) via API. In this part, I will show how to Create report via API. The Second part would focus on how we can Schedule report.
Those who are new to vROps API topic can go through one of my old posts.
Introduction to vROps REST API
vROps REST API docs can be found at https://vROPS.fqdn/suite-api/docs/rest/index.html.
Look for /api/reports section. We will be using the POST action for /api/reports. On the right-hand side you would see sample requests for Create Report like below.
You can use either XML or JSON body for vROPs. I will be using JSON. Below is the sample request in JSON format. We need to get highlighted UUIDs.
{
"resourceId" : "24ae0ae8-2823-438a-a588-04c320f15e17",
"reportDefinitionId" : "97d19754-0ad3-4de1-b35b-d8ad5d07be24",
"traversalSpec" : {
"name" : "vSphere Hosts and Clusters",
"rootAdapterKindKey" : "VMWARE",
"rootResourceKindKey" : "vSphere World",
"adapterInstanceAssociation" : false,
"others" : [ ],
"otherAttributes" : {
}
},
"others" : [ ],
"otherAttributes" : {
},
"id" : null
}
First one is Resource ID. It is the ID of the resource, for example, a VirtualMachine, Host, Clusters, Datastore etc. You can get the ID by firing below request in web-browser.
https://vROPS.fqdn/suite-api/api/resources.
Look for the resource name(in our case a virtual machine) for which you want to run the report, then note down the Identifier as shown below.
Next is to get the ReportDefinitionID. It is the ID of the report which you want to execute remotely. You can get the ID by firing below the request.
https://vROPS.fqdn/suite-api/api/reportdefinitions
Look for the name of the report.In our case VM Inventory - Disk Space Report.
Now let's understand what does Traversal Spec means.It means how would you traverse down for generating the report, i.e while generating report we have to select an Object.In our case, we want to execute this report for a Virtual Machine. Imagine you are doing it manually, so you will select vSphere Hosts and Clusters. Similarly via API as well, we have to look for vSphere Hosts and Clusters kind key values. So we note down rootAdapterKindkey and rootResourceKindKey values.( as highlighted above)
That's it. Our request is now ready for generating report.
For firing REST calls you can use your preferred REST tools. Most common are plugins for Mozilla, Chrome and Postman.
Execution
Method : POST
URL: https://vROPS.fqdn/suite-api/api/reports
Enter Content-Type header value as application/json.
Ready to FIRE!!
You can verify the response from
That's it. Verify that the report has been successfully generated by going to vROps Report GUI!!
In the next blog part, I will show how we can extend this and Schedule Report as well. Combination of these operations via API will be useful in many use-cases.
Stay tuned!!
Those who are new to vROps API topic can go through one of my old posts.
Introduction to vROps REST API
vROps REST API docs can be found at https://vROPS.fqdn/suite-api/docs/rest/index.html.
Look for /api/reports section. We will be using the POST action for /api/reports. On the right-hand side you would see sample requests for Create Report like below.
You can use either XML or JSON body for vROPs. I will be using JSON. Below is the sample request in JSON format. We need to get highlighted UUIDs.
{
"resourceId" : "24ae0ae8-2823-438a-a588-04c320f15e17",
"reportDefinitionId" : "97d19754-0ad3-4de1-b35b-d8ad5d07be24",
"traversalSpec" : {
"name" : "vSphere Hosts and Clusters",
"rootAdapterKindKey" : "VMWARE",
"rootResourceKindKey" : "vSphere World",
"adapterInstanceAssociation" : false,
"others" : [ ],
"otherAttributes" : {
}
},
"others" : [ ],
"otherAttributes" : {
},
"id" : null
}
First one is Resource ID. It is the ID of the resource, for example, a VirtualMachine, Host, Clusters, Datastore etc. You can get the ID by firing below request in web-browser.
https://vROPS.fqdn/suite-api/api/resources.
Look for the resource name(in our case a virtual machine) for which you want to run the report, then note down the Identifier as shown below.
Next is to get the ReportDefinitionID. It is the ID of the report which you want to execute remotely. You can get the ID by firing below the request.
https://vROPS.fqdn/suite-api/api/reportdefinitions
Look for the name of the report.In our case VM Inventory - Disk Space Report.
Now let's understand what does Traversal Spec means.It means how would you traverse down for generating the report, i.e while generating report we have to select an Object.In our case, we want to execute this report for a Virtual Machine. Imagine you are doing it manually, so you will select vSphere Hosts and Clusters. Similarly via API as well, we have to look for vSphere Hosts and Clusters kind key values. So we note down rootAdapterKindkey and rootResourceKindKey values.( as highlighted above)
That's it. Our request is now ready for generating report.
For firing REST calls you can use your preferred REST tools. Most common are plugins for Mozilla, Chrome and Postman.
Execution
Method : POST
URL: https://vROPS.fqdn/suite-api/api/reports
Enter Content-Type header value as application/json.
Ready to FIRE!!
You can verify the response from
That's it. Verify that the report has been successfully generated by going to vROps Report GUI!!
In the next blog part, I will show how we can extend this and Schedule Report as well. Combination of these operations via API will be useful in many use-cases.
Stay tuned!!