diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index d829783224..e11d56f929 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -5807,10 +5807,21 @@ components: description: Team handle. type: string type: array + version: + $ref: "#/components/schemas/ListStreamQueryVersion" required: - query_string - data_source type: object + ListStreamQueryVersion: + description: |- + Version of the query for the logs transaction stream widget. When omitted, v1 query behavior is + preserved. Set to `sequential_query` to use v2 behavior. **This feature is in Preview.** + enum: + - sequential_query + type: string + x-enum-varnames: + - SEQUENTIAL_QUERY ListStreamResponseFormat: description: Widget response format. enum: diff --git a/examples/v1/dashboards/CreateDashboard_153558925.py b/examples/v1/dashboards/CreateDashboard_153558925.py new file mode 100644 index 0000000000..7db3c75fec --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_153558925.py @@ -0,0 +1,67 @@ +""" +Create a new dashboard with logs_transaction_stream list_stream widget and version +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.dashboards_api import DashboardsApi +from datadog_api_client.v1.model.dashboard import Dashboard +from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType +from datadog_api_client.v1.model.list_stream_column import ListStreamColumn +from datadog_api_client.v1.model.list_stream_column_width import ListStreamColumnWidth +from datadog_api_client.v1.model.list_stream_compute_aggregation import ListStreamComputeAggregation +from datadog_api_client.v1.model.list_stream_compute_items import ListStreamComputeItems +from datadog_api_client.v1.model.list_stream_group_by_items import ListStreamGroupByItems +from datadog_api_client.v1.model.list_stream_query import ListStreamQuery +from datadog_api_client.v1.model.list_stream_query_version import ListStreamQueryVersion +from datadog_api_client.v1.model.list_stream_response_format import ListStreamResponseFormat +from datadog_api_client.v1.model.list_stream_source import ListStreamSource +from datadog_api_client.v1.model.list_stream_widget_definition import ListStreamWidgetDefinition +from datadog_api_client.v1.model.list_stream_widget_definition_type import ListStreamWidgetDefinitionType +from datadog_api_client.v1.model.list_stream_widget_request import ListStreamWidgetRequest +from datadog_api_client.v1.model.widget import Widget + +body = Dashboard( + layout_type=DashboardLayoutType.ORDERED, + title="Example-Dashboard with list_stream widget", + widgets=[ + Widget( + definition=ListStreamWidgetDefinition( + type=ListStreamWidgetDefinitionType.LIST_STREAM, + requests=[ + ListStreamWidgetRequest( + columns=[ + ListStreamColumn( + width=ListStreamColumnWidth.AUTO, + field="timestamp", + ), + ], + query=ListStreamQuery( + data_source=ListStreamSource.LOGS_TRANSACTION_STREAM, + query_string="", + group_by=[ + ListStreamGroupByItems( + facet="service", + ), + ], + compute=[ + ListStreamComputeItems( + facet="service", + aggregation=ListStreamComputeAggregation.COUNT, + ), + ], + version=ListStreamQueryVersion.SEQUENTIAL_QUERY, + ), + response_format=ListStreamResponseFormat.EVENT_LIST, + ), + ], + ), + ), + ], +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = DashboardsApi(api_client) + response = api_instance.create_dashboard(body=body) + + print(response) diff --git a/src/datadog_api_client/v1/model/list_stream_query.py b/src/datadog_api_client/v1/model/list_stream_query.py index 5adb4e99df..2e59c635fc 100644 --- a/src/datadog_api_client/v1/model/list_stream_query.py +++ b/src/datadog_api_client/v1/model/list_stream_query.py @@ -21,6 +21,7 @@ from datadog_api_client.v1.model.list_stream_issue_persona import ListStreamIssuePersona from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort from datadog_api_client.v1.model.list_stream_issue_state import ListStreamIssueState + from datadog_api_client.v1.model.list_stream_query_version import ListStreamQueryVersion class ListStreamQuery(ModelNormal): @@ -43,6 +44,7 @@ def openapi_types(_): from datadog_api_client.v1.model.list_stream_issue_persona import ListStreamIssuePersona from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort from datadog_api_client.v1.model.list_stream_issue_state import ListStreamIssueState + from datadog_api_client.v1.model.list_stream_query_version import ListStreamQueryVersion return { "assignee_uuids": ([str],), @@ -59,6 +61,7 @@ def openapi_types(_): "storage": (str,), "suspected_causes": ([str],), "team_handles": ([str],), + "version": (ListStreamQueryVersion,), } attribute_map = { @@ -76,6 +79,7 @@ def openapi_types(_): "storage": "storage", "suspected_causes": "suspected_causes", "team_handles": "team_handles", + "version": "version", } def __init__( @@ -94,6 +98,7 @@ def __init__( storage: Union[str, UnsetType] = unset, suspected_causes: Union[List[str], UnsetType] = unset, team_handles: Union[List[str], UnsetType] = unset, + version: Union[ListStreamQueryVersion, UnsetType] = unset, **kwargs, ): """ @@ -140,6 +145,10 @@ def __init__( :param team_handles: Filter by team handles. Usable only with ``issue_stream``. :type team_handles: [str], optional + + :param version: Version of the query for the logs transaction stream widget. When omitted, v1 query behavior is + preserved. Set to ``sequential_query`` to use v2 behavior. **This feature is in Preview.** + :type version: ListStreamQueryVersion, optional """ if assignee_uuids is not unset: kwargs["assignee_uuids"] = assignee_uuids @@ -165,6 +174,8 @@ def __init__( kwargs["suspected_causes"] = suspected_causes if team_handles is not unset: kwargs["team_handles"] = team_handles + if version is not unset: + kwargs["version"] = version super().__init__(kwargs) self_.data_source = data_source diff --git a/src/datadog_api_client/v1/model/list_stream_query_version.py b/src/datadog_api_client/v1/model/list_stream_query_version.py new file mode 100644 index 0000000000..7c96753866 --- /dev/null +++ b/src/datadog_api_client/v1/model/list_stream_query_version.py @@ -0,0 +1,36 @@ +# 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 ListStreamQueryVersion(ModelSimple): + """ + Version of the query for the logs transaction stream widget. When omitted, v1 query behavior is + preserved. Set to `sequential_query` to use v2 behavior. **This feature is in Preview.** + + :param value: If omitted defaults to "sequential_query". Must be one of ["sequential_query"]. + :type value: str + """ + + allowed_values = { + "sequential_query", + } + SEQUENTIAL_QUERY: ClassVar["ListStreamQueryVersion"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ListStreamQueryVersion.SEQUENTIAL_QUERY = ListStreamQueryVersion("sequential_query") diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 8736815702..0611a0942c 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -315,6 +315,7 @@ from datadog_api_client.v1.model.list_stream_issue_persona import ListStreamIssuePersona from datadog_api_client.v1.model.list_stream_issue_state import ListStreamIssueState from datadog_api_client.v1.model.list_stream_query import ListStreamQuery +from datadog_api_client.v1.model.list_stream_query_version import ListStreamQueryVersion from datadog_api_client.v1.model.list_stream_response_format import ListStreamResponseFormat from datadog_api_client.v1.model.list_stream_source import ListStreamSource from datadog_api_client.v1.model.list_stream_widget_definition import ListStreamWidgetDefinition @@ -1665,6 +1666,7 @@ "ListStreamIssuePersona", "ListStreamIssueState", "ListStreamQuery", + "ListStreamQueryVersion", "ListStreamResponseFormat", "ListStreamSource", "ListStreamWidgetDefinition", diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.frozen new file mode 100644 index 0000000000..8fa8e29815 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.frozen @@ -0,0 +1 @@ +2026-06-30T18:19:26.621Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.yaml new file mode 100644 index 0000000000..ea00cfb507 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version-1782843566 + with list_stream widget","widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"compute":[{"aggregation":"count","facet":"service"}],"data_source":"logs_transaction_stream","group_by":[{"facet":"service"}],"query_string":"","version":"sequential_query"},"response_format":"event_list"}],"type":"list_stream"}}]}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/dashboard + response: + body: + string: '{"id":"72a-q2p-zau","title":"Test-Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version-1782843566 + with list_stream widget","description":null,"author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI + Account","layout_type":"ordered","url":"/dashboard/72a-q2p-zau/test-createanewdashboardwithlogstransactionstreamliststreamwidgetandversion-1782","template_variables":null,"widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"compute":[{"aggregation":"count","facet":"service"}],"data_source":"logs_transaction_stream","group_by":[{"facet":"service"}],"query_string":"","version":"sequential_query"},"response_format":"event_list"}],"type":"list_stream"},"id":7740630869906828}],"notify_list":null,"created_at":"2026-06-30T18:19:26.794909+00:00","modified_at":"2026-06-30T18:19:26.794909+00:00","restricted_roles":[]}' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/dashboard/72a-q2p-zau + response: + body: + string: '{"deleted_dashboard_id":"72a-q2p-zau"}' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/features/dashboards.feature b/tests/v1/features/dashboards.feature index 932dc22b0b..42df30e0a6 100644 --- a/tests/v1/features/dashboards.feature +++ b/tests/v1/features/dashboards.feature @@ -721,6 +721,15 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].query.compute[0].facet" is equal to "service" And the response "widgets[0].definition.requests[0].query.compute[0].aggregation" is equal to "count" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with logs_transaction_stream list_stream widget and version + Given new "CreateDashboard" request + And body with value {"layout_type": "ordered", "title": "{{ unique }} with list_stream widget","widgets": [{"definition": {"type": "list_stream","requests": [{"columns":[{"width":"auto","field":"timestamp"}],"query":{"data_source":"logs_transaction_stream","query_string":"","group_by":[{"facet":"service"}],"compute":[{"facet":"service","aggregation":"count"}],"version":"sequential_query"},"response_format":"event_list"}]}}]} + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests[0].query.data_source" is equal to "logs_transaction_stream" + And the response "widgets[0].definition.requests[0].query.version" is equal to "sequential_query" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with manage_status widget Given new "CreateDashboard" request