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
5 changes: 5 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
119 changes: 119 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1983124927.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -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 <code>datadog16</code>, <code>
* datadog32</code>, <code>semantic</code>, <code>classic</code>, and <code>dog_classic</code>. 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;
Expand Down Expand Up @@ -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)
Expand All @@ -444,6 +473,7 @@ public int hashCode() {
colorByGroups,
customLinks,
description,
palette,
requests,
time,
title,
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
Loading
Loading