Skip to content

Commit ae03bd1

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add style object to dashboard widget formulas (#945)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 3311ba5 commit ae03bd1

File tree

10 files changed

+268
-4
lines changed

10 files changed

+268
-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.4",
7-
"regenerated": "2022-12-09 17:41:08.830863",
8-
"spec_repo_commit": "9e20f8a4"
7+
"regenerated": "2022-12-13 17:18:35.179183",
8+
"spec_repo_commit": "8cd868ba"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-12-09 17:41:08.842402",
13-
"spec_repo_commit": "9e20f8a4"
12+
"regenerated": "2022-12-13 17:18:35.195191",
13+
"spec_repo_commit": "8cd868ba"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18043,6 +18043,8 @@ components:
1804318043
type: string
1804418044
limit:
1804518045
$ref: '#/components/schemas/WidgetFormulaLimit'
18046+
style:
18047+
$ref: '#/components/schemas/WidgetFormulaStyle'
1804618048
required:
1804718049
- formula
1804818050
type: object
@@ -18056,6 +18058,20 @@ components:
1805618058
order:
1805718059
$ref: '#/components/schemas/QuerySortOrder'
1805818060
type: object
18061+
WidgetFormulaStyle:
18062+
description: Styling options for widget formulas.
18063+
properties:
18064+
palette:
18065+
description: The color palette used to display the formula. A guide to the
18066+
available color palettes can be found at https://docs.datadoghq.com/dashboards/guide/widget_colors
18067+
example: classic
18068+
type: string
18069+
palette_index:
18070+
description: Index specifying which color to use within the palette.
18071+
example: 1
18072+
format: int64
18073+
type: integer
18074+
type: object
1805918075
WidgetGrouping:
1806018076
description: The kind of grouping to use.
1806118077
enum:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2022-12-13T17:13:10.406Z"
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 and formula style attributes",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "d9c31185d1a248ed6600ec8889b2414a",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 659,
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": 559,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"layout_type\":\"ordered\",\"reflow_type\":\"auto\",\"title\":\"Test-Create_a_new_dashboard_with_timeseries_widget_and_formula_style_attributes-1670951590 with formula style\",\"widgets\":[{\"definition\":{\"legend_columns\":[\"avg\",\"min\",\"max\",\"value\",\"sum\"],\"legend_layout\":\"auto\",\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\",\"style\":{\"palette\":\"classic\",\"palette_index\":4}}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"show_legend\":true,\"time\":{},\"title\":\"styled timeseries\",\"type\":\"timeseries\"}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 1073,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 1073,
45+
"text": "{\"notify_list\":null,\"description\":null,\"restricted_roles\":[],\"author_name\":null,\"template_variables\":null,\"is_read_only\":false,\"id\":\"k2c-ici-a4c\",\"title\":\"Test-Create_a_new_dashboard_with_timeseries_widget_and_formula_style_attributes-1670951590 with formula style\",\"url\":\"/dashboard/k2c-ici-a4c/test-createanewdashboardwithtimeserieswidgetandformulastyleattributes-1670951590\",\"created_at\":\"2022-12-13T17:13:10.630153+00:00\",\"modified_at\":\"2022-12-13T17:13:10.630153+00:00\",\"reflow_type\":\"auto\",\"author_handle\":\"[email protected]\",\"widgets\":[{\"definition\":{\"legend_columns\":[\"avg\",\"min\",\"max\",\"value\",\"sum\"],\"title\":\"styled timeseries\",\"legend_layout\":\"auto\",\"show_legend\":true,\"time\":{},\"requests\":[{\"formulas\":[{\"formula\":\"query1\",\"style\":{\"palette_index\":4,\"palette\":\"classic\"}}],\"style\":{\"line_width\":\"normal\",\"palette\":\"dog_classic\",\"line_type\":\"solid\"},\"display_type\":\"line\",\"response_format\":\"timeseries\",\"queries\":[{\"query\":\"avg:system.cpu.user{*}\",\"data_source\":\"metrics\",\"name\":\"query1\"}]}],\"type\":\"timeseries\"},\"id\":5980026334932933}],\"layout_type\":\"ordered\"}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 491,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2022-12-13T17:13:10.417Z",
61+
"time": 266
62+
},
63+
{
64+
"_id": "e31c38adf67c8de660bc778a91bbe8bf",
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": 520,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/dashboard/k2c-ici-a4c"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"deleted_dashboard_id\":\"k2c-ici-a4c\"}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 489,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2022-12-13T17:13:10.707Z",
104+
"time": 195
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Create a new dashboard with timeseries widget and formula style attributes
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:
13+
"Example-Create_a_new_dashboard_with_timeseries_widget_and_formula_style_attributes with formula style",
14+
widgets: [
15+
{
16+
definition: {
17+
title: "styled timeseries",
18+
showLegend: true,
19+
legendLayout: "auto",
20+
legendColumns: ["avg", "min", "max", "value", "sum"],
21+
time: {},
22+
type: "timeseries",
23+
requests: [
24+
{
25+
formulas: [
26+
{
27+
formula: "query1",
28+
style: {
29+
paletteIndex: 4,
30+
palette: "classic",
31+
},
32+
},
33+
],
34+
queries: [
35+
{
36+
query: "avg:system.cpu.user{*}",
37+
dataSource: "metrics",
38+
name: "query1",
39+
},
40+
],
41+
responseFormat: "timeseries",
42+
style: {
43+
palette: "dog_classic",
44+
lineType: "solid",
45+
lineWidth: "normal",
46+
},
47+
displayType: "line",
48+
},
49+
],
50+
},
51+
},
52+
],
53+
layoutType: "ordered",
54+
reflowType: "auto",
55+
},
56+
};
57+
58+
apiInstance
59+
.createDashboard(params)
60+
.then((data: v1.Dashboard) => {
61+
console.log(
62+
"API called successfully. Returned data: " + JSON.stringify(data)
63+
);
64+
})
65+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@ Feature: Dashboards
479479
When the request is sent
480480
Then the response status is 200 OK
481481

