diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index d829783224a..e11d56f929c 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.java b/examples/v1/dashboards/CreateDashboard_153558925.java new file mode 100644 index 00000000000..7cfd98eb345 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_153558925.java @@ -0,0 +1,82 @@ +// Create a new dashboard with logs_transaction_stream list_stream widget and version + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.DashboardsApi; +import com.datadog.api.client.v1.model.Dashboard; +import com.datadog.api.client.v1.model.DashboardLayoutType; +import com.datadog.api.client.v1.model.ListStreamColumn; +import com.datadog.api.client.v1.model.ListStreamColumnWidth; +import com.datadog.api.client.v1.model.ListStreamComputeAggregation; +import com.datadog.api.client.v1.model.ListStreamComputeItems; +import com.datadog.api.client.v1.model.ListStreamGroupByItems; +import com.datadog.api.client.v1.model.ListStreamQuery; +import com.datadog.api.client.v1.model.ListStreamQueryVersion; +import com.datadog.api.client.v1.model.ListStreamResponseFormat; +import com.datadog.api.client.v1.model.ListStreamSource; +import com.datadog.api.client.v1.model.ListStreamWidgetDefinition; +import com.datadog.api.client.v1.model.ListStreamWidgetDefinitionType; +import com.datadog.api.client.v1.model.ListStreamWidgetRequest; +import com.datadog.api.client.v1.model.Widget; +import com.datadog.api.client.v1.model.WidgetDefinition; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + Dashboard body = + new Dashboard() + .layoutType(DashboardLayoutType.ORDERED) + .title("Example-Dashboard with list_stream widget") + .widgets( + Collections.singletonList( + new Widget() + .definition( + new WidgetDefinition( + new ListStreamWidgetDefinition() + .type(ListStreamWidgetDefinitionType.LIST_STREAM) + .requests( + Collections.singletonList( + new ListStreamWidgetRequest() + .columns( + Collections.singletonList( + new ListStreamColumn() + .width(ListStreamColumnWidth.AUTO) + .field("timestamp"))) + .query( + new ListStreamQuery() + .dataSource( + ListStreamSource + .LOGS_TRANSACTION_STREAM) + .queryString("") + .groupBy( + Collections.singletonList( + new ListStreamGroupByItems() + .facet("service"))) + .compute( + Collections.singletonList( + new ListStreamComputeItems() + .facet("service") + .aggregation( + ListStreamComputeAggregation + .COUNT))) + .version( + ListStreamQueryVersion + .SEQUENTIAL_QUERY)) + .responseFormat( + ListStreamResponseFormat.EVENT_LIST))))))); + + try { + Dashboard result = apiInstance.createDashboard(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DashboardsApi#createDashboard"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/ListStreamQuery.java b/src/main/java/com/datadog/api/client/v1/model/ListStreamQuery.java index 2b2d13f72d5..7e0dfc21e40 100644 --- a/src/main/java/com/datadog/api/client/v1/model/ListStreamQuery.java +++ b/src/main/java/com/datadog/api/client/v1/model/ListStreamQuery.java @@ -34,7 +34,8 @@ ListStreamQuery.JSON_PROPERTY_STATES, ListStreamQuery.JSON_PROPERTY_STORAGE, ListStreamQuery.JSON_PROPERTY_SUSPECTED_CAUSES, - ListStreamQuery.JSON_PROPERTY_TEAM_HANDLES + ListStreamQuery.JSON_PROPERTY_TEAM_HANDLES, + ListStreamQuery.JSON_PROPERTY_VERSION }) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") @@ -83,6 +84,9 @@ public class ListStreamQuery { public static final String JSON_PROPERTY_TEAM_HANDLES = "team_handles"; private List teamHandles = null; + public static final String JSON_PROPERTY_VERSION = "version"; + private ListStreamQueryVersion version; + public ListStreamQuery() {} @JsonCreator @@ -468,6 +472,33 @@ public void setTeamHandles(List teamHandles) { this.teamHandles = teamHandles; } + public ListStreamQuery version(ListStreamQueryVersion version) { + this.version = version; + this.unparsed |= !version.isValid(); + return this; + } + + /** + * 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. + * + * @return version + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ListStreamQueryVersion getVersion() { + return version; + } + + public void setVersion(ListStreamQueryVersion version) { + if (!version.isValid()) { + this.unparsed = true; + } + this.version = version; + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -539,6 +570,7 @@ public boolean equals(Object o) { && Objects.equals(this.storage, listStreamQuery.storage) && Objects.equals(this.suspectedCauses, listStreamQuery.suspectedCauses) && Objects.equals(this.teamHandles, listStreamQuery.teamHandles) + && Objects.equals(this.version, listStreamQuery.version) && Objects.equals(this.additionalProperties, listStreamQuery.additionalProperties); } @@ -559,6 +591,7 @@ public int hashCode() { storage, suspectedCauses, teamHandles, + version, additionalProperties); } @@ -582,6 +615,7 @@ public String toString() { sb.append(" storage: ").append(toIndentedString(storage)).append("\n"); sb.append(" suspectedCauses: ").append(toIndentedString(suspectedCauses)).append("\n"); sb.append(" teamHandles: ").append(toIndentedString(teamHandles)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); diff --git a/src/main/java/com/datadog/api/client/v1/model/ListStreamQueryVersion.java b/src/main/java/com/datadog/api/client/v1/model/ListStreamQueryVersion.java new file mode 100644 index 00000000000..dd63426df7b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/ListStreamQueryVersion.java @@ -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. + */ + +package com.datadog.api.client.v1.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * 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. + */ +@JsonSerialize(using = ListStreamQueryVersion.ListStreamQueryVersionSerializer.class) +public class ListStreamQueryVersion extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("sequential_query")); + + public static final ListStreamQueryVersion SEQUENTIAL_QUERY = + new ListStreamQueryVersion("sequential_query"); + + ListStreamQueryVersion(String value) { + super(value, allowedValues); + } + + public static class ListStreamQueryVersionSerializer + extends StdSerializer { + public ListStreamQueryVersionSerializer(Class t) { + super(t); + } + + public ListStreamQueryVersionSerializer() { + this(null); + } + + @Override + public void serialize( + ListStreamQueryVersion value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ListStreamQueryVersion fromValue(String value) { + return new ListStreamQueryVersion(value); + } +} diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.freeze new file mode 100644 index 00000000000..8fa8e29815b --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.freeze @@ -0,0 +1 @@ +2026-06-30T18:19:26.621Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.json b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.json new file mode 100644 index 00000000000..95a9f18de23 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_logs_transaction_stream_list_stream_widget_and_version.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "7d2dcbfd-4f25-70cd-30d2-db347a6251ab" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/dashboard/72a-q2p-zau", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_dashboard_id\":\"72a-q2p-zau\"}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6ad9f4e6-a510-1411-4aa4-81cf0551672f" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature index 932dc22b0b3..42df30e0a6f 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/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