From 6872c4e3842e69f35ef262822ab6f76f5efbca51 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 18 Aug 2026 14:09:08 +0000 Subject: [PATCH] Regenerate client from commit 10ef69a of spec repo --- .generator/schemas/v2/openapi.yaml | 160 ++++++++++++ .../dashboards/ValidateDashboardWidgets.java | 39 +++ .../com/datadog/api/client/ApiClient.java | 5 +- .../api/client/v2/api/DashboardsApi.java | 156 ++++++++++++ .../DashboardWidgetValidationLayoutType.java | 61 +++++ .../DashboardWidgetValidationReflowType.java | 61 +++++ .../DashboardWidgetValidationRequest.java | 222 ++++++++++++++++ .../DashboardWidgetValidationResponse.java | 166 ++++++++++++ .../DashboardWidgetValidationResult.java | 240 ++++++++++++++++++ .../api/client/v2/api/dashboards.feature | 29 +++ .../com/datadog/api/client/v2/api/undo.json | 6 + 11 files changed, 1143 insertions(+), 2 deletions(-) create mode 100644 examples/v2/dashboards/ValidateDashboardWidgets.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationLayoutType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationReflowType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResult.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index db0bdfdf15a..c459277c7d4 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -30853,6 +30853,94 @@ components: example: Jane Doe type: string type: object + DashboardWidgetValidationLayoutType: + description: Layout type used to apply dashboard-specific widget layout validation. + enum: + - ordered + - free + example: ordered + type: string + x-enum-varnames: + - ORDERED + - FREE + DashboardWidgetValidationReflowType: + description: Reflow behavior used for an ordered dashboard. + enum: + - auto + - fixed + example: auto + type: string + x-enum-varnames: + - AUTO + - FIXED + DashboardWidgetValidationRequest: + description: Request containing dashboard widgets and their layout context. + properties: + layout_type: + $ref: "#/components/schemas/DashboardWidgetValidationLayoutType" + reflow_type: + $ref: "#/components/schemas/DashboardWidgetValidationReflowType" + nullable: true + widgets: + description: Dashboard widgets to validate. + example: + - definition: + content: Valid note + type: note + items: + $ref: "#/components/schemas/DashboardWidgetValidationWidget" + type: array + required: + - widgets + - layout_type + type: object + DashboardWidgetValidationResponse: + description: Ordered validation results corresponding to the requested widgets. + properties: + results: + description: Validation results in the same order as the requested widgets. + items: + $ref: "#/components/schemas/DashboardWidgetValidationResult" + type: array + required: + - results + type: object + DashboardWidgetValidationResult: + description: Validation result for one dashboard widget. + properties: + error_message: + description: Validation error message, when the widget is invalid. + example: Invalid widget definition at position `0` of type `timeseries`. + nullable: true + type: string + error_path: + description: Path to the invalid value, when available. + example: "['requests', 0, 'display_type']" + nullable: true + type: string + is_valid: + description: Whether the widget passed validation. + example: false + type: boolean + widget_type: + description: Type of the validated widget, when available. + example: timeseries + nullable: true + type: string + required: + - is_valid + - widget_type + - error_message + - error_path + type: object + DashboardWidgetValidationWidget: + additionalProperties: {} + description: A dashboard widget to validate. + example: + definition: + content: Valid note + type: note + type: object DataAttributesRulesItemsIfTagExists: description: The behavior when the tag already exists. enum: @@ -138616,6 +138704,78 @@ paths: tags: - Dashboard Lists x-codegen-request-body-name: body + /api/v2/dashboard/widgets/validate: + post: + description: Validate dashboard widgets without creating or updating a dashboard. + operationId: ValidateDashboardWidgets + requestBody: + content: + application/json: + examples: + default: + value: + layout_type: ordered + widgets: + - definition: + content: Valid note + type: note + schema: + $ref: "#/components/schemas/DashboardWidgetValidationRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + results: + - error_message: + error_path: + is_valid: true + widget_type: note + schema: + $ref: "#/components/schemas/DashboardWidgetValidationResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "422": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Unprocessable Entity + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - dashboards_read + - AuthZ: + - dashboards_write + summary: Validate dashboard widgets + tags: + - Dashboards + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - dashboards_read + - dashboards_write + x-unstable: |- + **Note**: This endpoint is in Preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/dashboard/{dashboard_id}/shared: get: description: Retrieve shared dashboards associated with the specified dashboard. diff --git a/examples/v2/dashboards/ValidateDashboardWidgets.java b/examples/v2/dashboards/ValidateDashboardWidgets.java new file mode 100644 index 00000000000..0c91c2e47ae --- /dev/null +++ b/examples/v2/dashboards/ValidateDashboardWidgets.java @@ -0,0 +1,39 @@ +// Validate dashboard widgets returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DashboardsApi; +import com.datadog.api.client.v2.model.DashboardWidgetValidationLayoutType; +import com.datadog.api.client.v2.model.DashboardWidgetValidationReflowType; +import com.datadog.api.client.v2.model.DashboardWidgetValidationRequest; +import com.datadog.api.client.v2.model.DashboardWidgetValidationResponse; +import java.util.Collections; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.validateDashboardWidgets", true); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + DashboardWidgetValidationRequest body = + new DashboardWidgetValidationRequest() + .layoutType(DashboardWidgetValidationLayoutType.ORDERED) + .reflowType(DashboardWidgetValidationReflowType.AUTO) + .widgets( + Collections.singletonList( + Map.ofEntries( + Map.entry("definition", "{'content': 'Valid note', 'type': 'note'}")))); + + try { + DashboardWidgetValidationResponse result = apiInstance.validateDashboardWidgets(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DashboardsApi#validateDashboardWidgets"); + 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/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 0d8443e0d1a..607f633c5b5 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1056,13 +1056,14 @@ public class ApiClient { put("v2.listCSMAgentlessHosts", false); put("v2.listCSMUnifiedHostFacets", false); put("v2.listCSMUnifiedHosts", false); + put("v2.getDashboardUsage", false); + put("v2.listDashboardsUsage", false); + put("v2.validateDashboardWidgets", false); put("v2.listSharedDashboardsByDashboardId", false); put("v2.createDashboardSecureEmbed", false); put("v2.deleteDashboardSecureEmbed", false); put("v2.getDashboardSecureEmbed", false); put("v2.updateDashboardSecureEmbed", false); - put("v2.getDashboardUsage", false); - put("v2.listDashboardsUsage", false); put("v2.getDataObservabilityMonitorRunStatus", false); put("v2.runDataObservabilityMonitor", false); put("v2.createDataset", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/DashboardsApi.java b/src/main/java/com/datadog/api/client/v2/api/DashboardsApi.java index 5e47a0374eb..feb4baceff7 100644 --- a/src/main/java/com/datadog/api/client/v2/api/DashboardsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/DashboardsApi.java @@ -7,6 +7,8 @@ import com.datadog.api.client.Pair; import com.datadog.api.client.v2.model.DashboardUsage; import com.datadog.api.client.v2.model.DashboardUsageResponse; +import com.datadog.api.client.v2.model.DashboardWidgetValidationRequest; +import com.datadog.api.client.v2.model.DashboardWidgetValidationResponse; import com.datadog.api.client.v2.model.ListDashboardsUsageResponse; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; @@ -514,4 +516,158 @@ public ApiResponse listDashboardsUsageWithHttpInfo( false, new GenericType() {}); } + + /** + * Validate dashboard widgets. + * + *

See {@link #validateDashboardWidgetsWithHttpInfo}. + * + * @param body (required) + * @return DashboardWidgetValidationResponse + * @throws ApiException if fails to make API call + */ + public DashboardWidgetValidationResponse validateDashboardWidgets( + DashboardWidgetValidationRequest body) throws ApiException { + return validateDashboardWidgetsWithHttpInfo(body).getData(); + } + + /** + * Validate dashboard widgets. + * + *

See {@link #validateDashboardWidgetsWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<DashboardWidgetValidationResponse> + */ + public CompletableFuture validateDashboardWidgetsAsync( + DashboardWidgetValidationRequest body) { + return validateDashboardWidgetsWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Validate dashboard widgets without creating or updating a dashboard. + * + * @param body (required) + * @return ApiResponse<DashboardWidgetValidationResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
422 Unprocessable Entity -
429 Too many requests -
+ */ + public ApiResponse validateDashboardWidgetsWithHttpInfo( + DashboardWidgetValidationRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "validateDashboardWidgets"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling validateDashboardWidgets"); + } + // create path and map variables + String localVarPath = "/api/v2/dashboard/widgets/validate"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DashboardsApi.validateDashboardWidgets", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Validate dashboard widgets. + * + *

See {@link #validateDashboardWidgetsWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<DashboardWidgetValidationResponse>> + */ + public CompletableFuture> + validateDashboardWidgetsWithHttpInfoAsync(DashboardWidgetValidationRequest body) { + // Check if unstable operation is enabled + String operationId = "validateDashboardWidgets"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling validateDashboardWidgets")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/dashboard/widgets/validate"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DashboardsApi.validateDashboardWidgets", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationLayoutType.java b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationLayoutType.java new file mode 100644 index 00000000000..f2f820d1a4a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationLayoutType.java @@ -0,0 +1,61 @@ +/* + * 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.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Layout type used to apply dashboard-specific widget layout validation. */ +@JsonSerialize( + using = DashboardWidgetValidationLayoutType.DashboardWidgetValidationLayoutTypeSerializer.class) +public class DashboardWidgetValidationLayoutType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("ordered", "free")); + + public static final DashboardWidgetValidationLayoutType ORDERED = + new DashboardWidgetValidationLayoutType("ordered"); + public static final DashboardWidgetValidationLayoutType FREE = + new DashboardWidgetValidationLayoutType("free"); + + DashboardWidgetValidationLayoutType(String value) { + super(value, allowedValues); + } + + public static class DashboardWidgetValidationLayoutTypeSerializer + extends StdSerializer { + public DashboardWidgetValidationLayoutTypeSerializer( + Class t) { + super(t); + } + + public DashboardWidgetValidationLayoutTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DashboardWidgetValidationLayoutType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DashboardWidgetValidationLayoutType fromValue(String value) { + return new DashboardWidgetValidationLayoutType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationReflowType.java b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationReflowType.java new file mode 100644 index 00000000000..31cc5dac0d5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationReflowType.java @@ -0,0 +1,61 @@ +/* + * 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.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Reflow behavior used for an ordered dashboard. */ +@JsonSerialize( + using = DashboardWidgetValidationReflowType.DashboardWidgetValidationReflowTypeSerializer.class) +public class DashboardWidgetValidationReflowType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("auto", "fixed")); + + public static final DashboardWidgetValidationReflowType AUTO = + new DashboardWidgetValidationReflowType("auto"); + public static final DashboardWidgetValidationReflowType FIXED = + new DashboardWidgetValidationReflowType("fixed"); + + DashboardWidgetValidationReflowType(String value) { + super(value, allowedValues); + } + + public static class DashboardWidgetValidationReflowTypeSerializer + extends StdSerializer { + public DashboardWidgetValidationReflowTypeSerializer( + Class t) { + super(t); + } + + public DashboardWidgetValidationReflowTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DashboardWidgetValidationReflowType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DashboardWidgetValidationReflowType fromValue(String value) { + return new DashboardWidgetValidationReflowType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationRequest.java b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationRequest.java new file mode 100644 index 00000000000..9cd19a5127b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationRequest.java @@ -0,0 +1,222 @@ +/* + * 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.v2.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; + +/** Request containing dashboard widgets and their layout context. */ +@JsonPropertyOrder({ + DashboardWidgetValidationRequest.JSON_PROPERTY_LAYOUT_TYPE, + DashboardWidgetValidationRequest.JSON_PROPERTY_REFLOW_TYPE, + DashboardWidgetValidationRequest.JSON_PROPERTY_WIDGETS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardWidgetValidationRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_LAYOUT_TYPE = "layout_type"; + private DashboardWidgetValidationLayoutType layoutType; + + public static final String JSON_PROPERTY_REFLOW_TYPE = "reflow_type"; + private DashboardWidgetValidationReflowType reflowType; + + public static final String JSON_PROPERTY_WIDGETS = "widgets"; + private List> widgets = new ArrayList<>(); + + public DashboardWidgetValidationRequest() {} + + @JsonCreator + public DashboardWidgetValidationRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_LAYOUT_TYPE) + DashboardWidgetValidationLayoutType layoutType, + @JsonProperty(required = true, value = JSON_PROPERTY_WIDGETS) + List> widgets) { + this.layoutType = layoutType; + this.unparsed |= !layoutType.isValid(); + this.widgets = widgets; + } + + public DashboardWidgetValidationRequest layoutType( + DashboardWidgetValidationLayoutType layoutType) { + this.layoutType = layoutType; + this.unparsed |= !layoutType.isValid(); + return this; + } + + /** + * Layout type used to apply dashboard-specific widget layout validation. + * + * @return layoutType + */ + @JsonProperty(JSON_PROPERTY_LAYOUT_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DashboardWidgetValidationLayoutType getLayoutType() { + return layoutType; + } + + public void setLayoutType(DashboardWidgetValidationLayoutType layoutType) { + if (!layoutType.isValid()) { + this.unparsed = true; + } + this.layoutType = layoutType; + } + + public DashboardWidgetValidationRequest reflowType( + DashboardWidgetValidationReflowType reflowType) { + this.reflowType = reflowType; + this.unparsed |= !reflowType.isValid(); + return this; + } + + /** + * Reflow behavior used for an ordered dashboard. + * + * @return reflowType + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_REFLOW_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DashboardWidgetValidationReflowType getReflowType() { + return reflowType; + } + + public void setReflowType(DashboardWidgetValidationReflowType reflowType) { + if (!reflowType.isValid()) { + this.unparsed = true; + } + this.reflowType = reflowType; + } + + public DashboardWidgetValidationRequest widgets(List> widgets) { + this.widgets = widgets; + return this; + } + + public DashboardWidgetValidationRequest addWidgetsItem(Map widgetsItem) { + this.widgets.add(widgetsItem); + return this; + } + + /** + * Dashboard widgets to validate. + * + * @return widgets + */ + @JsonProperty(JSON_PROPERTY_WIDGETS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List> getWidgets() { + return widgets; + } + + public void setWidgets(List> widgets) { + this.widgets = widgets; + } + + /** + * 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 DashboardWidgetValidationRequest + */ + @JsonAnySetter + public DashboardWidgetValidationRequest 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 DashboardWidgetValidationRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardWidgetValidationRequest dashboardWidgetValidationRequest = + (DashboardWidgetValidationRequest) o; + return Objects.equals(this.layoutType, dashboardWidgetValidationRequest.layoutType) + && Objects.equals(this.reflowType, dashboardWidgetValidationRequest.reflowType) + && Objects.equals(this.widgets, dashboardWidgetValidationRequest.widgets) + && Objects.equals( + this.additionalProperties, dashboardWidgetValidationRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(layoutType, reflowType, widgets, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardWidgetValidationRequest {\n"); + sb.append(" layoutType: ").append(toIndentedString(layoutType)).append("\n"); + sb.append(" reflowType: ").append(toIndentedString(reflowType)).append("\n"); + sb.append(" widgets: ").append(toIndentedString(widgets)).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/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResponse.java b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResponse.java new file mode 100644 index 00000000000..b32202d37c7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResponse.java @@ -0,0 +1,166 @@ +/* + * 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.v2.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; + +/** Ordered validation results corresponding to the requested widgets. */ +@JsonPropertyOrder({DashboardWidgetValidationResponse.JSON_PROPERTY_RESULTS}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardWidgetValidationResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RESULTS = "results"; + private List results = new ArrayList<>(); + + public DashboardWidgetValidationResponse() {} + + @JsonCreator + public DashboardWidgetValidationResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_RESULTS) + List results) { + this.results = results; + for (DashboardWidgetValidationResult item : results) { + this.unparsed |= item.unparsed; + } + } + + public DashboardWidgetValidationResponse results(List results) { + this.results = results; + for (DashboardWidgetValidationResult item : results) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DashboardWidgetValidationResponse addResultsItem( + DashboardWidgetValidationResult resultsItem) { + this.results.add(resultsItem); + this.unparsed |= resultsItem.unparsed; + return this; + } + + /** + * Validation results in the same order as the requested widgets. + * + * @return results + */ + @JsonProperty(JSON_PROPERTY_RESULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + if (results != null) { + for (DashboardWidgetValidationResult item : results) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * 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 DashboardWidgetValidationResponse + */ + @JsonAnySetter + public DashboardWidgetValidationResponse 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 DashboardWidgetValidationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardWidgetValidationResponse dashboardWidgetValidationResponse = + (DashboardWidgetValidationResponse) o; + return Objects.equals(this.results, dashboardWidgetValidationResponse.results) + && Objects.equals( + this.additionalProperties, dashboardWidgetValidationResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(results, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardWidgetValidationResponse {\n"); + sb.append(" results: ").append(toIndentedString(results)).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/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResult.java b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResult.java new file mode 100644 index 00000000000..cfc2721d684 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DashboardWidgetValidationResult.java @@ -0,0 +1,240 @@ +/* + * 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.v2.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.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Validation result for one dashboard widget. */ +@JsonPropertyOrder({ + DashboardWidgetValidationResult.JSON_PROPERTY_ERROR_MESSAGE, + DashboardWidgetValidationResult.JSON_PROPERTY_ERROR_PATH, + DashboardWidgetValidationResult.JSON_PROPERTY_IS_VALID, + DashboardWidgetValidationResult.JSON_PROPERTY_WIDGET_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardWidgetValidationResult { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ERROR_MESSAGE = "error_message"; + private String errorMessage; + + public static final String JSON_PROPERTY_ERROR_PATH = "error_path"; + private String errorPath; + + public static final String JSON_PROPERTY_IS_VALID = "is_valid"; + private Boolean isValid; + + public static final String JSON_PROPERTY_WIDGET_TYPE = "widget_type"; + private String widgetType; + + public DashboardWidgetValidationResult() {} + + @JsonCreator + public DashboardWidgetValidationResult( + @JsonProperty(required = true, value = JSON_PROPERTY_ERROR_MESSAGE) String errorMessage, + @JsonProperty(required = true, value = JSON_PROPERTY_ERROR_PATH) String errorPath, + @JsonProperty(required = true, value = JSON_PROPERTY_IS_VALID) Boolean isValid, + @JsonProperty(required = true, value = JSON_PROPERTY_WIDGET_TYPE) String widgetType) { + this.errorMessage = errorMessage; + if (errorMessage != null) {} + this.errorPath = errorPath; + if (errorPath != null) {} + this.isValid = isValid; + this.widgetType = widgetType; + if (widgetType != null) {} + } + + public DashboardWidgetValidationResult errorMessage(String errorMessage) { + this.errorMessage = errorMessage; + if (errorMessage != null) {} + return this; + } + + /** + * Validation error message, when the widget is invalid. + * + * @return errorMessage + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ERROR_MESSAGE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public DashboardWidgetValidationResult errorPath(String errorPath) { + this.errorPath = errorPath; + if (errorPath != null) {} + return this; + } + + /** + * Path to the invalid value, when available. + * + * @return errorPath + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ERROR_PATH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getErrorPath() { + return errorPath; + } + + public void setErrorPath(String errorPath) { + this.errorPath = errorPath; + } + + public DashboardWidgetValidationResult isValid(Boolean isValid) { + this.isValid = isValid; + return this; + } + + /** + * Whether the widget passed validation. + * + * @return isValid + */ + @JsonProperty(JSON_PROPERTY_IS_VALID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getIsValid() { + return isValid; + } + + public void setIsValid(Boolean isValid) { + this.isValid = isValid; + } + + public DashboardWidgetValidationResult widgetType(String widgetType) { + this.widgetType = widgetType; + if (widgetType != null) {} + return this; + } + + /** + * Type of the validated widget, when available. + * + * @return widgetType + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_WIDGET_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getWidgetType() { + return widgetType; + } + + public void setWidgetType(String widgetType) { + this.widgetType = widgetType; + } + + /** + * 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 DashboardWidgetValidationResult + */ + @JsonAnySetter + public DashboardWidgetValidationResult 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 DashboardWidgetValidationResult object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardWidgetValidationResult dashboardWidgetValidationResult = + (DashboardWidgetValidationResult) o; + return Objects.equals(this.errorMessage, dashboardWidgetValidationResult.errorMessage) + && Objects.equals(this.errorPath, dashboardWidgetValidationResult.errorPath) + && Objects.equals(this.isValid, dashboardWidgetValidationResult.isValid) + && Objects.equals(this.widgetType, dashboardWidgetValidationResult.widgetType) + && Objects.equals( + this.additionalProperties, dashboardWidgetValidationResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(errorMessage, errorPath, isValid, widgetType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardWidgetValidationResult {\n"); + sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); + sb.append(" errorPath: ").append(toIndentedString(errorPath)).append("\n"); + sb.append(" isValid: ").append(toIndentedString(isValid)).append("\n"); + sb.append(" widgetType: ").append(toIndentedString(widgetType)).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/v2/api/dashboards.feature b/src/test/resources/com/datadog/api/client/v2/api/dashboards.feature index 347955175ea..ce7cef9a96a 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/dashboards.feature @@ -99,3 +99,32 @@ Feature: Dashboards When the request is sent Then the response status is 200 OK And the response "meta.page" has field "total" + + @generated @skip @team:DataDog/dashboards-backend + Scenario: Validate dashboard widgets returns "Bad Request" response + Given operation "ValidateDashboardWidgets" enabled + And new "ValidateDashboardWidgets" request + And body with value {"layout_type": "ordered", "reflow_type": "auto", "widgets": [{"definition": {"content": "Valid note", "type": "note"}}]} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/dashboards-backend + Scenario: Validate dashboard widgets returns "OK" response + Given operation "ValidateDashboardWidgets" enabled + And new "ValidateDashboardWidgets" request + And body with value {"layout_type": "ordered", "reflow_type": "auto", "widgets": [{"definition": {"content": "Valid note", "type": "note"}}]} + When the request is sent + Then the response status is 200 OK + And the response "results" has length 1 + And the response "results[0].is_valid" is equal to true + And the response "results[0].widget_type" is equal to "note" + And the response "results[0]" has field "error_message" + And the response "results[0]" has field "error_path" + + @generated @skip @team:DataDog/dashboards-backend + Scenario: Validate dashboard widgets returns "Unprocessable Entity" response + Given operation "ValidateDashboardWidgets" enabled + And new "ValidateDashboardWidgets" request + And body with value {"layout_type": "ordered", "reflow_type": "auto", "widgets": [{"definition": {"content": "Valid note", "type": "note"}}]} + When the request is sent + Then the response status is 422 Unprocessable Entity diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index df961ee10c8..5d00d889c22 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -2157,6 +2157,12 @@ "type": "safe" } }, + "ValidateDashboardWidgets": { + "tag": "Dashboards", + "undo": { + "type": "safe" + } + }, "ListSharedDashboardsByDashboardId": { "tag": "Dashboard Sharing", "undo": {