Skip to content

dataset_views

dataset_views

create_semantic_model async

create_semantic_model(
    auth: DomoAuth,
    data_source_name: str,
    schema: dict,
    *,
    data_source_description: str | None = None,
    cloud_id: str = "domo",
    body: dict | None = None,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Create a new data model (POST /api/query/v1/semantic-models).

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
data_source_name str

Model display name

required
schema dict

The model definition: {"objects": {...}, "relationships": [...]} (the shape produced by DataModelTemplate.to_schema())

required
data_source_description str | None

Optional model description

None
cloud_id str

Cloud engine ID (defaults to "domo")

'domo'
body dict | None

Fully pre-built payload; overrides the generated envelope

None
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description
ResponseGetData

ResponseGetData containing the new model's dataSourceId.

Note

The Domo API has a validation bug where non-primary relationships require a non-null alias field but rejects all string values for it. The workaround is to set primary=True for all relationships in the schema. The DataModelTemplate.to_schema() method preserves whatever primary values are set on the relationships.

Source code in src/crew_dcs/routes/dataset/dataset_views.py
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def create_semantic_model(
    auth: DomoAuth,
    data_source_name: str,
    schema: dict,
    *,
    data_source_description: str | None = None,
    cloud_id: str = "domo",
    body: dict | None = None,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Create a new data model (POST /api/query/v1/semantic-models).

    Args:
        auth: Authentication object
        data_source_name: Model display name
        schema: The model definition: ``{"objects": {...}, "relationships": [...]}``
            (the shape produced by ``DataModelTemplate.to_schema()``)
        data_source_description: Optional model description
        cloud_id: Cloud engine ID (defaults to "domo")
        body: Fully pre-built payload; overrides the generated envelope
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters

    Returns:
        ResponseGetData containing the new model's ``dataSourceId``.

    Note:
        The Domo API has a validation bug where non-primary relationships
        require a non-null ``alias`` field but rejects all string values for it.
        The workaround is to set ``primary=True`` for all relationships in the
        schema. The ``DataModelTemplate.to_schema()`` method preserves whatever
        ``primary`` values are set on the relationships.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/query/v1/semantic-models"

    if body is None:
        body = {
            "dataSourceName": data_source_name,
            "dataSourceDescription": data_source_description,
            "cloudId": cloud_id,
            "schema": schema,
        }

    res = await gd.get_data(
        auth=auth,
        url=url,
        method="POST",
        body=body,
        context=context,
    )

    if not res.is_success:
        raise Dataset_CRUD_Error(dataset_id="new", res=res)

    return res

get_dataset_view_schema_indexed async

get_dataset_view_schema_indexed(
    auth: DomoAuth,
    dataset_id: str,
    include_data_control_column_details: bool = True,
    flatten: bool | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Get the indexed schema for a dataset view with optional data control column details.

This endpoint returns the schema structure for a dataset view, including: - Column definitions with types and visibility - SELECT query structure - View template information - Data control column details (if requested)

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
dataset_id str

The dataset view ID

required
include_data_control_column_details bool

If True, includes data control column details

True
flatten bool | None

If False, preserves per-table join structure (required to get a data model's model.objects / modeledColumns). If None, the param is omitted and the API default applies.

None
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description
ResponseGetData

ResponseGetData object containing:

ResponseGetData
  • name: View name
ResponseGetData
  • tables: Array of tables with column definitions
ResponseGetData
  • select: SELECT query structure
ResponseGetData
  • dataSourceId: Dataset ID
ResponseGetData
  • versionId: Version ID
ResponseGetData
  • viewTemplate: Template information with select string and fromItemInfo
ResponseGetData
  • dataControlDetails: Data control column details (if requested)

Raises:

Type Description
Dataset_GET_Error

If schema retrieval fails

Source code in src/crew_dcs/routes/dataset/dataset_views.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def get_dataset_view_schema_indexed(
    auth: DomoAuth,
    dataset_id: str,
    include_data_control_column_details: bool = True,
    flatten: bool | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Get the indexed schema for a dataset view with optional data control column details.

    This endpoint returns the schema structure for a dataset view, including:
    - Column definitions with types and visibility
    - SELECT query structure
    - View template information
    - Data control column details (if requested)

    Args:
        auth: Authentication object
        dataset_id: The dataset view ID
        include_data_control_column_details: If True, includes data control column details
        flatten: If False, preserves per-table join structure (required to get a
            data model's ``model.objects`` / ``modeledColumns``). If None, the
            param is omitted and the API default applies.
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object containing:
        - name: View name
        - tables: Array of tables with column definitions
        - select: SELECT query structure
        - dataSourceId: Dataset ID
        - versionId: Version ID
        - viewTemplate: Template information with select string and fromItemInfo
        - dataControlDetails: Data control column details (if requested)

    Raises:
        Dataset_GET_Error: If schema retrieval fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/query/v1/datasources/{dataset_id}/schema/indexed"

    params = {}
    if include_data_control_column_details:
        params["options"] = "INCLUDE_DATA_CONTROL_COLUMN_DETAILS"
    if flatten is not None:
        params["flatten"] = "true" if flatten else "false"

    res = await gd.get_data(
        auth=auth,
        url=url,
        method="GET",
        params=params,
        context=context,
    )

    if not res.is_success:
        raise Dataset_GET_Error(dataset_id=dataset_id, res=res)

    return res

update_semantic_model async

update_semantic_model(
    auth: DomoAuth,
    model_id: str,
    schema: dict,
    *,
    data_source_name: str | None = None,
    data_source_description: str | None = None,
    last_updated: str | None = None,
    cloud_id: str = "domo",
    can_edit: bool = True,
    body: dict | None = None,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Update a data model (PUT /api/query/v1/semantic-models/{model_id}).

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
model_id str

The data model (semantic model) datasource ID

required
schema dict

The model definition: {"objects": {...}, "relationships": [...]} (the shape produced by DataModelTemplate.to_schema())

required
data_source_name str | None

Model display name

None
data_source_description str | None

Model description

None
last_updated str | None

ISO-8601 last-updated timestamp echoed back to the API

None
cloud_id str

Cloud engine ID (defaults to "domo")

'domo'
can_edit bool

Whether the caller can edit (defaults to True)

True
body dict | None

Fully pre-built payload; overrides the generated envelope

None
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}
Source code in src/crew_dcs/routes/dataset/dataset_views.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def update_semantic_model(
    auth: DomoAuth,
    model_id: str,
    schema: dict,
    *,
    data_source_name: str | None = None,
    data_source_description: str | None = None,
    last_updated: str | None = None,
    cloud_id: str = "domo",
    can_edit: bool = True,
    body: dict | None = None,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Update a data model (PUT /api/query/v1/semantic-models/{model_id}).

    Args:
        auth: Authentication object
        model_id: The data model (semantic model) datasource ID
        schema: The model definition: ``{"objects": {...}, "relationships": [...]}``
            (the shape produced by ``DataModelTemplate.to_schema()``)
        data_source_name: Model display name
        data_source_description: Model description
        last_updated: ISO-8601 last-updated timestamp echoed back to the API
        cloud_id: Cloud engine ID (defaults to "domo")
        can_edit: Whether the caller can edit (defaults to True)
        body: Fully pre-built payload; overrides the generated envelope
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = (
        f"https://{auth.domo_instance}.domo.com/api/query/v1/semantic-models/{model_id}"
    )

    if body is None:
        body = {
            "dataSourceName": data_source_name,
            "dataSourceDescription": data_source_description,
            "lastUpdated": last_updated,
            "schema": schema,
            "cloudId": cloud_id,
            "canEdit": can_edit,
        }

    res = await gd.get_data(
        auth=auth,
        url=url,
        method="PUT",
        body=body,
        context=context,
    )

    if not res.is_success:
        raise Dataset_CRUD_Error(dataset_id=model_id, res=res)

    return res

update_view async

update_view(
    auth: DomoAuth,
    view_id: str,
    schema: dict,
    *,
    data_source_name: str | None = None,
    trigger: dict | None = None,
    data_provider_type: str | None = None,
    body: dict | None = None,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Update a dataset view's definition (PUT /api/query/v1/views/{view_id}).

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
view_id str

The dataset view ID

required
schema dict

The view schema payload (tables + viewTemplate + tableAliases). Typically a (possibly edited) get_dataset_view_schema_indexed response augmented with tableAliases.

required
data_source_name str | None

View display name

None
trigger dict | None

Refresh trigger config (defaults to {})

None
data_provider_type str | None

Data provider type (usually None for views)

None
body dict | None

Fully pre-built payload; overrides the generated envelope

None
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters

{}
Source code in src/crew_dcs/routes/dataset/dataset_views.py
 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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def update_view(
    auth: DomoAuth,
    view_id: str,
    schema: dict,
    *,
    data_source_name: str | None = None,
    trigger: dict | None = None,
    data_provider_type: str | None = None,
    body: dict | None = None,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Update a dataset view's definition (PUT /api/query/v1/views/{view_id}).

    Args:
        auth: Authentication object
        view_id: The dataset view ID
        schema: The view schema payload (tables + viewTemplate + tableAliases).
            Typically a (possibly edited) ``get_dataset_view_schema_indexed``
            response augmented with ``tableAliases``.
        data_source_name: View display name
        trigger: Refresh trigger config (defaults to ``{}``)
        data_provider_type: Data provider type (usually None for views)
        body: Fully pre-built payload; overrides the generated envelope
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/query/v1/views/{view_id}"

    if body is None:
        body = {
            "dataSourceName": data_source_name,
            "trigger": trigger or {},
            "dataProviderType": data_provider_type,
            "schema": schema,
        }

    res = await gd.get_data(
        auth=auth,
        url=url,
        method="PUT",
        body=body,
        context=context,
    )

    if not res.is_success:
        raise Dataset_CRUD_Error(dataset_id=view_id, res=res)

    return res