Skip to content

Commit a472edb

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add sort field to SLOListWidgetQuery (#1026)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 637b4f5 commit a472edb

File tree

8 files changed

+334
-4
lines changed

8 files changed

+334
-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": "2023-02-14 22:24:35.435746",
8-
"spec_repo_commit": "7a7cb634"
7+
"regenerated": "2023-02-15 14:54:20.667520",
8+
"spec_repo_commit": "3371aaa2"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-02-14 22:24:35.448427",
13-
"spec_repo_commit": "7a7cb634"
12+
"regenerated": "2023-02-15 14:54:20.679789",
13+
"spec_repo_commit": "3371aaa2"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9668,6 +9668,11 @@ components:
96689668
description: Widget query.
96699669
example: env:prod AND service:my-app
96709670
type: string
9671+
sort:
9672+
description: Options for sorting results.
9673+
items:
9674+
$ref: '#/components/schemas/WidgetFieldSort'
9675+
type: array
96719676
required:
96729677
- query_string
96739678
type: object
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-02-14T18:54:56.599Z"
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with slo list widget with sort",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "a4b727ac685f572ba6bba942086c5af1",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 280,
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": 547,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"name\":\"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896\",\"query\":{\"denominator\":\"sum:httpservice.hits{!code:3xx}.as_count()\",\"numerator\":\"sum:httpservice.hits{code:2xx}.as_count()\"},\"thresholds\":[{\"target\":95,\"timeframe\":\"7d\",\"warning\":98}],\"type\":\"metric\"}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/slo"
39+
},
40+
"response": {
41+
"bodySize": 647,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 647,
45+
"text": "{\"data\":[{\"id\":\"80091437d0165587a0831040981e44f9\",\"name\":\"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896\",\"tags\":[],\"monitor_tags\":[],\"thresholds\":[{\"timeframe\":\"7d\",\"target\":95.0,\"target_display\":\"95.\",\"warning\":98.0,\"warning_display\":\"98.\"}],\"type\":\"metric\",\"type_id\":1,\"description\":\"\",\"timeframe\":\"7d\",\"warning_threshold\":98,\"target_threshold\":95,\"query\":{\"denominator\":\"sum:httpservice.hits{!code:3xx}.as_count()\",\"numerator\":\"sum:httpservice.hits{code:2xx}.as_count()\"},\"creator\":{\"name\":null,\"handle\":\"[email protected]\",\"email\":\"[email protected]\"},\"created_at\":1676400896,\"modified_at\":1676400896}],\"error\":null}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 618,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2023-02-14T18:54:56.619Z",
61+
"time": 212
62+
},
63+
{
64+
"_id": "5e4765b17db434d7ffd55d5a84dc0226",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 467,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
},
76+
{
77+
"_fromType": "array",
78+
"name": "content-type",
79+
"value": "application/json"
80+
}
81+
],
82+
"headersSize": 559,
83+
"httpVersion": "HTTP/1.1",
84+
"method": "POST",
85+
"postData": {
86+
"mimeType": "application/json",
87+
"params": [],
88+
"text": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896\",\"widgets\":[{\"definition\":{\"requests\":[{\"query\":{\"limit\":75,\"query_string\":\"env:prod AND service:my-app\",\"sort\":[{\"column\":\"status.sli\",\"order\":\"asc\"}]},\"request_type\":\"slo_list\"}],\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"slo_list\"},\"layout\":{\"height\":21,\"width\":60,\"x\":0,\"y\":0}}]}"
89+
},
90+
"queryString": [],
91+
"url": "https://api.datadoghq.com/api/v1/dashboard"
92+
},
93+
"response": {
94+
"bodySize": 776,
95+
"content": {
96+
"mimeType": "application/json",
97+
"size": 776,
98+
"text": "{\"id\":\"6hq-ih3-tzg\",\"title\":\"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896\",\"description\":\"\",\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"free\",\"url\":\"/dashboard/6hq-ih3-tzg/test-createanewdashboardwithslolistwidgetwithsort-1676400896\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"requests\":[{\"query\":{\"limit\":75,\"query_string\":\"env:prod AND service:my-app\",\"sort\":[{\"column\":\"status.sli\",\"order\":\"asc\"}]},\"request_type\":\"slo_list\"}],\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"slo_list\"},\"layout\":{\"height\":21,\"width\":60,\"x\":0,\"y\":0},\"id\":1642439378480719}],\"notify_list\":[],\"created_at\":\"2023-02-14T18:54:57.012649+00:00\",\"modified_at\":\"2023-02-14T18:54:57.012649+00:00\",\"restricted_roles\":[]}\n"
99+
},
100+
"cookies": [],
101+
"headers": [
102+
{
103+
"name": "content-type",
104+
"value": "application/json"
105+
}
106+
],
107+
"headersSize": 490,
108+
"httpVersion": "HTTP/1.1",
109+
"redirectURL": "",
110+
"status": 200,
111+
"statusText": "OK"
112+
},
113+
"startedDateTime": "2023-02-14T18:54:56.842Z",
114+
"time": 219
115+
},
116+
{
117+
"_id": "60e194a3d250c7f428af022b3e6e2b1b",
118+
"_order": 0,
119+
"cache": {},
120+
"request": {
121+
"bodySize": 0,
122+
"cookies": [],
123+
"headers": [
124+
{
125+
"_fromType": "array",
126+
"name": "accept",
127+
"value": "application/json"
128+
}
129+
],
130+
"headersSize": 520,
131+
"httpVersion": "HTTP/1.1",
132+
"method": "DELETE",
133+
"queryString": [],
134+
"url": "https://api.datadoghq.com/api/v1/dashboard/6hq-ih3-tzg"
135+
},
136+
"response": {
137+
"bodySize": 39,
138+
"content": {
139+
"mimeType": "application/json",
140+
"size": 39,
141+
"text": "{\"deleted_dashboard_id\":\"6hq-ih3-tzg\"}\n"
142+
},
143+
"cookies": [],
144+
"headers": [
145+
{
146+
"name": "content-type",
147+
"value": "application/json"
148+
}
149+
],
150+
"headersSize": 489,
151+
"httpVersion": "HTTP/1.1",
152+
"redirectURL": "",
153+
"status": 200,
154+
"statusText": "OK"
155+
},
156+
"startedDateTime": "2023-02-14T18:54:57.071Z",
157+
"time": 192
158+
},
159+
{
160+
"_id": "518d81951afd78981f3fe895abd3f819",
161+
"_order": 0,
162+
"cache": {},
163+
"request": {
164+
"bodySize": 0,
165+
"cookies": [],
166+
"headers": [
167+
{
168+
"_fromType": "array",
169+
"name": "accept",
170+
"value": "application/json"
171+
}
172+
],
173+
"headersSize": 529,
174+
"httpVersion": "HTTP/1.1",
175+
"method": "DELETE",
176+
"queryString": [],
177+
"url": "https://api.datadoghq.com/api/v1/slo/80091437d0165587a0831040981e44f9"
178+
},
179+
"response": {
180+
"bodySize": 59,
181+
"content": {
182+
"mimeType": "application/json",
183+
"size": 59,
184+
"text": "{\"data\":[\"80091437d0165587a0831040981e44f9\"],\"error\":null}\n"
185+
},
186+
"cookies": [],
187+
"headers": [
188+
{
189+
"name": "content-type",
190+
"value": "application/json"
191+
}
192+
],
193+
"headersSize": 616,
194+
"httpVersion": "HTTP/1.1",
195+
"redirectURL": "",
196+
"status": 200,
197+
"statusText": "OK"
198+
},
199+
"startedDateTime": "2023-02-14T18:54:57.286Z",
200+
"time": 180
201+
}
202+
],
203+
"pages": [],
204+
"version": "1.2"
205+
}
206+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Create a new dashboard with slo list widget with sort
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-Create_a_new_dashboard_with_slo_list_widget_with_sort",
13+
description: "",
14+
widgets: [
15+
{
16+
layout: {
17+
x: 0,
18+
y: 0,
19+
width: 60,
20+
height: 21,
21+
},
22+
definition: {
23+
titleSize: "16",
24+
titleAlign: "left",
25+
type: "slo_list",
26+
requests: [
27+
{
28+
query: {
29+
queryString: "env:prod AND service:my-app",
30+
limit: 75,
31+
sort: [
32+
{
33+
column: "status.sli",
34+
order: "asc",
35+
},
36+
],
37+
},
38+
requestType: "slo_list",
39+
},
40+
],
41+
},
42+
},
43+
],
44+
templateVariables: [],
45+
layoutType: "free",
46+
isReadOnly: false,
47+
notifyList: [],
48+
},
49+
};
50+
51+
apiInstance
52+
.createDashboard(params)
53+
.then((data: v1.Dashboard) => {
54+
console.log(
55+
"API called successfully. Returned data: " + JSON.stringify(data)
56+
);
57+
})
58+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,19 @@ Feature: Dashboards
462462
And the response "widgets[0].definition.requests[0].query.query_string" is equal to "env:prod AND service:my-app"
463463
And the response "widgets[0].definition.requests[0].query.limit" is equal to 75
464464

