Skip to content

Commit 9c0d518

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Fix Toplist widget's stacked display style - remove legend as required field (#2030)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent c875ad2 commit 9c0d518

File tree

7 files changed

+133
-17
lines changed

7 files changed

+133
-17
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-10-02 14:33:47.262024",
8-
"spec_repo_commit": "3b4747f4"
7+
"regenerated": "2024-10-02 16:22:36.580860",
8+
"spec_repo_commit": "3f12bebc"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-10-02 14:33:47.276476",
13-
"spec_repo_commit": "3b4747f4"
12+
"regenerated": "2024-10-02 16:22:36.595663",
13+
"spec_repo_commit": "3f12bebc"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18188,7 +18188,6 @@ components:
1818818188
$ref: '#/components/schemas/ToplistWidgetStackedType'
1818918189
required:
1819018190
- type
18191-
- legend
1819218191
type: object
1819318192
ToplistWidgetStackedType:
1819418193
default: stacked
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024-09-30T17:24:52.299Z

cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.yml

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Create a new dashboard with a toplist widget with stacked type and no legend specified
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::DashboardsAPI.new
5+
6+
body = DatadogAPIClient::V1::Dashboard.new({
7+
title: "Example-Dashboard",
8+
description: "",
9+
widgets: [
10+
DatadogAPIClient::V1::Widget.new({
11+
layout: DatadogAPIClient::V1::WidgetLayout.new({
12+
x: 0,
13+
y: 0,
14+
width: 47,
15+
height: 15,
16+
}),
17+
definition: DatadogAPIClient::V1::ToplistWidgetDefinition.new({
18+
title: "",
19+
title_size: "16",
20+
title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
21+
time: DatadogAPIClient::V1::WidgetLegacyLiveSpan.new({}),
22+
style: DatadogAPIClient::V1::ToplistWidgetStyle.new({
23+
display: DatadogAPIClient::V1::ToplistWidgetStacked.new({
24+
type: DatadogAPIClient::V1::ToplistWidgetStackedType::STACKED,
25+
}),
26+
scaling: DatadogAPIClient::V1::ToplistWidgetScaling::RELATIVE,
27+
palette: "dog_classic",
28+
}),
29+
type: DatadogAPIClient::V1::ToplistWidgetDefinitionType::TOPLIST,
30+
requests: [
31+
DatadogAPIClient::V1::ToplistWidgetRequest.new({
32+
queries: [
33+
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
34+
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
35+
name: "query1",
36+
query: "avg:system.cpu.user{*} by {service}",
37+
aggregator: DatadogAPIClient::V1::FormulaAndFunctionMetricAggregation::AVG,
38+
}),
39+
],
40+
formulas: [
41+
DatadogAPIClient::V1::WidgetFormula.new({
42+
formula: "query1",
43+
}),
44+
],
45+
sort: DatadogAPIClient::V1::WidgetSortBy.new({
46+
count: 10,
47+
order_by: [
48+
DatadogAPIClient::V1::WidgetGroupSort.new({
49+
type: DatadogAPIClient::V1::GroupType::GROUP,
50+
name: "service",
51+
order: DatadogAPIClient::V1::WidgetSort::ASCENDING,
52+
}),
53+
],
54+
}),
55+
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::SCALAR,
56+
}),
57+
],
58+
}),
59+
}),
60+
],
61+
template_variables: [],
62+
layout_type: DatadogAPIClient::V1::DashboardLayoutType::FREE,
63+
is_read_only: false,
64+
notify_list: [],
65+
})
66+
p api_instance.create_dashboard(body)

features/v1/dashboards.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,19 @@ Feature: Dashboards
206206
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "group"
207207
And the response "widgets[0].definition.requests[0].sort.order_by[0].name" is equal to "service"
208208

209+
@skip-typescript @team:DataDog/dashboards-backend
210+
Scenario: Create a new dashboard with a toplist widget with stacked type and no legend specified
211+
Given new "CreateDashboard" request
212+
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":[]}
213+
When the request is sent
214+
Then the response status is 200 OK
215+
And the response "widgets[0].definition.type" is equal to "toplist"
216+
And the response "widgets[0].definition.requests[0].sort.order_by[0].order" is equal to "asc"
217+
And the response "widgets[0].definition.requests[0].sort.order_by[0].type" is equal to "group"
218+
And the response "widgets[0].definition.requests[0].sort.order_by[0].name" is equal to "service"
219+
And the response "widgets[0].definition.style.display.type" is equal to "stacked"
220+
And the response "widgets[0].definition.style.display" does not have field "legend"
221+
209222
@team:DataDog/dashboards-backend
210223
Scenario: Create a new dashboard with alert_graph widget
211224
Given there is a valid "monitor" in the system

lib/datadog_api_client/v1/models/toplist_widget_stacked.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ToplistWidgetStacked
2222
include BaseGenericModel
2323

2424
# Top list widget stacked legend behavior.
25-
attr_reader :legend
25+
attr_accessor :legend
2626

2727
# Top list widget stacked display type.
2828
attr_reader :type
@@ -78,21 +78,10 @@ def initialize(attributes = {})
7878
# @return true if the model is valid
7979
# @!visibility private
8080
def valid?
81-
return false if @legend.nil?
8281
return false if @type.nil?
8382
true
8483
end
8584

86-
# Custom attribute writer method with validation
87-
# @param legend [Object] Object to be assigned
88-
# @!visibility private
89-
def legend=(legend)
90-
if legend.nil?
91-
fail ArgumentError, 'invalid value for "legend", legend cannot be nil.'
92-
end
93-
@legend = legend
94-
end
95-
9685
# Custom attribute writer method with validation
9786
# @param type [Object] Object to be assigned
9887
# @!visibility private

0 commit comments

Comments
 (0)