482+
@team:DataDog/dashboards
483+
Scenario: Create a new dashboard with timeseries widget and formula style attributes
484+
Given new "CreateDashboard" request
485+
And body with value {"title": "{{ unique }} with formula style","widgets": [{"definition": {"title": "styled timeseries","show_legend": true,"legend_layout": "auto","legend_columns": ["avg","min","max","value","sum"],"time": {},"type": "timeseries","requests": [{"formulas": [{"formula": "query1","style": {"palette_index": 4,"palette": "classic"}}],"queries": [{"query": "avg:system.cpu.user{*}","data_source": "metrics","name": "query1"}],"response_format": "timeseries","style": {"palette": "dog_classic","line_type": "solid","line_width": "normal"},"display_type": "line"}]}}],"layout_type": "ordered","reflow_type": "auto"}
486+
When the request is sent
487+
Then the response status is 200 OK
488+
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1"
489+
And the response "widgets[0].definition.requests[0].formulas[0].style.palette" is equal to "classic"
490+
And the response "widgets[0].definition.requests[0].formulas[0].style.palette_index" is equal to 4
491+
482492
@team:DataDog/dashboards
483493
Scenario: Create a new dashboard with timeseries widget containing style attributes
484494
Given new "CreateDashboard" request

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ export { WidgetEventSize } from "./models/WidgetEventSize";
10391039
export { WidgetFieldSort } from "./models/WidgetFieldSort";
10401040
export { WidgetFormula } from "./models/WidgetFormula";
10411041
export { WidgetFormulaLimit } from "./models/WidgetFormulaLimit";
1042+
export { WidgetFormulaStyle } from "./models/WidgetFormulaStyle";
10421043
export { WidgetGrouping } from "./models/WidgetGrouping";
10431044
export { WidgetHorizontalAlign } from "./models/WidgetHorizontalAlign";
10441045
export { WidgetImageSizing } from "./models/WidgetImageSizing";

packages/datadog-api-client-v1/models/ObjectSerializer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ import { WidgetEvent } from "./WidgetEvent";
539539
import { WidgetFieldSort } from "./WidgetFieldSort";
540540
import { WidgetFormula } from "./WidgetFormula";
541541
import { WidgetFormulaLimit } from "./WidgetFormulaLimit";
542+
import { WidgetFormulaStyle } from "./WidgetFormulaStyle";
542543
import { WidgetLayout } from "./WidgetLayout";
543544
import { WidgetMarker } from "./WidgetMarker";
544545
import { WidgetRequestStyle } from "./WidgetRequestStyle";
@@ -1907,6 +1908,7 @@ const typeMap: { [index: string]: any } = {
19071908
WidgetFieldSort: WidgetFieldSort,
19081909
WidgetFormula: WidgetFormula,
19091910
WidgetFormulaLimit: WidgetFormulaLimit,
1911+
WidgetFormulaStyle: WidgetFormulaStyle,
19101912
WidgetLayout: WidgetLayout,
19111913
WidgetMarker: WidgetMarker,
19121914
WidgetRequestStyle: WidgetRequestStyle,

packages/datadog-api-client-v1/models/WidgetFormula.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { TableWidgetCellDisplayMode } from "./TableWidgetCellDisplayMode";
77
import { WidgetConditionalFormat } from "./WidgetConditionalFormat";
88
import { WidgetFormulaLimit } from "./WidgetFormulaLimit";
9+
import { WidgetFormulaStyle } from "./WidgetFormulaStyle";
910

1011
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
1112

@@ -33,6 +34,10 @@ export class WidgetFormula {
3334
* Options for limiting results returned.
3435
*/
3536
"limit"?: WidgetFormulaLimit;
37+
/**
38+
* Styling options for widget formulas.
39+
*/
40+
"style"?: WidgetFormulaStyle;
3641

3742
/**
3843
* @ignore
@@ -64,6 +69,10 @@ export class WidgetFormula {
6469
baseName: "limit",
6570
type: "WidgetFormulaLimit",
6671
},
72+
style: {
73+
baseName: "style",
74+
type: "WidgetFormulaStyle",
75+
},
6776
};
6877

6978
/**
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Styling options for widget formulas.
11+
*/
12+
export class WidgetFormulaStyle {
13+
/**
14+
* The color palette used to display the formula. A guide to the available color palettes can be found at https://docs.datadoghq.com/dashboards/guide/widget_colors
15+
*/
16+
"palette"?: string;
17+
/**
18+
* Index specifying which color to use within the palette.
19+
*/
20+
"paletteIndex"?: number;
21+
22+
/**
23+
* @ignore
24+
*/
25+
"unparsedObject"?: any;
26+
27+
/**
28+
* @ignore
29+
*/
30+
static readonly attributeTypeMap: AttributeTypeMap = {
31+
palette: {
32+
baseName: "palette",
33+
type: "string",
34+
},
35+
paletteIndex: {
36+
baseName: "palette_index",
37+
type: "number",
38+
format: "int64",
39+
},
40+
};
41+
42+
/**
43+
* @ignore
44+
*/
45+
static getAttributeTypeMap(): AttributeTypeMap {
46+
return WidgetFormulaStyle.attributeTypeMap;
47+
}
48+
49+
public constructor() {}
50+
}

0 commit comments

Comments
 (0)