Question

Nutanix Rest API v3 FIQL Filtering

  • 29 September 2021
  • 7 replies
  • 602 views

I’m looking for more details regarding the use of the “filter” attribute and getting a list of VMs.

https://www.nutanix.dev/reference/prism_central/v3/api/vms/postvmslist/ 

 

I've been able to filter down VMs returned using the filter = “vm_name==my-vm-name” in my Rest API quiries but I was looking for some more examples.

In particular it would be great if I could find VMs by IP address or MAC address to try and hunt down VMs without doing a full VM list query.

Is there additional documentation on the FIQL filtering options in the REST api?


7 replies

I’m looking for the same information.

I can’t seem to find any documentation on this.

Are there any wildcards that can be used? * doesn’t seem to work.

I did figure out that if you include .*VMNAME.* it appears that wildcards do work. However this appears to switch the API to a case sensitive regex.
I found that if I encoded my queries like:
.*[Vv][Mm][Nn][Aa][Mm][Ee].* that it would return any VMs that contained the word “VMNAME” in either letter case. 
I then did some manual filtering if I wanted to get an exact match.

This was over all still much faster than dumping the entire list of VMs and filtering it down.

Cool, this is usefull information. Thanks!

I didn’t expect that the API would require me to handle the regex part, but on the other hand it allows for most flexibility ofcourse.

 

@Nutanix, I still could use some more documentation on this though :blush:

Userlevel 2
Badge +1

I’m going to continue this thread instead of creating my own to keep the rest of the posters in the loop.

@Jon - the last I read from you on this topic was that you hadn’t productized the filtering in the V3 API, but that was 2 years ago. Any updates on the filter functionality?

In my specific case I want to filter VMs on a category value and I can’t find any proper reference or documentation on how to do this in the Prism Central V3 API.

It’d be extremely convenient to filter directly in the API call instead of grabbing all VMs and then filter in my code.

Userlevel 6
Badge +29

@Martin Edelius - What version of PC are you trying to use in this case? Just want to make sure I get my ducks in the right order when I respond

Userlevel 2
Badge +1

Hi @Jon.

Sorry for the delayed reply, time is in short supply. :)

We’re using pc.2021.9.0.3.

What I’m actually looking for is proper documentation on how I can use filters in general when using Nutanix API’s. The FIQL standard/syntax is in itself relatively poorly documented and I can’t find any examples relating to JSON, only XML.

I can get my search to work for simple things like name but categories or similar “arrays” of values is a complete mystery.

Any update on this? I am trying to explore REST APIs to filter Vms, Hosts

  • Get VMs under a particular host
  • Get Hosts under a particular Cluster

Hoping this filtering is possible with FIQL. If we can get some documentation around this will be useful

 

Reply