in src/pkg/qs_user_gov.py [0:0]
def update_role(user):
"""
Update QuickSight user role.
If the User's role is downgraded, delete the user.
"""
updated = False
try:
QS_CLIENT.update_user(
UserName=user.qs_username,
AwsAccountId=user.account_id,
Namespace=user.namespace,
Role=user.qs_role,
Email=user.email,
)
LOGGER.info(f"[{user.qs_username}] role set to: {user.qs_role}")
updated = True
except ClientError as err:
if (
err.response['Error']['Code'] == 'ResourceNotFoundException'
or err.response['Error']['Code'] == 'InvalidParameterValueException'
):
delete_user(user)
return updated