Skip to content

Commit 17e7165

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add trend support for cell_display_mode (#2053)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent ba56fea commit 17e7165

File tree

14 files changed

+426
-5
lines changed

14 files changed

+426
-5
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-20 18:33:38.403757",
8-
"spec_repo_commit": "d3fcdb89"
7+
"regenerated": "2025-02-21 08:00:34.875274",
8+
"spec_repo_commit": "8f2d39c3"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-20 18:33:38.419806",
13-
"spec_repo_commit": "d3fcdb89"
12+
"regenerated": "2025-02-21 08:00:34.890789",
13+
"spec_repo_commit": "8f2d39c3"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17396,11 +17396,13 @@ components:
1739617396
enum:
1739717397
- number
1739817398
- bar
17399+
- trend
1739917400
example: number
1740017401
type: string
1740117402
x-enum-varnames:
1740217403
- NUMBER
1740317404
- BAR
17405+
- TREND
1740417406
TableWidgetDefinition:
1740517407
description: The table visualization is available on timeboards and screenboards.
1740617408
It displays columns of metrics grouped by tag key.
@@ -23089,6 +23091,8 @@ components:
2308923091
type: string
2309023092
cell_display_mode:
2309123093
$ref: '#/components/schemas/TableWidgetCellDisplayMode'
23094+
cell_display_mode_options:
23095+
$ref: '#/components/schemas/WidgetFormulaCellDisplayModeOptions'
2309223096
conditional_formats:
2309323097
description: List of conditional formats.
2309423098
items:
@@ -23107,6 +23111,37 @@ components:
2310723111
required:
2310823112
- formula
2310923113
type: object
23114+
WidgetFormulaCellDisplayModeOptions:
23115+
description: Cell display mode options for the widget formula. (only if `cell_display_mode`
23116+
is set to `trend`).
23117+
properties:
23118+
trend_type:
23119+
$ref: '#/components/schemas/WidgetFormulaCellDisplayModeOptionsTrendType'
23120+
y_scale:
23121+
$ref: '#/components/schemas/WidgetFormulaCellDisplayModeOptionsYScale'
23122+
type: object
23123+
WidgetFormulaCellDisplayModeOptionsTrendType:
23124+
description: Trend type for the cell display mode options.
23125+
enum:
23126+
- area
23127+
- line
23128+
- bars
23129+
example: area
23130+
type: string
23131+
x-enum-varnames:
23132+
- AREA
23133+
- LINE
23134+
- BARS
23135+
WidgetFormulaCellDisplayModeOptionsYScale:
23136+
description: Y scale for the cell display mode options.
23137+
enum:
23138+
- shared
23139+
- independent
23140+
example: shared
23141+
type: string
23142+
x-enum-varnames:
23143+
- SHARED
23144+
- INDEPENDENT
2311023145
WidgetFormulaLimit:
2311123146
description: Options for limiting results returned.
2311223147
properties:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2025-02-14T13:36:57.006Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with query_table widget and cell_display_mode is trend",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "9d4358ff728ac463b983e41258632fa2",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 756,
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": 557,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"description\":\"\",\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_query_table_widget_and_cell_display_mode_is_trend-1739540217\",\"widgets\":[{\"definition\":{\"has_search_bar\":\"auto\",\"requests\":[{\"formulas\":[{\"cell_display_mode\":\"trend\",\"cell_display_mode_options\":{\"trend_type\":\"line\",\"y_scale\":\"shared\"},\"conditional_formats\":[],\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {host}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":500,\"order_by\":[{\"index\":0,\"order\":\"desc\",\"type\":\"formula\"}]}}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"query_table\"},\"layout\":{\"height\":32,\"width\":54,\"x\":0,\"y\":0}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 1108,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 1108,
45+
"text": "{\"id\":\"qw6-574-sem\",\"title\":\"Test-Create_a_new_dashboard_with_query_table_widget_and_cell_display_mode_is_trend-1739540217\",\"description\":\"\",\"author_handle\":\"[email protected]\",\"author_name\":\"frog\",\"layout_type\":\"free\",\"url\":\"/dashboard/qw6-574-sem/test-createanewdashboardwithquerytablewidgetandcelldisplaymodeistrend-1739540217\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"has_search_bar\":\"auto\",\"requests\":[{\"formulas\":[{\"cell_display_mode\":\"trend\",\"cell_display_mode_options\":{\"trend_type\":\"line\",\"y_scale\":\"shared\"},\"conditional_formats\":[],\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {host}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":500,\"order_by\":[{\"index\":0,\"order\":\"desc\",\"type\":\"formula\"}]}}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"query_table\"},\"layout\":{\"height\":32,\"width\":54,\"x\":0,\"y\":0},\"id\":6048610427342909}],\"notify_list\":[],\"created_at\":\"2025-02-14T13:36:57.493950+00:00\",\"modified_at\":\"2025-02-14T13:36:57.493950+00:00\",\"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-14T13:36:57.008Z",
61+
"time": 617
62+
},
63+
{
64+
"_id": "56170a3f6fdc72d7c9fd25036e59824a",
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": 518,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/dashboard/qw6-574-sem"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"deleted_dashboard_id\":\"qw6-574-sem\"}\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-14T13:36:57.635Z",
104+
"time": 567
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Create a new dashboard with query_table widget and cell_display_mode is trend
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+
layout: {
17+
x: 0,
18+
y: 0,
19+
width: 54,
20+
height: 32,
21+
},
22+
definition: {
23+
title: "",
24+
titleSize: "16",
25+
titleAlign: "left",
26+
time: {},
27+
type: "query_table",
28+
requests: [
29+
{
30+
queries: [
31+
{
32+
dataSource: "metrics",
33+
name: "query1",
34+
query: "avg:system.cpu.user{*} by {host}",
35+
aggregator: "avg",
36+
},
37+
],
38+
formulas: [
39+
{
40+
formula: "query1",
41+
conditionalFormats: [],
42+
cellDisplayMode: "trend",
43+
cellDisplayModeOptions: {
44+
trendType: "line",
45+
yScale: "shared",
46+
},
47+
},
48+
],
49+
sort: {
50+
count: 500,
51+
orderBy: [
52+
{
53+
type: "formula",
54+
index: 0,
55+
order: "desc",
56+
},
57+
],
58+
},
59+
responseFormat: "scalar",
60+
},
61+
],
62+
hasSearchBar: "auto",
63+
},
64+
},
65+
],
66+
templateVariables: [],
67+
layoutType: "free",
68+
notifyList: [],
69+
},
70+
};
71+
72+
apiInstance
73+
.createDashboard(params)
74+
.then((data: v1.Dashboard) => {
75+
console.log(
76+
"API called successfully. Returned data: " + JSON.stringify(data)
77+
);
78+
})
79+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,17 @@ Feature: Dashboards
610610
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "formula"
611611
And the response "widgets[0].definition.requests[0].sort.order_by[0].index" is equal to 0
612612

