Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:47.262024",
"spec_repo_commit": "3b4747f4"
"regenerated": "2024-10-02 16:22:36.580860",
"spec_repo_commit": "3f12bebc"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-02 14:33:47.276476",
"spec_repo_commit": "3b4747f4"
"regenerated": "2024-10-02 16:22:36.595663",
"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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1413226400.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Create a new dashboard with a toplist widget with stacked type and no legend specified

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DashboardsAPI.new

body = DatadogAPIClient::V1::Dashboard.new({
title: "Example-Dashboard",
description: "",
widgets: [
DatadogAPIClient::V1::Widget.new({
layout: DatadogAPIClient::V1::WidgetLayout.new({
x: 0,
y: 0,
width: 47,
height: 15,
}),
definition: DatadogAPIClient::V1::ToplistWidgetDefinition.new({
title: "",
title_size: "16",
title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
time: DatadogAPIClient::V1::WidgetLegacyLiveSpan.new({}),
style: DatadogAPIClient::V1::ToplistWidgetStyle.new({
display: DatadogAPIClient::V1::ToplistWidgetStacked.new({
type: DatadogAPIClient::V1::ToplistWidgetStackedType::STACKED,
}),
scaling: DatadogAPIClient::V1::ToplistWidgetScaling::RELATIVE,
palette: "dog_classic",
}),
type: DatadogAPIClient::V1::ToplistWidgetDefinitionType::TOPLIST,
requests: [
DatadogAPIClient::V1::ToplistWidgetRequest.new({
queries: [
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
name: "query1",
query: "avg:system.cpu.user{*} by {service}",
aggregator: DatadogAPIClient::V1::FormulaAndFunctionMetricAggregation::AVG,
}),
],
formulas: [
DatadogAPIClient::V1::WidgetFormula.new({
formula: "query1",
}),
],
sort: DatadogAPIClient::V1::WidgetSortBy.new({
count: 10,
order_by: [
DatadogAPIClient::V1::WidgetGroupSort.new({
type: DatadogAPIClient::V1::GroupType::GROUP,
name: "service",
order: DatadogAPIClient::V1::WidgetSort::ASCENDING,
}),
],
}),
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::SCALAR,
}),
],
}),
}),
],
template_variables: [],
layout_type: DatadogAPIClient::V1::DashboardLayoutType::FREE,
is_read_only: false,
notify_list: [],
})
p api_instance.create_dashboard(body)
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
13 changes: 1 addition & 12 deletions lib/datadog_api_client/v1/models/toplist_widget_stacked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ToplistWidgetStacked
include BaseGenericModel

# Top list widget stacked legend behavior.
attr_reader :legend
attr_accessor :legend

# Top list widget stacked display type.
attr_reader :type
Expand Down Expand Up @@ -78,21 +78,10 @@ def initialize(attributes = {})
# @return true if the model is valid
# @!visibility private
def valid?
return false if @legend.nil?
return false if @type.nil?
true
end

# Custom attribute writer method with validation
# @param legend [Object] Object to be assigned
# @!visibility private
def legend=(legend)
if legend.nil?
fail ArgumentError, 'invalid value for "legend", legend cannot be nil.'
end
@legend = legend
end

# Custom attribute writer method with validation
# @param type [Object] Object to be assigned
# @!visibility private
Expand Down