- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How to get Number of DNS records using Rest API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2022 09:51 AM
Hi Everyone,
I am using REST API to get the DNS records details from InfoBlox and below is the API I am using
https://{{grid_master}}/wapi/v2.7/record:host?_max_results=1000&_paging=1&_return_as_object=1
From the result returned I am using "next_page_id" field to make further calls to the API. The next api calls looks like this
https://{{grid_master}}/wapi/v2.7/record:host?_max_results=1000&_paging=1&_return_as_object=1&_page_id=" + next_page_id
Now my issue is I am unable to get the total DNS records present in the grid master via API, so that I can limit the number of calls I can make. Can anyone let me know how can I get the total number of DNS records present in the grid?
Thanks,
Sandeep
Re: How to get Number of DNS records using Rest API
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 03:21 PM
I don't think you are looking for the number of records. You just want to know what next page is and keep parsing thought them.
Something like this might work (this is for devices that are discovered).
### Get the first set of devices and a page ID curl -s -k -u $MYUID:$PASS 'content-Type: application/json' -X GET "https://${IBGM}/wapi/v2.12.2/discovery:device?_paging=1&_return_as_object=1&_max_results=100" >$TMPFILE NEXT=$(egrep "next_page_id" $TMPFILE | awk -F\" '{print $4}') egrep '"address": "' $TMPFILE | awk -F\" '{print $4}' >>$OUTFILE ### If NEXT is exists, then use that to get next page while [ -n $NEXT ] ; do curl -s -k -u $MYUID:$PASS 'content-Type: application/json' -X GET "https://${IBGM}/wapi/v2.12.2/discovery:device?_paging=1&_return_as_object=1&_max_results=100&_page_id=$NEXT"| >$TMPFILE NEXT=$(egrep "next_page_id" $TMPFILE | awk -F\" '{print $4}') egrep '"address": "' $TMPFILE | awk -F\" '{print $4}' >>$OUTFILE done