diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 3e86f3a82c..87bad04350 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/docs/datadog_api_client.v1.model.rst b/docs/datadog_api_client.v1.model.rst index b20c86c2ba..c8e64dd024 100644 --- a/docs/datadog_api_client.v1.model.rst +++ b/docs/datadog_api_client.v1.model.rst @@ -613,6 +613,13 @@ datadog\_api\_client.v1.model.dashboard\_summary\_definition module :members: :show-inheritance: +datadog\_api\_client.v1.model.dashboard\_tab module +--------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.dashboard_tab + :members: + :show-inheritance: + datadog\_api\_client.v1.model.dashboard\_template\_variable module ------------------------------------------------------------------ diff --git a/src/datadog_api_client/v1/model/dashboard.py b/src/datadog_api_client/v1/model/dashboard.py index 7419676c1c..13c8ebc136 100644 --- a/src/datadog_api_client/v1/model/dashboard.py +++ b/src/datadog_api_client/v1/model/dashboard.py @@ -18,6 +18,7 @@ if TYPE_CHECKING: from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType + from datadog_api_client.v1.model.dashboard_tab import DashboardTab from datadog_api_client.v1.model.dashboard_template_variable_preset import DashboardTemplateVariablePreset from datadog_api_client.v1.model.dashboard_template_variable import DashboardTemplateVariable from datadog_api_client.v1.model.widget import Widget @@ -25,6 +26,9 @@ class Dashboard(ModelNormal): validations = { + "tabs": { + "max_items": 100, + }, "tags": { "max_items": 5, }, @@ -34,6 +38,7 @@ class Dashboard(ModelNormal): def openapi_types(_): from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType + from datadog_api_client.v1.model.dashboard_tab import DashboardTab from datadog_api_client.v1.model.dashboard_template_variable_preset import DashboardTemplateVariablePreset from datadog_api_client.v1.model.dashboard_template_variable import DashboardTemplateVariable from datadog_api_client.v1.model.widget import Widget @@ -50,6 +55,7 @@ def openapi_types(_): "notify_list": ([str], none_type), "reflow_type": (DashboardReflowType,), "restricted_roles": ([str],), + "tabs": ([DashboardTab], none_type), "tags": ([str], none_type), "template_variable_presets": ([DashboardTemplateVariablePreset], none_type), "template_variables": ([DashboardTemplateVariable], none_type), @@ -70,6 +76,7 @@ def openapi_types(_): "notify_list": "notify_list", "reflow_type": "reflow_type", "restricted_roles": "restricted_roles", + "tabs": "tabs", "tags": "tags", "template_variable_presets": "template_variable_presets", "template_variables": "template_variables", @@ -101,6 +108,7 @@ def __init__( notify_list: Union[List[str], none_type, UnsetType] = unset, reflow_type: Union[DashboardReflowType, UnsetType] = unset, restricted_roles: Union[List[str], UnsetType] = unset, + tabs: Union[List[DashboardTab], none_type, UnsetType] = unset, tags: Union[List[str], none_type, UnsetType] = unset, template_variable_presets: Union[List[DashboardTemplateVariablePreset], none_type, UnsetType] = unset, template_variables: Union[List[DashboardTemplateVariable], none_type, UnsetType] = unset, @@ -148,6 +156,9 @@ def __init__( :param restricted_roles: A list of role identifiers. Only the author and users associated with at least one of these roles can edit this dashboard. :type restricted_roles: [str], optional + :param tabs: List of tabs for organizing dashboard widgets into groups. + :type tabs: [DashboardTab], none_type, optional + :param tags: List of team names representing ownership of a dashboard. :type tags: [str], none_type, optional @@ -186,6 +197,8 @@ def __init__( kwargs["reflow_type"] = reflow_type if restricted_roles is not unset: kwargs["restricted_roles"] = restricted_roles + if tabs is not unset: + kwargs["tabs"] = tabs if tags is not unset: kwargs["tags"] = tags if template_variable_presets is not unset: diff --git a/src/datadog_api_client/v1/model/dashboard_tab.py b/src/datadog_api_client/v1/model/dashboard_tab.py new file mode 100644 index 0000000000..da72d5536c --- /dev/null +++ b/src/datadog_api_client/v1/model/dashboard_tab.py @@ -0,0 +1,54 @@ +# 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 typing import List + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + UUID, +) + + +class DashboardTab(ModelNormal): + validations = { + "name": { + "max_length": 100, + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + return { + "id": (UUID,), + "name": (str,), + "widget_ids": ([int],), + } + + attribute_map = { + "id": "id", + "name": "name", + "widget_ids": "widget_ids", + } + + def __init__(self_, id: UUID, name: str, widget_ids: List[int], **kwargs): + """ + Dashboard tab for organizing widgets. + + :param id: UUID of the tab. + :type id: UUID + + :param name: Name of the tab. + :type name: str + + :param widget_ids: 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. + :type widget_ids: [int] + """ + super().__init__(kwargs) + + self_.id = id + self_.name = name + self_.widget_ids = widget_ids diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 1710446bfc..901c03dadc 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -85,6 +85,7 @@ from datadog_api_client.v1.model.dashboard_share_type import DashboardShareType from datadog_api_client.v1.model.dashboard_summary import DashboardSummary from datadog_api_client.v1.model.dashboard_summary_definition import DashboardSummaryDefinition +from datadog_api_client.v1.model.dashboard_tab import DashboardTab from datadog_api_client.v1.model.dashboard_template_variable import DashboardTemplateVariable from datadog_api_client.v1.model.dashboard_template_variable_preset import DashboardTemplateVariablePreset from datadog_api_client.v1.model.dashboard_template_variable_preset_value import DashboardTemplateVariablePresetValue @@ -1238,6 +1239,7 @@ "DashboardShareType", "DashboardSummary", "DashboardSummaryDefinition", + "DashboardTab", "DashboardTemplateVariable", "DashboardTemplateVariablePreset", "DashboardTemplateVariablePresetValue", diff --git a/tests/v1/features/dashboards.feature b/tests/v1/features/dashboards.feature index 349f7de6f9..180d587a83 100644 --- a/tests/v1/features/dashboards.feature +++ b/tests/v1/features/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