NabuCasa / pycognito

Python library for using AWS Cognito. With support for SRP.
Apache License 2.0
132 stars 39 forks source link

Add list_user_pool_clients with pagination and better pagination support for users and groups #267

Closed wazy closed 2 months ago

wazy commented 2 months ago

This PR does the following:

An example of why having pagination limit and explicit pagination token support is that this is useful in a very large pool let's say 1000 clients/groups/users where you need to have some way to request smaller chunks of items and then be able to continue from where you left off. I'm using this approach from a frontend calling lambda that uses these pycognito changes to retrieve pages of clients/groups/users one chunk at a time based on page_tokens passed back and forth.

Not sure if you are the correct one to tag for the PR review @ludeeus but let me know if you have any feedback/request for changes.

wazy commented 2 months ago

@ludeeus just added a commit to allow username to be specified for admin_update_profile along with a helper function to determine if attrs is already formatted for cognito - includes tests and doesn't break existing code

This can be done now to update a user's attributes ->

cognito = Cognito(user_pool_id=user_pool_id)
cognito.admin_update_profile(username=username, attrs=attrs)
ludeeus commented 2 months ago

Hi @wazy , I have not fully looked at this yet. But please split it up in several PRs, so each PR only add/change one thing.

And the token needs to be a local reference in the individual functions or there will be conflicts in an asynchronous workflow.

wazy commented 2 months ago

Hi @wazy , I have not fully looked at this yet. But please split it up in several PRs, so each PR only add/change one thing.

And the token needs to be a local reference in the individual functions or there will be conflicts in an asynchronous workflow.

I can break it into 2-3 PRs if you'd like.

I'm not sure asynch makes sense for the support of walking through the pagination manually since the next token becomes available once cognito responds with the requested results.

wazy commented 2 months ago

@ludeeus Created #268 #269 #270 to continue conversation :+1: