Skip to content

Commit 8dbac5a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Widgets API v2 OpenAPI spec (#3776)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 641b44f commit 8dbac5a

28 files changed

+2898
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 594 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Create a widget returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.WidgetsApi(configuration);
9+
10+
const params: v2.WidgetsApiCreateWidgetRequest = {
11+
body: {
12+
data: {
13+
attributes: {
14+
definition: {
15+
title: "My Widget",
16+
type: "bar_chart",
17+
},
18+
tags: [],
19+
},
20+
type: "widgets",
21+
},
22+
},
23+
experienceType: "ccm_reports",
24+
};
25+
26+
apiInstance
27+
.createWidget(params)
28+
.then((data: v2.WidgetResponse) => {
29+
console.log(
30+
"API called successfully. Returned data: " + JSON.stringify(data)
31+
);
32+
})
33+
.catch((error: any) => console.error(error));
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Delete a widget returns "No Content" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.WidgetsApi(configuration);
9+
10+
const params: v2.WidgetsApiDeleteWidgetRequest = {
11+
experienceType: "ccm_reports",
12+
uuid: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
13+
};
14+
15+
apiInstance
16+
.deleteWidget(params)
17+
.then((data: any) => {
18+
console.log(
19+
"API called successfully. Returned data: " + JSON.stringify(data)
20+
);
21+
})
22+
.catch((error: any) => console.error(error));

examples/v2/widgets/GetWidget.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Get a widget returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.WidgetsApi(configuration);
9+
10+
const params: v2.WidgetsApiGetWidgetRequest = {
11+
experienceType: "ccm_reports",
12+
uuid: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
13+
};
14+
15+
apiInstance
16+
.getWidget(params)
17+
.then((data: v2.WidgetResponse) => {
18+
console.log(
19+
"API called successfully. Returned data: " + JSON.stringify(data)
20+
);
21+
})
22+
.catch((error: any) => console.error(error));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Search widgets returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.WidgetsApi(configuration);
9+
10+
const params: v2.WidgetsApiSearchWidgetsRequest = {
11+
experienceType: "ccm_reports",
12+
};
13+
14+
apiInstance
15+
.searchWidgets(params)
16+
.then((data: v2.WidgetListResponse) => {
17+
console.log(
18+
"API called successfully. Returned data: " + JSON.stringify(data)
19+
);
20+
})
21+
.catch((error: any) => console.error(error));
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Update a widget returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.WidgetsApi(configuration);
9+
10+
const params: v2.WidgetsApiUpdateWidgetRequest = {
11+
body: {
12+
data: {
13+
attributes: {
14+
definition: {
15+
title: "My Widget",
16+
type: "bar_chart",
17+
},
18+
tags: [],
19+
},
20+
type: "widgets",
21+
},
22+
},
23+
experienceType: "ccm_reports",
24+
uuid: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
25+
};
26+
27+
apiInstance
28+
.updateWidget(params)
29+
.then((data: v2.WidgetResponse) => {
30+
console.log(
31+
"API called successfully. Returned data: " + JSON.stringify(data)
32+
);
33+
})
34+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11751,6 +11751,93 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
1175111751
},
1175211752
"operationResponseType": "PermissionsResponse",
1175311753
},
11754+
"v2.SearchWidgets": {
11755+
"experienceType": {
11756+
"type": "WidgetExperienceType",
11757+
"format": "",
11758+
},
11759+
"filterWidgetType": {
11760+
"type": "WidgetType",
11761+
"format": "",
11762+
},
11763+
"filterCreatorHandle": {
11764+
"type": "string",
11765+
"format": "",
11766+
},
11767+
"filterIsFavorited": {
11768+
"type": "boolean",
11769+
"format": "",
11770+
},
11771+
"filterTitle": {
11772+
"type": "string",
11773+
"format": "",
11774+
},
11775+
"filterTags": {
11776+
"type": "string",
11777+
"format": "",
11778+
},
11779+
"sort": {
11780+
"type": "string",
11781+
"format": "",
11782+
},
11783+
"pageNumber": {
11784+
"type": "number",
11785+
"format": "",
11786+
},
11787+
"pageSize": {
11788+
"type": "number",
11789+
"format": "",
11790+
},
11791+
"operationResponseType": "WidgetListResponse",
11792+
},
11793+
"v2.CreateWidget": {
11794+
"experienceType": {
11795+
"type": "WidgetExperienceType",
11796+
"format": "",
11797+
},
11798+
"body": {
11799+
"type": "CreateOrUpdateWidgetRequest",
11800+
"format": "",
11801+
},
11802+
"operationResponseType": "WidgetResponse",
11803+
},
11804+
"v2.GetWidget": {
11805+
"experienceType": {
11806+
"type": "WidgetExperienceType",
11807+
"format": "",
11808+
},
11809+
"uuid": {
11810+
"type": "string",
11811+
"format": "uuid",
11812+
},
11813+
"operationResponseType": "WidgetResponse",
11814+
},
11815+
"v2.UpdateWidget": {
11816+
"experienceType": {
11817+
"type": "WidgetExperienceType",
11818+
"format": "",
11819+
},
11820+
"uuid": {
11821+
"type": "string",
11822+
"format": "uuid",
11823+
},
11824+
"body": {
11825+
"type": "CreateOrUpdateWidgetRequest",
11826+
"format": "",
11827+
},
11828+
"operationResponseType": "WidgetResponse",
11829+
},
11830+
"v2.DeleteWidget": {
11831+
"experienceType": {
11832+
"type": "WidgetExperienceType",
11833+
"format": "",
11834+
},
11835+
"uuid": {
11836+
"type": "string",
11837+
"format": "uuid",
11838+
},
11839+
"operationResponseType": "{}",
11840+
},
1175411841
"v2.CreateWorkflow": {
1175511842
"body": {
1175611843
"type": "CreateWorkflowRequest",

features/v2/undo.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6357,6 +6357,47 @@
63576357
"type": "safe"
63586358
}
63596359
},
6360+
"SearchWidgets": {
6361+
"tag": "Widgets",
6362+
"undo": {
6363+
"type": "safe"
6364+
}
6365+
},
6366+
"CreateWidget": {
6367+
"tag": "Widgets",
6368+
"undo": {
6369+
"operationId": "DeleteWidget",
6370+
"parameters": [
6371+
{
6372+
"name": "experience_type",
6373+
"source": "experience_type"
6374+
},
6375+
{
6376+
"name": "uuid",
6377+
"source": "data.id"
6378+
}
6379+
],
6380+
"type": "unsafe"
6381+
}
6382+
},
6383+
"DeleteWidget": {
6384+
"tag": "Widgets",
6385+
"undo": {
6386+
"type": "idempotent"
6387+
}
6388+
},
6389+
"GetWidget": {
6390+
"tag": "Widgets",
6391+
"undo": {
6392+
"type": "safe"
6393+
}
6394+
},
6395+
"UpdateWidget": {
6396+
"tag": "Widgets",
6397+
"undo": {
6398+
"type": "safe"
6399+
}
6400+
},
63606401
"CreateWorkflow": {
63616402
"tag": "Workflow Automation",
63626403
"undo": {

features/v2/widgets.feature

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
@endpoint(widgets) @endpoint(widgets-v2)
2+
Feature: Widgets
3+
Create, read, update, and delete saved widgets. Widgets are reusable
4+
visualization components stored independently from any dashboard or
5+
notebook, partitioned by experience type and identified by a UUID.
6+
7+
Background:
8+
Given a valid "apiKeyAuth" key in the system
9+
And a valid "appKeyAuth" key in the system
10+
And an instance of "Widgets" API
11+
12+
@generated @skip @team:DataDog/reporting-and-sharing
13+
Scenario: Create a widget returns "Bad Request" response
14+
Given new "CreateWidget" request
15+
And request contains "experience_type" parameter from "REPLACE.ME"
16+
And body with value {"data": {"attributes": {"definition": {"title": "My Widget", "type": "bar_chart"}, "tags": []}, "type": "widgets"}}
17+
When the request is sent
18+
Then the response status is 400 Bad Request
19+
20+
@generated @skip @team:DataDog/reporting-and-sharing
21+
Scenario: Create a widget returns "OK" response
22+
Given new "CreateWidget" request
23+
And request contains "experience_type" parameter from "REPLACE.ME"
24+
And body with value {"data": {"attributes": {"definition": {"title": "My Widget", "type": "bar_chart"}, "tags": []}, "type": "widgets"}}
25+
When the request is sent
26+
Then the response status is 200 OK
27+
28+
@generated @skip @team:DataDog/reporting-and-sharing
29+
Scenario: Delete a widget returns "Bad Request" response
30+
Given new "DeleteWidget" request
31+
And request contains "experience_type" parameter from "REPLACE.ME"
32+
And request contains "uuid" parameter from "REPLACE.ME"
33+
When the request is sent
34+
Then the response status is 400 Bad Request
35+
36+
@generated @skip @team:DataDog/reporting-and-sharing
37+
Scenario: Delete a widget returns "No Content" response
38+
Given new "DeleteWidget" request
39+
And request contains "experience_type" parameter from "REPLACE.ME"
40+
And request contains "uuid" parameter from "REPLACE.ME"
41+
When the request is sent
42+
Then the response status is 204 No Content
43+
44+
@generated @skip @team:DataDog/reporting-and-sharing
45+
Scenario: Delete a widget returns "Not Found" response
46+
Given new "DeleteWidget" request
47+
And request contains "experience_type" parameter from "REPLACE.ME"
48+
And request contains "uuid" parameter from "REPLACE.ME"
49+
When the request is sent
50+
Then the response status is 404 Not Found
51+
52+
@generated @skip @team:DataDog/reporting-and-sharing
53+
Scenario: Get a widget returns "Bad Request" response
54+
Given new "GetWidget" request
55+
And request contains "experience_type" parameter from "REPLACE.ME"
56+
And request contains "uuid" parameter from "REPLACE.ME"
57+
When the request is sent
58+
Then the response status is 400 Bad Request
59+
60+
@generated @skip @team:DataDog/reporting-and-sharing
61+
Scenario: Get a widget returns "Not Found" response
62+
Given new "GetWidget" request
63+
And request contains "experience_type" parameter from "REPLACE.ME"
64+
And request contains "uuid" parameter from "REPLACE.ME"
65+
When the request is sent
66+
Then the response status is 404 Not Found
67+
68+
@generated @skip @team:DataDog/reporting-and-sharing
69+
Scenario: Get a widget returns "OK" response
70+
Given new "GetWidget" request
71+
And request contains "experience_type" parameter from "REPLACE.ME"
72+
And request contains "uuid" parameter from "REPLACE.ME"
73+
When the request is sent
74+
Then the response status is 200 OK
75+
76+
@generated @skip @team:DataDog/reporting-and-sharing
77+
Scenario: Search widgets returns "Bad Request" response
78+
Given new "SearchWidgets" request
79+
And request contains "experience_type" parameter from "REPLACE.ME"
80+
When the request is sent
81+
Then the response status is 400 Bad Request
82+
83+
@generated @skip @team:DataDog/reporting-and-sharing
84+
Scenario: Search widgets returns "OK" response
85+
Given new "SearchWidgets" request
86+
And request contains "experience_type" parameter from "REPLACE.ME"
87+
When the request is sent
88+
Then the response status is 200 OK
89+
90+
@generated @skip @team:DataDog/reporting-and-sharing
91+
Scenario: Update a widget returns "Bad Request" response
92+
Given new "UpdateWidget" request
93+
And request contains "experience_type" parameter from "REPLACE.ME"
94+
And request contains "uuid" parameter from "REPLACE.ME"
95+
And body with value {"data": {"attributes": {"definition": {"title": "My Widget", "type": "bar_chart"}, "tags": []}, "type": "widgets"}}
96+
When the request is sent
97+
Then the response status is 400 Bad Request
98+
99+
@generated @skip @team:DataDog/reporting-and-sharing
100+
Scenario: Update a widget returns "Not Found" response
101+
Given new "UpdateWidget" request
102+
And request contains "experience_type" parameter from "REPLACE.ME"
103+
And request contains "uuid" parameter from "REPLACE.ME"
104+
And body with value {"data": {"attributes": {"definition": {"title": "My Widget", "type": "bar_chart"}, "tags": []}, "type": "widgets"}}
105+
When the request is sent
106+
Then the response status is 404 Not Found
107+
108+
@generated @skip @team:DataDog/reporting-and-sharing
109+
Scenario: Update a widget returns "OK" response
110+
Given new "UpdateWidget" request
111+
And request contains "experience_type" parameter from "REPLACE.ME"
112+
And request contains "uuid" parameter from "REPLACE.ME"
113+
And body with value {"data": {"attributes": {"definition": {"title": "My Widget", "type": "bar_chart"}, "tags": []}, "type": "widgets"}}
114+
When the request is sent
115+
Then the response status is 200 OK

0 commit comments

Comments
 (0)