Skip to content

Commit e27844a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
dashboards - Add DashboardTab schema and tabs property to Dashboard spec (#3506)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 9aa93ff commit e27844a

File tree

4 files changed

+300
-3
lines changed

4 files changed

+300
-3
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,13 @@ components:
13141314
description: A role UUID.
13151315
type: string
13161316
type: array
1317+
tabs:
1318+
description: List of tabs for organizing dashboard widgets into groups.
1319+
items:
1320+
$ref: '#/components/schemas/DashboardTab'
1321+
maxItems: 100
1322+
nullable: true
1323+
type: array
13171324
tags:
13181325
description: List of team names representing ownership of a dashboard.
13191326
items:
@@ -1584,6 +1591,36 @@ components:
15841591
description: URL of the dashboard.
15851592
type: string
15861593
type: object
1594+
DashboardTab:
1595+
description: Dashboard tab for organizing widgets.
1596+
properties:
1597+
id:
1598+
description: UUID of the tab.
1599+
example: ''
1600+
format: uuid
1601+
type: string
1602+
name:
1603+
description: Name of the tab.
1604+
example: L
1605+
maxLength: 100
1606+
minLength: 1
1607+
type: string
1608+
widget_ids:
1609+
description: List of widget IDs belonging to this tab. The backend also
1610+
accepts positional references in @N format (1-indexed) as a convenience
1611+
for Terraform and other declarative tools.
1612+
example:
1613+
- 0
1614+
items:
1615+
description: Widget ID.
1616+
format: int64
1617+
type: integer
1618+
type: array
1619+
required:
1620+
- id
1621+
- name
1622+
- widget_ids
1623+
type: object
15871624
DashboardTemplateVariable:
15881625
description: Template variable.
15891626
properties:

src/main/java/com/datadog/api/client/v1/model/Dashboard.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
Dashboard.JSON_PROPERTY_NOTIFY_LIST,
3838
Dashboard.JSON_PROPERTY_REFLOW_TYPE,
3939
Dashboard.JSON_PROPERTY_RESTRICTED_ROLES,
40+
Dashboard.JSON_PROPERTY_TABS,
4041
Dashboard.JSON_PROPERTY_TAGS,
4142
Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS,
4243
Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLES,
@@ -81,6 +82,9 @@ public class Dashboard {
8182
public static final String JSON_PROPERTY_RESTRICTED_ROLES = "restricted_roles";
8283
private List<String> restrictedRoles = null;
8384

85+
public static final String JSON_PROPERTY_TABS = "tabs";
86+
private JsonNullable<List<DashboardTab>> tabs = JsonNullable.<List<DashboardTab>>undefined();
87+
8488
public static final String JSON_PROPERTY_TAGS = "tags";
8589
private JsonNullable<List<String>> tags = JsonNullable.<List<String>>undefined();
8690

@@ -373,6 +377,49 @@ public void setRestrictedRoles(List<String> restrictedRoles) {
373377
this.restrictedRoles = restrictedRoles;
374378
}
375379

380+
public Dashboard tabs(List<DashboardTab> tabs) {
381+
this.tabs = JsonNullable.<List<DashboardTab>>of(tabs);
382+
return this;
383+
}
384+
385+
public Dashboard addTabsItem(DashboardTab tabsItem) {
386+
if (this.tabs == null || !this.tabs.isPresent()) {
387+
this.tabs = JsonNullable.<List<DashboardTab>>of(new ArrayList<>());
388+
}
389+
try {
390+
this.tabs.get().add(tabsItem);
391+
} catch (java.util.NoSuchElementException e) {
392+
// this can never happen, as we make sure above that the value is present
393+
}
394+
return this;
395+
}
396+
397+
/**
398+
* List of tabs for organizing dashboard widgets into groups.
399+
*
400+
* @return tabs
401+
*/
402+
@jakarta.annotation.Nullable
403+
@JsonIgnore
404+
public List<DashboardTab> getTabs() {
405+
return tabs.orElse(null);
406+
}
407+
408+
@JsonProperty(JSON_PROPERTY_TABS)
409+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
410+
public JsonNullable<List<DashboardTab>> getTabs_JsonNullable() {
411+
return tabs;
412+
}
413+
414+
@JsonProperty(JSON_PROPERTY_TABS)
415+
public void setTabs_JsonNullable(JsonNullable<List<DashboardTab>> tabs) {
416+
this.tabs = tabs;
417+
}
418+
419+
public void setTabs(List<DashboardTab> tabs) {
420+
this.tabs = JsonNullable.<List<DashboardTab>>of(tabs);
421+
}
422+
376423
public Dashboard tags(List<String> tags) {
377424
this.tags = JsonNullable.<List<String>>of(tags);
378425
return this;
@@ -639,6 +686,7 @@ public boolean equals(Object o) {
639686
&& Objects.equals(this.notifyList, dashboard.notifyList)
640687
&& Objects.equals(this.reflowType, dashboard.reflowType)
641688
&& Objects.equals(this.restrictedRoles, dashboard.restrictedRoles)
689+
&& Objects.equals(this.tabs, dashboard.tabs)
642690
&& Objects.equals(this.tags, dashboard.tags)
643691
&& Objects.equals(this.templateVariablePresets, dashboard.templateVariablePresets)
644692
&& Objects.equals(this.templateVariables, dashboard.templateVariables)
@@ -662,6 +710,7 @@ public int hashCode() {
662710
notifyList,
663711
reflowType,
664712
restrictedRoles,
713+
tabs,
665714
tags,
666715
templateVariablePresets,
667716
templateVariables,
@@ -686,6 +735,7 @@ public String toString() {
686735
sb.append(" notifyList: ").append(toIndentedString(notifyList)).append("\n");
687736
sb.append(" reflowType: ").append(toIndentedString(reflowType)).append("\n");
688737
sb.append(" restrictedRoles: ").append(toIndentedString(restrictedRoles)).append("\n");
738+
sb.append(" tabs: ").append(toIndentedString(tabs)).append("\n");
689739
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
690740
sb.append(" templateVariablePresets: ")
691741
.append(toIndentedString(templateVariablePresets))
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2019-Present Datadog, Inc.
5+
*/
6+
7+
package com.datadog.api.client.v1.model;
8+
9+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
10+
import com.fasterxml.jackson.annotation.JsonAnySetter;
11+
import com.fasterxml.jackson.annotation.JsonCreator;
12+
import com.fasterxml.jackson.annotation.JsonIgnore;
13+
import com.fasterxml.jackson.annotation.JsonInclude;
14+
import com.fasterxml.jackson.annotation.JsonProperty;
15+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
16+
import java.util.ArrayList;
17+
import java.util.HashMap;
18+
import java.util.List;
19+
import java.util.Map;
20+
import java.util.Objects;
21+
import java.util.UUID;
22+
23+
/** Dashboard tab for organizing widgets. */
24+
@JsonPropertyOrder({
25+
DashboardTab.JSON_PROPERTY_ID,
26+
DashboardTab.JSON_PROPERTY_NAME,
27+
DashboardTab.JSON_PROPERTY_WIDGET_IDS
28+
})
29+
@jakarta.annotation.Generated(
30+
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
31+
public class DashboardTab {
32+
@JsonIgnore public boolean unparsed = false;
33+
public static final String JSON_PROPERTY_ID = "id";
34+
private UUID id;
35+
36+
public static final String JSON_PROPERTY_NAME = "name";
37+
private String name;
38+
39+
public static final String JSON_PROPERTY_WIDGET_IDS = "widget_ids";
40+
private List<Long> widgetIds = new ArrayList<>();
41+
42+
public DashboardTab() {}
43+
44+
@JsonCreator
45+
public DashboardTab(
46+
@JsonProperty(required = true, value = JSON_PROPERTY_ID) UUID id,
47+
@JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name,
48+
@JsonProperty(required = true, value = JSON_PROPERTY_WIDGET_IDS) List<Long> widgetIds) {
49+
this.id = id;
50+
this.name = name;
51+
this.widgetIds = widgetIds;
52+
}
53+
54+
public DashboardTab id(UUID id) {
55+
this.id = id;
56+
return this;
57+
}
58+
59+
/**
60+
* UUID of the tab.
61+
*
62+
* @return id
63+
*/
64+
@JsonProperty(JSON_PROPERTY_ID)
65+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
66+
public UUID getId() {
67+
return id;
68+
}
69+
70+
public void setId(UUID id) {
71+
this.id = id;
72+
}
73+
74+
public DashboardTab name(String name) {
75+
this.name = name;
76+
return this;
77+
}
78+
79+
/**
80+
* Name of the tab.
81+
*
82+
* @return name
83+
*/
84+
@JsonProperty(JSON_PROPERTY_NAME)
85+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
86+
public String getName() {
87+
return name;
88+
}
89+
90+
public void setName(String name) {
91+
this.name = name;
92+
}
93+
94+
public DashboardTab widgetIds(List<Long> widgetIds) {
95+
this.widgetIds = widgetIds;
96+
return this;
97+
}
98+
99+
public DashboardTab addWidgetIdsItem(Long widgetIdsItem) {
100+
this.widgetIds.add(widgetIdsItem);
101+
return this;
102+
}
103+
104+
/**
105+
* List of widget IDs belonging to this tab. The backend also accepts positional references in @N
106+
* format (1-indexed) as a convenience for Terraform and other declarative tools.
107+
*
108+
* @return widgetIds
109+
*/
110+
@JsonProperty(JSON_PROPERTY_WIDGET_IDS)
111+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
112+
public List<Long> getWidgetIds() {
113+
return widgetIds;
114+
}
115+
116+
public void setWidgetIds(List<Long> widgetIds) {
117+
this.widgetIds = widgetIds;
118+
}
119+
120+
/**
121+
* A container for additional, undeclared properties. This is a holder for any undeclared
122+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
123+
*/
124+
private Map<String, Object> additionalProperties;
125+
126+
/**
127+
* Set the additional (undeclared) property with the specified name and value. If the property
128+
* does not already exist, create it otherwise replace it.
129+
*
130+
* @param key The arbitrary key to set
131+
* @param value The associated value
132+
* @return DashboardTab
133+
*/
134+
@JsonAnySetter
135+
public DashboardTab putAdditionalProperty(String key, Object value) {
136+
if (this.additionalProperties == null) {
137+
this.additionalProperties = new HashMap<String, Object>();
138+
}
139+
this.additionalProperties.put(key, value);
140+
return this;
141+
}
142+
143+
/**
144+
* Return the additional (undeclared) property.
145+
*
146+
* @return The additional properties
147+
*/
148+
@JsonAnyGetter
149+
public Map<String, Object> getAdditionalProperties() {
150+
return additionalProperties;
151+
}
152+
153+
/**
154+
* Return the additional (undeclared) property with the specified name.
155+
*
156+
* @param key The arbitrary key to get
157+
* @return The specific additional property for the given key
158+
*/
159+
public Object getAdditionalProperty(String key) {
160+
if (this.additionalProperties == null) {
161+
return null;
162+
}
163+
return this.additionalProperties.get(key);
164+
}
165+
166+
/** Return true if this DashboardTab object is equal to o. */
167+
@Override
168+
public boolean equals(Object o) {
169+
if (this == o) {
170+
return true;
171+
}
172+
if (o == null || getClass() != o.getClass()) {
173+
return false;
174+
}
175+
DashboardTab dashboardTab = (DashboardTab) o;
176+
return Objects.equals(this.id, dashboardTab.id)
177+
&& Objects.equals(this.name, dashboardTab.name)
178+
&& Objects.equals(this.widgetIds, dashboardTab.widgetIds)
179+
&& Objects.equals(this.additionalProperties, dashboardTab.additionalProperties);
180+
}
181+
182+
@Override
183+
public int hashCode() {
184+
return Objects.hash(id, name, widgetIds, additionalProperties);
185+
}
186+
187+
@Override
188+
public String toString() {
189+
StringBuilder sb = new StringBuilder();
190+
sb.append("class DashboardTab {\n");
191+
sb.append(" id: ").append(toIndentedString(id)).append("\n");
192+
sb.append(" name: ").append(toIndentedString(name)).append("\n");
193+
sb.append(" widgetIds: ").append(toIndentedString(widgetIds)).append("\n");
194+
sb.append(" additionalProperties: ")
195+
.append(toIndentedString(additionalProperties))
196+
.append("\n");
197+
sb.append('}');
198+
return sb.toString();
199+
}
200+
201+
/**
202+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
203+
*/
204+
private String toIndentedString(Object o) {
205+
if (o == null) {
206+
return "null";
207+
}
208+
return o.toString().replace("\n", "\n ");
209+
}
210+
}

src/test/resources/com/datadog/api/client/v1/api/dashboards.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Feature: Dashboards
9090
@generated @skip @team:DataDog/dashboards-backend
9191
Scenario: Create a new dashboard returns "Bad Request" response
9292
Given new "CreateDashboard" request
93-
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
93+
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
9494
When the request is sent
9595
Then the response status is 400 Bad Request
9696

@@ -1373,15 +1373,15 @@ Feature: Dashboards
13731373
Scenario: Update a dashboard returns "Bad Request" response
13741374
Given new "UpdateDashboard" request
13751375
And request contains "dashboard_id" parameter from "REPLACE.ME"
1376-
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
1376+
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
13771377
When the request is sent
13781378
Then the response status is 400 Bad Request
13791379

13801380
@generated @skip @team:DataDog/dashboards-backend
13811381
Scenario: Update a dashboard returns "Item Not Found" response
13821382
Given new "UpdateDashboard" request
13831383
And request contains "dashboard_id" parameter from "REPLACE.ME"
1384-
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
1384+
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}
13851385
When the request is sent
13861386
Then the response status is 404 Item Not Found
13871387

0 commit comments

Comments
 (0)