Skip to content

Commit

Permalink
Ensure clients can handle empty oneOf objects (#1830)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Sep 30, 2024
1 parent 71984dc commit 889b87f
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-30 13:57:00.510111",
"spec_repo_commit": "eb66b1cf"
"regenerated": "2024-09-30 14:37:34.279249",
"spec_repo_commit": "60bc9127"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-30 13:57:00.525119",
"spec_repo_commit": "eb66b1cf"
"regenerated": "2024-09-30 14:37:34.293454",
"spec_repo_commit": "60bc9127"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2024-09-24T19:19:31.807Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"log": {
"_recordingName": "Dashboards/Clients deserialize a dashboard with a empty time object",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "25f142c77556d0a07f60c9aea7b1aa17",
"_order": 0,
"cache": {},
"request": {
"bodySize": 550,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 559,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"layout_type\":\"ordered\",\"title\":\"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571\",\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"}}]}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard"
},
"response": {
"bodySize": 976,
"content": {
"mimeType": "application/json",
"size": 976,
"text": "{\"id\":\"han-5zg-c32\",\"title\":\"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571\",\"description\":null,\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/han-5zg-c32/test-clientsdeserializeadashboardwithaemptytimeobject-1727205571\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"},\"id\":4274057372149908}],\"notify_list\":null,\"created_at\":\"2024-09-24T19:19:32.071328+00:00\",\"modified_at\":\"2024-09-24T19:19:32.071328+00:00\",\"experience_type\":\"default\",\"restricted_roles\":[]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 657,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-09-24T19:19:31.819Z",
"time": 291
},
{
"_id": "9350b5ff5d55807a27b71a985a5d0edd",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 520,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard/han-5zg-c32"
},
"response": {
"bodySize": 39,
"content": {
"mimeType": "application/json",
"size": 39,
"text": "{\"deleted_dashboard_id\":\"han-5zg-c32\"}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 656,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-09-24T19:19:32.127Z",
"time": 172
}
],
"pages": [],
"version": "1.2"
}
}
59 changes: 59 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1433408735.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Clients deserialize a dashboard with a empty time object
*/

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DashboardsApi(configuration);

const params: v1.DashboardsApiCreateDashboardRequest = {
body: {
title: "Example-Dashboard",
widgets: [
{
definition: {
title: "Example Cloud Cost Query",
titleSize: "16",
titleAlign: "left",
type: "timeseries",
requests: [
{
formulas: [
{
formula: "query1",
},
],
queries: [
{
dataSource: "cloud_cost",
name: "query1",
query:
"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)",
},
],
responseFormat: "timeseries",
style: {
palette: "dog_classic",
lineType: "solid",
lineWidth: "normal",
},
displayType: "bars",
},
],
time: {},
},
},
],
layoutType: "ordered",
},
};

apiInstance
.createDashboard(params)
.then((data: v1.Dashboard) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
8 changes: 8 additions & 0 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Feature: Dashboards
And a valid "appKeyAuth" key in the system
And an instance of "Dashboards" API

@replay-only @team:DataDog/dashboards-backend
Scenario: Clients deserialize a dashboard with a empty time object
Given new "CreateDashboard" request
And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "Example Cloud Cost Query", "title_size": "16", "title_align": "left", "type": "timeseries", "requests": [ { "formulas": [ { "formula": "query1" } ], "queries": [ { "data_source": "cloud_cost", "name": "query1", "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" } ], "response_format": "timeseries", "style": { "palette": "dog_classic", "line_type": "solid", "line_width": "normal" }, "display_type": "bars" } ], "time": {} } } ], "layout_type": "ordered" }
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.time" is equal to {}

@team:DataDog/dashboards-backend
Scenario: Create a distribution widget using a histogram request containing a formulas and functions APM Stats query
Given new "CreateDashboard" request
Expand Down

0 comments on commit 889b87f

Please sign in to comment.