Skip to content

card_gaps

card_gaps

create_kpi_card async

create_kpi_card(
    auth: DomoAuth,
    dataset_id: str,
    card_title: str,
    *,
    chart_type: str = "single-value",
    value_column: str | None = None,
    aggregation: str = "sum",
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Create a KPI card backed by a dataset.

Convenience wrapper around PUT /content/v3/cards/kpi that builds the card body from a dataset id, title, chart type, and value column.

Source code in src/crew_dcs/routes/card_gaps.py
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
async def create_kpi_card(
    auth: DomoAuth,
    dataset_id: str,
    card_title: str,
    *,
    chart_type: str = "single-value",
    value_column: str | None = None,
    aggregation: str = "sum",
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Create a KPI card backed by a dataset.

    Convenience wrapper around PUT /content/v3/cards/kpi that builds the card
    body from a dataset id, title, chart type, and value column.
    """
    body = generate_kpi_card_body(
        dataset_id=dataset_id,
        card_title=card_title,
        chart_type=chart_type,
        value_column=value_column,
        aggregation=aggregation,
    )
    return await put_content_cards_kpi(
        auth=auth, body=body, context=context, **context_kwargs
    )

generate_kpi_card_body

generate_kpi_card_body(
    dataset_id: str,
    card_title: str,
    chart_type: str = "single-value",
    value_column: str | None = None,
    aggregation: str = "sum",
) -> dict[str, Any]

Generate the payload for PUT /content/v3/cards/kpi.

Builds a minimal single-metric KPI card definition backed by dataset_id.

Source code in src/crew_dcs/routes/card_gaps.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def generate_kpi_card_body(
    dataset_id: str,
    card_title: str,
    chart_type: str = "single-value",
    value_column: str | None = None,
    aggregation: str = "sum",
) -> dict[str, Any]:
    """Generate the payload for PUT /content/v3/cards/kpi.

    Builds a minimal single-metric KPI card definition backed by `dataset_id`.
    """
    return {
        "title": card_title,
        "chartType": chart_type,
        "dataSource": {"dataSourceId": dataset_id},
        "columns": (
            [{"column": value_column, "aggregation": aggregation}]
            if value_column
            else []
        ),
    }