diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 3e86f3a82c2..87bad04350b 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1390,6 +1390,13 @@ components: description: A role UUID. type: string type: array + tabs: + description: List of tabs for organizing dashboard widgets into groups. + items: + $ref: '#/components/schemas/DashboardTab' + maxItems: 100 + nullable: true + type: array tags: description: List of team names representing ownership of a dashboard. items: @@ -1681,6 +1688,36 @@ components: description: URL of the dashboard. type: string type: object + DashboardTab: + description: Dashboard tab for organizing widgets. + properties: + id: + description: UUID of the tab. + example: '' + format: uuid + type: string + name: + description: Name of the tab. + example: L + maxLength: 100 + minLength: 1 + type: string + widget_ids: + description: List of widget IDs belonging to this tab. The backend also + accepts positional references in @N format (1-indexed) as a convenience + for Terraform and other declarative tools. + example: + - 0 + items: + description: Widget ID. + format: int64 + type: integer + type: array + required: + - id + - name + - widget_ids + type: object DashboardTemplateVariable: description: Template variable. properties: diff --git a/src/main/java/com/datadog/api/client/v1/model/Dashboard.java b/src/main/java/com/datadog/api/client/v1/model/Dashboard.java index deb39215262..eed5de68911 100644 --- a/src/main/java/com/datadog/api/client/v1/model/Dashboard.java +++ b/src/main/java/com/datadog/api/client/v1/model/Dashboard.java @@ -37,6 +37,7 @@ Dashboard.JSON_PROPERTY_NOTIFY_LIST, Dashboard.JSON_PROPERTY_REFLOW_TYPE, Dashboard.JSON_PROPERTY_RESTRICTED_ROLES, + Dashboard.JSON_PROPERTY_TABS, Dashboard.JSON_PROPERTY_TAGS, Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS, Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLES, @@ -81,6 +82,9 @@ public class Dashboard { public static final String JSON_PROPERTY_RESTRICTED_ROLES = "restricted_roles"; private List restrictedRoles = null; + public static final String JSON_PROPERTY_TABS = "tabs"; + private JsonNullable> tabs = JsonNullable.>undefined(); + public static final String JSON_PROPERTY_TAGS = "tags"; private JsonNullable> tags = JsonNullable.>undefined(); @@ -373,6 +377,49 @@ public void setRestrictedRoles(List restrictedRoles) { this.restrictedRoles = restrictedRoles; } + public Dashboard tabs(List tabs) { + this.tabs = JsonNullable.>of(tabs); + return this; + } + + public Dashboard addTabsItem(DashboardTab tabsItem) { + if (this.tabs == null || !this.tabs.isPresent()) { + this.tabs = JsonNullable.>of(new ArrayList<>()); + } + try { + this.tabs.get().add(tabsItem); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } + return this; + } + + /** + * List of tabs for organizing dashboard widgets into groups. + * + * @return tabs + */ + @jakarta.annotation.Nullable + @JsonIgnore + public List getTabs() { + return tabs.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TABS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable> getTabs_JsonNullable() { + return tabs; + } + + @JsonProperty(JSON_PROPERTY_TABS) + public void setTabs_JsonNullable(JsonNullable> tabs) { + this.tabs = tabs; + } + + public void setTabs(List tabs) { + this.tabs = JsonNullable.>of(tabs); + } + public Dashboard tags(List tags) { this.tags = JsonNullable.>of(tags); return this; @@ -639,6 +686,7 @@ public boolean equals(Object o) { && Objects.equals(this.notifyList, dashboard.notifyList) && Objects.equals(this.reflowType, dashboard.reflowType) && Objects.equals(this.restrictedRoles, dashboard.restrictedRoles) + && Objects.equals(this.tabs, dashboard.tabs) && Objects.equals(this.tags, dashboard.tags) && Objects.equals(this.templateVariablePresets, dashboard.templateVariablePresets) && Objects.equals(this.templateVariables, dashboard.templateVariables) @@ -662,6 +710,7 @@ public int hashCode() { notifyList, reflowType, restrictedRoles, + tabs, tags, templateVariablePresets, templateVariables, @@ -686,6 +735,7 @@ public String toString() { sb.append(" notifyList: ").append(toIndentedString(notifyList)).append("\n"); sb.append(" reflowType: ").append(toIndentedString(reflowType)).append("\n"); sb.append(" restrictedRoles: ").append(toIndentedString(restrictedRoles)).append("\n"); + sb.append(" tabs: ").append(toIndentedString(tabs)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" templateVariablePresets: ") .append(toIndentedString(templateVariablePresets)) diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardTab.java b/src/main/java/com/datadog/api/client/v1/model/DashboardTab.java new file mode 100644 index 00000000000..0fd659786a0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardTab.java @@ -0,0 +1,210 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** Dashboard tab for organizing widgets. */ +@JsonPropertyOrder({ + DashboardTab.JSON_PROPERTY_ID, + DashboardTab.JSON_PROPERTY_NAME, + DashboardTab.JSON_PROPERTY_WIDGET_IDS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardTab { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private UUID id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_WIDGET_IDS = "widget_ids"; + private List widgetIds = new ArrayList<>(); + + public DashboardTab() {} + + @JsonCreator + public DashboardTab( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) UUID id, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_WIDGET_IDS) List widgetIds) { + this.id = id; + this.name = name; + this.widgetIds = widgetIds; + } + + public DashboardTab id(UUID id) { + this.id = id; + return this; + } + + /** + * UUID of the tab. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public DashboardTab name(String name) { + this.name = name; + return this; + } + + /** + * Name of the tab. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DashboardTab widgetIds(List widgetIds) { + this.widgetIds = widgetIds; + return this; + } + + public DashboardTab addWidgetIdsItem(Long widgetIdsItem) { + this.widgetIds.add(widgetIdsItem); + return this; + } + + /** + * List of widget IDs belonging to this tab. The backend also accepts positional references in @N + * format (1-indexed) as a convenience for Terraform and other declarative tools. + * + * @return widgetIds + */ + @JsonProperty(JSON_PROPERTY_WIDGET_IDS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getWidgetIds() { + return widgetIds; + } + + public void setWidgetIds(List widgetIds) { + this.widgetIds = widgetIds; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DashboardTab + */ + @JsonAnySetter + public DashboardTab putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DashboardTab object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardTab dashboardTab = (DashboardTab) o; + return Objects.equals(this.id, dashboardTab.id) + && Objects.equals(this.name, dashboardTab.name) + && Objects.equals(this.widgetIds, dashboardTab.widgetIds) + && Objects.equals(this.additionalProperties, dashboardTab.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, widgetIds, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardTab {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" widgetIds: ").append(toIndentedString(widgetIds)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\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 349f7de6f9d..180d587a837 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 @@ -91,7 +91,7 @@ Feature: Dashboards @generated @skip @team:DataDog/dashboards-backend Scenario: Create a new dashboard returns "Bad Request" response Given new "CreateDashboard" request - 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"}}]} + 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"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1342,7 +1342,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Bad Request" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - 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"}}]} + 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"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1350,7 +1350,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Item Not Found" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - 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"}}]} + 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"}}]} When the request is sent Then the response status is 404 Item Not Found