infobloxopen/infoblox-client

How to search for string array types with get_object?

Closed this issue · 2 comments

eest commented

When searching for "ipv4address" records using get_object() I can filter on a specific type using the types field:

host_addresses = conn.get_object('ipv4address', {'network': '192.168.1.0/24', 'status': 'USED', 'types': "HOST"})

Looking at WAPI manual at https://docs.infoblox.com/download/attachments/8945695/Infoblox_RESTful_API_Documentation_2.9.pdf it says the following regarding types:

types
The types of associated objects. This field supports both single and array search.
Type
String array.
Search
The field is available for search via
• ‘:=’ (case insensitive search)
• ‘=’ (exact equality)
Notes
types is part of the base object. types cannot be updated.
types cannot be written.

How would I perform an array search? I feel I have tried all ways I can think of, including:

host_addresses = conn.get_object('ipv4address', {'network': '192.168.1.0/24', 'status': 'USED', 'types': "HOST,FA"})
host_addresses = conn.get_object('ipv4address', {'network': '192.168.1.0/24', 'status': 'USED', 'types': "[HOST,FA]"})
host_addresses = conn.get_object('ipv4address', {'network': '192.168.1.0/24', 'status': 'USED', 'types': ["HOST","FA"]})

... none of them return a result and I cant seem to find any reference regarding what the definition of a "String array" actually means in the context of WAPI.

@eest hi.

I didn't find any information in the wapidoc on how to perform array-search. But I was able to test it on my WAPI instance.

Array-search can be performed this way using curl:

curl -v -k1 -u ${WAPI_USER}:${WAPI_PASS} -X GET https://${WAPI_HOST}/wapi/v2.12/ipv4address\?network=192.168.1.0/24\&types=HOST\&types=FA

But the infoblox-client encodes array values as single key/value pair. I've fixed this behavior in the #287 PR. Take a look at this PR if you want to know more about the fix. I hope it will be merged soon.

eest commented

@achernevskii thank you for the information!