Group Routes

auth = dmda.DomoTokenAuth(
    domo_instance=os.environ['DOMO_INSTANCE'],
    domo_access_token=os.environ["DOMO_ACCESS_TOKEN"],
)

Search and Get Routes


source

search_groups_by_name

 search_groups_by_name (auth:domolibrary.client.DomoAuth.DomoAuth,
                        search_name:str, is_exact_match:bool=True,
                        debug_api:bool=False,
                        session:httpx.AsyncClient=None,
                        debug_num_stacks_to_drop=1, parent_class:str=None)

uses /content/v2/groups/grouplist api – includes user details


source

SearchGroups_Error

 SearchGroups_Error
                     (res:domolibrary.client.ResponseGetData.ResponseGetDa
                     ta, message=None)

base exception


source

Group_GET_Error

 Group_GET_Error (res:domolibrary.client.ResponseGetData.ResponseGetData,
                  message=None)

base exception

Sample implementation of search_groups_by_name

search_name = "Test Groupie"
try:
    res = await search_groups_by_name(
        auth=auth, search_name=search_name, debug_api=False
    )
    print(res)
except (Group_GET_Error, SearchGroups_Error) as e:
    print(e)
🛑  SearchGroups_Error 🛑 - function: get_traceback || status 200 || There is no exact match for Test Groupie at domo-community

source

get_all_groups

 get_all_groups (auth:domolibrary.client.DomoAuth.DomoAuth,
                 session:httpx.AsyncClient=None, debug_api:bool=False,
                 debug_loop:bool=False, debug_num_stacks_to_drop:int=1,
                 parent_class:str=None, return_raw:bool=False,
                 maximum=None)

uses /content/v2/groups/grouplist api – includes user details

Sample implementation of get_all_groups

res = await get_all_groups(auth=auth, maximum = 5)

print(f"{len(res.response)} groups retrieved")

