= dmda.DomoAuth(
auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
access_token
)
auth
= "8c16c8ab-c068-4110-940b-f738d7146efc" design_id
EnterpriseApps
Routes
get_app_by_id
get_app_by_id (auth:mbison.client.core.DomoAuth, design_id:str, debug_api:bool=False)
Exported source
class App_API_Exception(dmda.API_Exception):
def __init__(self, res, message= None):
super().__init__(res = res,message = message)
def get_app_by_id(auth: dmda.DomoAuth, design_id: str, debug_api: bool = False):
= f"/api/apps/v1/designs/{design_id}"
endpoint
= dmda.domo_api_request(
res =endpoint,
endpoint="get",
request_type=auth,
auth=debug_api,
debug_api
)
if not res.is_success:
raise App_API_Exception(res = res, message ="is app shared with authenticated user?")
return res
App_API_Exception
App_API_Exception (res, message=None)
Common base class for all non-exit exceptions.
= get_app_by_id(auth=auth, design_id=design_id, debug_api=False).response
domo_app domo_app
{'id': '8c16c8ab-c068-4110-940b-f738d7146efc',
'name': 'nbdev_documentation',
'owner': '1893952720',
'createdBy': '1893952720',
'createdDate': '2022-12-02T17:26:03Z',
'updatedBy': '1893952720',
'updatedDate': '2022-12-02T17:39:38Z',
'description': None,
'versions': [],
'latestVersion': '1.0.0',
'instances': [],
'referencingCards': [],
'owners': [],
'creator': None,
'deletedDate': None,
'trusted': False,
'hasThumbnail': None}
get_app_versions
get_app_versions (auth:mbison.client.core.DomoAuth, design_id, debug_api:bool=False)
Exported source
def get_app_versions(auth: dmda.DomoAuth, design_id, debug_api: bool = False):
= f"/domoapps/designs/{design_id}/versions"
endpoint
return dmda.domo_api_request(
=endpoint, auth=auth, request_type="get", debug_api=debug_api
endpoint )
= get_app_versions(
app_versions =auth,
auth# design_id=domo_app["id"]
=design_id,
design_id
).response
app_versions
['1.0.0']
get_app_source_by_version
get_app_source_by_version (auth:mbison.client.core.DomoAuth, download_path, design_id, version, debug_api:bool=False)
Exported source
def get_app_source_by_version(
auth: dmda.DomoAuth,
download_path,
design_id,
version,bool = False,
debug_api:
):
= dmut.change_suffix(download_path, ".zip")
download_path
= f"/domoapps/designs/{design_id}/versions/{version}/assets"
endpoint
= dmda.domo_api_stream_request(
res =endpoint,
endpoint="get",
request_type=auth,
auth=debug_api,
debug_api=download_path,
download_path
)
if not res.is_success:
raise App_API_Exception(res = res, message = f"unable to download assets for {design_id}")
return res
= get_app_source_by_version(
res =auth,
auth=design_id,
design_id=app_versions[0],
version=False,
debug_api="../../TEST/route.zip",
download_path )
done writing stream
get_all_apps
get_all_apps (auth:mbison.client.core.DomoAuth, debug_api:bool=False)
Exported source
def get_all_apps(auth: dmda.DomoAuth, debug_api: bool = False):
= "/api/apps/v1/designs"
endpoint
= {
params "checkAdminAuthority" : True,
"deleted": False,
"direction" : "desc",
# "parts" : "owners,creator,thumbnail",
"search" : "",
"withPermission" : "ADMIN"}
= dmda.domo_api_request(
res =endpoint,
endpoint="get",
request_type=params,
params=auth,
auth=debug_api,
debug_api
)
return res
def get_app_permissions(design_id, auth : dmda.DomoAuth, debug_api: bool = False):
= f'/api/apps/v1/designs/{design_id}/permissions'
endpoint
= dmda.domo_api_request(
res =endpoint,
endpoint="get",
request_type=auth,
auth=debug_api,
debug_api
)
if not res.is_success:
raise App_API_Exception(res = res)
return res
= 'aace1266-dc7f-42cb-8595-46069d91a703'
design_id
get_app_permissions(= design_id,
design_id= auth
auth )
--------------------------------------------------------------------------- App_API_Exception Traceback (most recent call last) Cell In[21], line 3 1 design_id = 'aace1266-dc7f-42cb-8595-46069d91a703' ----> 3 get_app_permissions( 4 design_id= design_id, 5 auth = auth 6 ) Cell In[20], line 12, in get_app_permissions(design_id, auth, debug_api) 4 res = dmda.domo_api_request( 5 endpoint=endpoint, 6 request_type="get", 7 auth=auth, 8 debug_api=debug_api, 9 ) 11 if not res.is_success: ---> 12 raise App_API_Exception(res = res) 14 return res App_API_Exception: || 404 - No static resource api/apps/v1/designs/aace1266-dc7f-42cb-8595-46069d91a703/permissions. || domo-community
def share_app(auth : dm):
= 'https://domo-community.domo.com/api/apps/v1/designs/dde86741-c198-4b9e-8686-cc60f8dfd5be/permissions/ADMIN' url
Classes
DomoEnterpriseApp
DomoEnterpriseApp (auth:mbison.client.core.DomoAuth, id:str, name:str, owner:mbison.feature.users.DomoUser, created_dt:datetime.datetime, lastmodified_dt:datetime.datetime, versions:List[str], current_version:str, referencing_cards:List[dict])
Exported source
@dataclass
class DomoEnterpriseApp:
= field(repr=False)
auth: dmda.DomoAuth id: str
str
name:
owner: dmdu.DomoUser
created_dt: dt.datetime
lastmodified_dt: dt.datetimestr]
versions: List[str
current_version: dict]
referencing_cards: List[
@classmethod
def _from_json(cls, obj, auth: dmda.DomoAuth, debug_api: bool = False):
= None
domo_user
try:
if obj.get("owner"):
= dmdu.DomoUser.get_by_id(
domo_user =obj["owner"], auth=auth, debug_api=debug_api
user_id
)
except dmdu.User_API_Exception as e:
print(e)
return cls(
=auth,
authid=obj["id"],
=obj["name"],
name=domo_user,
owner=obj["createdDate"],
created_dt=obj["updatedDate"],
lastmodified_dt=obj["versions"],
versions=obj["latestVersion"],
current_version=obj["referencingCards"],
referencing_cards
)
@classmethod
def get_by_id(
cls,
design_id,
auth: dmda.DomoAuth,bool = False,
debug_api: bool = False,
return_raw:
):= get_app_by_id(auth=auth, design_id=design_id, debug_api=debug_api)
res
if return_raw:
return res
return cls._from_json(obj=res.response, auth=auth, debug_api=debug_api)
def get_source_code(
self,
str = None,
version: bool = False,
debug_api: ="./EXPORT/",
download_folder=None,
file_name
):
= file_name or f"{self.id} - {version or self.current_version}.zip"
file_name = dmut.change_suffix(file_name, ".zip")
file_name
= os.path.join(download_folder, file_name)
download_path
return get_app_source_by_version(
=self.auth,
auth=download_path,
download_path=self.id,
design_id=version or self.current_version,
version=debug_api,
debug_api
)
def get_versions(self, debug_api: bool = False, return_raw: bool = False):
= get_app_versions(auth=self.auth, design_id=self.id, debug_api=debug_api)
res if return_raw:
return res
self.versions = res.response
return self.versions
# design_id = '897f9ffc-1ce2-4247-94d3-7afcb0192abb'
= DomoEnterpriseApp.get_by_id(design_id = design_id, auth = auth)
domo_app
domo_app.get_versions()= domo_app.versions[-1]
domo_app.current_version domo_app
DomoEnterpriseApp(id='8c16c8ab-c068-4110-940b-f738d7146efc', name='nbdev_documentation', owner=DomoUser(id=1893952720, display_name='Jae Wilson1', role_id=810756122, email='jae@datacrew.space'), created_dt='2022-12-02T17:26:03Z', lastmodified_dt='2022-12-02T17:39:38Z', versions=['1.0.0'], current_version='1.0.0', referencing_cards=[])
='../../TEST') domo_app.get_source_code(download_folder
done writing stream
ResponseGetData(response=True, is_success=True, status=200, download_path='..\\..\\TEST\\8c16c8ab-c068-4110-940b-f738d7146efc - 1.0.0.zip')
DomoEnterpriseApps
DomoEnterpriseApps (auth:mbison.client.core.DomoAuth, enterprise_apps:List[__main__.DomoEnterpriseApp]=None )
= auth).get_apps(debug_api = False, return_raw = False)[0:5] DomoEnterpriseApps(auth
[DomoEnterpriseApp(id='e09d6625-3680-4fac-bc71-1cd81607eb9a', name='YouTubeViewer Demographic', owner=None, created_dt='2016-07-19T22:10:36Z', lastmodified_dt='2016-09-20T21:41:39Z', versions=[], current_version='1.0.7', referencing_cards=[]),
DomoEnterpriseApp(id='f0b9f8b5-3dac-43c1-8e6e-fe2a7c8e248e', name='iframeApp', owner=None, created_dt='2018-04-24T21:41:02Z', lastmodified_dt='2018-04-24T21:41:02Z', versions=[], current_version='1.0.0', referencing_cards=[]),
DomoEnterpriseApp(id='e2fca4a6-f099-4bba-8163-1b88fb53d427', name='Inline Editing', owner=None, created_dt='2020-11-17T20:16:32Z', lastmodified_dt='2023-10-03T18:58:42Z', versions=[], current_version='5.1.4', referencing_cards=[]),
DomoEnterpriseApp(id='883bec29-4d9c-4caf-b144-9b3a6d07a001', name='form-builder-master', owner=None, created_dt='2019-12-05T23:18:19Z', lastmodified_dt='2024-07-08T16:37:47Z', versions=[], current_version='3.2.7', referencing_cards=[]),
DomoEnterpriseApp(id='c5aa00cc-8c6b-4571-a5cf-6ae5ddcf56a8', name='sugarforce', owner=DomoUser(id=1141078945, display_name='Justin Pumford', role_id=2097317660, email='jpumford@gmail.com'), created_dt='2021-04-14T02:59:48Z', lastmodified_dt='2021-04-14T02:59:49Z', versions=[], current_version='0.1.0', referencing_cards=[])]