diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e922a2a26a..a6d35cbd21 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1443,6 +1443,8 @@ components: format: date-time readOnly: true type: string + default_timeframe: + $ref: "#/components/schemas/DashboardDefaultTimeframeSetting" description: description: Description of the dashboard. nullable: true @@ -1557,6 +1559,18 @@ components: required: - data type: object + DashboardDefaultTimeframeSetting: + description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe. + discriminator: + mapping: + fixed: "#/components/schemas/DashboardFixedTimeframe" + live: "#/components/schemas/DashboardLiveTimeframe" + propertyName: type + nullable: true + oneOf: + - $ref: "#/components/schemas/DashboardLiveTimeframe" + - $ref: "#/components/schemas/DashboardFixedTimeframe" + type: object DashboardDeleteResponse: description: Response from the delete dashboard call. properties: @@ -1564,6 +1578,36 @@ components: description: ID of the deleted dashboard. type: string type: object + DashboardFixedTimeframe: + description: A fixed dashboard timeframe. + properties: + from: + description: Start time in milliseconds since epoch. + example: 1712080128000 + format: int64 + minimum: 0 + type: integer + to: + description: End time in milliseconds since epoch. + example: 1712083128000 + format: int64 + minimum: 0 + type: integer + type: + $ref: "#/components/schemas/DashboardFixedTimeframeType" + required: + - type + - from + - to + type: object + DashboardFixedTimeframeType: + description: Type of fixed timeframe. + enum: + - fixed + example: fixed + type: string + x-enum-varnames: + - FIXED DashboardGlobalTime: description: Object containing the live span selection for the dashboard. properties: @@ -1672,6 +1716,32 @@ components: $ref: "#/components/schemas/DashboardList" type: array type: object + DashboardLiveTimeframe: + description: A live dashboard timeframe. + properties: + type: + $ref: "#/components/schemas/DashboardLiveTimeframeType" + unit: + $ref: "#/components/schemas/WidgetLiveSpanUnit" + value: + description: Value of the live timeframe span. + example: 4 + format: int64 + minimum: 1 + type: integer + required: + - type + - value + - unit + type: object + DashboardLiveTimeframeType: + description: Type of live timeframe. + enum: + - live + example: live + type: string + x-enum-varnames: + - LIVE DashboardReflowType: description: |- Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'. diff --git a/docs/datadog_api_client.v1.model.rst b/docs/datadog_api_client.v1.model.rst index 1b6e3313f9..134b1fdbdd 100644 --- a/docs/datadog_api_client.v1.model.rst +++ b/docs/datadog_api_client.v1.model.rst @@ -564,6 +564,13 @@ datadog\_api\_client.v1.model.dashboard\_bulk\_delete\_request module :members: :show-inheritance: +datadog\_api\_client.v1.model.dashboard\_default\_timeframe\_setting module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.dashboard_default_timeframe_setting + :members: + :show-inheritance: + datadog\_api\_client.v1.model.dashboard\_delete\_response module ---------------------------------------------------------------- @@ -571,6 +578,20 @@ datadog\_api\_client.v1.model.dashboard\_delete\_response module :members: :show-inheritance: +datadog\_api\_client.v1.model.dashboard\_fixed\_timeframe module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.dashboard_fixed_timeframe + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.dashboard\_fixed\_timeframe\_type module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.dashboard_fixed_timeframe_type + :members: + :show-inheritance: + datadog\_api\_client.v1.model.dashboard\_global\_time module ------------------------------------------------------------ @@ -620,6 +641,20 @@ datadog\_api\_client.v1.model.dashboard\_list\_list\_response module :members: :show-inheritance: +datadog\_api\_client.v1.model.dashboard\_live\_timeframe module +--------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.dashboard_live_timeframe + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.dashboard\_live\_timeframe\_type module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.dashboard_live_timeframe_type + :members: + :show-inheritance: + datadog\_api\_client.v1.model.dashboard\_reflow\_type module ------------------------------------------------------------ diff --git a/src/datadog_api_client/v1/model/dashboard.py b/src/datadog_api_client/v1/model/dashboard.py index 13c8ebc136..3104f4c3c6 100644 --- a/src/datadog_api_client/v1/model/dashboard.py +++ b/src/datadog_api_client/v1/model/dashboard.py @@ -16,12 +16,15 @@ if TYPE_CHECKING: + from datadog_api_client.v1.model.dashboard_default_timeframe_setting import DashboardDefaultTimeframeSetting 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 + from datadog_api_client.v1.model.dashboard_live_timeframe import DashboardLiveTimeframe + from datadog_api_client.v1.model.dashboard_fixed_timeframe import DashboardFixedTimeframe class Dashboard(ModelNormal): @@ -36,6 +39,7 @@ class Dashboard(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v1.model.dashboard_default_timeframe_setting import DashboardDefaultTimeframeSetting 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 @@ -47,6 +51,7 @@ def openapi_types(_): "author_handle": (str,), "author_name": (str, none_type), "created_at": (datetime,), + "default_timeframe": (DashboardDefaultTimeframeSetting,), "description": (str, none_type), "id": (str,), "is_read_only": (bool,), @@ -68,6 +73,7 @@ def openapi_types(_): "author_handle": "author_handle", "author_name": "author_name", "created_at": "created_at", + "default_timeframe": "default_timeframe", "description": "description", "id": "id", "is_read_only": "is_read_only", @@ -101,6 +107,11 @@ def __init__( author_handle: Union[str, UnsetType] = unset, author_name: Union[str, none_type, UnsetType] = unset, created_at: Union[datetime, UnsetType] = unset, + default_timeframe: Union[ + Union[DashboardDefaultTimeframeSetting, DashboardLiveTimeframe, DashboardFixedTimeframe], + none_type, + UnsetType, + ] = unset, description: Union[str, none_type, UnsetType] = unset, id: Union[str, UnsetType] = unset, is_read_only: Union[bool, UnsetType] = unset, @@ -128,6 +139,9 @@ def __init__( :param created_at: Creation date of the dashboard. :type created_at: datetime, optional + :param default_timeframe: The default timeframe applied when opening the dashboard. Set to ``null`` to clear the dashboard's default timeframe. + :type default_timeframe: DashboardDefaultTimeframeSetting, none_type, optional + :param description: Description of the dashboard. :type description: str, none_type, optional @@ -183,6 +197,8 @@ def __init__( kwargs["author_name"] = author_name if created_at is not unset: kwargs["created_at"] = created_at + if default_timeframe is not unset: + kwargs["default_timeframe"] = default_timeframe if description is not unset: kwargs["description"] = description if id is not unset: diff --git a/src/datadog_api_client/v1/model/dashboard_default_timeframe_setting.py b/src/datadog_api_client/v1/model/dashboard_default_timeframe_setting.py new file mode 100644 index 0000000000..a9b5bd208c --- /dev/null +++ b/src/datadog_api_client/v1/model/dashboard_default_timeframe_setting.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 datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class DashboardDefaultTimeframeSetting(ModelComposed): + _nullable = True + + def __init__(self, **kwargs): + """ + The default timeframe applied when opening the dashboard. Set to ``null`` to clear the dashboard's default timeframe. + + :param type: Type of live timeframe. + :type type: DashboardLiveTimeframeType + + :param unit: Unit of the time span. + :type unit: WidgetLiveSpanUnit + + :param value: Value of the live timeframe span. + :type value: int + + :param _from: Start time in milliseconds since epoch. + :type _from: int + + :param to: End time in milliseconds since epoch. + :type to: int + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v1.model.dashboard_live_timeframe import DashboardLiveTimeframe + from datadog_api_client.v1.model.dashboard_fixed_timeframe import DashboardFixedTimeframe + + return { + "oneOf": [ + DashboardLiveTimeframe, + DashboardFixedTimeframe, + ], + } diff --git a/src/datadog_api_client/v1/model/dashboard_fixed_timeframe.py b/src/datadog_api_client/v1/model/dashboard_fixed_timeframe.py new file mode 100644 index 0000000000..260da325a5 --- /dev/null +++ b/src/datadog_api_client/v1/model/dashboard_fixed_timeframe.py @@ -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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.dashboard_fixed_timeframe_type import DashboardFixedTimeframeType + + +class DashboardFixedTimeframe(ModelNormal): + validations = { + "_from": { + "inclusive_minimum": 0, + }, + "to": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.dashboard_fixed_timeframe_type import DashboardFixedTimeframeType + + return { + "_from": (int,), + "to": (int,), + "type": (DashboardFixedTimeframeType,), + } + + attribute_map = { + "_from": "from", + "to": "to", + "type": "type", + } + + def __init__(self_, _from: int, to: int, type: DashboardFixedTimeframeType, **kwargs): + """ + A fixed dashboard timeframe. + + :param _from: Start time in milliseconds since epoch. + :type _from: int + + :param to: End time in milliseconds since epoch. + :type to: int + + :param type: Type of fixed timeframe. + :type type: DashboardFixedTimeframeType + """ + super().__init__(kwargs) + + self_._from = _from + self_.to = to + self_.type = type diff --git a/src/datadog_api_client/v1/model/dashboard_fixed_timeframe_type.py b/src/datadog_api_client/v1/model/dashboard_fixed_timeframe_type.py new file mode 100644 index 0000000000..415182e3c8 --- /dev/null +++ b/src/datadog_api_client/v1/model/dashboard_fixed_timeframe_type.py @@ -0,0 +1,35 @@ +# 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 DashboardFixedTimeframeType(ModelSimple): + """ + Type of fixed timeframe. + + :param value: If omitted defaults to "fixed". Must be one of ["fixed"]. + :type value: str + """ + + allowed_values = { + "fixed", + } + FIXED: ClassVar["DashboardFixedTimeframeType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DashboardFixedTimeframeType.FIXED = DashboardFixedTimeframeType("fixed") diff --git a/src/datadog_api_client/v1/model/dashboard_live_timeframe.py b/src/datadog_api_client/v1/model/dashboard_live_timeframe.py new file mode 100644 index 0000000000..8d26802219 --- /dev/null +++ b/src/datadog_api_client/v1/model/dashboard_live_timeframe.py @@ -0,0 +1,60 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.dashboard_live_timeframe_type import DashboardLiveTimeframeType + from datadog_api_client.v1.model.widget_live_span_unit import WidgetLiveSpanUnit + + +class DashboardLiveTimeframe(ModelNormal): + validations = { + "value": { + "inclusive_minimum": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.dashboard_live_timeframe_type import DashboardLiveTimeframeType + from datadog_api_client.v1.model.widget_live_span_unit import WidgetLiveSpanUnit + + return { + "type": (DashboardLiveTimeframeType,), + "unit": (WidgetLiveSpanUnit,), + "value": (int,), + } + + attribute_map = { + "type": "type", + "unit": "unit", + "value": "value", + } + + def __init__(self_, type: DashboardLiveTimeframeType, unit: WidgetLiveSpanUnit, value: int, **kwargs): + """ + A live dashboard timeframe. + + :param type: Type of live timeframe. + :type type: DashboardLiveTimeframeType + + :param unit: Unit of the time span. + :type unit: WidgetLiveSpanUnit + + :param value: Value of the live timeframe span. + :type value: int + """ + super().__init__(kwargs) + + self_.type = type + self_.unit = unit + self_.value = value diff --git a/src/datadog_api_client/v1/model/dashboard_live_timeframe_type.py b/src/datadog_api_client/v1/model/dashboard_live_timeframe_type.py new file mode 100644 index 0000000000..396f38b6d6 --- /dev/null +++ b/src/datadog_api_client/v1/model/dashboard_live_timeframe_type.py @@ -0,0 +1,35 @@ +# 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 DashboardLiveTimeframeType(ModelSimple): + """ + Type of live timeframe. + + :param value: If omitted defaults to "live". Must be one of ["live"]. + :type value: str + """ + + allowed_values = { + "live", + } + LIVE: ClassVar["DashboardLiveTimeframeType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DashboardLiveTimeframeType.LIVE = DashboardLiveTimeframeType("live") diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 85c9757ab5..8126d6f813 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -78,7 +78,10 @@ from datadog_api_client.v1.model.dashboard_bulk_action_data import DashboardBulkActionData from datadog_api_client.v1.model.dashboard_bulk_action_data_list import DashboardBulkActionDataList from datadog_api_client.v1.model.dashboard_bulk_delete_request import DashboardBulkDeleteRequest +from datadog_api_client.v1.model.dashboard_default_timeframe_setting import DashboardDefaultTimeframeSetting from datadog_api_client.v1.model.dashboard_delete_response import DashboardDeleteResponse +from datadog_api_client.v1.model.dashboard_fixed_timeframe import DashboardFixedTimeframe +from datadog_api_client.v1.model.dashboard_fixed_timeframe_type import DashboardFixedTimeframeType from datadog_api_client.v1.model.dashboard_global_time import DashboardGlobalTime from datadog_api_client.v1.model.dashboard_global_time_live_span import DashboardGlobalTimeLiveSpan from datadog_api_client.v1.model.dashboard_invite_type import DashboardInviteType @@ -86,6 +89,8 @@ from datadog_api_client.v1.model.dashboard_list import DashboardList from datadog_api_client.v1.model.dashboard_list_delete_response import DashboardListDeleteResponse from datadog_api_client.v1.model.dashboard_list_list_response import DashboardListListResponse +from datadog_api_client.v1.model.dashboard_live_timeframe import DashboardLiveTimeframe +from datadog_api_client.v1.model.dashboard_live_timeframe_type import DashboardLiveTimeframeType from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType from datadog_api_client.v1.model.dashboard_resource_type import DashboardResourceType from datadog_api_client.v1.model.dashboard_restore_request import DashboardRestoreRequest @@ -1475,7 +1480,10 @@ "DashboardBulkActionData", "DashboardBulkActionDataList", "DashboardBulkDeleteRequest", + "DashboardDefaultTimeframeSetting", "DashboardDeleteResponse", + "DashboardFixedTimeframe", + "DashboardFixedTimeframeType", "DashboardGlobalTime", "DashboardGlobalTimeLiveSpan", "DashboardInviteType", @@ -1483,6 +1491,8 @@ "DashboardList", "DashboardListDeleteResponse", "DashboardListListResponse", + "DashboardLiveTimeframe", + "DashboardLiveTimeframeType", "DashboardReflowType", "DashboardResourceType", "DashboardRestoreRequest", diff --git a/tests/v1/features/dashboards.feature b/tests/v1/features/dashboards.feature index 932dc22b0b..2fb06cd716 100644 --- a/tests/v1/features/dashboards.feature +++ b/tests/v1/features/dashboards.feature @@ -90,7 +90,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": [], "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"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "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 @@ -1463,7 +1463,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": [], "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"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "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 @@ -1471,7 +1471,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": [], "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"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "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