Skip to content

core

core

DomoBeastMode entity class.

A typed class for beast mode (calculated field) templates, providing access to the formula definition, column references, and metadata via the composition pattern (bm.Template.get()).

DomoBeastMode dataclass

DomoBeastMode(
    auth: DomoAuth,
    id: str,
    raw: dict,
    name: str = "",
    locked: bool = False,
    legacy_id: str = "",
    Template: DomoBeastMode_TemplateManager | None = None,
)

Bases: DomoEntity

A Domo dataset-level beast mode (reusable calculated field / template).

This is the governed, reusable counterpart to a card-level inline formula (kpi_builder.build_formula / DomoCard.create(measure_formula=...)): a beast mode created here is persisted on the dataset, appears in Domo's beast-mode catalog, and can be referenced by name from many cards.

Usage

bm = await DomoBeastMode.create( auth=auth, name="Net Income", expression="SUM(CASE WHEN AccountType='Revenue' THEN Amount " "WHEN AccountType='Expenditures' THEN -Amount ELSE 0 END)", dataset_id=dataset_id, data_type="DECIMAL", aggregated=True, ) await bm.Template.get(include_hidden=True) # load full formula await bm.delete()

create async classmethod

create(
    auth: DomoAuth,
    name: str,
    expression: str,
    dataset_id: str,
    *,
    data_type: str = "STRING",
    aggregated: bool = False,
    return_raw: bool = False,
    context: RouteContext | None = None,
    **context_kwargs
) -> DomoBeastMode

Create a reusable dataset-level beast mode and return it.

Parameters:

Name Type Description Default
auth DomoAuth

DomoAuth instance.

required
name str

Display name of the beast mode.

required
expression str

Beast Mode SQL (columns in backticks).

required
dataset_id str

Dataset the beast mode is associated with.

required
data_type str

Result data type (e.g. "DECIMAL", "STRING").

'STRING'
aggregated bool

Whether the expression aggregates (SUM/AVG/...).

False
return_raw bool

Return the raw create response instead of a DomoBeastMode.

False
context RouteContext | None

Optional RouteContext.

