Reply

Infoblox DDI API - Pagination

[ Edited ]
New Member
Posts: 1
1859     1

Hello,

I am a bit rusty with APIs, and I am attempting to retrieve all the IPAM addresses under 

GET /ipam/address. I am struggling with retrieving more than 1000 records.


In the API documentation, it states I can pass a parameter using "_page_token."

I attempted to do this by adding to my curl request

../api/ddi/v1/ipam/address?_page_token=3

But that doesn't work I still recieve the same 1000 records and I don't seem to recieve a id or token in the response.

Any help would be great!

Re: Infoblox DDI API - Pagination

Techie
Posts: 8
1859     1

This is a function I wrote for infoblox networks to get around pagination

 

def get_infoblox_networks(conn, max_results=950): # iblox sets the max result per page as 1000 so set it at 950 to be safe.
"""
Fetch all networks from an Infoblox instance with pagination.
"""
networks = []
page_id = None

while True:
params = {
'_paging': 1,
'_max_results': max_results,
'_return_as_object': 1,
'_return_fields': 'network,comment,extattrs'
}

if page_id:
params['_page_id'] = page_id

response = conn.get_object('network', params)

if not response:
break

networks.extend(response)
page_id = response[0].get('_next_page_id', None)

if not page_id:
break

return networks

Showing results for 
Search instead for 
Did you mean: 

Recommended for You