613+
@team:DataDog/dashboards-backend
614+
Scenario: Create a new dashboard with query_table widget and cell_display_mode is trend
615+
Given new "CreateDashboard" request
616+
And body from file "dashboards_json_payload/query_table_widget_cell_display_mode_trend.json"
617+
When the request is sent
618+
Then the response status is 200 OK
619+
And the response "widgets[0].definition.type" is equal to "query_table"
620+
And the response "widgets[0].definition.requests[0].formulas[0].cell_display_mode" is equal to "trend"
621+
And the response "widgets[0].definition.requests[0].formulas[0].cell_display_mode_options.trend_type" is equal to "line"
622+
And the response "widgets[0].definition.requests[0].formulas[0].cell_display_mode_options.y_scale" is equal to "shared"
623+
613624
@team:DataDog/dashboards-backend
614625
Scenario: Create a new dashboard with query_table widget and text formatting
615626
Given new "CreateDashboard" request
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"title":"{{ unique }}",
3+
"description":"",
4+
"widgets":[
5+
{
6+
"layout":{
7+
"x":0,
8+
"y":0,
9+
"width":54,
10+
"height":32
11+
},
12+
"definition":{
13+
"title":"",
14+
"title_size":"16",
15+
"title_align":"left",
16+
"time":{
17+
18+
},
19+
"type":"query_table",
20+
"requests":[
21+
{
22+
"queries":[
23+
{
24+
"data_source":"metrics",
25+
"name":"query1",
26+
"query":"avg:system.cpu.user{*} by {host}",
27+
"aggregator":"avg"
28+
}
29+
],
30+
"formulas":[
31+
{
32+
"formula":"query1",
33+
"conditional_formats":[
34+
35+
],
36+
"cell_display_mode": "trend",
37+
"cell_display_mode_options": {
38+
"trend_type": "line",
39+
"y_scale": "shared"
40+
}
41+
}
42+
],
43+
"sort": {
44+
"count":500,
45+
"order_by":[
46+
{
47+
"type":"formula",
48+
"index":0,
49+
"order":"desc"
50+
}
51+
]
52+
},
53+
"response_format":"scalar"
54+
}
55+
],
56+
"has_search_bar":"auto"
57+
}
58+
}
59+
],
60+
"template_variables":[
61+
62+
],
63+
"layout_type":"free",
64+
"notify_list":[
65+
66+
]
67+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,9 @@ export { WidgetEvent } from "./models/WidgetEvent";
11951195
export { WidgetEventSize } from "./models/WidgetEventSize";
11961196
export { WidgetFieldSort } from "./models/WidgetFieldSort";
11971197
export { WidgetFormula } from "./models/WidgetFormula";
1198+
export { WidgetFormulaCellDisplayModeOptions } from "./models/WidgetFormulaCellDisplayModeOptions";
1199+
export { WidgetFormulaCellDisplayModeOptionsTrendType } from "./models/WidgetFormulaCellDisplayModeOptionsTrendType";
1200+
export { WidgetFormulaCellDisplayModeOptionsYScale } from "./models/WidgetFormulaCellDisplayModeOptionsYScale";
11981201
export { WidgetFormulaLimit } from "./models/WidgetFormulaLimit";
11991202
export { WidgetFormulaSort } from "./models/WidgetFormulaSort";
12001203
export { WidgetFormulaStyle } from "./models/WidgetFormulaStyle";

0 commit comments

Comments
 (0)