None
Source code in src/crew_dcs/classes/DomoBeastMode/core.py
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
@classmethod
async def create(
    cls,
    auth: DomoAuth,
    name: str,
    expression: str,
    dataset_id: str,
    *,
    data_type: str = "STRING",
    aggregated: bool = False,
    return_raw: bool = False,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoBeastMode:
    """Create a reusable dataset-level beast mode and return it.

    Args:
        auth: DomoAuth instance.
        name: Display name of the beast mode.
        expression: Beast Mode SQL (columns in backticks).
        dataset_id: Dataset the beast mode is associated with.
        data_type: Result data type (e.g. ``"DECIMAL"``, ``"STRING"``).
        aggregated: Whether the expression aggregates (SUM/AVG/...).
        return_raw: Return the raw create response instead of a DomoBeastMode.
        context: Optional RouteContext.
    """
    context = RouteContext.build_context(context=context, **context_kwargs)
    res = await beastmode_routes.create_beastmode(
        auth=auth,
        name=name,
        expression=expression,
        dataset_id=dataset_id,
        data_type=data_type,
        aggregated=aggregated,
        return_raw=True,
        context=context,
    )
    if not res.is_success:
        raise BeastMode_CRUD_Error(operation="create", res=res)
    if return_raw:
        return res
    return cls.from_dict(auth=auth, obj=res.response)

delete async

delete(
    *, context: RouteContext | None = None, **context_kwargs
) -> Any

Delete this beast mode.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
198
199
200
201
202
203
204
205
206
207
208
async def delete(
    self,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> Any:
    """Delete this beast mode."""
    context = RouteContext.build_context(context=context, **context_kwargs)
    return await beastmode_routes.delete_beastmode(
        auth=self.auth, beastmode_id=str(self.id), context=context
    )

from_dict classmethod

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

Create a DomoBeastMode from a search result or template API response.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
@classmethod
def from_dict(cls, auth: DomoAuth, obj: dict[str, Any]) -> DomoBeastMode:
    """Create a DomoBeastMode from a search result or template API response."""
    bm = cls(
        auth=auth,
        id=str(obj.get("id", "")),
        raw=obj,
        name=obj.get("name", ""),
        locked=obj.get("locked", False),
        legacy_id=obj.get("legacyId", ""),
    )
    # If the response includes full template data, populate it
    if "expression" in obj:
        bm.Template.template = BeastModeTemplate.from_dict(obj)
    return bm

get_by_id async classmethod

get_by_id(
    auth: DomoAuth,
    id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> DomoBeastMode

Retrieve a beast mode template by id.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
@classmethod
async def get_by_id(
    cls,
    auth: DomoAuth,
    id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoBeastMode:
    """Retrieve a beast mode template by id."""
    context = RouteContext.build_context(context=context, **context_kwargs)
    res = await beastmode_routes.get_beastmode_by_id(
        auth=auth, beastmode_id=str(id), context=context
    )
    return cls.from_dict(auth=auth, obj=res.response)

get_entity_by_id async classmethod

get_entity_by_id(
    entity_id: str, auth: DomoAuth, **kwargs: Any
) -> DomoBeastMode

Internal wrapper used by the base refresh() method.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
148
149
150
151
152
153
@classmethod
async def get_entity_by_id(
    cls, entity_id: str, auth: DomoAuth, **kwargs: Any
) -> DomoBeastMode:
    """Internal wrapper used by the base refresh() method."""
    return await cls.get_by_id(auth=auth, id=entity_id, **kwargs)

lock async

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

Lock this beast mode.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
234
235
236
237
238
239
240
241
242
243
244
245
246
247
async def lock(
    self,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Lock this beast mode."""
    return await self.set_locked(
        is_locked=True,
        return_raw=return_raw,
        context=context,
        **context_kwargs,
    )

set_locked async

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

Lock or unlock this beast mode.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
async def set_locked(
    self,
    is_locked: bool,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Lock or unlock this beast mode."""
    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await beastmode_routes.lock_beastmode(
        auth=self.auth,
        beastmode_id=str(self.id),
        is_locked=is_locked,
        context=context,
    )

    if return_raw:
        return res

    self.locked = is_locked
    return self

to_measure_ref

to_measure_ref(
    data_type: str = "DECIMAL",
) -> dict[str, Any]

Return a card-builder measure_beastmode reference for this beast mode.

Reference is by legacyId (not display name), so renaming the beast mode does not break the cards that use it. Pass the result to DomoCard.create(measure_beastmode=...).

Requires legacy_id and the expression: create() populates both, or call await bm.Template.get() first to load the expression.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
def to_measure_ref(self, data_type: str = "DECIMAL") -> dict[str, Any]:
    """Return a card-builder ``measure_beastmode`` reference for this beast mode.

    Reference is by ``legacyId`` (not display name), so renaming the beast
    mode does not break the cards that use it. Pass the result to
    ``DomoCard.create(measure_beastmode=...)``.

    Requires ``legacy_id`` and the expression: create() populates both, or
    call ``await bm.Template.get()`` first to load the expression.
    """
    expression = ""
    if self.Template and self.Template.template:
        expression = self.Template.template.expression or ""
    elif isinstance(self.raw, dict):
        expression = self.raw.get("expression", "")
    return {
        "legacy_id": self.legacy_id,
        "template_id": int(self.id),
        "name": self.name,
        "expression": expression,
        "data_type": data_type,
    }

unlock async

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

Unlock this beast mode.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
249
250
251
252
253
254
255
256
257
258
259
260
261
262
async def unlock(
    self,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Unlock this beast mode."""
    return await self.set_locked(
        is_locked=False,
        return_raw=return_raw,
        context=context,
        **context_kwargs,
    )

DomoBeastMode_TemplateManager dataclass

DomoBeastMode_TemplateManager(
    parent: DomoBeastMode,
    template: BeastModeTemplate | None = None,
)

Manager for a beast mode's template definition.

Provides typed access to the beast mode's formula, column references, and metadata via the template API.

Usage

await bm.Template.get(include_hidden=True) bm.Template.template # BeastModeTemplate bm.Template.referenced_columns # set[str]

referenced_columns property

referenced_columns: set[str]

Columns referenced by this beast mode. Empty if template not loaded.

get async

get(
    include_hidden: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> BeastModeTemplate

Fetch the template definition for this beast mode.

Parameters:

Name Type Description Default
include_hidden bool

Include hidden/internal calculations

False
context RouteContext | None

Optional RouteContext for request configuration

None

Returns:

Type Description
BeastModeTemplate

BeastModeTemplate instance with typed access to all definition data.

Source code in src/crew_dcs/classes/DomoBeastMode/core.py
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
async def get(
    self,
    include_hidden: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> BeastModeTemplate:
    """Fetch the template definition for this beast mode.

    Args:
        include_hidden: Include hidden/internal calculations
        context: Optional RouteContext for request configuration

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

    res = await beastmode_routes.get_beastmode_by_id(
        auth=self.auth,
        beastmode_id=self.parent.id,
        include_hidden=include_hidden,
        context=context,
    )

    if res.is_success:
        self.template = BeastModeTemplate.from_dict(res.response)

    return self.template