-
Notifications
You must be signed in to change notification settings - Fork 147
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
OKTA-672843 include response for next() during paging operation #379
OKTA-672843 include response for next() during paging operation #379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
94208cc
to
759735e
Compare
…l to next() during paging
759735e
to
4d1cbb3
Compare
so, when u first call list_users, it's also, in the example below (from the readme), should it be from okta.client import Client as OktaClient
import asyncio
async def main():
client = OktaClient()
users, resp, err = await client.list_users()
while True:
for user in users:
print(user.profile.login)
if resp.has_next():
users, err, response = await resp.next(True) # Specify True to receive the response object as the third part of the tuple for further analysis
else:
break |
@gabrielsroka Yes, at least we don't break existing scripts for users but now we have the functionality for those who requested |
There are no existing scripts that pass in Or you could just create a new method. also, in the example (from the readme), should it be resp or response ? |
also, since you're adding a new feature, maybe u could take another look at the 2-line PR i submitted last year, which @justinabrokwah-okta approved, but then got rolled back |
why is it includeResponse and not include_response? |
to answer my own q, it looks like u need 2 different variables: resp and resp2. so you can't reuse the get_headers(), either. if i change resp2 to resp, i get a weird error, it looks like dicts aren't being converted to objects -- idk if this is a bug: import okta.client
# import okta.api_response
import asyncio
async def main():
# async with reuses the session, so it's much faster.
async with okta.client.Client() as client:
# Paginate users
# resp: okta.api_response.OktaAPIResponse
params = {'filter': 'profile.lastName eq "Doe"', 'limit': 1}
users, resp, err = await client.list_users(params)
print(resp.get_headers().get('x-rate-limit-remaining'))
while True:
for user in users:
print(user.profile.login)
if resp.has_next():
users, err, resp2 = await resp.next(True)
print(resp2.get_headers().get('x-rate-limit-remaining'))
else: break
asyncio.run(main()) |
This change adds a parameter to api_response.next() which causes the response to be returned as the third tuple value during paging operations; this provides access to rate limit headers.