diff --git a/.apigentools-info b/.apigentools-info index cd72e302b452..4a8be6309ac0 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -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" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 28ad73f8c537..b9b317f38b3f 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -18188,7 +18188,6 @@ components: $ref: '#/components/schemas/ToplistWidgetStackedType' required: - type - - legend type: object ToplistWidgetStackedType: default: stacked diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.frozen b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.frozen new file mode 100644 index 000000000000..f6e6007e992f --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.frozen @@ -0,0 +1 @@ +2024-09-30T17:24:52.299Z \ No newline at end of file diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.yml b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.yml new file mode 100644 index 000000000000..96d1adb081fa --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-toplist-widget-with-stacked-type-and-no-legend-specified.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Mon, 30 Sep 2024 17:24:52 GMT + request: + body: + encoding: UTF-8 + string: '{"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}}]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/dashboard + response: + body: + encoding: UTF-8 + string: '{"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":"frog@datadoghq.com","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":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Mon, 30 Sep 2024 17:24:52 GMT + request: + body: null + headers: + Accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/dashboard/2az-xeg-xar + response: + body: + encoding: UTF-8 + string: '{"deleted_dashboard_id":"2az-xeg-xar"} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/dashboards/CreateDashboard_1413226400.rb b/examples/v1/dashboards/CreateDashboard_1413226400.rb new file mode 100644 index 000000000000..2795ed2bccb8 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1413226400.rb @@ -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) diff --git a/features/v1/dashboards.feature b/features/v1/dashboards.feature index de855fec2dd2..09231d8d7893 100644 --- a/features/v1/dashboards.feature +++ b/features/v1/dashboards.feature @@ -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 diff --git a/lib/datadog_api_client/v1/models/toplist_widget_stacked.rb b/lib/datadog_api_client/v1/models/toplist_widget_stacked.rb index 8699d2dd301c..aecad6bf5cec 100644 --- a/lib/datadog_api_client/v1/models/toplist_widget_stacked.rb +++ b/lib/datadog_api_client/v1/models/toplist_widget_stacked.rb @@ -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 @@ -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