EnterpriseApps

auth = dmda.DomoAuth(
    domo_instance=os.environ["DOMO_INSTANCE"],
    access_token=os.environ["DOMO_ACCESS_TOKEN"],
)
auth

design_id = "8c16c8ab-c068-4110-940b-f738d7146efc"

Routes


source

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):

    endpoint = f"/api/apps/v1/designs/{design_id}"

    res = dmda.domo_api_request(
        endpoint=endpoint,
        request_type="get",
        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

source

App_API_Exception

 App_API_Exception (res, message=None)

Common base class for all non-exit exceptions.

domo_app = get_app_by_id(auth=auth, design_id=design_id, debug_api=False).response
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}

source

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):

    endpoint = f"/domoapps/designs/{design_id}/versions"

    return dmda.domo_api_request(
        endpoint=endpoint, auth=auth, request_type="get", debug_api=debug_api
    )
app_versions = get_app_versions(
    auth=auth,
    # design_id=domo_app["id"]
    design_id=design_id,
).response

app_versions
['1.0.0']

source

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,
    debug_api: bool = False,
):

    download_path = dmut.change_suffix(download_path, ".zip")

    endpoint = f"/domoapps/designs/{design_id}/versions/{version}/assets"

    res = dmda.domo_api_stream_request(
        endpoint=endpoint,
        request_type="get",
        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
res = get_app_source_by_version(
    auth=auth,
    design_id=design_id,
    version=app_versions[0],
    debug_api=False,
    download_path="../../TEST/route.zip",
)
done writing stream

source

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):

    endpoint = "/api/apps/v1/designs"

    params = {
        "checkAdminAuthority" : True, 
        "deleted": False,
        "direction" : "desc",
        # "parts" : "owners,creator,thumbnail",
        "search" : "",
        "withPermission" : "ADMIN"}


    res = dmda.domo_api_request(
        endpoint=endpoint,
        request_type="get",
        params=params,
        auth=auth,
        debug_api=debug_api,
    )


    return res
def get_app_permissions(design_id, auth : dmda.DomoAuth, debug_api: bool = False):
    endpoint = f'/api/apps/v1/designs/{design_id}/permissions'

    res = dmda.domo_api_request(
        endpoint=endpoint,
        request_type="get",
        auth=auth,
        debug_api=debug_api,
    )

    if not res.is_success:
        raise App_API_Exception(res = res)
    
    return res
design_id = 'aace1266-dc7f-42cb-8595-46069d91a703'

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):
url = 'https://domo-community.domo.com/api/apps/v1/designs/dde86741-c198-4b9e-8686-cc60f8dfd5be/permissions/ADMIN'

Classes


source

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:
    auth: dmda.DomoAuth = field(repr=False)
    id: str
    name: str
    owner: dmdu.DomoUser
    created_dt: dt.datetime
    lastmodified_dt: dt.datetime
    versions: List[str]
    current_version: str
    referencing_cards: List[dict]

    @classmethod
    def _from_json(cls, obj, auth: dmda.DomoAuth, debug_api: bool = False):

        domo_user = None

        try:
            if obj.get("owner"):
                domo_user = dmdu.DomoUser.get_by_id(
                    user_id=obj["owner"], auth=auth, debug_api=debug_api
                )

        except dmdu.User_API_Exception as e:
            print(e)

        return cls(
            auth=auth,
            id=obj["id"],
            name=obj["name"],
            owner=domo_user,
            created_dt=obj["createdDate"],
            lastmodified_dt=obj["updatedDate"],
            versions=obj["versions"],
            current_version=obj["latestVersion"],
            referencing_cards=obj["referencingCards"],
        )

    @classmethod
    def get_by_id(
        cls,
        design_id,
        auth: dmda.DomoAuth,
        debug_api: bool = False,
        return_raw: bool = False,
    ):
        res = get_app_by_id(auth=auth, design_id=design_id, debug_api=debug_api)

        if return_raw:
            return res

        return cls._from_json(obj=res.response, auth=auth, debug_api=debug_api)

    def get_source_code(
        self,
        version: str = None,
        debug_api: bool = False,
        download_folder="./EXPORT/",
        file_name=None,
    ):

        file_name = file_name or f"{self.id} - {version or self.current_version}.zip"
        file_name = dmut.change_suffix(file_name, ".zip")

        download_path = os.path.join(download_folder, file_name)
        
        return get_app_source_by_version(
            auth=self.auth,
            download_path=download_path,
            design_id=self.id,
            version=version or self.current_version,
            debug_api=debug_api,
        )


    def get_versions(self, debug_api: bool = False, return_raw: bool = False):

        res = get_app_versions(auth=self.auth, design_id=self.id, debug_api=debug_api)
        if return_raw:
            return res

        self.versions = res.response
        return self.versions
# design_id = '897f9ffc-1ce2-4247-94d3-7afcb0192abb'
domo_app = DomoEnterpriseApp.get_by_id(design_id = design_id, auth = auth)

domo_app.get_versions()
domo_app.current_version = domo_app.versions[-1]
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=[])
domo_app.get_source_code(download_folder='../../TEST')
done writing stream
ResponseGetData(response=True, is_success=True, status=200, download_path='..\\..\\TEST\\8c16c8ab-c068-4110-940b-f738d7146efc - 1.0.0.zip')

source

DomoEnterpriseApps

 DomoEnterpriseApps (auth:mbison.client.core.DomoAuth,
                     enterprise_apps:List[__main__.DomoEnterpriseApp]=None
                     )
DomoEnterpriseApps(auth = auth).get_apps(debug_api = False, return_raw = False)[0:5]
[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=[])]