= dmda.DomoTokenAuth(
auth =os.environ['DOMO_INSTANCE'],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token )
Group Routes
Search and Get Routes
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
SearchGroups_Error
SearchGroups_Error (res:domolibrary.client.ResponseGetData.ResponseGetDa ta, message=None)
base exception
Group_GET_Error
Group_GET_Error (res:domolibrary.client.ResponseGetData.ResponseGetData, message=None)
base exception
Sample implementation of search_groups_by_name
= "Test Groupie"
search_name try:
= await search_groups_by_name(
res =auth, search_name=search_name, debug_api=False
auth
)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
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
= await get_all_groups(auth=auth, maximum = 5)
res
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 |
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)
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)
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)
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
= await toggle_system_group_visibility(auth=auth, is_hide_system_groups=True)
res
= await get_all_groups(auth=auth)
res = res.response
all_groups
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
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
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(="test_group_name",
group_name=GroupType_Enum.ADHOC.value,
group_type="from jupyter",
description )
{'name': 'test_group_name', 'type': 'adHoc', 'description': 'from jupyter'}
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:
= await create_group(
res =auth, group_name="Test Group ABCD", debug_api=False
auth
)
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
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
= "1513712315"
group_id
try:
await update_group(
=auth,
auth=group_id,
group_id# group_name="Test Group ABCs",
="open",
group_type=f"updated via API on {dt.date.today()}",
description={"dynamicDefinition": "hello world"},
additional_params=False,
debug_api
)
except dmde.RouteError as e:
print(e)
🛑 Group_CRUD_Error 🛑 - function: get_traceback || status 400 || Bad Request at domo-community
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:
= await create_group(
res =auth,
auth="hello world",
group_name=f"updated via API on {dt.date.today()}",
description=False,
debug_api
)
= res.response.get("id")
group_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
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
= 1781661643
group_id
= await get_group_owners(
res =auth,
auth=group_id,
group_id= False,
debug_api # debug_loop = True,
= False
return_raw
)
pd.DataFrame(res.response)
type | id | displayName | |
---|---|---|---|
0 | GROUP | 822382906 | Grant: Manage all groups |
1 | USER | 1893952720 | Jae Wilson1 |
2 | GROUP | 1781661643 | TestMembership |
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
= 1781661643
group_id
= await get_group_membership(
res =auth,
auth=group_id,
group_id= None
maximum
)
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
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”}
= 123) generate_body_update_group_membership(group_id
[{'groupId': 123}]
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”}
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”}
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
= 1513712315
group_id
= {"id": auth.user_id, "type": "USER"}
add_user_obj
try:
print(await update_group_membership(
=auth,
auth=group_id,
group_id=[add_user_obj],
add_member_arr=[add_user_obj],
add_owner_arr= False
debug_api
))
except dmde.RouteError as e:
print(e)
ResponseGetData(status=200, response='', is_success=True, parent_class=None)