diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index c90f6ecfc03..f1ba0803ac1 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -16663,6 +16663,11 @@ components: description: description: The description of the widget. type: string + palette: + description: >- + Color palette to apply to the widget. Supported values include `datadog16`, `datadog32`, `semantic`, `classic`, and `dog_classic`. A guide to the available color palettes can be found at https://docs.datadoghq.com/dashboards/guide/widget_colors + example: datadog16 + type: string requests: $ref: "#/components/schemas/ScatterPlotWidgetDefinitionRequests" time: diff --git a/examples/v1/dashboards/CreateDashboard_1983124927.java b/examples/v1/dashboards/CreateDashboard_1983124927.java new file mode 100644 index 00000000000..fae4fba131d --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1983124927.java @@ -0,0 +1,119 @@ +// Create a new dashboard with scatterplot widget and palette + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.DashboardsApi; +import com.datadog.api.client.v1.model.Dashboard; +import com.datadog.api.client.v1.model.DashboardLayoutType; +import com.datadog.api.client.v1.model.FormulaAndFunctionMetricAggregation; +import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource; +import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition; +import com.datadog.api.client.v1.model.FormulaAndFunctionQueryDefinition; +import com.datadog.api.client.v1.model.FormulaAndFunctionResponseFormat; +import com.datadog.api.client.v1.model.ScatterPlotWidgetDefinition; +import com.datadog.api.client.v1.model.ScatterPlotWidgetDefinitionRequests; +import com.datadog.api.client.v1.model.ScatterPlotWidgetDefinitionType; +import com.datadog.api.client.v1.model.ScatterplotDimension; +import com.datadog.api.client.v1.model.ScatterplotTableRequest; +import com.datadog.api.client.v1.model.ScatterplotWidgetFormula; +import com.datadog.api.client.v1.model.Widget; +import com.datadog.api.client.v1.model.WidgetAxis; +import com.datadog.api.client.v1.model.WidgetDefinition; +import com.datadog.api.client.v1.model.WidgetLayout; +import com.datadog.api.client.v1.model.WidgetLegacyLiveSpan; +import com.datadog.api.client.v1.model.WidgetTextAlign; +import com.datadog.api.client.v1.model.WidgetTime; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + Dashboard body = + new Dashboard() + .title("Example-Dashboard") + .description("") + .widgets( + Collections.singletonList( + new Widget() + .layout(new WidgetLayout().x(0L).y(0L).width(47L).height(15L)) + .definition( + new WidgetDefinition( + new ScatterPlotWidgetDefinition() + .title("") + .titleSize("16") + .titleAlign(WidgetTextAlign.LEFT) + .time(new WidgetTime(new WidgetLegacyLiveSpan())) + .type(ScatterPlotWidgetDefinitionType.SCATTERPLOT) + .requests( + new ScatterPlotWidgetDefinitionRequests() + .table( + new ScatterplotTableRequest() + .formulas( + Arrays.asList( + new ScatterplotWidgetFormula() + .formula("query1") + .dimension(ScatterplotDimension.X) + .alias(""), + new ScatterplotWidgetFormula() + .formula("query2") + .dimension(ScatterplotDimension.Y) + .alias(""))) + .queries( + Arrays.asList( + new FormulaAndFunctionQueryDefinition( + new FormulaAndFunctionMetricQueryDefinition() + .dataSource( + FormulaAndFunctionMetricDataSource + .METRICS) + .name("query1") + .query( + "avg:system.cpu.user{*} by" + + " {service}") + .aggregator( + FormulaAndFunctionMetricAggregation + .AVG)), + new FormulaAndFunctionQueryDefinition( + new FormulaAndFunctionMetricQueryDefinition() + .dataSource( + FormulaAndFunctionMetricDataSource + .METRICS) + .name("query2") + .query( + "avg:system.mem.used{*} by" + + " {service}") + .aggregator( + FormulaAndFunctionMetricAggregation + .AVG)))) + .responseFormat( + FormulaAndFunctionResponseFormat.SCALAR))) + .xaxis( + new WidgetAxis() + .scale("linear") + .includeZero(true) + .min("auto") + .max("auto")) + .yaxis( + new WidgetAxis() + .scale("linear") + .includeZero(true) + .min("auto") + .max("auto")) + .palette("datadog16"))))) + .layoutType(DashboardLayoutType.FREE); + + try { + Dashboard result = apiInstance.createDashboard(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DashboardsApi#createDashboard"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/ScatterPlotWidgetDefinition.java b/src/main/java/com/datadog/api/client/v1/model/ScatterPlotWidgetDefinition.java index b9028989df2..17f8b3828f6 100644 --- a/src/main/java/com/datadog/api/client/v1/model/ScatterPlotWidgetDefinition.java +++ b/src/main/java/com/datadog/api/client/v1/model/ScatterPlotWidgetDefinition.java @@ -27,6 +27,7 @@ ScatterPlotWidgetDefinition.JSON_PROPERTY_COLOR_BY_GROUPS, ScatterPlotWidgetDefinition.JSON_PROPERTY_CUSTOM_LINKS, ScatterPlotWidgetDefinition.JSON_PROPERTY_DESCRIPTION, + ScatterPlotWidgetDefinition.JSON_PROPERTY_PALETTE, ScatterPlotWidgetDefinition.JSON_PROPERTY_REQUESTS, ScatterPlotWidgetDefinition.JSON_PROPERTY_TIME, ScatterPlotWidgetDefinition.JSON_PROPERTY_TITLE, @@ -49,6 +50,9 @@ public class ScatterPlotWidgetDefinition { public static final String JSON_PROPERTY_DESCRIPTION = "description"; private String description; + public static final String JSON_PROPERTY_PALETTE = "palette"; + private String palette; + public static final String JSON_PROPERTY_REQUESTS = "requests"; private ScatterPlotWidgetDefinitionRequests requests; @@ -177,6 +181,30 @@ public void setDescription(String description) { this.description = description; } + public ScatterPlotWidgetDefinition palette(String palette) { + this.palette = palette; + return this; + } + + /** + * Color palette to apply to the widget. Supported values include datadog16, + * datadog32, semantic, classic, and dog_classic. A + * guide to the available color palettes can be found at + * https://docs.datadoghq.com/dashboards/guide/widget_colors + * + * @return palette + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PALETTE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPalette() { + return palette; + } + + public void setPalette(String palette) { + this.palette = palette; + } + public ScatterPlotWidgetDefinition requests(ScatterPlotWidgetDefinitionRequests requests) { this.requests = requests; this.unparsed |= requests.unparsed; @@ -426,6 +454,7 @@ public boolean equals(Object o) { return Objects.equals(this.colorByGroups, scatterPlotWidgetDefinition.colorByGroups) && Objects.equals(this.customLinks, scatterPlotWidgetDefinition.customLinks) && Objects.equals(this.description, scatterPlotWidgetDefinition.description) + && Objects.equals(this.palette, scatterPlotWidgetDefinition.palette) && Objects.equals(this.requests, scatterPlotWidgetDefinition.requests) && Objects.equals(this.time, scatterPlotWidgetDefinition.time) && Objects.equals(this.title, scatterPlotWidgetDefinition.title) @@ -444,6 +473,7 @@ public int hashCode() { colorByGroups, customLinks, description, + palette, requests, time, title, @@ -462,6 +492,7 @@ public String toString() { sb.append(" colorByGroups: ").append(toIndentedString(colorByGroups)).append("\n"); sb.append(" customLinks: ").append(toIndentedString(customLinks)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" palette: ").append(toIndentedString(palette)).append("\n"); sb.append(" requests: ").append(toIndentedString(requests)).append("\n"); sb.append(" time: ").append(toIndentedString(time)).append("\n"); sb.append(" title: ").append(toIndentedString(title)).append("\n"); diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature index 89bc4c8d308..0ae944ed1b8 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature @@ -1007,6 +1007,15 @@ Feature: Dashboards Then the response status is 200 OK And the response "widgets[0].definition.type" is equal to "scatterplot" + @team:ddoghq/dashboards-backend + Scenario: Create a new dashboard with scatterplot widget and palette + Given new "CreateDashboard" request + And body from file "dashboards_json_payload/scatterplot_palette_widget.json" + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.type" is equal to "scatterplot" + And the response "widgets[0].definition.palette" is equal to "datadog16" + @team:ddoghq/dashboards-backend Scenario: Create a new dashboard with servicemap widget Given new "CreateDashboard" request diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards_json_payload/scatterplot_palette_widget.json b/src/test/resources/com/datadog/api/client/v1/api/dashboards_json_payload/scatterplot_palette_widget.json new file mode 100644 index 00000000000..e9a1a1beea4 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v1/api/dashboards_json_payload/scatterplot_palette_widget.json @@ -0,0 +1,69 @@ +{ + "title": "{{ unique }}", + "description": "", + "widgets": [ + { + "layout": { + "x": 0, + "y": 0, + "width": 47, + "height": 15 + }, + "definition": { + "title": "", + "title_size": "16", + "title_align": "left", + "time": {}, + "type": "scatterplot", + "requests": { + "table": { + "formulas": [ + { + "formula": "query1", + "dimension": "x", + "alias": "" + }, + { + "formula": "query2", + "dimension": "y", + "alias": "" + } + ], + "queries": [ + { + "data_source": "metrics", + "name": "query1", + "query": "avg:system.cpu.user{*} by {service}", + "aggregator": "avg" + }, + { + "data_source": "metrics", + "name": "query2", + "query": "avg:system.mem.used{*} by {service}", + "aggregator": "avg" + } + ], + "response_format": "scalar" + } + }, + "xaxis": { + "scale": "linear", + "include_zero": true, + "min": "auto", + "max": "auto" + }, + "yaxis": { + "scale": "linear", + "include_zero": true, + "min": "auto", + "max": "auto" + }, + "color_by_groups": [], + "palette": "datadog16" + } + } + ], + "template_variables": [], + "layout_type": "free", + "notify_list": [] +} diff --git a/src/test/resources/generated-test/test-runner-data/manifest.json b/src/test/resources/generated-test/test-runner-data/manifest.json index 2d30f82bcdc..17825bd2f6b 100644 --- a/src/test/resources/generated-test/test-runner-data/manifest.json +++ b/src/test/resources/generated-test/test-runner-data/manifest.json @@ -700,6 +700,13 @@ "scenario": "Create a new dashboard with scatterplot widget", "version": "v1" }, + { + "feature": "Dashboards", + "feature_file": "../../com/datadog/api/client/v1/api/dashboards.feature", + "file": "v1/dashboards/create-a-new-dashboard-with-scatterplot-widget-and-palette.json", + "scenario": "Create a new dashboard with scatterplot widget and palette", + "version": "v1" + }, { "feature": "Dashboards", "feature_file": "../../com/datadog/api/client/v1/api/dashboards.feature", diff --git a/src/test/resources/generated-test/test-runner-data/v1/dashboards/create-a-new-dashboard-with-scatterplot-widget-and-palette.json b/src/test/resources/generated-test/test-runner-data/v1/dashboards/create-a-new-dashboard-with-scatterplot-widget-and-palette.json new file mode 100644 index 00000000000..a0ddee47d90 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v1/dashboards/create-a-new-dashboard-with-scatterplot-widget-and-palette.json @@ -0,0 +1,94 @@ +{ + "api": "Dashboards", + "expected_status": 200, + "feature": "Dashboards", + "id": "v1/Dashboards/Create a new dashboard with scatterplot widget and palette", + "operation_id": "CreateDashboard", + "request": { + "body": { + "schema": { + "format": null, + "ref": "Dashboard", + "type": "object" + }, + "source": "dashboards_json_payload/scatterplot_palette_widget.json", + "value": { + "description": "", + "layout_type": "free", + "notify_list": [], + "template_variables": [], + "title": "{{ unique }}", + "widgets": [ + { + "definition": { + "color_by_groups": [], + "palette": "datadog16", + "requests": { + "table": { + "formulas": [ + { + "alias": "", + "dimension": "x", + "formula": "query1" + }, + { + "alias": "", + "dimension": "y", + "formula": "query2" + } + ], + "queries": [ + { + "aggregator": "avg", + "data_source": "metrics", + "name": "query1", + "query": "avg:system.cpu.user{*} by {service}" + }, + { + "aggregator": "avg", + "data_source": "metrics", + "name": "query2", + "query": "avg:system.mem.used{*} by {service}" + } + ], + "response_format": "scalar" + } + }, + "time": {}, + "title": "", + "title_align": "left", + "title_size": "16", + "type": "scatterplot", + "xaxis": { + "include_zero": true, + "max": "auto", + "min": "auto", + "scale": "linear" + }, + "yaxis": { + "include_zero": true, + "max": "auto", + "min": "auto", + "scale": "linear" + } + }, + "layout": { + "height": 15, + "width": 47, + "x": 0, + "y": 0 + } + } + ] + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v1/dashboard" + }, + "scenario": "Create a new dashboard with scatterplot widget and palette", + "schema_version": 1, + "version": "v1" +} diff --git a/src/test/resources/generated-test/test-server-data/v1/dashboards.json b/src/test/resources/generated-test/test-server-data/v1/dashboards.json index 47da3191cde..672d251a961 100644 --- a/src/test/resources/generated-test/test-server-data/v1/dashboards.json +++ b/src/test/resources/generated-test/test-server-data/v1/dashboards.json @@ -8361,6 +8361,128 @@ "scenario": "Create a new dashboard with scatterplot widget", "version": "v1" }, + { + "feature": "Dashboards", + "frozen_at": "2026-11-20T16:55:42.353Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "description": "", + "layout_type": "free", + "notify_list": [], + "template_variables": [], + "title": "Test-Create_a_new_dashboard_with_scatterplot_widget_and_palette-1795193742", + "widgets": [ + { + "definition": { + "color_by_groups": [], + "palette": "datadog16", + "requests": { + "table": { + "formulas": [ + { + "alias": "", + "dimension": "x", + "formula": "query1" + }, + { + "alias": "", + "dimension": "y", + "formula": "query2" + } + ], + "queries": [ + { + "aggregator": "avg", + "data_source": "metrics", + "name": "query1", + "query": "avg:system.cpu.user{*} by {service}" + }, + { + "aggregator": "avg", + "data_source": "metrics", + "name": "query2", + "query": "avg:system.mem.used{*} by {service}" + } + ], + "response_format": "scalar" + } + }, + "time": {}, + "title": "", + "title_align": "left", + "title_size": "16", + "type": "scatterplot", + "xaxis": { + "include_zero": true, + "max": "auto", + "min": "auto", + "scale": "linear" + }, + "yaxis": { + "include_zero": true, + "max": "auto", + "min": "auto", + "scale": "linear" + } + }, + "layout": { + "height": 15, + "width": 47, + "x": 0, + "y": 0 + } + } + ] + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v1/dashboard", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"id\":\"9ba-iyz-8ex\",\"title\":\"Test-Create_a_new_dashboard_with_scatterplot_widget_and_palette-1795193742\",\"description\":\"\",\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"free\",\"url\":\"/dashboard/9ba-iyz-8ex/test-createanewdashboardwithscatterplotwidgetandpalette-1795193742\",\"template_variables\":[],\"widgets\":[{\"definition\":{\"color_by_groups\":[],\"palette\":\"datadog16\",\"requests\":{\"table\":{\"formulas\":[{\"alias\":\"\",\"dimension\":\"x\",\"formula\":\"query1\"},{\"alias\":\"\",\"dimension\":\"y\",\"formula\":\"query2\"}],\"queries\":[{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*} by {service}\"},{\"aggregator\":\"avg\",\"data_source\":\"metrics\",\"name\":\"query2\",\"query\":\"avg:system.mem.used{*} by {service}\"}],\"response_format\":\"scalar\"}},\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"scatterplot\",\"xaxis\":{\"include_zero\":true,\"max\":\"auto\",\"min\":\"auto\",\"scale\":\"linear\"},\"yaxis\":{\"include_zero\":true,\"max\":\"auto\",\"min\":\"auto\",\"scale\":\"linear\"}},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0},\"id\":3666106239805653}],\"notify_list\":[],\"created_at\":\"2026-11-20T16:55:42.500311+00:00\",\"modified_at\":\"2026-11-20T16:55:42.500311+00:00\",\"experience_type\":\"default\",\"restricted_roles\":[]}" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v1/dashboard/9ba-iyz-8ex", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"deleted_dashboard_id\":\"9ba-iyz-8ex\"}" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Create a new dashboard with scatterplot widget and palette", + "version": "v1" + }, { "feature": "Dashboards", "frozen_at": "2024-11-15T19:32:52.734Z",