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

Would be nice to have a NS1.listZones() and/or Zone.list() #68

Open
nyetwurk opened this issue Jul 22, 2020 · 5 comments
Open

Would be nice to have a NS1.listZones() and/or Zone.list() #68

nyetwurk opened this issue Jul 22, 2020 · 5 comments

Comments

@nyetwurk
Copy link

something akin to

    return zones.Zone(self.config, None)._rest.list()
@nyetwurk
Copy link
Author

Perhaps Zone itself can have a list() method that just extracts a list of bare zone['zone']s

@nyetwurk nyetwurk changed the title Would be nice to have a api.listZones() Would be nice to have a NS1.listZones() and/or Zone.list() Jul 22, 2020
@rupa
Copy link
Contributor

rupa commented Jul 23, 2020

huh, definitely fair to want easier access to list, seems like an oversight.

I don't think I'd want it on Zone objects, as it's higher scope, but I think a listZones method on the client is appropriate. I'll see if i can whip up a PR.

@nyetwurk
Copy link
Author

this code more or less works for me (from an api client, not an api patch)

    data = zones.Zone(api.config, None)._rest.list()
    print("known zones:")
    for z in data:
      print(z["zone"])

@rupa
Copy link
Contributor

rupa commented Jul 30, 2020

yep, that works, but it's not really the way we envisioned its use. usually we access this via the "rest layer"

zones = client.zones()
zones.list()

for the "high-level" interface, I still believe that a listZones function is appropriate - my suspicion is that it hasn't been implemented as it should return Zone objects, and loading all of those zones would take N API calls. I would not want that happening if i had thousands of zones in my list!

what I'd like to do, and proposed, is to make listZones return a list of mostly empty Zone objects, and you would have to make a call to "load" the ones you want. That would need a bit of docs/comments explaining it, and i worry a bit if it would be more confusing than useful, but I'm inclined to add it. it's definitely on the radar!

@ThiagoYU
Copy link
Contributor

ThiagoYU commented Oct 6, 2021

Hi @nyetwurk @rupa, thanks for this report
We already created a ticket about this.

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

3 participants