- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Infoblox DDI API - Pagination
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 11:58 AM - edited 04-16-2024 12:00 PM
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!
Solved! Go to Solution.
Re: Infoblox DDI API - Pagination
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 10:08 AM
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