-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: docsImprovement to the documentation for an API.Improvement to the documentation for an API.
Description
Environment details
- OS type and version: Linux, CentOS 7
- Python version: 3.8.10
- pip version: 20.2.3
google-api-python-client
version: 2.49.0
Steps to reproduce
- Follow the sample pagination code here: https://googleapis.github.io/google-api-python-client/docs/pagination.html
- Implement this technique for the users list API, against a Cloud Identity environment that has 100, 200, 300, or 400 users (because pageSize defaults to 100... this should theoretically be reproduced with 5 users and a pageSize of 5, etc.)
Code example
request = service.users().list(domain='*********.com', orderBy='email')
users = []
while request is not None:
user_list = request.execute()
for user in user_list['users']:
users.append(user)
request = service.users().list_next(request, user_list)
Output
After the first N pages of users returns from the API, the response object contains this (see below), and the code sample produces an infinite loop:
{'etag': '"SEQQBYC70u6XQ2UUjmjNYw6b0a5EzY0mTMShjiZga8A/HMFwD2wLX237BRmKZQUJYB5ZE7U"', 'kind': 'admin#directory#users'}
{'etag': '"SEQQBYC70u6XQ2UUjmjNYw6b0a5EzY0mTMShjiZga8A/HMFwD2wLX237BRmKZQUJYB5ZE7U"', 'kind': 'admin#directory#users'}
{'etag': '"SEQQBYC70u6XQ2UUjmjNYw6b0a5EzY0mTMShjiZga8A/HMFwD2wLX237BRmKZQUJYB5ZE7U"', 'kind': 'admin#directory#users'}
{'etag': '"SEQQBYC70u6XQ2UUjmjNYw6b0a5EzY0mTMShjiZga8A/HMFwD2wLX237BRmKZQUJYB5ZE7U"', 'kind': 'admin#directory#users'}
...
jcfrt
Metadata
Metadata
Assignees
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: docsImprovement to the documentation for an API.Improvement to the documentation for an API.