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

Modify get_users to return all users in the user pool instead of just the first 60 #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions warrant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,17 +463,27 @@ def get_users(self, attr_map=None):
"""
Returns all users for a user pool. Returns instances of the
self.user_class.
:param attr_map:
:return:
:param attr_map: Dictionary map from Cognito attributes to attribute
names we would like to show to our users
:return: list of self.user_class
"""
kwargs = {"UserPoolId":self.user_pool_id}
response = self.client.list_users(UserPoolId=self.user_pool_id)
user_list = response.get("Users")
page_token = response.get("PaginationToken")

while page_token:
response = self.client.list_users(
UserPoolId=self.user_pool_id,
PaginationToken=page_token
)
user_list.extend(response.get("Users"))
page_token = response.get("PaginationToken")

response = self.client.list_users(**kwargs)
return [self.get_user_obj(user.get('Username'),
attribute_list=user.get('Attributes'),
metadata={'username':user.get('Username')},
attr_map=attr_map)
for user in response.get('Users')]
for user in user_list]

def admin_get_user(self, attr_map=None):
"""
Expand Down