Skip to content

Commit c4abc80

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Add number_format to each formula in widget (#2056)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 1565ef5 commit c4abc80

File tree

17 files changed

+651
-4
lines changed

17 files changed

+651
-4
lines changed

.apigentools-info

+4-4
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:51.941033",
8-
"spec_repo_commit": "f0e5fdcf"
7+
"regenerated": "2025-02-20 13:35:04.708998",
8+
"spec_repo_commit": "c64543d0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-19 19:09:51.956708",
13-
"spec_repo_commit": "f0e5fdcf"
12+
"regenerated": "2025-02-20 13:35:04.724917",
13+
"spec_repo_commit": "c64543d0"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

+66
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:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2025-02-17T16:50:56.669Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with timeseries widget with custom_unit",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "38821fcaedaff1a1d6f2dc3c1a613e9e",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 712,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 555,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"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}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 1053,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 1053,
45+
"text": "{\"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\":[]}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 657,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2025-02-17T16:50:56.672Z",
61+
"time": 613
62+
},
63+
{
64+
"_id": "5ad97c5eb82dbeca915d3aedcc9af901",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 516,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/dashboard/a8v-698-pen"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"deleted_dashboard_id\":\"a8v-698-pen\"}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 655,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2025-02-17T16:50:57.291Z",
104+
"time": 561
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Create a new dashboard with timeseries widget with custom_unit
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.DashboardsApi(configuration);
9+
10+
const params: v1.DashboardsApiCreateDashboardRequest = {
11+
body: {
12+
title: "Example-Dashboard",
13+
description: "",
14+
widgets: [
15+
{
16+
definition: {
17+
title: "",
18+
titleSize: "16",
19+
titleAlign: "left",
20+
showLegend: true,
21+
legendLayout: "auto",
22+
time: {},
23+
type: "timeseries",
24+
requests: [
25+
{
26+
formulas: [
27+
{
28+
formula: "query1",
29+
numberFormat: {
30+
unitScale: {
31+
type: "canonical_unit",
32+
unitName: "apdex",
33+
},
34+
unit: {
35+
type: "canonical_unit",
36+
unitName: "fraction",
37+
},
38+
},
39+
},
40+
],
41+
queries: [
42+
{
43+
dataSource: "metrics",
44+
name: "query1",
45+
query: "avg:system.cpu.user{*}",
46+
},
47+
],
48+
responseFormat: "timeseries",
49+
displayType: "line",
50+
},
51+
],
52+
},
53+
layout: {
54+
x: 0,
55+
y: 0,
56+
width: 12,
57+
height: 5,
58+
},
59+
},
60+
],
61+
templateVariables: [],
62+
layoutType: "ordered",
63+
notifyList: [],
64+
reflowType: "fixed",
65+
},
66+
};
67+
68+
apiInstance
69+
.createDashboard(params)
70+
.then((data: v1.Dashboard) => {
71+
console.log(
72+
"API called successfully. Returned data: " + JSON.stringify(data)
73+
);
74+
})
75+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

+12
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,18 @@ Feature: Dashboards
817817
And the response "widgets[0].definition.requests[0].display_type" is equal to "bars"
818818
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()"
819819

820+
@team:DataDog/dashboards-backend
821+
Scenario: Create a new dashboard with timeseries widget with custom_unit
822+
Given new "CreateDashboard" request
823+
And body from file "dashboards_json_payload/timeseries_widget_with_custom_unit.json"
824+
When the request is sent
825+
Then the response status is 200 OK
826+
And the response "widgets[0].definition.type" is equal to "timeseries"
827+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.type" is equal to "canonical_unit"
828+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit_scale.unit_name" is equal to "apdex"
829+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.type" is equal to "canonical_unit"
830+
And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.unit_name" is equal to "fraction"
831+
820832
@team:DataDog/dashboards-backend
821833
Scenario: Create a new dashboard with toplist widget
822834
Given new "CreateDashboard" request
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"title": "{{ unique }}",
3+
"description": "",
4+
"widgets": [
5+
{
6+
"definition": {
7+
"title": "",
8+
"title_size": "16",
9+
"title_align": "left",
10+
"show_legend": true,
11+
"legend_layout": "auto",
12+
"time": {},
13+
"type": "timeseries",
14+
"requests": [
15+
{
16+
"formulas": [
17+
{
18+
"formula": "query1",
19+
"number_format": {
20+
"unit_scale": {
21+
"type": "canonical_unit",
22+
"unit_name": "apdex"
23+
},
24+
"unit": {
25+
"type": "canonical_unit",
26+
"unit_name": "fraction"
27+
}
28+
}
29+
}
30+
],
31+
"queries": [
32+
{
33+
"data_source": "metrics",
34+
"name": "query1",
35+
"query": "avg:system.cpu.user{*}"
36+
}
37+
],
38+
"response_format": "timeseries",
39+
"display_type": "line"
40+
}
41+
]
42+
},
43+
"layout": {
44+
"x": 0,
45+
"y": 0,
46+
"width": 12,
47+
"height": 5
48+
}
49+
}
50+
],
51+
"template_variables": [],
52+
"layout_type": "ordered",
53+
"notify_list": [],
54+
"reflow_type": "fixed"
55+
}

packages/datadog-api-client-v1/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,12 @@ export { NoteWidgetDefinition } from "./models/NoteWidgetDefinition";
702702
export { NoteWidgetDefinitionType } from "./models/NoteWidgetDefinitionType";
703703
export { NotifyEndState } from "./models/NotifyEndState";
704704
export { NotifyEndType } from "./models/NotifyEndType";
705+
export { NumberFormatUnit } from "./models/NumberFormatUnit";
706+
export { NumberFormatUnitCanonical } from "./models/NumberFormatUnitCanonical";
707+
export { NumberFormatUnitCustom } from "./models/NumberFormatUnitCustom";
708+
export { NumberFormatUnitCustomType } from "./models/NumberFormatUnitCustomType";
709+
export { NumberFormatUnitScale } from "./models/NumberFormatUnitScale";
710+
export { NumberFormatUnitScaleType } from "./models/NumberFormatUnitScaleType";
705711
export { OnMissingDataOption } from "./models/OnMissingDataOption";
706712
export { Organization } from "./models/Organization";
707713
export { OrganizationBilling } from "./models/OrganizationBilling";
@@ -1213,6 +1219,7 @@ export { WidgetNewFixedSpanType } from "./models/WidgetNewFixedSpanType";
12131219
export { WidgetNewLiveSpan } from "./models/WidgetNewLiveSpan";
12141220
export { WidgetNewLiveSpanType } from "./models/WidgetNewLiveSpanType";
12151221
export { WidgetNodeType } from "./models/WidgetNodeType";
1222+
export { WidgetNumberFormat } from "./models/WidgetNumberFormat";
12161223
export { WidgetOrderBy } from "./models/WidgetOrderBy";
12171224
export { WidgetPalette } from "./models/WidgetPalette";
12181225
export { WidgetRequestStyle } from "./models/WidgetRequestStyle";

0 commit comments

Comments
 (0)