Skip to content

DomoMetric

DomoMetric

DomoMetric dataclass

DomoMetric(
    auth: DomoAuth,
    id: str,
    raw: dict = dict(),
    name: str | None = None,
    owner_id: str | None = None,
)

Bases: DomoEntity

Domo Metric entity.

from_dict classmethod

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

Convert an API response dict to a DomoMetric instance.

Source code in src/crew_dcs/classes/DomoMetric.py
33
34
35
36
37
38
39
40
41
42
@classmethod
def from_dict(cls, auth: DomoAuth, obj: dict[str, Any]) -> DomoMetric:
    """Convert an API response dict to a DomoMetric instance."""
    return cls(
        auth=auth,
        id=str(obj.get("id") or obj.get("metricId") or ""),
        name=obj.get("name"),
        owner_id=str(obj["ownerId"]) if obj.get("ownerId") else None,
        raw=obj,
    )

get_by_id async classmethod

get_by_id(
    auth: DomoAuth, metric_id: str, **kwargs
) -> DomoMetric

Not supported — the Metrics API has no individual get-by-ID endpoint.

Source code in src/crew_dcs/classes/DomoMetric.py
44
45
46
47
48
49
50
51
52
53
54
55
@classmethod
async def get_by_id(
    cls,
    auth: DomoAuth,
    metric_id: str,
    **kwargs,
) -> DomoMetric:
    """Not supported — the Metrics API has no individual get-by-ID endpoint."""
    raise NotImplementedError(
        "DomoMetric does not support get_by_id — "
        "use DomoMetrics.get() or DomoMetrics.get_owned_by()."
    )

get_entity_by_id async classmethod

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

Internal wrapper used by the base refresh() method.

Source code in src/crew_dcs/classes/DomoMetric.py
57
58
59
60
61
62
@classmethod
async def get_entity_by_id(
    cls, entity_id: str, auth: DomoAuth, **kwargs
) -> DomoMetric:
    """Internal wrapper used by the base refresh() method."""
    return await cls.get_by_id(auth=auth, metric_id=entity_id, **kwargs)

update_owner async

update_owner(
    to_user_id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> DomoMetric

Transfer ownership of this metric to another user.

Source code in src/crew_dcs/classes/DomoMetric.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
async def update_owner(
    self,
    to_user_id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoMetric:
    """Transfer ownership of this metric to another user."""
    await metric_routes.update_metric_owner(
        auth=self.auth,
        metric_id=self.id,
        to_user_id=to_user_id,
        context=context,
    )
    self.owner_id = to_user_id
    return self

DomoMetrics dataclass

DomoMetrics(auth: DomoAuth)

Bases: DomoManager

Collection manager for DomoMetric objects.

get async

get(
    filter_body: dict | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[DomoMetric] | ResponseGetData

Retrieve metrics, optionally filtered by a custom body.

Source code in src/crew_dcs/classes/DomoMetric.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
async def get(
    self,
    filter_body: dict | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[DomoMetric] | ResponseGetData:
    """Retrieve metrics, optionally filtered by a custom body."""
    res = await metric_routes.get_metrics(
        auth=self.auth,
        filter_body=filter_body,
        context=context,
    )

    if return_raw:
        return res

    items = res.response if isinstance(res.response, list) else []
    return [DomoMetric.from_dict(auth=self.auth, obj=obj) for obj in items]

get_owned_by async

get_owned_by(
    user_id: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[DomoMetric] | ResponseGetData

Retrieve all metrics owned by a specific user.

Source code in src/crew_dcs/classes/DomoMetric.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
async def get_owned_by(
    self,
    user_id: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[DomoMetric] | ResponseGetData:
    """Retrieve all metrics owned by a specific user."""
    res = await metric_routes.get_owned_metrics(
        auth=self.auth,
        user_id=user_id,
        context=context,
    )

    if return_raw:
        return res

    items = res.response if isinstance(res.response, list) else []
    return [DomoMetric.from_dict(auth=self.auth, obj=obj) for obj in items]

transfer_all async

transfer_all(
    from_user_id: str,
    to_user_id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Transfer all metrics from one user to another.

Source code in src/crew_dcs/classes/DomoMetric.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
async def transfer_all(
    self,
    from_user_id: str,
    to_user_id: str,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> ResponseGetData:
    """Transfer all metrics from one user to another."""
    return await metric_routes.transfer_metrics(
        auth=self.auth,
        from_user_id=from_user_id,
        to_user_id=to_user_id,
        context=context,
    )