Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-prefixes (and probably others) ignores next field and therefor only returns first 1000 entries #54

Open
nickper opened this issue Aug 11, 2022 · 1 comment

Comments

@nickper
Copy link

nickper commented Aug 11, 2022

I noticed that the library does nothing with the provided next field of the api, and therefor stays quiet about the fact that not all values were returned.
Can something be added (an extra key for example) which automatically request the next url (based on the next field) and add it to the to return list.

https://127.0.0.1/api/ipam/prefixes/

HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 1160,
    "next": "https://127.0.0.1/api/ipam/prefixes/?limit=1000?offset=1000",

https://127.0.0.1/api/ipam/prefixes/?limit=1000?offset=1000

HTTP 200 OK
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 1160,
    "next": "https://127.0.0.1/api/ipam/prefixes/?limit=1000&offset=2000",
    "previous": "https://127.0.0.1/api/ipam/prefixes/?limit=1000",

I now do this as temporary solution

prefixes = []
offset_num = 0
while 1:
    templist = netbox.ipam.get_ip_prefixes(offset=offset_num)
    if templist:
        prefixes.extend(templist)
        offset_num += 1000
        templist = []
    else:
        break

The loop continues until an empty list is returned, which requires an extra unnecessary api call.

@dragonfly-net
Copy link

Reproduced with ipam.get_ip_addresses(), only 1000 records. I want to add some new functions for search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants