Skip to content
Open
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
160 changes: 160 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
39 changes: 39 additions & 0 deletions examples/v2/dashboards/ValidateDashboardWidgets.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/datadog/api/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
156 changes: 156 additions & 0 deletions src/main/java/com/datadog/api/client/v2/api/DashboardsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -514,4 +516,158 @@ public ApiResponse<ListDashboardsUsageResponse> listDashboardsUsageWithHttpInfo(
false,
new GenericType<ListDashboardsUsageResponse>() {});
}

/**
* Validate dashboard widgets.
*
* <p>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.
*
* <p>See {@link #validateDashboardWidgetsWithHttpInfoAsync}.
*
* @param body (required)
* @return CompletableFuture&lt;DashboardWidgetValidationResponse&gt;
*/
public CompletableFuture<DashboardWidgetValidationResponse> 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&lt;DashboardWidgetValidationResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table border="1">
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
* <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<DashboardWidgetValidationResponse> 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<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder =
apiClient.createBuilder(
"v2.DashboardsApi.validateDashboardWidgets",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
return apiClient.invokeAPI(
"POST",
builder,
localVarHeaderParams,
new String[] {"application/json"},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<DashboardWidgetValidationResponse>() {});
}

/**
* Validate dashboard widgets.
*
* <p>See {@link #validateDashboardWidgetsWithHttpInfo}.
*
* @param body (required)
* @return CompletableFuture&lt;ApiResponse&lt;DashboardWidgetValidationResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<DashboardWidgetValidationResponse>>
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<ApiResponse<DashboardWidgetValidationResponse>> 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<ApiResponse<DashboardWidgetValidationResponse>> 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<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.DashboardsApi.validateDashboardWidgets",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
} catch (ApiException ex) {
CompletableFuture<ApiResponse<DashboardWidgetValidationResponse>> result =
new CompletableFuture<>();
result.completeExceptionally(ex);
return result;
}
return apiClient.invokeAPIAsync(
"POST",
builder,
localVarHeaderParams,
new String[] {"application/json"},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<DashboardWidgetValidationResponse>() {});
}
}
Loading
Loading