465+
@team:DataDog/dashboards
466+
Scenario: Create a new dashboard with slo list widget with sort
467+
Given there is a valid "slo" in the system
468+
And new "CreateDashboard" request
469+
And body from file "dashboards_json_payload/slo_list_widget_with_sort.json"
470+
When the request is sent
471+
Then the response status is 200 OK
472+
And the response "widgets[0].definition.type" is equal to "slo_list"
473+
And the response "widgets[0].definition.requests[0].query.query_string" is equal to "env:prod AND service:my-app"
474+
And the response "widgets[0].definition.requests[0].query.limit" is equal to 75
475+
And the response "widgets[0].definition.requests[0].query.sort[0].column" is equal to "status.sli"
476+
And the response "widgets[0].definition.requests[0].query.sort[0].order" is equal to "asc"
477+
465478
@team:DataDog/dashboards
466479
Scenario: Create a new dashboard with slo widget
467480
Given there is a valid "slo" in the system
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"title": "{{ unique }}",
3+
"description": "",
4+
"widgets": [
5+
{
6+
"layout": {
7+
"x": 0,
8+
"y": 0,
9+
"width": 60,
10+
"height": 21
11+
},
12+
"definition": {
13+
"title_size": "16",
14+
"title_align": "left",
15+
"type": "slo_list",
16+
"requests": [
17+
{
18+
"query": {
19+
"query_string": "env:prod AND service:my-app",
20+
"limit": 75,
21+
"sort": [
22+
{
23+
"column": "status.sli",
24+
"order": "asc"
25+
}
26+
]
27+
},
28+
"request_type": "slo_list"
29+
}
30+
]
31+
}
32+
}
33+
],
34+
"template_variables": [],
35+
"layout_type": "free",
36+
"is_read_only": false,
37+
"notify_list": []
38+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* This product includes software developed at Datadog (https://www.datadoghq.com/).
44
* Copyright 2020-Present Datadog, Inc.
55
*/
6+
import { WidgetFieldSort } from "./WidgetFieldSort";
67

78
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
89

@@ -18,6 +19,10 @@ export class SLOListWidgetQuery {
1819
* Widget query.
1920
*/
2021
"queryString": string;
22+
/**
23+
* Options for sorting results.
24+
*/
25+
"sort"?: Array<WidgetFieldSort>;
2126

2227
/**
2328
* @ignore
@@ -38,6 +43,10 @@ export class SLOListWidgetQuery {
3843
type: "string",
3944
required: true,
4045
},
46+
sort: {
47+
baseName: "sort",
48+
type: "Array<WidgetFieldSort>",
49+
},
4150
};
4251

4352
/**

0 commit comments

Comments
 (0)