diff --git a/.apigentools-info b/.apigentools-info index 0bc95a9fed..ec2b88c224 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-19 19:09:52.950548", - "spec_repo_commit": "f0e5fdcf" + "regenerated": "2025-02-20 13:34:59.325200", + "spec_repo_commit": "c64543d0" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-02-19 19:09:52.967553", - "spec_repo_commit": "f0e5fdcf" + "regenerated": "2025-02-20 13:34:59.340610", + "spec_repo_commit": "c64543d0" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 79e471c068..f38bee54f5 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -9727,6 +9727,62 @@ components: items: $ref: '#/components/schemas/NotifyEndType' type: array + NumberFormatUnit: + description: Number format unit. + oneOf: + - $ref: '#/components/schemas/NumberFormatUnitCanonical' + - $ref: '#/components/schemas/NumberFormatUnitCustom' + NumberFormatUnitCanonical: + description: Canonical unit. + properties: + per_unit_name: + description: The name of the unit per item. + example: bytes + type: string + type: + $ref: '#/components/schemas/NumberFormatUnitScaleType' + unit_name: + description: The name of the unit. + example: bytes + type: string + type: object + NumberFormatUnitCustom: + description: Custom unit. + properties: + label: + description: The label for the custom unit. + maxLength: 12 + minLength: 1 + type: string + type: + $ref: '#/components/schemas/NumberFormatUnitCustomType' + type: object + NumberFormatUnitCustomType: + description: The type of custom unit. + enum: + - custom_unit_label + type: string + x-enum-varnames: + - CUSTOM_UNIT_LABEL + NumberFormatUnitScale: + description: The definition of `NumberFormatUnitScale` object. + nullable: true + properties: + type: + $ref: '#/components/schemas/NumberFormatUnitScaleType' + unit_name: + description: The name of the unit. + example: bytes + type: string + type: object + NumberFormatUnitScaleType: + description: The type of unit scale. + enum: + - canonical_unit + example: canonical_unit + type: string + x-enum-varnames: + - CANONICAL_UNIT OnMissingDataOption: description: 'Controls how groups or monitors are treated if an evaluation does not return any data points. @@ -23044,6 +23100,8 @@ components: type: string limit: $ref: '#/components/schemas/WidgetFormulaLimit' + number_format: + $ref: '#/components/schemas/WidgetNumberFormat' style: $ref: '#/components/schemas/WidgetFormulaStyle' required: @@ -23463,6 +23521,14 @@ components: x-enum-varnames: - HOST - CONTAINER + WidgetNumberFormat: + description: Number format options for the widget. + properties: + unit: + $ref: '#/components/schemas/NumberFormatUnit' + unit_scale: + $ref: '#/components/schemas/NumberFormatUnitScale' + type: object WidgetOrderBy: description: What to order by. enum: diff --git a/docs/datadog_api_client.v1.model.rst b/docs/datadog_api_client.v1.model.rst index af87c57369..e07487971e 100644 --- a/docs/datadog_api_client.v1.model.rst +++ b/docs/datadog_api_client.v1.model.rst @@ -2650,6 +2650,48 @@ datadog\_api\_client.v1.model.notify\_end\_type module :members: :show-inheritance: +datadog\_api\_client.v1.model.number\_format\_unit module +--------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.number_format_unit + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.number\_format\_unit\_canonical module +-------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.number_format_unit_canonical + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.number\_format\_unit\_custom module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.number_format_unit_custom + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.number\_format\_unit\_custom\_type module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.number_format_unit_custom_type + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.number\_format\_unit\_scale module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.number_format_unit_scale + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.number\_format\_unit\_scale\_type module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.number_format_unit_scale_type + :members: + :show-inheritance: + datadog\_api\_client.v1.model.on\_missing\_data\_option module -------------------------------------------------------------- @@ -6304,6 +6346,13 @@ datadog\_api\_client.v1.model.widget\_node\_type module :members: :show-inheritance: +datadog\_api\_client.v1.model.widget\_number\_format module +----------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.widget_number_format + :members: + :show-inheritance: + datadog\_api\_client.v1.model.widget\_order\_by module ------------------------------------------------------ diff --git a/examples/v1/dashboards/CreateDashboard_3520534424.py b/examples/v1/dashboards/CreateDashboard_3520534424.py new file mode 100644 index 0000000000..399a459234 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_3520534424.py @@ -0,0 +1,91 @@ +""" +Create a new dashboard with timeseries widget with custom_unit +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.dashboards_api import DashboardsApi +from datadog_api_client.v1.model.dashboard import Dashboard +from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType +from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType +from datadog_api_client.v1.model.formula_and_function_metric_data_source import FormulaAndFunctionMetricDataSource +from datadog_api_client.v1.model.formula_and_function_metric_query_definition import ( + FormulaAndFunctionMetricQueryDefinition, +) +from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat +from datadog_api_client.v1.model.number_format_unit_canonical import NumberFormatUnitCanonical +from datadog_api_client.v1.model.number_format_unit_scale import NumberFormatUnitScale +from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType +from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition +from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType +from datadog_api_client.v1.model.timeseries_widget_legend_layout import TimeseriesWidgetLegendLayout +from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest +from datadog_api_client.v1.model.widget import Widget +from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType +from datadog_api_client.v1.model.widget_formula import WidgetFormula +from datadog_api_client.v1.model.widget_layout import WidgetLayout +from datadog_api_client.v1.model.widget_legacy_live_span import WidgetLegacyLiveSpan +from datadog_api_client.v1.model.widget_number_format import WidgetNumberFormat +from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign + +body = Dashboard( + title="Example-Dashboard", + description="", + widgets=[ + Widget( + definition=TimeseriesWidgetDefinition( + title="", + title_size="16", + title_align=WidgetTextAlign.LEFT, + show_legend=True, + legend_layout=TimeseriesWidgetLegendLayout.AUTO, + time=WidgetLegacyLiveSpan(), + type=TimeseriesWidgetDefinitionType.TIMESERIES, + requests=[ + TimeseriesWidgetRequest( + formulas=[ + WidgetFormula( + formula="query1", + number_format=WidgetNumberFormat( + unit_scale=NumberFormatUnitScale( + type=NumberFormatUnitScaleType.CANONICAL_UNIT, + unit_name="apdex", + ), + unit=NumberFormatUnitCanonical( + type=NumberFormatUnitScaleType.CANONICAL_UNIT, + unit_name="fraction", + ), + ), + ), + ], + queries=[ + FormulaAndFunctionMetricQueryDefinition( + data_source=FormulaAndFunctionMetricDataSource.METRICS, + name="query1", + query="avg:system.cpu.user{*}", + ), + ], + response_format=FormulaAndFunctionResponseFormat.TIMESERIES, + display_type=WidgetDisplayType.LINE, + ), + ], + ), + layout=WidgetLayout( + x=0, + y=0, + width=12, + height=5, + ), + ), + ], + template_variables=[], + layout_type=DashboardLayoutType.ORDERED, + notify_list=[], + reflow_type=DashboardReflowType.FIXED, +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DashboardsApi(api_client) + response = api_instance.create_dashboard(body=body) + + print(response) diff --git a/src/datadog_api_client/v1/model/number_format_unit.py b/src/datadog_api_client/v1/model/number_format_unit.py new file mode 100644 index 0000000000..0dcb8809fd --- /dev/null +++ b/src/datadog_api_client/v1/model/number_format_unit.py @@ -0,0 +1,49 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class NumberFormatUnit(ModelComposed): + def __init__(self, **kwargs): + """ + Number format unit. + + :param per_unit_name: The name of the unit per item. + :type per_unit_name: str, optional + + :param type: The type of unit scale. + :type type: NumberFormatUnitScaleType, optional + + :param unit_name: The name of the unit. + :type unit_name: str, optional + + :param label: The label for the custom unit. + :type label: str, optional + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v1.model.number_format_unit_canonical import NumberFormatUnitCanonical + from datadog_api_client.v1.model.number_format_unit_custom import NumberFormatUnitCustom + + return { + "oneOf": [ + NumberFormatUnitCanonical, + NumberFormatUnitCustom, + ], + } diff --git a/src/datadog_api_client/v1/model/number_format_unit_canonical.py b/src/datadog_api_client/v1/model/number_format_unit_canonical.py new file mode 100644 index 0000000000..956d424afe --- /dev/null +++ b/src/datadog_api_client/v1/model/number_format_unit_canonical.py @@ -0,0 +1,62 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType + + +class NumberFormatUnitCanonical(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType + + return { + "per_unit_name": (str,), + "type": (NumberFormatUnitScaleType,), + "unit_name": (str,), + } + + attribute_map = { + "per_unit_name": "per_unit_name", + "type": "type", + "unit_name": "unit_name", + } + + def __init__( + self_, + per_unit_name: Union[str, UnsetType] = unset, + type: Union[NumberFormatUnitScaleType, UnsetType] = unset, + unit_name: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Canonical unit. + + :param per_unit_name: The name of the unit per item. + :type per_unit_name: str, optional + + :param type: The type of unit scale. + :type type: NumberFormatUnitScaleType, optional + + :param unit_name: The name of the unit. + :type unit_name: str, optional + """ + if per_unit_name is not unset: + kwargs["per_unit_name"] = per_unit_name + if type is not unset: + kwargs["type"] = type + if unit_name is not unset: + kwargs["unit_name"] = unit_name + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/number_format_unit_custom.py b/src/datadog_api_client/v1/model/number_format_unit_custom.py new file mode 100644 index 0000000000..51546e493e --- /dev/null +++ b/src/datadog_api_client/v1/model/number_format_unit_custom.py @@ -0,0 +1,61 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.number_format_unit_custom_type import NumberFormatUnitCustomType + + +class NumberFormatUnitCustom(ModelNormal): + validations = { + "label": { + "max_length": 12, + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.number_format_unit_custom_type import NumberFormatUnitCustomType + + return { + "label": (str,), + "type": (NumberFormatUnitCustomType,), + } + + attribute_map = { + "label": "label", + "type": "type", + } + + def __init__( + self_, + label: Union[str, UnsetType] = unset, + type: Union[NumberFormatUnitCustomType, UnsetType] = unset, + **kwargs, + ): + """ + Custom unit. + + :param label: The label for the custom unit. + :type label: str, optional + + :param type: The type of custom unit. + :type type: NumberFormatUnitCustomType, optional + """ + if label is not unset: + kwargs["label"] = label + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/number_format_unit_custom_type.py b/src/datadog_api_client/v1/model/number_format_unit_custom_type.py new file mode 100644 index 0000000000..264c4c0c54 --- /dev/null +++ b/src/datadog_api_client/v1/model/number_format_unit_custom_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class NumberFormatUnitCustomType(ModelSimple): + """ + The type of custom unit. + + :param value: If omitted defaults to "custom_unit_label". Must be one of ["custom_unit_label"]. + :type value: str + """ + + allowed_values = { + "custom_unit_label", + } + CUSTOM_UNIT_LABEL: ClassVar["NumberFormatUnitCustomType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NumberFormatUnitCustomType.CUSTOM_UNIT_LABEL = NumberFormatUnitCustomType("custom_unit_label") diff --git a/src/datadog_api_client/v1/model/number_format_unit_scale.py b/src/datadog_api_client/v1/model/number_format_unit_scale.py new file mode 100644 index 0000000000..fe2596d67a --- /dev/null +++ b/src/datadog_api_client/v1/model/number_format_unit_scale.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType + + +class NumberFormatUnitScale(ModelNormal): + _nullable = True + + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType + + return { + "type": (NumberFormatUnitScaleType,), + "unit_name": (str,), + } + + attribute_map = { + "type": "type", + "unit_name": "unit_name", + } + + def __init__( + self_, + type: Union[NumberFormatUnitScaleType, UnsetType] = unset, + unit_name: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + The definition of ``NumberFormatUnitScale`` object. + + :param type: The type of unit scale. + :type type: NumberFormatUnitScaleType, optional + + :param unit_name: The name of the unit. + :type unit_name: str, optional + """ + if type is not unset: + kwargs["type"] = type + if unit_name is not unset: + kwargs["unit_name"] = unit_name + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/number_format_unit_scale_type.py b/src/datadog_api_client/v1/model/number_format_unit_scale_type.py new file mode 100644 index 0000000000..65cc5d2943 --- /dev/null +++ b/src/datadog_api_client/v1/model/number_format_unit_scale_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class NumberFormatUnitScaleType(ModelSimple): + """ + The type of unit scale. + + :param value: If omitted defaults to "canonical_unit". Must be one of ["canonical_unit"]. + :type value: str + """ + + allowed_values = { + "canonical_unit", + } + CANONICAL_UNIT: ClassVar["NumberFormatUnitScaleType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NumberFormatUnitScaleType.CANONICAL_UNIT = NumberFormatUnitScaleType("canonical_unit") diff --git a/src/datadog_api_client/v1/model/widget_formula.py b/src/datadog_api_client/v1/model/widget_formula.py index 99bbaa01a3..3c252d1c83 100644 --- a/src/datadog_api_client/v1/model/widget_formula.py +++ b/src/datadog_api_client/v1/model/widget_formula.py @@ -17,6 +17,7 @@ from datadog_api_client.v1.model.table_widget_cell_display_mode import TableWidgetCellDisplayMode from datadog_api_client.v1.model.widget_conditional_format import WidgetConditionalFormat from datadog_api_client.v1.model.widget_formula_limit import WidgetFormulaLimit + from datadog_api_client.v1.model.widget_number_format import WidgetNumberFormat from datadog_api_client.v1.model.widget_formula_style import WidgetFormulaStyle @@ -26,6 +27,7 @@ def openapi_types(_): from datadog_api_client.v1.model.table_widget_cell_display_mode import TableWidgetCellDisplayMode from datadog_api_client.v1.model.widget_conditional_format import WidgetConditionalFormat from datadog_api_client.v1.model.widget_formula_limit import WidgetFormulaLimit + from datadog_api_client.v1.model.widget_number_format import WidgetNumberFormat from datadog_api_client.v1.model.widget_formula_style import WidgetFormulaStyle return { @@ -34,6 +36,7 @@ def openapi_types(_): "conditional_formats": ([WidgetConditionalFormat],), "formula": (str,), "limit": (WidgetFormulaLimit,), + "number_format": (WidgetNumberFormat,), "style": (WidgetFormulaStyle,), } @@ -43,6 +46,7 @@ def openapi_types(_): "conditional_formats": "conditional_formats", "formula": "formula", "limit": "limit", + "number_format": "number_format", "style": "style", } @@ -53,6 +57,7 @@ def __init__( cell_display_mode: Union[TableWidgetCellDisplayMode, UnsetType] = unset, conditional_formats: Union[List[WidgetConditionalFormat], UnsetType] = unset, limit: Union[WidgetFormulaLimit, UnsetType] = unset, + number_format: Union[WidgetNumberFormat, UnsetType] = unset, style: Union[WidgetFormulaStyle, UnsetType] = unset, **kwargs, ): @@ -74,6 +79,9 @@ def __init__( :param limit: Options for limiting results returned. :type limit: WidgetFormulaLimit, optional + :param number_format: Number format options for the widget. + :type number_format: WidgetNumberFormat, optional + :param style: Styling options for widget formulas. :type style: WidgetFormulaStyle, optional """ @@ -85,6 +93,8 @@ def __init__( kwargs["conditional_formats"] = conditional_formats if limit is not unset: kwargs["limit"] = limit + if number_format is not unset: + kwargs["number_format"] = number_format if style is not unset: kwargs["style"] = style super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/widget_number_format.py b/src/datadog_api_client/v1/model/widget_number_format.py new file mode 100644 index 0000000000..fe008b4688 --- /dev/null +++ b/src/datadog_api_client/v1/model/widget_number_format.py @@ -0,0 +1,59 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.number_format_unit import NumberFormatUnit + from datadog_api_client.v1.model.number_format_unit_scale import NumberFormatUnitScale + from datadog_api_client.v1.model.number_format_unit_canonical import NumberFormatUnitCanonical + from datadog_api_client.v1.model.number_format_unit_custom import NumberFormatUnitCustom + + +class WidgetNumberFormat(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.number_format_unit import NumberFormatUnit + from datadog_api_client.v1.model.number_format_unit_scale import NumberFormatUnitScale + + return { + "unit": (NumberFormatUnit,), + "unit_scale": (NumberFormatUnitScale,), + } + + attribute_map = { + "unit": "unit", + "unit_scale": "unit_scale", + } + + def __init__( + self_, + unit: Union[NumberFormatUnit, NumberFormatUnitCanonical, NumberFormatUnitCustom, UnsetType] = unset, + unit_scale: Union[NumberFormatUnitScale, none_type, UnsetType] = unset, + **kwargs, + ): + """ + Number format options for the widget. + + :param unit: Number format unit. + :type unit: NumberFormatUnit, optional + + :param unit_scale: The definition of ``NumberFormatUnitScale`` object. + :type unit_scale: NumberFormatUnitScale, none_type, optional + """ + if unit is not unset: + kwargs["unit"] = unit + if unit_scale is not unset: + kwargs["unit_scale"] = unit_scale + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index a1d98826f1..63dbca1c5c 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -438,6 +438,12 @@ from datadog_api_client.v1.model.notebooks_response_page import NotebooksResponsePage from datadog_api_client.v1.model.notify_end_state import NotifyEndState from datadog_api_client.v1.model.notify_end_type import NotifyEndType +from datadog_api_client.v1.model.number_format_unit import NumberFormatUnit +from datadog_api_client.v1.model.number_format_unit_canonical import NumberFormatUnitCanonical +from datadog_api_client.v1.model.number_format_unit_custom import NumberFormatUnitCustom +from datadog_api_client.v1.model.number_format_unit_custom_type import NumberFormatUnitCustomType +from datadog_api_client.v1.model.number_format_unit_scale import NumberFormatUnitScale +from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType from datadog_api_client.v1.model.on_missing_data_option import OnMissingDataOption from datadog_api_client.v1.model.org_downgraded_response import OrgDowngradedResponse from datadog_api_client.v1.model.organization import Organization @@ -1045,6 +1051,7 @@ from datadog_api_client.v1.model.widget_new_live_span import WidgetNewLiveSpan from datadog_api_client.v1.model.widget_new_live_span_type import WidgetNewLiveSpanType from datadog_api_client.v1.model.widget_node_type import WidgetNodeType +from datadog_api_client.v1.model.widget_number_format import WidgetNumberFormat from datadog_api_client.v1.model.widget_order_by import WidgetOrderBy from datadog_api_client.v1.model.widget_palette import WidgetPalette from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle @@ -1442,6 +1449,12 @@ "NotebooksResponsePage", "NotifyEndState", "NotifyEndType", + "NumberFormatUnit", + "NumberFormatUnitCanonical", + "NumberFormatUnitCustom", + "NumberFormatUnitCustomType", + "NumberFormatUnitScale", + "NumberFormatUnitScaleType", "OnMissingDataOption", "OrgDowngradedResponse", "Organization", @@ -1965,6 +1978,7 @@ "WidgetNewLiveSpan", "WidgetNewLiveSpanType", "WidgetNodeType", + "WidgetNumberFormat", "WidgetOrderBy", "WidgetPalette", "WidgetRequestStyle", diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_timeseries_widget_with_custom_unit.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_timeseries_widget_with_custom_unit.frozen new file mode 100644 index 0000000000..f53218e126 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_timeseries_widget_with_custom_unit.frozen @@ -0,0 +1 @@ +2025-02-17T16:50:56.669Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_timeseries_widget_with_custom_unit.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_timeseries_widget_with_custom_unit.yaml new file mode 100644 index 0000000000..9d72ec52de --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_timeseries_widget_with_custom_unit.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '{"description":"","layout_type":"ordered","notify_list":[],"reflow_type":"fixed","template_variables":[],"title":"Test-Create_a_new_dashboard_with_timeseries_widget_with_custom_unit-1739811056","widgets":[{"definition":{"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1","number_format":{"unit":{"type":"canonical_unit","unit_name":"fraction"},"unit_scale":{"type":"canonical_unit","unit_name":"apdex"}}}],"queries":[{"data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*}"}],"response_format":"timeseries"}],"show_legend":true,"time":{},"title":"","title_align":"left","title_size":"16","type":"timeseries"},"layout":{"height":5,"width":12,"x":0,"y":0}}]}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/dashboard + response: + body: + string: '{"id":"a8v-698-pen","title":"Test-Create_a_new_dashboard_with_timeseries_widget_with_custom_unit-1739811056","description":"","author_handle":"frog@datadoghq.com","author_name":"frog","layout_type":"ordered","url":"/dashboard/a8v-698-pen/test-createanewdashboardwithtimeserieswidgetwithcustomunit-1739811056","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1","number_format":{"unit":{"type":"canonical_unit","unit_name":"fraction"},"unit_scale":{"type":"canonical_unit","unit_name":"apdex"}}}],"queries":[{"data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*}"}],"response_format":"timeseries"}],"show_legend":true,"time":{},"title":"","title_align":"left","title_size":"16","type":"timeseries"},"layout":{"height":5,"width":12,"x":0,"y":0},"id":6721814968677378}],"notify_list":[],"created_at":"2025-02-17T16:50:57.183740+00:00","modified_at":"2025-02-17T16:50:57.183740+00:00","reflow_type":"fixed","restricted_roles":[]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/dashboard/a8v-698-pen + response: + body: + string: '{"deleted_dashboard_id":"a8v-698-pen"} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/features/dashboards.feature b/tests/v1/features/dashboards.feature index ebcfc7a25b..49b4659a83 100644 --- a/tests/v1/features/dashboards.feature +++ b/tests/v1/features/dashboards.feature @@ -817,6 +817,18 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].display_type" is equal to "bars" And the response "widgets[0].definition.requests[0].q" is equal to "sum:trace.test.errors{env:prod,service:datadog-api-spec} by {resource_name}.as_count()" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with timeseries widget with custom_unit + Given new "CreateDashboard" request + And body from file "dashboards_json_payload/timeseries_widget_with_custom_unit.json" + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.type" is equal to "timeseries" + And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.type" is equal to "canonical_unit" + And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.unit_name" is equal to "apdex" + And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.type" is equal to "canonical_unit" + And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.unit_name" is equal to "fraction" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with toplist widget Given new "CreateDashboard" request diff --git a/tests/v1/features/dashboards_json_payload/timeseries_widget_with_custom_unit.json b/tests/v1/features/dashboards_json_payload/timeseries_widget_with_custom_unit.json new file mode 100644 index 0000000000..6630dadb3d --- /dev/null +++ b/tests/v1/features/dashboards_json_payload/timeseries_widget_with_custom_unit.json @@ -0,0 +1,55 @@ +{ + "title": "{{ unique }}", + "description": "", + "widgets": [ + { + "definition": { + "title": "", + "title_size": "16", + "title_align": "left", + "show_legend": true, + "legend_layout": "auto", + "time": {}, + "type": "timeseries", + "requests": [ + { + "formulas": [ + { + "formula": "query1", + "number_format": { + "unit_scale": { + "type": "canonical_unit", + "unit_name": "apdex" + }, + "unit": { + "type": "canonical_unit", + "unit_name": "fraction" + } + } + } + ], + "queries": [ + { + "data_source": "metrics", + "name": "query1", + "query": "avg:system.cpu.user{*}" + } + ], + "response_format": "timeseries", + "display_type": "line" + } + ] + }, + "layout": { + "x": 0, + "y": 0, + "width": 12, + "height": 5 + } + } + ], + "template_variables": [], + "layout_type": "ordered", + "notify_list": [], + "reflow_type": "fixed" +}