Skip to content

Commit 9c57938

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Support incident_analytics enum in dashboard widget FormulaAndFunctionEventsDataSource data sources (#1719)
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 1e23907 commit 9c57938

File tree

8 files changed

+196
-4
lines changed

8 files changed

+196
-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": "2024-07-22 20:03:18.056182",
8-
"spec_repo_commit": "cd020fa6"
7+
"regenerated": "2024-07-23 15:33:50.395018",
8+
"spec_repo_commit": "015355f6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-07-22 20:03:18.075162",
13-
"spec_repo_commit": "cd020fa6"
12+
"regenerated": "2024-07-23 15:33:50.413026",
13+
"spec_repo_commit": "015355f6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,7 @@ components:
28672867
- events
28682868
- ci_tests
28692869
- ci_pipelines
2870+
- incident_analytics
28702871
example: logs
28712872
type: string
28722873
x-enum-varnames:
@@ -2880,6 +2881,7 @@ components:
28802881
- EVENTS
28812882
- CI_TESTS
28822883
- CI_PIPELINES
2884+
- INCIDENT_ANALYTICS
28832885
FormulaAndFunctionMetricAggregation:
28842886
description: The aggregation methods available for metrics queries.
28852887
enum:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2024-07-23T14:59:59.215Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new timeseries widget with incident_analytics data source",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "7463bd2484f9696fa67b31568a8933fd",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 681,
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": "{\"layout_type\":\"ordered\",\"reflow_type\":\"auto\",\"title\":\"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799 with incident_analytics datasource\",\"widgets\":[{\"definition\":{\"legend_columns\":[\"avg\",\"min\",\"max\",\"value\",\"sum\"],\"legend_layout\":\"auto\",\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"incident_analytics\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"test_level:test\"}}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"show_legend\":true,\"time\":{},\"title\":\"\",\"type\":\"timeseries\"}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 1095,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 1095,
45+
"text": "{\"id\":\"r29-a2b-nhh\",\"title\":\"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799 with incident_analytics datasource\",\"description\":null,\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/r29-a2b-nhh/test-createanewtimeserieswidgetwithincidentanalyticsdatasource-1721746799-with-i\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"legend_columns\":[\"avg\",\"min\",\"max\",\"value\",\"sum\"],\"legend_layout\":\"auto\",\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"incident_analytics\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"test_level:test\"}}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"show_legend\":true,\"time\":{},\"title\":\"\",\"type\":\"timeseries\"},\"id\":4216078110414841}],\"notify_list\":null,\"created_at\":\"2024-07-23T14:59:59.491800+00:00\",\"modified_at\":\"2024-07-23T14:59:59.491800+00:00\",\"reflow_type\":\"auto\",\"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": "2024-07-23T14:59:59.224Z",
61+
"time": 455
62+
},
63+
{
64+
"_id": "f15c962c8f92d14962e29e114b20212d",
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/r29-a2b-nhh"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"deleted_dashboard_id\":\"r29-a2b-nhh\"}\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": "2024-07-23T14:59:59.685Z",
104+
"time": 222
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Create a new timeseries widget with incident_analytics data source
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 with incident_analytics datasource",
13+
widgets: [
14+
{
15+
definition: {
16+
title: "",
17+
showLegend: true,
18+
legendLayout: "auto",
19+
legendColumns: ["avg", "min", "max", "value", "sum"],
20+
time: {},
21+
type: "timeseries",
22+
requests: [
23+
{
24+
formulas: [
25+
{
26+
formula: "query1",
27+
},
28+
],
29+
queries: [
30+
{
31+
dataSource: "incident_analytics",
32+
name: "query1",
33+
search: {
34+
query: "test_level:test",
35+
},
36+
indexes: ["*"],
37+
compute: {
38+
aggregation: "count",
39+
},
40+
groupBy: [],
41+
},
42+
],
43+
responseFormat: "timeseries",
44+
style: {
45+
palette: "dog_classic",
46+
lineType: "solid",
47+
lineWidth: "normal",
48+
},
49+
displayType: "line",
50+
},
51+
],
52+
},
53+
},
54+
],
55+
layoutType: "ordered",
56+
reflowType: "auto",
57+
},
58+
};
59+
60+
apiInstance
61+
.createDashboard(params)
62+
.then((data: v1.Dashboard) => {
63+
console.log(
64+
"API called successfully. Returned data: " + JSON.stringify(data)
65+
);
66+
})
67+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ Feature: Dashboards
830830
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "ci_tests"
831831
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"
832832

833+
@team:DataDog/dashboards-backend
834+
Scenario: Create a new timeseries widget with incident_analytics data source
835+
Given new "CreateDashboard" request
836+
And body with value {"title":"{{ unique }} with incident_analytics datasource","widgets":[{"definition":{"title":"","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"formulas":[{"formula":"query1"}],"queries":[{"data_source":"incident_analytics","name":"query1","search":{"query":"test_level:test"},"indexes":["*"],"compute":{"aggregation":"count"},"group_by":[]}],"response_format":"timeseries","style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]}}],"layout_type":"ordered","reflow_type":"auto"}
837+
When the request is sent
838+
Then the response status is 200 OK
839+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "incident_analytics"
840+
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"
841+
833842
@generated @skip @team:DataDog/dashboards-backend
834843
Scenario: Create a shared dashboard returns "Bad Request" response
835844
Given new "CreatePublicDashboard" request

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type FormulaAndFunctionEventsDataSource =
2121
| typeof EVENTS
2222
| typeof CI_TESTS
2323
| typeof CI_PIPELINES
24+
| typeof INCIDENT_ANALYTICS
2425
| UnparsedObject;
2526
export const LOGS = "logs";
2627
export const SPANS = "spans";
@@ -32,3 +33,4 @@ export const AUDIT = "audit";
3233
export const EVENTS = "events";
3334
export const CI_TESTS = "ci_tests";
3435
export const CI_PIPELINES = "ci_pipelines";
36+
export const INCIDENT_ANALYTICS = "incident_analytics";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ const enumsMap: { [key: string]: any[] } = {
732732
"events",
733733
"ci_tests",
734734
"ci_pipelines",
735+
"incident_analytics",
735736
],
736737
FormulaAndFunctionMetricAggregation: [
737738
"avg",

0 commit comments

Comments
 (0)