In the previous article about vRealize Operations API, I walked you through the process of connecting to your vROps instance using Postman. We set up variable, like a vROps URL, credentials, token etc. Today we will do something practical. We are going to bulk delete cancelled alerts. Cancelled alerts are marked by switched off light bulb.
In the first step we need to create call with authorization header. As you could find out from the previous article, we are going to use bearerToken to authenticate with vROps.
Call:
DELETE https://{{vrops}}/suite-api/api/alerts/bulk?
If you do not know what {{vrops}}
is, please read previous article.
Also please have a look at Postman collection on VMware {code} for vRealize Operations REST API. Looking over the code should give you a good understanding and ability to tweak a code to your needs.
Lets have a look at the body of the call. From documentation, we can read that this call require a body of type ns3:alert-query. That means that we can use various of filters to find the alerts which are of our interest.
As we are looking for alerts with particular status, we can set filter to CANCELED.
The body should look like this:
{
"alert-query": {
"alertStatus": "CANCELED"
}
}
Please like and share to spread the knowledge in the community.
If you want to chat with me please use Twitter: @AngrySysOps
Join my VMware Knowledge Base Group: https://bit.ly/3w54tbc
Visit my FB page: https://www.facebook.com/AngrySysOps
Read my blog: https://angrysysops.com
Subscribe to my channel : https://bit.ly/3vY16CT