Skip to content

definition

definition

AppStudio definition and view management via composition.

Provides typed access to app-level metadata (title, theme, navigation) and view management (each view is a DomoPage instance).

Usage

app = await DomoAppStudio.get_by_id(auth=auth, appstudio_id='667742883') await app.Definition.get() app.Definition.title # "Dynamic card rendering"

await app.Views.get() for view in app.Views.views: await view.Layout.get() await view.Layout.swap_cards({0: 123456})

AppStudioDefinition dataclass

AppStudioDefinition(
    data_app_id: int,
    title: str,
    enabled: bool = True,
    locked: bool = False,
    description: str | None = None,
    landing_view_id: int | None = None,
    nav_orientation: str = "TOP",
    show_domo_navigation: bool = True,
    show_logo: bool = False,
    show_navigation: bool = True,
    show_title: bool = True,
    app_type: str = "app",
    theme: dict | None = None,
    navigations: list[AppStudioNavigation] = list(),
    views: list[AppStudioViewRef] = list(),
    persist_settings: (
        AppStudioPersistSettings | None
    ) = None,
    owners: list[dict] = list(),
    icon_data_file_id: int = 0,
    nav_icon_data_file_id: int | None = None,
)

Typed representation of the v1/dataapps API response.

Contains app-level metadata: title, theme, navigation, views, etc. Use via DomoAppStudio.Definition.get() / .update().

AppStudioNavigation dataclass

AppStudioNavigation(
    data_app_id: int,
    entity: str,
    entity_id: str,
    title: str,
    nav_order: int,
    visible: bool,
    description: str | None = None,
    interaction: dict | None = None,
    icon: dict | None = None,
    icon_position: str | None = None,
    style: dict | None = None,
)

Navigation item in an AppStudio app.

AppStudioPersistSettings dataclass

AppStudioPersistSettings(
    data_app_id: int,
    persist_filters_enabled: bool = False,
    persist_interactions_enabled: bool = False,
    persist_date_enabled: bool = False,
    persist_variables_enabled: bool = False,
    persisted_columns: list = list(),
)

Persist settings for an AppStudio app.

AppStudioViewRef dataclass

AppStudioViewRef(
    view_id: int,
    title: str,
    parent_view_id: int = 0,
    view_order: int = 1,
    visible: bool = True,
    children: list = list(),
)

Reference to a view (page) within an AppStudio app.

This is a lightweight reference — the actual DomoPage is fetched separately via the Views manager.

DomoAppStudio_DefinitionManager dataclass

DomoAppStudio_DefinitionManager(
    parent: DomoEntity,
    definition: AppStudioDefinition | None = None,
)

Bases: DomoSubEntity

Manager for app-level metadata (title, theme, navigation, views).

Usage

app = await DomoAppStudio.get_by_id(auth=auth, appstudio_id='667742883') await app.Definition.get() app.Definition.title # "Dynamic card rendering" app.Definition.update() # push current state

apply_style async

apply_style(
    preset=None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> AppStudioDefinition

Apply a style preset to the app definition and save.

Fetches the definition if not already loaded, applies the preset, and saves the updated definition to the API.

Parameters:

Name Type Description Default
preset

An AppStudioStylePreset instance. Defaults to MINIMAL_LIGHT.

None
context RouteContext | None

Optional RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
AppStudioDefinition

The updated AppStudioDefinition.

Source code in src/crew_dcs/classes/DomoAppStudio/definition.py
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
385
386
387
388
389
390
async def apply_style(
    self,
    preset=None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> AppStudioDefinition:
    """Apply a style preset to the app definition and save.

    Fetches the definition if not already loaded, applies the preset,
    and saves the updated definition to the API.

    Args:
        preset: An AppStudioStylePreset instance. Defaults to MINIMAL_LIGHT.
        context: Optional RouteContext for request configuration
        **context_kwargs: Additional context parameters

    Returns:
        The updated AppStudioDefinition.
    """
    from .styling_optimizer import (
        MINIMAL_LIGHT,
        apply_preset_to_definition,
    )

    context = RouteContext.build_context(context=context, **context_kwargs)

    preset = preset or MINIMAL_LIGHT

    if not self.definition:
        await self.get(context=context)

    apply_preset_to_definition(self.definition, preset)
    await self.update(context=context)

    return self.definition

get async

get(
    *, context: RouteContext | None = None, **context_kwargs
) -> AppStudioDefinition

Fetch the app definition from the v1/dataapps API.

Parameters:

Name Type Description Default
context RouteContext | None

Optional RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
AppStudioDefinition

AppStudioDefinition with typed access to all app metadata

Source code in src/crew_dcs/classes/DomoAppStudio/definition.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
async def get(
    self,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> AppStudioDefinition:
    """Fetch the app definition from the v1/dataapps API.

    Args:
        context: Optional RouteContext for request configuration
        **context_kwargs: Additional context parameters

    Returns:
        AppStudioDefinition with typed access to all app metadata
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await appstudio_routes.get_appstudio_by_id(
        auth=self.parent.auth,
        appstudio_id=str(self.parent.id),
        context=context,
    )

    self.definition = AppStudioDefinition.from_dict(res.response)
    return self.definition

update async

update(
    *, context: RouteContext | None = None, **context_kwargs
) -> bool

Push the current definition state to the v1/dataapps API.

Parameters:

Name Type Description Default
context RouteContext | None

Optional RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
bool

True if successful, raises AppStudio_CRUD_Error otherwise

Source code in src/crew_dcs/classes/DomoAppStudio/definition.py
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
351
352
353
async def update(
    self,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> bool:
    """Push the current definition state to the v1/dataapps API.

    Args:
        context: Optional RouteContext for request configuration
        **context_kwargs: Additional context parameters

    Returns:
        True if successful, raises AppStudio_CRUD_Error otherwise
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    if not self.definition:
        raise ValueError("Definition not loaded. Call get() first.")

    res = await appstudio_routes.update_appstudio(
        auth=self.parent.auth,
        appstudio_id=str(self.parent.id),
        body=self.definition.get_body(),
        context=context,
    )

    return res.is_success

DomoAppStudio_ViewsManager dataclass

DomoAppStudio_ViewsManager(
    parent: DomoEntity, views: list[Any] = list()
)

Bases: DomoSubEntity

Manager for AppStudio views as DomoPage instances.

Each view in an AppStudio app IS a page — this manager fetches view IDs from the app definition and hydrates them as DomoPage objects, giving you full access to Layout.get(), Layout.swap_cards(), etc.

Usage

app = await DomoAppStudio.get_by_id(auth=auth, appstudio_id='667742883') await app.Views.get() for view in app.Views.views: print(f'View: {view.title} (page_id={view.id})') await view.Layout.get() await view.Layout.swap_cards({0: 123456})

get async

get(
    *, context: RouteContext | None = None, **context_kwargs
) -> list[Any]

Fetch all views as DomoPage instances.

Requires that the app definition has been loaded (via Definition.get() or get_by_id). Hydrates each view_id into a full DomoPage.

Parameters:

Name Type Description Default
context RouteContext | None

Optional RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
list[Any]

List of DomoPage instances, one per view

Source code in src/crew_dcs/classes/DomoAppStudio/definition.py
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
async def get(
    self,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[Any]:
    """Fetch all views as DomoPage instances.

    Requires that the app definition has been loaded (via Definition.get()
    or get_by_id). Hydrates each view_id into a full DomoPage.

    Args:
        context: Optional RouteContext for request configuration
        **context_kwargs: Additional context parameters

    Returns:
        List of DomoPage instances, one per view
    """
    from .. import DomoPage as dp

    context = RouteContext.build_context(context=context, **context_kwargs)

    # Get view IDs from the definition
    if not self.parent.Definition or not self.parent.Definition.definition:
        await self.parent.Definition.get(context=context)

    view_refs = self.parent.Definition.definition.views
    if not view_refs:
        self.views = []
        return self.views

    # Hydrate each view as a DomoPage
    self.views = []
    for view_ref in view_refs:
        page = await dp.DomoPage.get_by_id(
            auth=self.parent.auth,
            page_id=str(view_ref.view_id),
            include_layout=True,
            context=context,
        )
        self.views.append(page)

    return self.views