= "5e871f13-69d4-4012-8710-b61f654bb2b9"
DATASTORE_ID = "d2b23a60-b1d3-4577-ac85-32ecc619708a" COLLECTION_ID
AppDb
AppDb Routes
AppDb_CRUD_Exception
AppDb_CRUD_Exception (res, message=None)
base exception
AppDb_GET_Exception
AppDb_GET_Exception (res, message=None)
base exception
Datastores
Datastores indicate the app that a collection is associated with. A collection must be created inside a datastore
The app_name (name of the datastore) cannot be modified after it has been created
get_datastores
get_datastores (auth:domolibrary.client.DomoAuth.DomoAuth, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
= (await get_datastores(auth=auth)).response
datastores 0:2] datastores[
[{'id': 'cf1bf391-1391-4152-b15d-4b92bde60331',
'name': 'cf1bf391-1391-4152-b15d-4b92bde60331',
'customer': 'mmmm-0012-0200',
'owner': 1893952720,
'createdOn': '2021-04-21T08:55:20.655+00:00',
'updatedOn': '2021-04-21T08:55:20.655+00:00',
'updatedBy': 1893952720,
'datastore_id': 1240},
{'id': '321de28d-5d44-4ac9-aba8-0e223064d507',
'name': '321de28d-5d44-4ac9-aba8-0e223064d507',
'customer': 'mmmm-0012-0200',
'owner': 1893952720,
'createdOn': '2021-05-11T07:36:21.289+00:00',
'updatedOn': '2021-05-11T07:36:21.289+00:00',
'updatedBy': 1893952720,
'datastore_id': 1289}]
get_datastore_by_id
get_datastore_by_id (auth:domolibrary.client.DomoAuth.DomoAuth, datastore_id:str, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
await get_datastore_by_id(auth=auth, datastore_id=DATASTORE_ID)).response (
{'id': '5e871f13-69d4-4012-8710-b61f654bb2b9',
'name': 'my10c',
'customer': 'mmmm-0012-0200',
'owner': 1893952720,
'createdOn': '2024-06-28T14:13:27.397+00:00',
'updatedOn': '2024-06-28T14:13:27.397+00:00',
'updatedBy': 1893952720,
'datastore_id': 115414}
get_collections_from_datastore
get_collections_from_datastore (auth:domolibrary.client.DomoAuth.DomoAut h, datastore_id:str, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
await get_collections_from_datastore(auth=auth, datastore_id=DATASTORE_ID)).response (
[{'createdOn': '2024-06-28T14:13:27.541+00:00',
'updatedOn': '2024-08-14T03:00:04.922+00:00',
'id': 'd2b23a60-b1d3-4577-ac85-32ecc619708a',
'owner': 1893952720,
'datastoreUuid': '5e871f13-69d4-4012-8710-b61f654bb2b9',
'name': 'code',
'syncRequired': False,
'fullReplaceRequired': True,
'lastSync': '1970-01-02T00:00:00.000+00:00',
'updatedBy': 1893952720,
'syncEnabled': False}]
CRUD Datastores
create_collection
create_collection (auth:domolibrary.client.DomoAuth.DomoAuth, datastore_id:str, collection_name:str, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
Type | Default | Details | |
---|---|---|---|
auth | DomoAuth | ||
datastore_id | str | collections must be created inside a datastore which will show as the associated app_name | |
collection_name | str | ||
parent_class | str | None | |
debug_api | bool | False | |
session | AsyncClient | None | |
debug_num_stacks_to_drop | int | 1 |
create_datastore
create_datastore (auth:domolibrary.client.DomoAuth.DomoAuth, datastore_name=None, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
Type | Default | Details | |
---|---|---|---|
auth | DomoAuth | ||
datastore_name | NoneType | None | in UI shows up as appName, |
parent_class | str | None | |
debug_api | bool | False | |
session | AsyncClient | None | |
debug_num_stacks_to_drop | int | 1 |
Collections
get_collections
get_collections (auth:domolibrary.client.DomoAuth.DomoAuth, datastore_id:str=None, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
Type | Default | Details | |
---|---|---|---|
auth | DomoAuth | ||
datastore_id | str | None | filters for a specific datastoreId |
parent_class | str | None | |
debug_api | bool | False | |
session | AsyncClient | None | |
debug_num_stacks_to_drop | int | 1 |
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
= (await get_collections(auth=auth)).response
collections 0:2] collections[
[{'id': '3e6ba7a6-9261-44fd-8eef-987fdbb99e18',
'datastoreId': 'de230a76-bc70-404e-b3f4-a6f7dea45723',
'defaultPermissions': None,
'requiredAuthorities': None,
'owner': 826020125,
'name': 'ColumnConfig',
'datasourceId': None,
'schema': None,
'filters': None,
'syncEnabled': False,
'syncRequired': False,
'fullReplaceRequired': False,
'lastSync': None,
'createdOn': '2020-11-20T17:58:42.550Z',
'updatedOn': '2024-08-14T03:00:04.922Z',
'updatedBy': 826020125},
{'id': '7464cb2b-1905-4e10-b1f3-52e013394c41',
'datastoreId': 'de230a76-bc70-404e-b3f4-a6f7dea45723',
'defaultPermissions': None,
'requiredAuthorities': None,
'owner': 826020125,
'name': 'DatasetSettings',
'datasourceId': None,
'schema': None,
'filters': None,
'syncEnabled': False,
'syncRequired': False,
'fullReplaceRequired': False,
'lastSync': None,
'createdOn': '2020-11-20T17:58:42.667Z',
'updatedOn': '2024-08-14T03:00:04.922Z',
'updatedBy': 826020125}]
get_collection_by_id
get_collection_by_id (auth:domolibrary.client.DomoAuth.DomoAuth, collection_id, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
(await get_collection_by_id(auth=auth, collection_id=COLLECTION_ID, debug_api=False)
).response
{'id': 'd2b23a60-b1d3-4577-ac85-32ecc619708a',
'datastoreId': '5e871f13-69d4-4012-8710-b61f654bb2b9',
'defaultPermissions': None,
'requiredAuthorities': None,
'owner': 1893952720,
'name': 'code',
'datasourceId': None,
'schema': None,
'filters': None,
'syncEnabled': False,
'syncRequired': False,
'fullReplaceRequired': True,
'lastSync': None,
'createdOn': '2024-06-28T14:13:27.541Z',
'updatedOn': '2024-08-14T03:00:04.922Z',
'updatedBy': 1893952720}
get_documents_from_collection
get_documents_from_collection (auth:domolibrary.client.DomoAuth.DomoAuth, collection_id:str, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, body=None, debug_num_stacks_to_drop=1, query:dict=None)
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
= (
documents await get_documents_from_collection(
=auth, collection_id=COLLECTION_ID, debug_api=False
auth
)
).response documents
[{'id': '37948887-8ba3-4465-a749-c09518930229',
'datastoreId': '5e871f13-69d4-4012-8710-b61f654bb2b9',
'collectionId': 'd2b23a60-b1d3-4577-ac85-32ecc619708a',
'syncRequired': True,
'owner': '1893952720',
'createdBy': '1893952720',
'createdOn': '2024-06-28T15:30:19.818Z',
'updatedOn': '2024-11-11T19:34:07.382Z',
'updatedBy': '1893952720',
'content': {'update': 'testing_upsert',
'update_dt': '2024-06-28',
'id': 12387}},
{'id': '33857249-515b-4659-9779-b85f82675677',
'datastoreId': '5e871f13-69d4-4012-8710-b61f654bb2b9',
'collectionId': 'd2b23a60-b1d3-4577-ac85-32ecc619708a',
'syncRequired': True,
'owner': '1893952720',
'createdBy': '1893952720',
'createdOn': '2024-06-28T19:33:52.179Z',
'updatedOn': '2024-11-11T19:34:08.582Z',
'updatedBy': '1893952720',
'content': {'update': 'upsert_via_class',
'id': 123,
'update_dt': '2024-06-28'}}]
CRUD Collections
modify_collection_permissions
modify_collection_permissions (collection_id:str, auth:domolibrary.client.DomoAuth.DomoAuth, user_id:str=None, group_id:str=None, permi ssion=<Collection_Permission_Enum.READ_CON TENT: 'READ_CONTENT'>, debug_api:bool=False, return_raw:bool=False, parent_class:str=None, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
Exported source
class Collection_Permission_Enum(Enum):
= "READ_CONTENT"
READ_CONTENT = "ADMIN"
ADMIN = "UPDATE_CONTENT"
UPDATE_CONTENT
@gd.route_function
async def modify_collection_permissions(
str,
collection_id:
auth: dmda.DomoAuth,str = None,
user_id: str = None,
group_id: =Collection_Permission_Enum.READ_CONTENT,
permissionbool = False,
debug_api: bool = False,
return_raw: str = None,
parent_class: = None,
session: httpx.AsyncClient =1,
debug_num_stacks_to_drop
):
= f"https://{auth.domo_instance}.domo.com/api/datastores/v1/collections/{collection_id}/permission/{'USER' if user_id else {'GROUP'}}/{user_id or group_id}"
url
= {
params "overwrite": False,
"permissions": (
permission.valueif isinstance(permission, Collection_Permission_Enum)
else permission
),
}
= await gd.get_data(
res =auth,
auth="PUT",
method=params,
params=url,
url=debug_api,
debug_api=debug_num_stacks_to_drop,
num_stacks_to_drop=parent_class,
parent_class=session,
session
)
if return_raw:
return res
if not res.is_success:
raise AppDb_CRUD_Exception(
res,="unable to set permissions for {user_id} to {permission.value} in collection {collection_id}",
message
)
= f"set permissions for {user_id} to {permission.value} in collection {collection_id}"
res.response
return res
Collection_Permission_Enum
Collection_Permission_Enum (value, names=None, module=None, qualname=None, type=None, start=1)
An enumeration.
await modify_collection_permissions(
="b71d2341-8fe4-41af-b55b-163de11a906d",
collection_id="1893952720",
user_id=Collection_Permission_Enum.READ_CONTENT,
permission=auth,
auth )
ResponseGetData(status=204, response='set permissions for 1893952720 to READ_CONTENT in collection b71d2341-8fe4-41af-b55b-163de11a906d', is_success=True, parent_class=None)
# #| export
# # NOT SUPPORTED
# @gd.route_function
# async def update_collection_name(
# auth: dmda.DomoAuth,
# # datastore_id : str, # collections must be created inside a datastore which will show as the associated app_name
# collection_id: str,
# collection_name :str,
# parent_class: str = None,
# debug_api: bool = False,
# session: httpx.AsyncClient = None,
# debug_num_stacks_to_drop=1,
# ):
# url = f"https://{auth.domo_instance}.domo.com/api/datastores/v1/collections/{collection_id}"
# body = {"name": collection_name, "id" : collection_id}
# res = await gd.get_data(
# auth=auth,
# method="PUT",
# url=url,
# body = body,
# parent_class=parent_class,
# debug_api=debug_api,
# session=session,
# num_stacks_to_drop=debug_num_stacks_to_drop,
# )
# if not res.is_success:
# raise AppDb_CRUD_Exception(res)
# return res
# auth = dmda.DomoTokenAuth(
# domo_instance=os.environ['DOMO_INSTANCE'],
# domo_access_token=os.environ["DOMO_ACCESS_TOKEN"],
# )
# (await update_collection_name(auth = auth,
# collection_id =COLLECTION_ID,
# collection_name = f'DL - updated {dt.date.today()}',
# debug_api = True
# )).response
Documents
get_collection_document_by_id
get_collection_document_by_id (auth:domolibrary.client.DomoAuth.DomoAuth, collection_id:str, document_id:str, query:dict=None, parent_class:str=None, debug_api:bool=False, session:httpx.AsyncClient=None, debug_num_stacks_to_drop=1)
= dmda.DomoTokenAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
(await get_collection_document_by_id(
=auth, collection_id=COLLECTION_ID, document_id=documents[0]["id"]
auth
)"content"] ).response[
{'update': 'testing_upsert', 'update_dt': '2024-06-28', 'id': 12387}
CRUD Documents
update_document
update_document (auth:domolibrary.client.DomoAuth.DomoAuth, collection_id:str, document_id:str, content:dict, session:httpx.AsyncClient=None, debug_api:bool=False, parent_class:str=None, debug_num_stacks_to_drop:int=1)
create_document
create_document (auth:domolibrary.client.DomoAuth.DomoAuth, collection_id:str, content:dict, session:httpx.AsyncClient=None, debug_api:bool=False, parent_class:str=None, debug_num_stacks_to_drop:int=1)