API

Welcome to the Nutanix NEXT community. To get started please read our short welcome post. Thanks!

cancel
Showing results for 
Search instead for 
Did you mean: 

v3 - Filter syntax for /vms/list

SOLVED Go to solution
Wayfarer

v3 - Filter syntax for /vms/list

Hello,

 

The /vms/list V3 endpoint takes filters as one of it's options, though it isn't explained how to use those filters in the documentation or in the REST API Explorer.


The documentation shows: filter - string - optional - The filter used for the results.

 

I've tried using something like "vm_name=foo" and various other combinations, but each time I get:

 

{"api_version"=>"3.0", "code"=>400, "kind"=>"vm", "message_list"=>[{"message"=>"Given argument is invalid. Could not process given filter criteria.", "reason"=>"INVALID_ARGUMENT"}], "state"=>"ERROR"}

 

Does anyone have an example of the filter syntax?

 

Cheers, Gavin

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Wayfarer

Re: v3 - Filter syntax for /vms/list

I've figured out the syntax:

vm_name==$thing_to_filter_on

 

 

Tags (2)
3 REPLIES
Wayfarer

Re: v3 - Filter syntax for /vms/list

I've figured out the syntax:

vm_name==$thing_to_filter_on

 

 

Tags (2)
Community Manager

Re: v3 - Filter syntax for /vms/list

Always cool when we are able to figure it out and share it back with the community - Thanks for sharing @gsandie


--
Community Manager, Nutanix
Question Answered? Click Accept as Solution!
Wayfarer

Re: v3 - Filter syntax for /vms/list

You can also do "vm_name!=$thing_to_exclude" to filter on all vm_names apart from the ones you want to exclude.

 

Haven't figured out how to do a match on partials - e.g. "vm_name=~$thing_to_partial_match" - for those times you want to pull out a group of VMS with similar names.