5. FilteringΒΆ

Any collection is what the system calls a “queryset” and can be filtered via various operators.

For example, to find the groups that contain the name “foo”:

http://<Tower server name>/api/v1/groups/?name__contains=foo

To do an exact match:

http://<Tower server name>/api/v1/groups/?name=foo

If a resource is of an integer type, you must add “__int” to the end to cast your string input value to an integer, like so:

http://<Tower server name>/api/v1/arbitrary_resource/?x__int=5

Related resources can also be queried, like so:

http://<Tower server name>/api/v1/groups/?user__firstname__icontains=john

This will return all groups with users with names that include the string “John” in them.

You can also filter against more than one field at once:

http://<Tower server name>/api/v1/groups/?user__firstname__icontains=john&group__name__icontains__foo

This will find all groups containing a user whose name contains John where the group contains the string foo.

For more about what types of operators are available, see:

You may also wish to watch the API as the UI is being used to see how it is filtering on various criteria.