template_definition
template_definition ¶
Typed classes for Domo beast mode template definitions.
Models the /api/query/v1/functions/template/{id} API response
as structured dataclasses with from_dict classmethods.
Structure
BeastModeTemplate ├── id: int # numeric template ID ├── name: str # display name ├── expression: str # SQL formula ├── legacy_id: str # calculation_xxx ID used in card definitions ├── status: str # e.g., "VALID" ├── data_type: str | None # e.g., "DECIMAL", "STRING", "LONG" ├── column_positions: list[ColumnRef] # columns referenced in the expression ├── non_aggregated_columns: list[str] # columns used without aggregation ├── locked: bool ├── hidden: bool ├── variable: bool ├── aggregated: bool ├── links: list[dict] # associated resources (cards, datasets) └── functions: list[str] # SQL functions used (e.g., "COUNT", "SUM")
BeastModeTemplate
dataclass
¶
BeastModeTemplate(
id: int = 0,
name: str = "",
expression: str = "",
legacy_id: str = "",
status: str | None = None,
data_type: str | None = None,
column_positions: list[ColumnRef] = list(),
non_aggregated_columns: list[str] = list(),
locked: bool = False,
hidden: bool = False,
variable: bool = False,
aggregated: bool = False,
links: list[dict[str, Any]] = list(),
functions: list[str] = list(),
owner: int | None = None,
archived: bool = False,
_resolved_refs: dict[int, BeastModeTemplate] = dict(),
)
Typed representation of a beast mode template from the functions API.
Provides structured access to the beast mode's formula, column references, and metadata with convenience properties for lineage queries.
Usage
template = BeastModeTemplate.from_dict(api_response) template.referenced_columns # set[str] of source columns template.legacy_id # "calculation_xxx-xxx" for card def lookup template.to_formula() # convert to Formula for KpiDefinition
domo_beast_mode_refs
property
¶
domo_beast_mode_refs: list[int]
Template IDs referenced via DOMO_BEAST_MODE(nnn) in the expression.
Domo beast modes can reference other beast modes using the syntax
DOMO_BEAST_MODE(template_id). This property extracts those
numeric template IDs from the expression string.
Returns:
| Type | Description |
|---|---|
list[int]
|
List of integer template IDs referenced by this expression. |
referenced_columns
property
¶
referenced_columns: set[str]
All dataset columns referenced by this beast mode.
Combines columnPositions and nonAggregatedColumns, stripping backticks from column names. Also includes columns from resolved DOMO_BEAST_MODE references.
resolved_expression
property
¶
resolved_expression: str
Expression with DOMO_BEAST_MODE refs replaced by their expressions.
After calling resolve_domo_beast_mode_refs, this returns the
expression with DOMO_BEAST_MODE(nnn) replaced by the referenced
beast mode's actual SQL expression. Falls back to the raw expression
if not resolved.
from_dict
classmethod
¶
from_dict(obj: dict[str, Any]) -> BeastModeTemplate
Build a BeastModeTemplate from the template API response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
dict[str, Any]
|
Full API response dict from /api/query/v1/functions/template/{id} |
required |
Source code in src/crew_dcs/classes/DomoBeastMode/template_definition.py
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 | |
resolve_domo_beast_mode_refs
async
¶
resolve_domo_beast_mode_refs(
auth: DomoAuth,
*,
context: RouteContext | None = None,
**context_kwargs
) -> dict[int, BeastModeTemplate]
Fetch and resolve DOMO_BEAST_MODE(nnn) references in the expression.
Domo beast modes can reference other beast modes using the syntax
DOMO_BEAST_MODE(template_id). This method fetches the referenced
templates and stores them for use by resolved_expression and
referenced_columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
context
|
RouteContext | None
|
Optional RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
dict[int, BeastModeTemplate]
|
Dict mapping template IDs to their resolved BeastModeTemplate instances. |
Source code in src/crew_dcs/classes/DomoBeastMode/template_definition.py
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 | |
to_formula ¶
to_formula()
Convert to a Formula dataclass for merging into KpiDefinition.
Returns:
| Type | Description |
|---|---|
|
Formula instance with id, name, formula, and column references |
|
|
populated from this template. If DOMO_BEAST_MODE refs have been |
|
|
resolved, |
|
|
expression with refs replaced by names. |
Source code in src/crew_dcs/classes/DomoBeastMode/template_definition.py
219 220 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 | |