Skip to content

Commit 06832eb

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add number_format to each formula in widget (#2413)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent a0b2b2d commit 06832eb

17 files changed

+699
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-02-19 19:09:52.950548",
8-
"spec_repo_commit": "f0e5fdcf"
7+
"regenerated": "2025-02-20 13:34:59.325200",
8+
"spec_repo_commit": "c64543d0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-19 19:09:52.967553",
13-
"spec_repo_commit": "f0e5fdcf"
12+
"regenerated": "2025-02-20 13:34:59.340610",
13+
"spec_repo_commit": "c64543d0"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9727,6 +9727,62 @@ components:
97279727
items:
97289728
$ref: '#/components/schemas/NotifyEndType'
97299729
type: array
9730+
NumberFormatUnit:
9731+
description: Number format unit.
9732+
oneOf:
9733+
- $ref: '#/components/schemas/NumberFormatUnitCanonical'
9734+
- $ref: '#/components/schemas/NumberFormatUnitCustom'
9735+
NumberFormatUnitCanonical:
9736+
description: Canonical unit.
9737+
properties:
9738+
per_unit_name:
9739+
description: The name of the unit per item.
9740+
example: bytes
9741+
type: string
9742+
type:
9743+
$ref: '#/components/schemas/NumberFormatUnitScaleType'
9744+
unit_name:
9745+
description: The name of the unit.
9746+
example: bytes
9747+
type: string
9748+
type: object
9749+
NumberFormatUnitCustom:
9750+
description: Custom unit.
9751+
properties:
9752+
label:
9753+
description: The label for the custom unit.
9754+
maxLength: 12
9755+
minLength: 1
9756+
type: string
9757+
type:
9758+
$ref: '#/components/schemas/NumberFormatUnitCustomType'
9759+
type: object
9760+
NumberFormatUnitCustomType:
9761+
description: The type of custom unit.
9762+
enum:
9763+
- custom_unit_label
9764+
type: string
9765+
x-enum-varnames:
9766+
- CUSTOM_UNIT_LABEL
9767+
NumberFormatUnitScale:
9768+
description: The definition of `NumberFormatUnitScale` object.
9769+
nullable: true
9770+
properties:
9771+
type:
9772+
$ref: '#/components/schemas/NumberFormatUnitScaleType'
9773+
unit_name:
9774+
description: The name of the unit.
9775+
example: bytes
9776+
type: string
9777+
type: object
9778+
NumberFormatUnitScaleType:
9779+
description: The type of unit scale.
9780+
enum:
9781+
- canonical_unit
9782+
example: canonical_unit
9783+
type: string
9784+
x-enum-varnames:
9785+
- CANONICAL_UNIT
97309786
OnMissingDataOption:
97319787
description: 'Controls how groups or monitors are treated if an evaluation does
97329788
not return any data points.
@@ -23044,6 +23100,8 @@ components:
2304423100
type: string
2304523101
limit:
2304623102
$ref: '#/components/schemas/WidgetFormulaLimit'
23103+
number_format:
23104+
$ref: '#/components/schemas/WidgetNumberFormat'
2304723105
style:
2304823106
$ref: '#/components/schemas/WidgetFormulaStyle'
2304923107
required:
@@ -23463,6 +23521,14 @@ components:
2346323521
x-enum-varnames:
2346423522
- HOST
2346523523
- CONTAINER
23524+
WidgetNumberFormat:
23525+
description: Number format options for the widget.
23526+
properties:
23527+
unit:
23528+
$ref: '#/components/schemas/NumberFormatUnit'
23529+
unit_scale:
23530+
$ref: '#/components/schemas/NumberFormatUnitScale'
23531+
type: object
2346623532
WidgetOrderBy:
2346723533
description: What to order by.
2346823534
enum:

docs/datadog_api_client.v1.model.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,48 @@ datadog\_api\_client.v1.model.notify\_end\_type module
26502650
:members:
26512651
:show-inheritance:
26522652

2653+
datadog\_api\_client.v1.model.number\_format\_unit module
2654+
---------------------------------------------------------
2655+
2656+
.. automodule:: datadog_api_client.v1.model.number_format_unit
2657+
:members:
2658+
:show-inheritance:
2659+
2660+
datadog\_api\_client.v1.model.number\_format\_unit\_canonical module
2661+
--------------------------------------------------------------------
2662+
2663+
.. automodule:: datadog_api_client.v1.model.number_format_unit_canonical
2664+
:members:
2665+
:show-inheritance:
2666+
2667+
datadog\_api\_client.v1.model.number\_format\_unit\_custom module
2668+
-----------------------------------------------------------------
2669+
2670+
.. automodule:: datadog_api_client.v1.model.number_format_unit_custom
2671+
:members:
2672+
:show-inheritance:
2673+
2674+
datadog\_api\_client.v1.model.number\_format\_unit\_custom\_type module
2675+
-----------------------------------------------------------------------
2676+
2677+
.. automodule:: datadog_api_client.v1.model.number_format_unit_custom_type
2678+
:members:
2679+
:show-inheritance:
2680+
2681+
datadog\_api\_client.v1.model.number\_format\_unit\_scale module
2682+
----------------------------------------------------------------
2683+
2684+
.. automodule:: datadog_api_client.v1.model.number_format_unit_scale
2685+
:members:
2686+
:show-inheritance:
2687+
2688+
datadog\_api\_client.v1.model.number\_format\_unit\_scale\_type module
2689+
----------------------------------------------------------------------
2690+
2691+
.. automodule:: datadog_api_client.v1.model.number_format_unit_scale_type
2692+
:members:
2693+
:show-inheritance:
2694+
26532695
datadog\_api\_client.v1.model.on\_missing\_data\_option module
26542696
--------------------------------------------------------------
26552697

@@ -6304,6 +6346,13 @@ datadog\_api\_client.v1.model.widget\_node\_type module
63046346
:members:
63056347
:show-inheritance:
63066348

6349+
datadog\_api\_client.v1.model.widget\_number\_format module
6350+
-----------------------------------------------------------
6351+
6352+
.. automodule:: datadog_api_client.v1.model.widget_number_format
6353+
:members:
6354+
:show-inheritance:
6355+
63076356
datadog\_api\_client.v1.model.widget\_order\_by module
63086357
------------------------------------------------------
63096358

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
"""
2+
Create a new dashboard with timeseries widget with custom_unit
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
7+
from datadog_api_client.v1.model.dashboard import Dashboard
8+
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
9+
from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType
10+
from datadog_api_client.v1.model.formula_and_function_metric_data_source import FormulaAndFunctionMetricDataSource
11+
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
12+
FormulaAndFunctionMetricQueryDefinition,
13+
)
14+
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat
15+
from datadog_api_client.v1.model.number_format_unit_canonical import NumberFormatUnitCanonical
16+
from datadog_api_client.v1.model.number_format_unit_scale import NumberFormatUnitScale
17+
from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType
18+
from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition
19+
from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType
20+
from datadog_api_client.v1.model.timeseries_widget_legend_layout import TimeseriesWidgetLegendLayout
21+
from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest
22+
from datadog_api_client.v1.model.widget import Widget
23+
from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType
24+
from datadog_api_client.v1.model.widget_formula import WidgetFormula
25+
from datadog_api_client.v1.model.widget_layout import WidgetLayout
26+
from datadog_api_client.v1.model.widget_legacy_live_span import WidgetLegacyLiveSpan
27+
from datadog_api_client.v1.model.widget_number_format import WidgetNumberFormat
28+
from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign
29+
30+
body = Dashboard(
31+
title="Example-Dashboard",
32+
description="",
33+
widgets=[
34+
Widget(
35+
definition=TimeseriesWidgetDefinition(
36+
title="",
37+
title_size="16",
38+
title_align=WidgetTextAlign.LEFT,
39+
show_legend=True,
40+
legend_layout=TimeseriesWidgetLegendLayout.AUTO,
41+
time=WidgetLegacyLiveSpan(),
42+
type=TimeseriesWidgetDefinitionType.TIMESERIES,
43+
requests=[
44+
TimeseriesWidgetRequest(
45+
formulas=[
46+
WidgetFormula(
47+
formula="query1",
48+
number_format=WidgetNumberFormat(
49+
unit_scale=NumberFormatUnitScale(
50+
type=NumberFormatUnitScaleType.CANONICAL_UNIT,
51+
unit_name="apdex",
52+
),
53+
unit=NumberFormatUnitCanonical(
54+
type=NumberFormatUnitScaleType.CANONICAL_UNIT,
55+
unit_name="fraction",
56+
),
57+
),
58+
),
59+
],
60+
queries=[
61+
FormulaAndFunctionMetricQueryDefinition(
62+
data_source=FormulaAndFunctionMetricDataSource.METRICS,
63+
name="query1",
64+
query="avg:system.cpu.user{*}",
65+
),
66+
],
67+
response_format=FormulaAndFunctionResponseFormat.TIMESERIES,
68+
display_type=WidgetDisplayType.LINE,
69+
),
70+
],
71+
),
72+
layout=WidgetLayout(
73+
x=0,
74+
y=0,
75+
width=12,
76+
height=5,
77+
),
78+
),
79+
],
80+
template_variables=[],
81+
layout_type=DashboardLayoutType.ORDERED,
82+
notify_list=[],
83+
reflow_type=DashboardReflowType.FIXED,
84+
)
85+
86+
configuration = Configuration()
87+
with ApiClient(configuration) as api_client:
88+
api_instance = DashboardsApi(api_client)
89+
response = api_instance.create_dashboard(body=body)
90+
91+
print(response)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelComposed,
9+
cached_property,
10+
)
11+
12+
13+
class NumberFormatUnit(ModelComposed):
14+
def __init__(self, **kwargs):
15+
"""
16+
Number format unit.
17+
18+
:param per_unit_name: The name of the unit per item.
19+
:type per_unit_name: str, optional
20+
21+
:param type: The type of unit scale.
22+
:type type: NumberFormatUnitScaleType, optional
23+
24+
:param unit_name: The name of the unit.
25+
:type unit_name: str, optional
26+
27+
:param label: The label for the custom unit.
28+
:type label: str, optional
29+
"""
30+
super().__init__(kwargs)
31+
32+
@cached_property
33+
def _composed_schemas(_):
34+
# we need this here to make our import statements work
35+
# we must store _composed_schemas in here so the code is only run
36+
# when we invoke this method. If we kept this at the class
37+
# level we would get an error because the class level
38+
# code would be run when this module is imported, and these composed
39+
# classes don't exist yet because their module has not finished
40+
# loading
41+
from datadog_api_client.v1.model.number_format_unit_canonical import NumberFormatUnitCanonical
42+
from datadog_api_client.v1.model.number_format_unit_custom import NumberFormatUnitCustom
43+
44+
return {
45+
"oneOf": [
46+
NumberFormatUnitCanonical,
47+
NumberFormatUnitCustom,
48+
],
49+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType
18+
19+
20+
class NumberFormatUnitCanonical(ModelNormal):
21+
@cached_property
22+
def openapi_types(_):
23+
from datadog_api_client.v1.model.number_format_unit_scale_type import NumberFormatUnitScaleType
24+
25+
return {
26+
"per_unit_name": (str,),
27+
"type": (NumberFormatUnitScaleType,),
28+
"unit_name": (str,),
29+
}
30+
31+
attribute_map = {
32+
"per_unit_name": "per_unit_name",
33+
"type": "type",
34+
"unit_name": "unit_name",
35+
}
36+
37+
def __init__(
38+
self_,
39+
per_unit_name: Union[str, UnsetType] = unset,
40+
type: Union[NumberFormatUnitScaleType, UnsetType] = unset,
41+
unit_name: Union[str, UnsetType] = unset,
42+
**kwargs,
43+
):
44+
"""
45+
Canonical unit.
46+
47+
:param per_unit_name: The name of the unit per item.
48+
:type per_unit_name: str, optional
49+
50+
:param type: The type of unit scale.
51+
:type type: NumberFormatUnitScaleType, optional
52+
53+
:param unit_name: The name of the unit.
54+
:type unit_name: str, optional
55+
"""
56+
if per_unit_name is not unset:
57+
kwargs["per_unit_name"] = per_unit_name
58+
if type is not unset:
59+
kwargs["type"] = type
60+
if unit_name is not unset:
61+
kwargs["unit_name"] = unit_name
62+
super().__init__(kwargs)

0 commit comments

Comments
 (0)