def register_user_in_groups()

in packages/constructs/L3/analytics/quicksight-namespace-l3-construct/src/python/quicksight_namespace_user/quicksight_namespace_user.py [0:0]


def register_user_in_groups(username):
    group_name_allusers = NAMESPACE+"-ALLUSERS"
    # Get list of groups in Namespace:
    groups = list_groups().get('GroupList', None)
    new = []
    for group in groups:
        new.append(group['GroupName'])
    groups = new

    # Check and Create Groups if they do not exist:
    for group_name in QUICKSIGHT_GROUPS:
        if group_name not in groups:
            create_group(group_name)
    if group_name_allusers not in groups:
        create_group(group_name_allusers)

    # Add user into ALLUSER group
    response = create_group_membership(username, group_name_allusers)

    # Add user into LOB specific groups
    for group_name in QUICKSIGHT_GROUPS:
        response = create_group_membership(username, group_name)