RoleHierarchy

a class based approach to handling role hierarchy

source

extract_role_hierarchy

 extract_role_hierarchy (role:domolibrary.classes.DomoRole.DomoRole,
                         hierarchy_delimiter, debug_prn:bool=False)
Type Default Details
role DomoRole
hierarchy_delimiter
debug_prn bool False
Returns DomoRole augments the domo role with a hierarchy INT attribute

source

get_roles_w_hierarchy

 get_roles_w_hierarchy (auth, hierarchy_delimiter=' - h',
                        debug_prn:bool=False, debug_api:bool=False)

gets instance roles and adds an attribute hierarchy

Type Default Details
auth
hierarchy_delimiter str - h post fix to delimit hierarchy number. assumes scale of 1:10, system accounts will be included.
debug_prn bool False
debug_api bool False
token_auth = dmda.DomoTokenAuth(
    domo_instance=os.environ['DOMO_INSTANCE'],
    domo_access_token=os.environ["DOMO_ACCESS_TOKEN"],
)


domo_roles = await get_roles_w_hierarchy(auth=token_auth)


pd.DataFrame(
    [
        {
            "role_name": role.name,
            "role_id": role.id,
            "description": role.description,
            "hierarchy": role.hierarchy,
        }
        for role in sorted(domo_roles, key=lambda x: x.hierarchy, reverse=True)
    ]
)
role_name role_id description hierarchy
0 Admin 1 Full access to everything 9
1 manual_super_admin 275763436 Full access to everything - h9 9
2 Privileged 2 Full access except for editing users and setti... 7
3 Editor 3 Can edit Cards, Pages, DataSets, and Dataflows 5
4 Participant 4 Read only access to Cards and Pages 3
5 Social 5 Access limited to social features 1
6 super_admin_v3 104295428 upsert via DomoLibrary 0
7 test_update_metadata 108369421 last updated - 2024-11-11 0
8 super_admin 810756122 all grants - updated on 2024-11-07 0
9 dl_test 1348436096 deployed via domo_library script - updated 202... 0
10 dl department library 1563101750 deployed via domo_library script - updated 202... 0
11 dl test 1662852841 deployed via domo_library script - updated 202... 0
12 dl_department_admin 1856229592 deployed via domo_library script - updated 202... 0
13 Community_Default_Priviliged 2097317660 Full access except for editing users and setti... 0

source

calc_role

 calc_role (current_role_id, new_role_name, auth, hierarchy_delimiter=' -
            h', is_alter_system_roles:bool=False, debug_prn:bool=False)

compares current role to new role hierarchy and returns the higher one. will not adjust system roles

Type Default Details
current_role_id
new_role_name
auth
hierarchy_delimiter str - h
is_alter_system_roles bool False by default calc role will not apply to system roles and will always update to a system role
debug_prn bool False
print(await calc_role(3, "manual_super_admin", auth=token_auth, debug_prn=True))
print("\n")
print(
    await calc_role(
        3,
        "manual_super_admin",
        is_alter_system_roles=True,
        auth=token_auth,
        debug_prn=True,
    )
)
print("\n")
try:
    print(
        await calc_role(
            3, "social", is_alter_system_roles=True, auth=token_auth, debug_prn=True
        )
    )
except Exception as e:
    print(e)
print("\n")
print(
    await calc_role(
        3, "Social", is_alter_system_roles=True, auth=token_auth, debug_prn=True
    )
)
Editor is a system role -- no changes
DomoRole(id=3, name='Editor', description='Can edit Cards, Pages, DataSets, and Dataflows', is_system_role=True, is_default_role=False, grants=[], membership_ls=[])


upgrade role: Editor - 5 to a manual_super_admin - 9
DomoRole(id=275763436, name='manual_super_admin', description='Full access to everything - h9', is_system_role=0, is_default_role=False, grants=[], membership_ls=[])


social not found in domo-community


do nothing:  Editor - 5 exceeds or equals Social - 1
DomoRole(id=3, name='Editor', description='Can edit Cards, Pages, DataSets, and Dataflows', is_system_role=True, is_default_role=False, grants=[], membership_ls=[])