Hi! I've got several questions about the usage of v2 API which I have not been able to solve by myself after looking a little while.
on some endpoints, for example, GET /alerts, GET /vms and a few more things are functioning for me as expected, but on other endpoints, such as POST /vms/{uuid}/set_power_state I am receiving the following response:
I've been searching for detailed information on your error code (such as 1100 listed above) and couldn’t find. Is there any documentation to the error codes that you can send me a link to?
Also, in a few of the API endpoints I couldn’t understand exactly what is the expected query parameter to be sent. 2 examples of endpoints I felt I am lacking knowledge what exactly meant to be sent
GET /vms
filter: Filter criteria - semicolon for AND, comma for OR. where can I find what counts as filter criteria?
POST /alerts/acknowledge
classification - unsure which classifications can be sent
And regarding the documentation of REST APIs, we only have this https://www.nutanix.dev/reference/prism_element/v2/api/ documentation for APIs, but let me get back to you with some detailed answer about the parameters required for those 2 API endpoints after implementing the same.
Thanks a lot Anish!
about - Are you sure when executing API POST /vms/{uuid}/set_power_state , you are entering all the required parameters?
quite sure, I did a GET /vms , took “uuid” field I got from one of the vms there.
Hey @Tomer-M , thanks for the udpate. Let me research more on this error and get back as soon as I find anything.
I was using a username for authentication and the user did not have permissions to do such actions, that’s why I was getting the access denied message, my bad. Thanks!
Ahh I see, that makes sense @Tomer-M , glad it worked out.
Awesome.
If you could still somehow figure what are the possibilities for filters for get /vms and get /hosts it would be great, as for some filters I'm getting "message": "Exception while retrieving entities : java.lang.RuntimeException: Unrecognized field X passed, unable to build filter.", and for other filters it seems to be functioning as expected. Thanks!
hey @Tomer-M , sure I will get back to you on this after researching on this.
Yes this error message is expected “"message": "Exception while retrieving entities : java.lang.RuntimeException: Unrecognized field X passed, unable to build filter.",” when wrong parameters are passed.
Hey @Tomer-M , So I did a little research on the Filter parameter for the GET /vms and GET /hosts v2 API.
Unfortunately, filters are officially not supported. Therefore any filters would be unsupported/undocumented.
Now it does not mean they don’t work. It’s just that you have to figure out which params are supported by trying them out.
I will tell you what I do is I usually do a simple GET of the object, examine it that helps me figure out what POST syntax works
Then try filtering on some of its params to see which ones work. Unfortunately, we don’t have any documentation for this. Hopefully, REST API v4 is better documented.
In the above do you notice : affected_entities": t { "entity_type": "cluster", "entity_type_display_name": null, "entity_name": null, "uuid": "000582c6-cf0d-e0a8-0000-000000016950", "id": "92496" }
]
I think this is what “affected_entities” is an array of above params. And “entity_type” here is a string “cluster” and I think It can be “host”,”vm” etc type of entities, and as per above the “entity_type_ids” would be the id value “92496”(here it is the cluster ID).
] I've tried inserting both the “uuid” and “id” fields mentioned here for my alerts, but it did not have any effect (other alerts with different id or uuid fields were not filtered)
Hey @Tomer-M ,thanks a lot buddy for such kind words, really appreciate them.
It is always a pleasure to help.
So let me research about this param more and get back to you soon.
Thanks a lot @AnishWalia20, I’ll be waiting for your response. thanks!
Hey @Tomer-M , so I researched a bit on it.
So basically the parameter “entity_ids” could most likely be the list of UUIDs of the alerts you want to get? I’m just guessing since you mentioned it doesn’t work or show anything differently with the entity ids of VMs, cluster, host etc.
Within the REST API, the entity usually designates a returned object, so it could be anything.
Since this is a GET method, this is a list of things you get, not one you specify like in a POST method.
If any of these answers help, please mark one of them as ‘Best Answer’. This will help others in the community find the same content much faster. Thanks for contributing to the community.