Skip to content

Commit

Permalink
Fix Toplist widget's stacked display style - remove legend as require…
Browse files Browse the repository at this point in the history
…d field (#1838)

Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Oct 2, 2024
1 parent 9032786 commit 330aef7
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 7 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-10-02 14:33:57.486086",
"spec_repo_commit": "3b4747f4"
"regenerated": "2024-10-02 16:22:29.866275",
"spec_repo_commit": "3f12bebc"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-02 14:33:57.582216",
"spec_repo_commit": "3b4747f4"
"regenerated": "2024-10-02 16:22:29.880506",
"spec_repo_commit": "3f12bebc"
}
}
}
1 change: 0 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18188,7 +18188,6 @@ components:
$ref: '#/components/schemas/ToplistWidgetStackedType'
required:
- type
- legend
type: object
ToplistWidgetStackedType:
default: stacked
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2024-09-30T17:24:52.299Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"log": {
"_recordingName": "Dashboards/Create a new dashboard with a toplist widget with stacked type and no legend specified",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "1668edb0df4aa19bf3e773c89dbafdd3",
"_order": 0,
"cache": {},
"request": {
"bodySize": 726,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 557,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"description\":\"\",\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_a_toplist_widget_with_stacked_type_and_no_legend_specified-1727717092\",\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {service}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":10,\"order_by\":[{\"name\":\"service\",\"order\":\"asc\",\"type\":\"group\"}]}}],\"style\":{\"display\":{\"type\":\"stacked\"},\"palette\":\"dog_classic\",\"scaling\":\"relative\"},\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"toplist\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0}}]}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard"
},
"response": {
"bodySize": 1082,
"content": {
"mimeType": "application/json",
"size": 1082,
"text": "{\"id\":\"2az-xeg-xar\",\"title\":\"Test-Create_a_new_dashboard_with_a_toplist_widget_with_stacked_type_and_no_legend_specified-1727717092\",\"description\":\"\",\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"free\",\"url\":\"/dashboard/2az-xeg-xar/test-createanewdashboardwithatoplistwidgetwithstackedtypeandnolegendspecified-17\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {service}\"}],\"response_format\":\"scalar\",\"sort\":{\"count\":10,\"order_by\":[{\"name\":\"service\",\"order\":\"asc\",\"type\":\"group\"}]}}],\"style\":{\"display\":{\"type\":\"stacked\"},\"palette\":\"dog_classic\",\"scaling\":\"relative\"},\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"toplist\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0},\"id\":688132644515996}],\"notify_list\":[],\"created_at\":\"2024-09-30T17:24:52.542207+00:00\",\"modified_at\":\"2024-09-30T17:24:52.542207+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-30T17:24:52.306Z",
"time": 295
},
{
"_id": "bf18df2e89763aab55ba5494d3060e55",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 518,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard/2az-xeg-xar"
},
"response": {
"bodySize": 39,
"content": {
"mimeType": "application/json",
"size": 39,
"text": "{\"deleted_dashboard_id\":\"2az-xeg-xar\"}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 655,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-09-30T17:24:52.617Z",
"time": 188
}
],
"pages": [],
"version": "1.2"
}
}
80 changes: 80 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1413226400.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Create a new dashboard with a toplist widget with stacked type and no legend specified
*/

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",
description: "",
widgets: [
{
layout: {
x: 0,
y: 0,
width: 47,
height: 15,
},
definition: {
title: "",
titleSize: "16",
titleAlign: "left",
time: {},
style: {
display: {
type: "stacked",
},
scaling: "relative",
palette: "dog_classic",
},
type: "toplist",
requests: [
{
queries: [
{
dataSource: "metrics",
name: "query1",
query: "avg:system.cpu.user{*} by {service}",
aggregator: "avg",
},
],
formulas: [
{
formula: "query1",
},
],
sort: {
count: 10,
orderBy: [
{
type: "group",
name: "service",
order: "asc",
},
],
},
responseFormat: "scalar",
},
],
},
},
],
templateVariables: [],
layoutType: "free",
isReadOnly: false,
notifyList: [],
},
};

apiInstance
.createDashboard(params)
.then((data: v1.Dashboard) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
13 changes: 13 additions & 0 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ Feature: Dashboards
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "group"
And the response "widgets[0].definition.requests[0].sort.order_by[0].name" is equal to "service"

@skip-typescript @team:DataDog/dashboards-backend
Scenario: Create a new dashboard with a toplist widget with stacked type and no legend specified
Given new "CreateDashboard" request
And body with value {"title":"{{ unique }}","description":"","widgets":[{"layout":{"x":0,"y":0,"width":47,"height":15},"definition":{"title":"","title_size":"16","title_align":"left","time":{},"style":{"display": {"type": "stacked"},"scaling": "relative","palette": "dog_classic"},"type":"toplist","requests":[{"queries":[{"data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*} by {service}","aggregator":"avg"}],"formulas":[{"formula":"query1"}],"sort":{"count":10,"order_by":[{"type":"group","name":"service","order":"asc"}]},"response_format":"scalar"}]}}],"template_variables":[],"layout_type":"free","is_read_only":false,"notify_list":[]}
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.type" is equal to "toplist"
And the response "widgets[0].definition.requests[0].sort.order_by[0].order" is equal to "asc"
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "group"
And the response "widgets[0].definition.requests[0].sort.order_by[0].name" is equal to "service"
And the response "widgets[0].definition.style.display.type" is equal to "stacked"
And the response "widgets[0].definition.style.display" does not have field "legend"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with alert_graph widget
Given there is a valid "monitor" in the system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ToplistWidgetStacked {
/**
* Top list widget stacked legend behavior.
*/
"legend": ToplistWidgetLegend;
"legend"?: ToplistWidgetLegend;
/**
* Top list widget stacked display type.
*/
Expand All @@ -40,7 +40,6 @@ export class ToplistWidgetStacked {
legend: {
baseName: "legend",
type: "ToplistWidgetLegend",
required: true,
},
type: {
baseName: "type",
Expand Down

0 comments on commit 330aef7

Please sign in to comment.