Skip to content

Commit

Permalink
Added pagination support and sorted the user list
Browse files Browse the repository at this point in the history
  • Loading branch information
dnmll committed Oct 12, 2023
1 parent cd9e81f commit a905d10
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cid/helpers/quicksight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,25 @@ def select_dashboard(self, force=False) -> str:

def select_user(self):
""" Select a user from the list of users """
all_users = []
next_token = None
try:
user_list = self.identityClient.list_users(AwsAccountId=self.account_id, Namespace='default').get('UserList')
while True:
if next_token:
response = self.identityClient.list_users(AwsAccountId=self.account_id, Namespace='default', NextToken=next_token)
else:
response = self.identityClient.list_users(AwsAccountId=self.account_id, Namespace='default')

user_list = response.get('UserList', [])
all_users.extend(user_list)

next_token = response.get('NextToken')
if not next_token:
break

# Sort the users by UserName
user_list = sorted(all_users, key=lambda x: x.get('UserName'))

except self.client.exceptions.AccessDeniedException as exc:
raise CidCritical('AccessDenied for listing users, your can explicitly provide --quicksight-user parameter') from exc

Expand Down

0 comments on commit a905d10

Please sign in to comment.