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
42 changes: 42 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11743,6 +11743,48 @@ datadog\_api\_client.v2.model.dashboard\_usage\_user module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.dashboard\_widget\_validation\_layout\_type module
--------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.dashboard_widget_validation_layout_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.dashboard\_widget\_validation\_reflow\_type module
--------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.dashboard_widget_validation_reflow_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.dashboard\_widget\_validation\_request module
---------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.dashboard_widget_validation_request
:members:
:show-inheritance:

datadog\_api\_client.v2.model.dashboard\_widget\_validation\_response module
----------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.dashboard_widget_validation_response
:members:
:show-inheritance:

datadog\_api\_client.v2.model.dashboard\_widget\_validation\_result module
--------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.dashboard_widget_validation_result
:members:
:show-inheritance:

datadog\_api\_client.v2.model.dashboard\_widget\_validation\_widget module
--------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.dashboard_widget_validation_widget
:members:
:show-inheritance:

datadog\_api\_client.v2.model.data\_attributes\_rules\_items\_if\_tag\_exists module
------------------------------------------------------------------------------------

Expand Down
26 changes: 26 additions & 0 deletions examples/v2/dashboards/ValidateDashboardWidgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Validate dashboard widgets returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.dashboards_api import DashboardsApi
from datadog_api_client.v2.model.dashboard_widget_validation_layout_type import DashboardWidgetValidationLayoutType
from datadog_api_client.v2.model.dashboard_widget_validation_reflow_type import DashboardWidgetValidationReflowType
from datadog_api_client.v2.model.dashboard_widget_validation_request import DashboardWidgetValidationRequest
from datadog_api_client.v2.model.dashboard_widget_validation_widget import DashboardWidgetValidationWidget

body = DashboardWidgetValidationRequest(
layout_type=DashboardWidgetValidationLayoutType.ORDERED,
reflow_type=DashboardWidgetValidationReflowType.AUTO,
widgets=[
DashboardWidgetValidationWidget([("definition", "{'content': 'Valid note', 'type': 'note'}")]),
],
)

configuration = Configuration()
configuration.unstable_operations["validate_dashboard_widgets"] = True
with ApiClient(configuration) as api_client:
api_instance = DashboardsApi(api_client)
response = api_instance.validate_dashboard_widgets(body=body)

print(response)
5 changes: 3 additions & 2 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,14 @@ def __init__(
"v2.list_csm_agentless_hosts": False,
"v2.list_csm_unified_host_facets": False,
"v2.list_csm_unified_hosts": False,
"v2.get_dashboard_usage": False,
"v2.list_dashboards_usage": False,
"v2.validate_dashboard_widgets": False,
"v2.list_shared_dashboards_by_dashboard_id": False,
"v2.create_dashboard_secure_embed": False,
"v2.delete_dashboard_secure_embed": False,
"v2.get_dashboard_secure_embed": False,
"v2.update_dashboard_secure_embed": False,
"v2.get_dashboard_usage": False,
"v2.list_dashboards_usage": False,
"v2.get_data_observability_monitor_run_status": False,
"v2.run_data_observability_monitor": False,
"v2.create_dataset": False,
Expand Down
38 changes: 38 additions & 0 deletions src/datadog_api_client/v2/api/dashboards_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
UnsetType,
unset,
)
from datadog_api_client.v2.model.dashboard_widget_validation_response import DashboardWidgetValidationResponse
from datadog_api_client.v2.model.dashboard_widget_validation_request import DashboardWidgetValidationRequest
from datadog_api_client.v2.model.list_dashboards_usage_response import ListDashboardsUsageResponse
from datadog_api_client.v2.model.dashboard_usage import DashboardUsage
from datadog_api_client.v2.model.dashboard_usage_response import DashboardUsageResponse
Expand Down Expand Up @@ -95,6 +97,26 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._validate_dashboard_widgets_endpoint = _Endpoint(
settings={
"response_type": (DashboardWidgetValidationResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/dashboard/widgets/validate",
"operation_id": "validate_dashboard_widgets",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (DashboardWidgetValidationRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

def get_dashboard_usage(
self,
dashboard_id: str,
Expand Down Expand Up @@ -197,3 +219,19 @@ def list_dashboards_usage_with_pagination(
"kwargs": kwargs,
}
return endpoint.call_with_http_info_paginated(pagination)

def validate_dashboard_widgets(
self,
body: DashboardWidgetValidationRequest,
) -> DashboardWidgetValidationResponse:
"""Validate dashboard widgets.

Validate dashboard widgets without creating or updating a dashboard.

:type body: DashboardWidgetValidationRequest
:rtype: DashboardWidgetValidationResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._validate_dashboard_widgets_endpoint.call_with_http_info(**kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class DashboardWidgetValidationLayoutType(ModelSimple):
"""
Layout type used to apply dashboard-specific widget layout validation.

:param value: Must be one of ["ordered", "free"].
:type value: str
"""

allowed_values = {
"ordered",
"free",
}
ORDERED: ClassVar["DashboardWidgetValidationLayoutType"]
FREE: ClassVar["DashboardWidgetValidationLayoutType"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


DashboardWidgetValidationLayoutType.ORDERED = DashboardWidgetValidationLayoutType("ordered")
DashboardWidgetValidationLayoutType.FREE = DashboardWidgetValidationLayoutType("free")
Loading
Loading