Skip to content

core

core

DomoAppStudio dataclass

DomoAppStudio(
    auth: DomoAuth,
    id: int,
    raw: dict,
    title: str = None,
    is_locked: bool = None,
    owners: list = list(),
    custom_attributes: dict = dict(),
    Lineage: DomoLineage = None,
    Definition: DomoAppStudio_DefinitionManager
    | None = None,
    Views: DomoAppStudio_ViewsManager | None = None,
)

Bases: DomoEntity_w_Lineage

add_appstudio_owner async classmethod

add_appstudio_owner(
    auth: DomoAuth,
    appstudio_id_ls: list[int],
    group_id_ls: list[int],
    user_id_ls: list[int],
    note: str | None = None,
    send_email: bool = False,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
@classmethod
async def add_appstudio_owner(
    cls,
    auth: DomoAuth,
    appstudio_id_ls: list[int],  # AppStudio IDs to be updated by owner,
    group_id_ls: list[int],  # DomoGroup IDs to share page with
    user_id_ls: list[int],  # DomoUser IDs to share page with
    note: str | None = None,  # message for automated email
    send_email: bool = False,  # send or not email to the new owners
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await appstudio_routes.add_page_owner(
        auth=auth,
        appstudio_id_ls=appstudio_id_ls,
        group_id_ls=group_id_ls,
        user_id_ls=user_id_ls,
        note=note,
        send_email=send_email,
        context=context,
    )

    return res  # noqa: RET504

from_dict classmethod

from_dict(auth: DomoAuth, obj: dict[str, Any])

Create a DomoAppStudio instance from a dictionary representation.

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
165
166
167
168
@classmethod
def from_dict(cls, auth: DomoAuth, obj: dict[str, Any]):
    """Create a DomoAppStudio instance from a dictionary representation."""
    return cls._from_content_stacks_v3(page_obj=obj, auth=auth)

get_accesslist async

get_accesslist(
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
async def get_accesslist(
    self,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await appstudio_routes.get_appstudio_access(
        auth=self.auth,
        appstudio_id=self.id,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise Exception("error getting access list")

    from ..DomoGroup import core as dmg

    s = {
        # "explicit_shared_user_count": res.response.get("explicitSharedUserCount"),
        "total_user_count": res.response.get("totalUserCount"),
    }

    user_ls = res.response.get("users", None)
    domo_users = []
    if user_ls and isinstance(user_ls, list) and len(user_ls) > 0:
        domo_users_manager = dmdu.DomoUsers(auth=self.auth)
        domo_users = await domo_users_manager.search_by_id(
            user_ids=[user.get("id") for user in user_ls],
            only_allow_one=False,
            suppress_no_results_error=True,
        )

    group_ls = res.response.get("groups", None)
    domo_groups = []
    if group_ls and isinstance(group_ls, list) and len(group_ls) > 0:
        domo_groups = await dmce.gather_with_concurrency(
            n=60,
            *[  # noqa: B026
                dmg.DomoGroup.get_by_id(group_id=group.get("id"), auth=self.auth)
                for group in group_ls
            ],
        )

    return {
        **s,
        "domo_users": domo_users,
        "domo_groups": domo_groups,
    }

get_by_id async classmethod

get_by_id(
    appstudio_id: str,
    auth: DomoAuth,
    return_raw: bool = False,
    debug_api: bool = False,
    session: AsyncClient = None,
    debug_num_stacks_to_drop: int = 2,
    check_if_published: bool | None = None,
    parent_auth_retrieval_fn: Callable | None = None,
    parent_auth: DomoAuth | None = None,
    max_subscriptions_to_check: int | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
@classmethod
async def get_by_id(
    cls,
    appstudio_id: str,
    auth: DomoAuth,
    return_raw: bool = False,
    debug_api: bool = False,
    session: httpx.AsyncClient = None,
    debug_num_stacks_to_drop: int = 2,
    check_if_published: bool | None = None,
    parent_auth_retrieval_fn: Callable | None = None,
    parent_auth: DomoAuth | None = None,
    max_subscriptions_to_check: int | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    # Auto-enable publish checking when parent auth is provided (either directly or via retrieval fn)
    # unless explicitly disabled
    if (parent_auth_retrieval_fn or parent_auth) and check_if_published is None:
        check_if_published = True

    context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await appstudio_routes.get_appstudio_by_id(
        auth=auth,
        appstudio_id=appstudio_id,
        context=context,
    )

    if return_raw:
        return res

    is_published = False
    subscription = None
    if check_if_published and (parent_auth_retrieval_fn or parent_auth):
        # Create a retrieval function from parent_auth if only parent_auth was provided
        effective_retrieval_fn = parent_auth_retrieval_fn
        if not effective_retrieval_fn and parent_auth:
            effective_retrieval_fn = lambda _domain: parent_auth  # noqa: E731

        # Local import to avoid circular dependency
        from ..subentity.lineage.federation_context import FederationContext

        probe = FederationContext.from_entity_id(
            auth=auth,
            entity_id=str(appstudio_id),
            entity_type="DATA_APP",
        )
        is_published = await probe.check_if_published(
            retrieve_parent_auth_fn=effective_retrieval_fn,
            entity_type="DATA_APP",
            session=session,
            debug_api=debug_api,
            max_subscriptions_to_check=max_subscriptions_to_check,
        )
        if is_published:
            subscription = probe.subscription

    app = await cls._from_content_stacks_v3(
        page_obj=res.response,
        auth=auth,
    )

    if is_published and subscription:
        helper = app.enable_federation_support()
        helper.hydrate_from_existing(
            subscription=subscription,
            parent_auth_retrieval_fn=parent_auth_retrieval_fn,
            parent_auth=parent_auth,
            content_type="DATA_APP",
            entity_id=str(appstudio_id),
        )

    # Auto-trace lineage if parent_auth_retrieval_fn is provided
    if parent_auth_retrieval_fn and app.Lineage:
        await app.Lineage.get(
            parent_auth_retrieval_fn=parent_auth_retrieval_fn,
            parent_auth=parent_auth,
            session=session,
            debug_api=debug_api,
            context=context,
        )

    return app

optimize_style async

optimize_style(
    preset_name: str = "minimal_light",
    save: bool = True,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Apply a style preset to the entire app (definition + all views).

Convenience method that delegates to the styling optimizer module.

Parameters:

Name Type Description Default
preset_name str

Name of the preset to apply (case-insensitive). Available presets: MINIMAL_LIGHT, MINIMAL_DARK, EXECUTIVE, DENSE.

'minimal_light'
save bool

If True, saves all changes to the API.

True
context RouteContext | None

Optional RouteContext for request configuration.

None
**context_kwargs

Additional context parameters.

{}

Returns:

Type Description

The updated AppStudioDefinition.

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
async def optimize_style(
    self,
    preset_name: str = "minimal_light",
    save: bool = True,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Apply a style preset to the entire app (definition + all views).

    Convenience method that delegates to the styling optimizer module.

    Args:
        preset_name: Name of the preset to apply (case-insensitive).
            Available presets: MINIMAL_LIGHT, MINIMAL_DARK, EXECUTIVE, DENSE.
        save: If True, saves all changes to the API.
        context: Optional RouteContext for request configuration.
        **context_kwargs: Additional context parameters.

    Returns:
        The updated AppStudioDefinition.
    """
    from .styling_optimizer import get_preset_by_name, optimize_app

    context = RouteContext.build_context(context=context, **context_kwargs)
    preset = get_preset_by_name(preset_name)

    return await optimize_app(
        app=self,
        preset=preset,
        save=save,
        context=context,
    )

share async

share(
    domo_users: list | None = None,
    domo_groups: list | None = None,
    message: str | None = None,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
async def share(
    self,
    domo_users: list | None = None,  # DomoUsers to share page with,
    domo_groups: list | None = None,  # DomoGroups to share page with
    message: str | None = None,  # message for automated email
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(context=context, **context_kwargs)

    if domo_groups:
        domo_groups = (
            domo_groups if isinstance(domo_groups, list) else [domo_groups]
        )
    if domo_users:
        domo_users = domo_users if isinstance(domo_users, list) else [domo_users]

    res = await appstudio_routes.share(
        auth=self.auth,
        appstudio_ids=[self.id],
        group_ids=[group.id for group in domo_groups] if domo_groups else None,
        user_ids=[user.id for user in domo_users] if domo_users else None,
        message=message,
        context=context,
    )

    return res  # noqa: RET504

DomoAppStudios dataclass

DomoAppStudios()

get_appstudios async classmethod

get_appstudios(
    auth=DomoAuth,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_loop: bool = False,
    session: AsyncClient = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

use admin_summary to retrieve all appstudios in an instance -- regardless of user access NOTE: some appstudios APIs will not return results if appstudio access isn't explicitly shared

Calls route

Source code in src/crew_dcs/classes/DomoAppStudio/core.py
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
@classmethod
async def get_appstudios(
    cls,
    auth=DomoAuth,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_loop: bool = False,
    session: httpx.AsyncClient = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """use admin_summary to retrieve all appstudios in an instance -- regardless of user access
    NOTE: some appstudios APIs will not return results if appstudio access isn't explicitly shared
    """
    is_close_session = not session

    session = session or httpx.AsyncClient()

    context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=cls.__name__,
        **context_kwargs,
    )

    try:
        res = await appstudio_routes.get_appstudios_adminsummary(
            auth=auth, debug_loop=debug_loop, context=context
        )

        if return_raw:
            return res

        if not res.is_success:
            raise Exception("unable to retrieve appstudios")

        return await dmce.gather_with_concurrency(
            n=60,
            *[  # noqa: B026
                DomoAppStudio._from_adminsummary(
                    page_obj, auth=auth, context=context
                )
                for page_obj in res.response
            ],
        )

    finally:
        if is_close_session:
            await session.aclose()