pd.DataFrame(res.response)
5 groups retrieved
name groupId owners groupType memberCount created description
0 ADM | Orientation 49793884 [{'type': 'GROUP', 'id': '49793884', 'displayN... open 15 2023-06-08 20:59:05.0
1 Admin Test 1814479647 [{'type': 'USER', 'id': '55874022', 'displayNa... closed 3 2023-01-29 23:37:13.0
2 April 2023 Cohort 926594289 [{'type': 'USER', 'id': '958797472', 'displayN... closed 33 2023-04-03 17:50:31.0 Group for ALL Domo Customer Orientation worksh...
3 BCAMP 368426120 [{'type': 'GROUP', 'id': '822382906', 'display... closed 2 2024-03-06 03:58:55.0
4 Bcamp April 2024 1502227797 [] adHoc 36 2024-04-02 03:44:09.0 NaN

source

get_group_by_id

 get_group_by_id (auth:domolibrary.client.DomoAuth.DomoAuth, group_id:str,
                  debug_api:bool=False, session:httpx.AsyncClient=None,
                  parent_class:str=None, debug_num_stacks_to_drop:int=1)

uses /content/v2/groups/ api – does not return details

await get_group_by_id(auth=auth, group_id=1259653287)
ResponseGetData(status=200, response={'id': 1259653287, 'name': 'Test Group 2_deleted_7ece7d46-48ef-11ee-b1a1-12193c00dc43', 'type': 'open', 'userIds': [], 'creatorId': 1893952720, 'memberCount': 0, 'guid': 'aabb6587-ad53-11ed-82c3-0a09ba383c95', 'description': 'update metadata - updated 2023-09-01', 'hidden': False, 'default': False, 'active': False}, is_success=True, parent_class=None)

source

toggle_system_group_visibility

 toggle_system_group_visibility (auth, is_hide_system_groups:bool,
                                 debug_api:bool=False,
                                 debug_prn:bool=False,
                                 debug_num_stacks_to_drop=1,
                                 parent_class:str=None,
                                 session:httpx.AsyncClient=None)

source

is_system_groups_visible

 is_system_groups_visible (auth:domolibrary.client.DomoAuth.DomoAuth,
                           session:httpx.AsyncClient,
                           debug_api:bool=False,
                           debug_num_stacks_to_drop=1,
                           parent_class:str=None, return_raw:bool=False)

source

Group_CRUD_Error

 Group_CRUD_Error (res:domolibrary.client.ResponseGetData.ResponseGetData,
                   message=None)

base exception

await is_system_groups_visible(auth=auth)
ResponseGetData(status=200, response={'keyspace': 'domo', 'issuer': 'domo', 'entityId': 'mmmm-0012-0200', 'key': 'groups.system.enabled', 'value': True, 'values': ['true']}, is_success=True, parent_class=None)

sample toggle_group_visibility

res = await toggle_system_group_visibility(auth=auth, is_hide_system_groups=True)

res = await get_all_groups(auth=auth)
all_groups = res.response

(await toggle_system_group_visibility(auth=auth, is_hide_system_groups=False)).response


# res = await get_all_groups(auth=auth)
# all_groups_with_hidden = res.response

# print(
#     f"there are {len(all_groups)} standard groups, and {len(all_groups_with_hidden)} groups including system groups"
# )

# [
#     group["name"]
#     for group in all_groups_with_hidden
#     if group["groupId"] not in [all_group["groupId"] for all_group in all_groups]
# ][0:5]
{'keyspace': 'domo',
 'issuer': 'domo',
 'entityId': 'mmmm-0012-0200',
 'key': 'groups.system.enabled',
 'value': True,
 'values': ['true']}

CRUD Routes


source

generate_body_create_group

 generate_body_create_group (group_name:str, group_type:str='open',
                             description:str='')

Generates the body to create group for content_v2_group API


source

GroupType_Enum

 GroupType_Enum (value, names=None, module=None, qualname=None, type=None,
                 start=1)

An enumeration.

sample_implementation of generate_body_create_group

generate_body_create_group(
    group_name="test_group_name",
    group_type=GroupType_Enum.ADHOC.value,
    description="from jupyter",
)
{'name': 'test_group_name', 'type': 'adHoc', 'description': 'from jupyter'}

source

create_group

 create_group (auth:domolibrary.client.DomoAuth.DomoAuth, group_name:str,
               group_type:str='open', description:str='',
               session:httpx.AsyncClient=None, debug_api:bool=False,
               debug_num_stacks_to_drop:int=1, parent_class:str=None,
               return_raw:bool=False)

Sample implementation of create_group

try:
    res = await create_group(
        auth=auth, group_name="Test Group ABCD", debug_api=False
    )
    res.response

except Group_CRUD_Error as e:
    print(e)
🛑  Group_CRUD_Error 🛑 - function: get_traceback || status 400 || Test Group ABCD already exists. Choose a different group_name at domo-community

source

update_group

 update_group (auth:domolibrary.client.DomoAuth.DomoAuth, group_id:int,
               group_name:str=None, group_type:str=None,
               description:str=None, additional_params:dict=None,
               debug_api:bool=False, session:httpx.AsyncClient=None,
               debug_num_stacks_to_drop=1, parent_class:str=None)

sample implementation of update_group

# changing group types has restrictions

group_id = "1513712315"

try:
    await update_group(
        auth=auth,
        group_id=group_id,
        # group_name="Test Group ABCs",
        group_type="open",
        description=f"updated via API on {dt.date.today()}",
        additional_params={"dynamicDefinition": "hello world"},
        debug_api=False,
    )

except dmde.RouteError as e:
    print(e)
🛑  Group_CRUD_Error 🛑 - function: get_traceback || status 400 || Bad Request at domo-community

source

delete_groups

 delete_groups (auth:domolibrary.client.DomoAuth.DomoAuth,
                group_ids:List[str], session:httpx.AsyncClient=None,
                debug_api:bool=False, debug_num_stacks_to_drop:int=1,
                parent_class:str=None, return_raw:bool=False)
Type Default Details
auth DomoAuth
group_ids List list of group_ids
session AsyncClient None
debug_api bool False
debug_num_stacks_to_drop int 1
parent_class str None
return_raw bool False
Returns ResponseGetData
try:
    res = await create_group(
        auth=auth,
        group_name="hello world",
        description=f"updated via API on {dt.date.today()}",
        debug_api=False,
    )

    group_id = res.response.get("id")

    await delete_groups(auth=auth, group_ids=group_id, debug_api=False)
except Exception as e:
    print(e)
🛑  Group_CRUD_Error 🛑 - function: get_traceback || status 400 || hello world already exists. Choose a different group_name at domo-community

Group Membership

GET Group Ownership


source

get_group_owners

 get_group_owners (auth:domolibrary.client.DomoAuth.DomoAuth,
                   group_id:str, debug_api:bool=False,
                   debug_num_stacks_to_drop=1,
                   session:httpx.AsyncClient=None, parent_class:str=None,
                   return_raw:bool=False)
Type Default Details
auth DomoAuth
group_id str
debug_api bool False
debug_num_stacks_to_drop int 1
session AsyncClient None
parent_class str None
return_raw bool False
Returns ResponseGetData maximum: int = None,
skip: int = 0,
debug_loop: bool = False,

sample implementation of get_ownership

group_id = 1781661643

res = await get_group_owners(
    auth=auth,
    group_id=group_id,
    debug_api = False, 
    # debug_loop = True,
    return_raw = False
)

pd.DataFrame(res.response)
type id displayName
0 GROUP 822382906 Grant: Manage all groups
1 USER 1893952720 Jae Wilson1
2 GROUP 1781661643 TestMembership

source

get_group_membership

 get_group_membership (auth:domolibrary.client.DomoAuth.DomoAuth,
                       group_id:str, return_raw:bool=False,
                       debug_api:bool=False, maximum=None,
                       session:httpx.AsyncClient=None,
                       parent_class:str=None,
                       debug_num_stacks_to_drop:int=1,
                       debug_loop:bool=False)

sample implementation of get_membership

group_id = 1781661643

res = await get_group_membership(
    auth=auth,
    group_id=group_id,
    maximum = None
)

pd.DataFrame(res.response)
userId role roleId lastSignIn location
0 696468809 Community_Default_Priviliged 2097317660 2021-04-19 16:36:26.944 NaN
1 1345737456 Privileged 2 2024-06-10 13:00:07.0
2 1141078945 Community_Default_Priviliged 2097317660 2021-04-28 03:58:56.0 NaN

CRUD Group Membership


source

generate_body_update_group_membership

 generate_body_update_group_membership (group_id:str,
                                        add_owner_arr:List[str]=None,
                                        remove_owner_arr:List[str]=None,
                                        remove_member_arr:List[str]=None,
                                        add_member_arr:List[str]=None)

each member or owner obj should be an object of shape {“type”, “id”}

generate_body_update_group_membership(group_id = 123)
[{'groupId': 123}]

source

update_group_owners

 update_group_owners (auth:domolibrary.client.DomoAuth.DomoAuth,
                      group_id:str, add_owner_arr:list[dict]=None,
                      remove_owner_arr:list[dict]=None,
                      debug_api:bool=False,
                      session:httpx.AsyncClient=None,
                      parent_class:str=None,
                      debug_num_stacks_to_drop:int=1)

each member or owner obj should be an object of shape {“type”, “id”}


source

update_group_members

 update_group_members (auth:domolibrary.client.DomoAuth.DomoAuth,
                       group_id:str, add_member_arr:list[dict]=None,
                       remove_member_arr:list[dict]=None,
                       debug_api:bool=False,
                       session:httpx.AsyncClient=None,
                       parent_class:str=None,
                       debug_num_stacks_to_drop:int=1)

each member or owner obj should be an object of shape {“type”, “id”}


source

update_group_membership

 update_group_membership (auth:domolibrary.client.DomoAuth.DomoAuth,
                          group_id:str, update_payload:dict=None,
                          add_member_arr:list[dict]=None,
                          remove_member_arr:list[dict]=None,
                          add_owner_arr:list[dict]=None,
                          remove_owner_arr:list[dict]=None,
                          debug_api:bool=False,
                          session:httpx.AsyncClient=None,
                          parent_class:str=None,
                          debug_num_stacks_to_drop:int=1)

each member or owner obj should be an object of shape {“type”, “id”}

Sample implementation of generate_body_update_group_membership and update_group_membership

group_id = 1513712315

add_user_obj = {"id": auth.user_id, "type": "USER"}

try:
    print(await update_group_membership(
        auth=auth,
        group_id=group_id,
        add_member_arr=[add_user_obj],
        add_owner_arr=[add_user_obj],
        debug_api = False
    ))

except dmde.RouteError as e:
    print(e)
ResponseGetData(status=200, response='', is_success=True, parent_class=None)