Skip to content

Iteration of results #63

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

Closed
jantman opened this issue Jul 28, 2015 · 4 comments
Closed

Iteration of results #63

jantman opened this issue Jul 28, 2015 · 4 comments

Comments

@jantman
Copy link
Contributor

jantman commented Jul 28, 2015

I'm using GitLab CE 7.12.2, and trying to list users via the API. I have 162 users. After connecting to GitLab using python-gitlab 0.9.2 from PyPi (my connection is self.conn), self.conn.User() returns a list with 20 items, a fraction of my users.

The GitLab API documentation says that it paginates responses with a default of 20 results per response.

It appears that python-gitlab is ignoring the pagination. The only use of the "page" response attribute that I see in the source code is on line 341 where it's deleted before passing to the constructor.

Could you please either implement pagination of responses so python-gitlab doesn't silently ignore results, or at least mention in the docs that this is happening?

Thanks.

@gpocentek
Copy link
Contributor

You can use the page and per_page arguments.

From the README:

for g in gl.Group(page=1, per_page=10):
    print (g)

@jantman
Copy link
Contributor Author

jantman commented Jul 28, 2015

@gpocentek Ok, I'd missed that, sorry. But doesn't that just add those as query parameters and build a URL based on them? The API Docs for Pagination specifically say,

Link headers are send back with each response. These have rel prev/next/first/last and contain the relevant URL. Please use these instead of generating your own URLs.

@dserodio
Copy link

The "automatic" pagination proposed by @jantman would be a great addition. There's no way to find out the max number of pages for a given resource

jantman added a commit to jantman/python-gitlab that referenced this issue Aug 5, 2015
jantman added a commit to jantman/python-gitlab that referenced this issue Aug 5, 2015
gpocentek pushed a commit that referenced this issue Aug 21, 2015
python-gitlab Issue #63 - implement pagination for list()
@gpocentek
Copy link
Contributor

Closing as this as been implemented in #64 . Thanks.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants