Skip to content

manager_view_definition

manager_view_definition

View definition manager for DomoDatasetView.

Provides access to the view's column mapping, source datasets, and join structure via the composition pattern (view.Definition.get(), view.Definition.used_columns_by_dataset, etc.).

DomoDatasetView_DefinitionManager dataclass

DomoDatasetView_DefinitionManager(
    parent: DomoDatasetView = None,
    view_def: ViewDefinition | None = None,
    raw: dict | None = None,
)

Bases: DomoSubEntity

Manager for a dataset view's definition.

Provides typed access to: - ViewDefinition with column mappings, source datasets, and joins - Convenience properties: used_columns_by_dataset, used_columns, source_dataset_ids

Usage

await view.Definition.get() view.Definition.view_def # ViewDefinition view.Definition.used_columns_by_dataset # dict[str, set[str]] view.Definition.used_columns # set[str] view.Definition.source_dataset_ids # set[str]

available_columns property

available_columns: list[str]

All available column names in the view's output. Empty if not loaded.

column_relationships property

column_relationships: set[ColumnRelationship]

Column-level lineage edges for this view. Empty if not loaded.

source_dataset_ids property

source_dataset_ids: set[str]

Source dataset IDs this view depends on. Empty if not loaded.

used_columns property

used_columns: set[str]

All source columns used by this view. Empty if not loaded.

used_columns_by_dataset property

used_columns_by_dataset: dict[str, set[str]]

Map of dataset_id -> set of source column names. Empty if not loaded.

build_put_schema async

build_put_schema(
    *, context: RouteContext | None = None, **context_kwargs
) -> dict

Build a PUT-ready schema from the loaded definition.

Resolves tableAliases (source-dataset display name -> id) by fetching each source dataset, then normalizes the read response with build_view_put_schema. Call get() first.

Source code in src/crew_dcs/classes/DomoDataset/manager_view_definition.py
 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
async def build_put_schema(
    self,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> dict:
    """Build a PUT-ready ``schema`` from the loaded definition.

    Resolves ``tableAliases`` (source-dataset display name -> id) by fetching
    each source dataset, then normalizes the read response with
    ``build_view_put_schema``. Call ``get()`` first.
    """
    if self.raw is None:
        raise ValueError(
            "Call `await view.Definition.get()` before build_put_schema()"
        )

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

    select_body = self.raw["viewTemplate"]["select"]["selectBody"]
    source_ids = [select_body["fromItem"]["name"].strip("`")]
    source_ids += [
        j["rightItem"]["name"].strip("`") for j in select_body.get("joins", [])
    ]

    table_aliases: dict[str, str] = {}
    for ds_id in source_ids:
        meta = await dataset_routes.get_dataset_by_id(
            auth=self.auth, dataset_id=ds_id, return_raw=True, context=context
        )
        table_aliases[meta.response.get("name")] = ds_id

    return build_view_put_schema(self.raw, table_aliases)

get async

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

Fetch the view definition for this dataset view.

Populates self.view_def with a typed ViewDefinition (and self.raw with the raw schema/indexed response, used to build a PUT payload).

Returns:

Type Description
ViewDefinition

ViewDefinition instance with typed access to all definition data.

Source code in src/crew_dcs/classes/DomoDataset/manager_view_definition.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
async def get(
    self,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> ViewDefinition:
    """Fetch the view definition for this dataset view.

    Populates self.view_def with a typed ViewDefinition (and self.raw with
    the raw schema/indexed response, used to build a PUT payload).

    Returns:
        ViewDefinition instance with typed access to all definition data.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await dataset_routes.get_dataset_view_schema_indexed(
        auth=self.auth,
        dataset_id=self.parent.id,
        context=context,
    )

    if res.is_success:
        self.raw = res.response
        self.view_def = ViewDefinition.from_dict(res.response)

    return self.view_def

update async

update(
    schema: dict | None = None,
    data_source_name: str | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Update this view's definition (PUT /api/query/v1/views/{id}).

Parameters:

Name Type Description Default
schema dict | None

The view schema payload (tables + viewTemplate + tableAliases). If omitted, it is built from the loaded definition via build_put_schema() (call get() first) — this performs an idempotent re-save of the current definition.

None
data_source_name str | None

Optional view display name.

None
Source code in src/crew_dcs/classes/DomoDataset/manager_view_definition.py
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
async def update(
    self,
    schema: dict | None = None,
    data_source_name: str | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Update this view's definition (PUT /api/query/v1/views/{id}).

    Args:
        schema: The view schema payload (tables + viewTemplate + tableAliases).
            If omitted, it is built from the loaded definition via
            ``build_put_schema()`` (call ``get()`` first) — this performs an
            idempotent re-save of the current definition.
        data_source_name: Optional view display name.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    if schema is None:
        schema = await self.build_put_schema(context=context)

    return await dataset_routes.update_view(
        auth=self.auth,
        view_id=self.parent.id,
        schema=schema,
        data_source_name=data_source_name,
        context=context,
    )