diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ed984a56d0e..87a6ec93802 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -30970,6 +30970,257 @@ components: example: 1722439510282 format: int64 type: integer + DdsqlTabularQueryColumn: + description: A single column of a DDSQL tabular query result. + properties: + name: + description: Name of the column as projected by the SQL statement. + example: service + type: string + type: + description: |- + DDSQL data type of the column's values, for example `VARCHAR`, `BIGINT`, + `DECIMAL`, `BOOLEAN`, `TIMESTAMP`, `JSON`, or an array variant such as + `VARCHAR[]`. See the + [DDSQL data-types reference](https://docs.datadoghq.com/ddsql_reference/#data-types) + for the full, up-to-date list. + example: VARCHAR + type: string + values: + description: |- + Column values in row order. The element type matches the column's `type`; + for example a `VARCHAR` column carries strings, a `TIMESTAMP` column carries + Unix-millisecond integers. `null` is allowed for missing values. + example: + - web-store + - checkout + items: {} + type: array + required: + - name + - type + - values + type: object + DdsqlTabularQueryColumns: + description: |- + Column-major result set. Each element carries one column's name, type, and values, + with one value per row of the result. Set when `state` is `completed`. + items: + $ref: "#/components/schemas/DdsqlTabularQueryColumn" + type: array + DdsqlTabularQueryFetchRequest: + description: Wrapper for a DDSQL tabular query fetch request. + properties: + data: + $ref: "#/components/schemas/DdsqlTabularQueryFetchRequestData" + required: + - data + type: object + DdsqlTabularQueryFetchRequestAttributes: + description: Attributes describing which previously submitted DDSQL query to fetch. + properties: + query_id: + description: |- + Opaque token returned by an earlier execute or fetch response that carried + `state: running`. Identifies the query to poll for results. + example: "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==" + type: string + required: + - query_id + type: object + DdsqlTabularQueryFetchRequestData: + description: JSON:API resource object for a DDSQL tabular query fetch request. + properties: + attributes: + $ref: "#/components/schemas/DdsqlTabularQueryFetchRequestAttributes" + type: + $ref: "#/components/schemas/DdsqlTabularQueryFetchRequestType" + required: + - type + - attributes + type: object + DdsqlTabularQueryFetchRequestType: + default: ddsql_query_fetch_request + description: JSON:API resource type for a DDSQL tabular query fetch request. + enum: + - ddsql_query_fetch_request + example: ddsql_query_fetch_request + type: string + x-enum-varnames: + - DDSQL_QUERY_FETCH_REQUEST + DdsqlTabularQueryRequest: + description: Wrapper for a DDSQL tabular query execution request. + properties: + data: + $ref: "#/components/schemas/DdsqlTabularQueryRequestData" + required: + - data + type: object + DdsqlTabularQueryRequestAttributes: + description: Attributes describing the DDSQL query to execute. + properties: + query: + description: |- + The DDSQL statement to execute. DDSQL is Datadog's SQL dialect, which is a subset + of PostgreSQL, scoped to Datadog data sources. + example: "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider" + type: string + row_limit: + description: |- + Cap on the number of rows returned. Defaults to 5,000 when omitted. Must be + between 1 and 10,000 inclusive; values outside this range are rejected with 400. + example: 1000 + format: int64 + maximum: 10000 + minimum: 1 + type: integer + time: + $ref: "#/components/schemas/DdsqlTabularQueryTimeWindow" + required: + - query + - time + type: object + DdsqlTabularQueryRequestData: + description: JSON:API resource object for a DDSQL tabular query execution request. + properties: + attributes: + $ref: "#/components/schemas/DdsqlTabularQueryRequestAttributes" + type: + $ref: "#/components/schemas/DdsqlTabularQueryRequestType" + required: + - type + - attributes + type: object + DdsqlTabularQueryRequestType: + default: ddsql_query_request + description: JSON:API resource type for a DDSQL tabular query request. + enum: + - ddsql_query_request + example: ddsql_query_request + type: string + x-enum-varnames: + - DDSQL_QUERY_REQUEST + DdsqlTabularQueryResponse: + description: |- + Response envelope for both the execute and fetch DDSQL tabular query endpoints. + Carries the JSON:API primary resource and a top-level `meta` block with + request-scoped observability handles. + properties: + data: + $ref: "#/components/schemas/DdsqlTabularQueryResponseData" + meta: + $ref: "#/components/schemas/DdsqlTabularQueryResponseMeta" + required: + - data + - meta + type: object + DdsqlTabularQueryResponseAttributes: + description: |- + Attributes of a DDSQL tabular query response. `query_id` is set when + `state` is `running`; `columns` is set when `state` is `completed`. + properties: + columns: + $ref: "#/components/schemas/DdsqlTabularQueryColumns" + query_id: + description: |- + Opaque token to pass to the fetch endpoint to poll for results. + Set when `state` is `running` and absent when `state` is `completed`. + example: "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==" + type: string + state: + $ref: "#/components/schemas/DdsqlTabularQueryState" + warnings: + $ref: "#/components/schemas/DdsqlTabularQueryWarnings" + required: + - state + type: object + DdsqlTabularQueryResponseData: + description: JSON:API resource object for a DDSQL tabular query response. + properties: + attributes: + $ref: "#/components/schemas/DdsqlTabularQueryResponseAttributes" + id: + description: Stable identifier for the query response resource. + example: "00000000-0000-0000-0000-000000000000" + type: string + type: + $ref: "#/components/schemas/DdsqlTabularQueryResponseType" + required: + - id + - type + - attributes + type: object + DdsqlTabularQueryResponseMeta: + description: |- + Top-level JSON:API meta block accompanying every DDSQL tabular query response. + Carries standard observability handles for client-side correlation. + properties: + elapsed: + description: Server-side time spent serving this request, in milliseconds. + example: 87 + format: int64 + type: integer + request_id: + description: |- + Echo of the `DD-Request-ID` header assigned by Datadog's edge to this request, + for support correlation. + example: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7082" + type: string + required: + - elapsed + - request_id + type: object + DdsqlTabularQueryResponseType: + default: ddsql_query_response + description: JSON:API resource type for a DDSQL tabular query response. + enum: + - ddsql_query_response + example: ddsql_query_response + type: string + x-enum-varnames: + - DDSQL_QUERY_RESPONSE + DdsqlTabularQueryState: + description: |- + Lifecycle state of a DDSQL tabular query response. + `running` means the query is still executing and the client should poll + the fetch endpoint with the returned `query_id`. `completed` means the + result set is inlined in `columns` and no further polling is required. + enum: + - running + - completed + example: completed + type: string + x-enum-varnames: + - RUNNING + - COMPLETED + DdsqlTabularQueryTimeWindow: + description: |- + Time window scoping the underlying data sources, expressed in Unix milliseconds + since the epoch. Inclusive on `from_timestamp`, exclusive on `to_timestamp`. + Results from static tables (for example, `dd.hosts`) are not affected by the + time window, but the field must still be provided. + properties: + from_timestamp: + description: Start of the query window (inclusive), in Unix milliseconds since the epoch. + example: 1736942400000 + format: int64 + type: integer + to_timestamp: + description: End of the query window (exclusive), in Unix milliseconds since the epoch. + example: 1736946000000 + format: int64 + type: integer + required: + - from_timestamp + - to_timestamp + type: object + DdsqlTabularQueryWarnings: + description: Non-fatal messages emitted by the query engine while serving this response. + items: + description: A single non-fatal warning message. + example: "Query result was truncated at the configured row_limit." + type: string + type: array DefaultRulesetsPerLanguageData: description: The primary data object in the default rulesets per language response. properties: @@ -133778,6 +134029,231 @@ paths: x-unstable: |- **Note: Data Access is in preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).** + /api/v2/ddsql/query/tabular: + post: + description: |- + Submit a DDSQL statement and return either a `running` state with an opaque `query_id` + for the client to poll, or a `completed` state with the column-major result set inlined + when the query finishes quickly enough to be served synchronously. + operationId: ExecuteDdsqlTabularQuery + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + query: "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider" + row_limit: 1000 + time: + from_timestamp: 1736942400000 + to_timestamp: 1736946000000 + type: ddsql_query_request + schema: + $ref: "#/components/schemas/DdsqlTabularQueryRequest" + required: true + responses: + "200": + content: + application/json: + examples: + completed: + summary: Query finished synchronously + value: + data: + attributes: + columns: + - name: service + type: VARCHAR + values: + - web-store + - checkout + - name: count + type: BIGINT + values: + - 1024 + - 512 + state: completed + id: "00000000-0000-0000-0000-000000000000" + type: ddsql_query_response + meta: + elapsed: 318 + request_id: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7081" + default: + summary: Query finished synchronously + value: + data: + attributes: + columns: + - name: service + type: VARCHAR + values: + - web-store + - checkout + - name: count + type: BIGINT + values: + - 1024 + - 512 + state: completed + id: "00000000-0000-0000-0000-000000000000" + type: ddsql_query_response + meta: + elapsed: 318 + request_id: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7081" + running: + summary: Query still executing + value: + data: + attributes: + query_id: "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==" + state: running + id: "00000000-0000-0000-0000-000000000000" + type: ddsql_query_response + meta: + elapsed: 42 + request_id: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7081" + schema: + $ref: "#/components/schemas/DdsqlTabularQueryResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + summary: Execute a tabular DDSQL query + tags: + - DDSQL + 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/ddsql/query/tabular/fetch: + post: + description: |- + Poll a previously submitted DDSQL query for results. Pass the opaque `query_id` returned + by a prior `ExecuteDdsqlTabularQuery` (or by a prior `FetchDdsqlTabularQuery` that + returned `state: running`) and the server returns either a `running` state to poll again + or a `completed` state with the column-major result set inlined. + operationId: FetchDdsqlTabularQuery + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + query_id: "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==" + type: ddsql_query_fetch_request + schema: + $ref: "#/components/schemas/DdsqlTabularQueryFetchRequest" + required: true + responses: + "200": + content: + application/json: + examples: + completed: + summary: Query finished + value: + data: + attributes: + columns: + - name: service + type: VARCHAR + values: + - web-store + - checkout + - name: count + type: BIGINT + values: + - 1024 + - 512 + state: completed + id: "00000000-0000-0000-0000-000000000000" + type: ddsql_query_response + meta: + elapsed: 87 + request_id: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7082" + default: + summary: Query finished + value: + data: + attributes: + columns: + - name: service + type: VARCHAR + values: + - web-store + - checkout + - name: count + type: BIGINT + values: + - 1024 + - 512 + state: completed + id: "00000000-0000-0000-0000-000000000000" + type: ddsql_query_response + meta: + elapsed: 87 + request_id: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7082" + running: + summary: Query still executing + value: + data: + attributes: + query_id: "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==" + state: running + id: "00000000-0000-0000-0000-000000000000" + type: ddsql_query_response + meta: + elapsed: 12 + request_id: "req-7f3e7d2c-1a0b-4d3e-9b2a-3c4d5e6f7082" + schema: + $ref: "#/components/schemas/DdsqlTabularQueryResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Internal Server Error + summary: Fetch the result of a DDSQL query + tags: + - DDSQL + 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/deletion/data/{product}: post: description: Creates a data deletion request by providing a query and a timeframe targeting the proper data. @@ -201794,6 +202270,12 @@ tags: Programmatic management of a customer's Datadog organization. Use this API to perform self-service organization lifecycle actions such as disabling the authenticated org. name: Customer Org + - description: |- + Execute DDSQL queries against the Datadog data catalog and poll for their results. + Queries are dispatched asynchronously: the initial request may return a `running` state with + a `query_id`, and clients poll the fetch endpoint until the response transitions to + `completed` with a column-major result set. + name: DDSQL - description: |- Search, send, or delete events for DORA Metrics to measure and improve your software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/) for more information. diff --git a/examples/v2/ddsql/ExecuteDdsqlTabularQuery.java b/examples/v2/ddsql/ExecuteDdsqlTabularQuery.java new file mode 100644 index 00000000000..0a3081f4b96 --- /dev/null +++ b/examples/v2/ddsql/ExecuteDdsqlTabularQuery.java @@ -0,0 +1,46 @@ +// Execute a tabular DDSQL query returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DdsqlApi; +import com.datadog.api.client.v2.model.DdsqlTabularQueryRequest; +import com.datadog.api.client.v2.model.DdsqlTabularQueryRequestAttributes; +import com.datadog.api.client.v2.model.DdsqlTabularQueryRequestData; +import com.datadog.api.client.v2.model.DdsqlTabularQueryRequestType; +import com.datadog.api.client.v2.model.DdsqlTabularQueryResponse; +import com.datadog.api.client.v2.model.DdsqlTabularQueryTimeWindow; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.executeDdsqlTabularQuery", true); + DdsqlApi apiInstance = new DdsqlApi(defaultClient); + + DdsqlTabularQueryRequest body = + new DdsqlTabularQueryRequest() + .data( + new DdsqlTabularQueryRequestData() + .attributes( + new DdsqlTabularQueryRequestAttributes() + .query( + "SELECT cloud_provider, count(*) FROM dd.hosts group by" + + " cloud_provider") + .rowLimit(1000L) + .time( + new DdsqlTabularQueryTimeWindow() + .fromTimestamp(1736942400000L) + .toTimestamp(1736946000000L))) + .type(DdsqlTabularQueryRequestType.DDSQL_QUERY_REQUEST)); + + try { + DdsqlTabularQueryResponse result = apiInstance.executeDdsqlTabularQuery(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DdsqlApi#executeDdsqlTabularQuery"); + 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/examples/v2/ddsql/FetchDdsqlTabularQuery.java b/examples/v2/ddsql/FetchDdsqlTabularQuery.java new file mode 100644 index 00000000000..9e4c904dbc2 --- /dev/null +++ b/examples/v2/ddsql/FetchDdsqlTabularQuery.java @@ -0,0 +1,38 @@ +// Fetch the result of a DDSQL query returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.DdsqlApi; +import com.datadog.api.client.v2.model.DdsqlTabularQueryFetchRequest; +import com.datadog.api.client.v2.model.DdsqlTabularQueryFetchRequestAttributes; +import com.datadog.api.client.v2.model.DdsqlTabularQueryFetchRequestData; +import com.datadog.api.client.v2.model.DdsqlTabularQueryFetchRequestType; +import com.datadog.api.client.v2.model.DdsqlTabularQueryResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.fetchDdsqlTabularQuery", true); + DdsqlApi apiInstance = new DdsqlApi(defaultClient); + + DdsqlTabularQueryFetchRequest body = + new DdsqlTabularQueryFetchRequest() + .data( + new DdsqlTabularQueryFetchRequestData() + .attributes( + new DdsqlTabularQueryFetchRequestAttributes() + .queryId("eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==")) + .type(DdsqlTabularQueryFetchRequestType.DDSQL_QUERY_FETCH_REQUEST)); + + try { + DdsqlTabularQueryResponse result = apiInstance.fetchDdsqlTabularQuery(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DdsqlApi#fetchDdsqlTabularQuery"); + 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/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index dacb988dec6..ecd6eaa113b 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1039,6 +1039,8 @@ public class ApiClient { put("v2.getAllDatasets", false); put("v2.getDataset", false); put("v2.updateDataset", false); + put("v2.executeDdsqlTabularQuery", false); + put("v2.fetchDdsqlTabularQuery", false); put("v2.cancelDataDeletionRequest", false); put("v2.createDataDeletionRequest", false); put("v2.getDataDeletionRequests", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/DdsqlApi.java b/src/main/java/com/datadog/api/client/v2/api/DdsqlApi.java new file mode 100644 index 00000000000..9c5cd2e2348 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/api/DdsqlApi.java @@ -0,0 +1,355 @@ +package com.datadog.api.client.v2.api; + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.ApiResponse; +import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.DdsqlTabularQueryFetchRequest; +import com.datadog.api.client.v2.model.DdsqlTabularQueryRequest; +import com.datadog.api.client.v2.model.DdsqlTabularQueryResponse; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.core.GenericType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlApi { + private ApiClient apiClient; + + public DdsqlApi() { + this(ApiClient.getDefaultApiClient()); + } + + public DdsqlApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Get the API client. + * + * @return API client + */ + public ApiClient getApiClient() { + return apiClient; + } + + /** + * Set the API client. + * + * @param apiClient an instance of API client + */ + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Execute a tabular DDSQL query. + * + *

See {@link #executeDdsqlTabularQueryWithHttpInfo}. + * + * @param body (required) + * @return DdsqlTabularQueryResponse + * @throws ApiException if fails to make API call + */ + public DdsqlTabularQueryResponse executeDdsqlTabularQuery(DdsqlTabularQueryRequest body) + throws ApiException { + return executeDdsqlTabularQueryWithHttpInfo(body).getData(); + } + + /** + * Execute a tabular DDSQL query. + * + *

See {@link #executeDdsqlTabularQueryWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<DdsqlTabularQueryResponse> + */ + public CompletableFuture executeDdsqlTabularQueryAsync( + DdsqlTabularQueryRequest body) { + return executeDdsqlTabularQueryWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Submit a DDSQL statement and return either a running state with an opaque + * query_id for the client to poll, or a completed state with the column-major + * result set inlined when the query finishes quickly enough to be served synchronously. + * + * @param body (required) + * @return ApiResponse<DdsqlTabularQueryResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
429 Too many requests -
500 Internal Server Error -
+ */ + public ApiResponse executeDdsqlTabularQueryWithHttpInfo( + DdsqlTabularQueryRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "executeDdsqlTabularQuery"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling executeDdsqlTabularQuery"); + } + // create path and map variables + String localVarPath = "/api/v2/ddsql/query/tabular"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DdsqlApi.executeDdsqlTabularQuery", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Execute a tabular DDSQL query. + * + *

See {@link #executeDdsqlTabularQueryWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<DdsqlTabularQueryResponse>> + */ + public CompletableFuture> + executeDdsqlTabularQueryWithHttpInfoAsync(DdsqlTabularQueryRequest body) { + // Check if unstable operation is enabled + String operationId = "executeDdsqlTabularQuery"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling executeDdsqlTabularQuery")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/ddsql/query/tabular"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DdsqlApi.executeDdsqlTabularQuery", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Fetch the result of a DDSQL query. + * + *

See {@link #fetchDdsqlTabularQueryWithHttpInfo}. + * + * @param body (required) + * @return DdsqlTabularQueryResponse + * @throws ApiException if fails to make API call + */ + public DdsqlTabularQueryResponse fetchDdsqlTabularQuery(DdsqlTabularQueryFetchRequest body) + throws ApiException { + return fetchDdsqlTabularQueryWithHttpInfo(body).getData(); + } + + /** + * Fetch the result of a DDSQL query. + * + *

See {@link #fetchDdsqlTabularQueryWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<DdsqlTabularQueryResponse> + */ + public CompletableFuture fetchDdsqlTabularQueryAsync( + DdsqlTabularQueryFetchRequest body) { + return fetchDdsqlTabularQueryWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Poll a previously submitted DDSQL query for results. Pass the opaque query_id + * returned by a prior ExecuteDdsqlTabularQuery (or by a prior + * FetchDdsqlTabularQuery that returned state: running) and the server returns + * either a running state to poll again or a completed state with the + * column-major result set inlined. + * + * @param body (required) + * @return ApiResponse<DdsqlTabularQueryResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
429 Too many requests -
500 Internal Server Error -
+ */ + public ApiResponse fetchDdsqlTabularQueryWithHttpInfo( + DdsqlTabularQueryFetchRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "fetchDdsqlTabularQuery"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling fetchDdsqlTabularQuery"); + } + // create path and map variables + String localVarPath = "/api/v2/ddsql/query/tabular/fetch"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DdsqlApi.fetchDdsqlTabularQuery", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Fetch the result of a DDSQL query. + * + *

See {@link #fetchDdsqlTabularQueryWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<DdsqlTabularQueryResponse>> + */ + public CompletableFuture> + fetchDdsqlTabularQueryWithHttpInfoAsync(DdsqlTabularQueryFetchRequest body) { + // Check if unstable operation is enabled + String operationId = "fetchDdsqlTabularQuery"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling fetchDdsqlTabularQuery")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/ddsql/query/tabular/fetch"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DdsqlApi.fetchDdsqlTabularQuery", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryColumn.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryColumn.java new file mode 100644 index 00000000000..3c509ab5747 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryColumn.java @@ -0,0 +1,214 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A single column of a DDSQL tabular query result. */ +@JsonPropertyOrder({ + DdsqlTabularQueryColumn.JSON_PROPERTY_NAME, + DdsqlTabularQueryColumn.JSON_PROPERTY_TYPE, + DdsqlTabularQueryColumn.JSON_PROPERTY_VALUES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryColumn { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_VALUES = "values"; + private List values = new ArrayList<>(); + + public DdsqlTabularQueryColumn() {} + + @JsonCreator + public DdsqlTabularQueryColumn( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type, + @JsonProperty(required = true, value = JSON_PROPERTY_VALUES) List values) { + this.name = name; + this.type = type; + this.values = values; + } + + public DdsqlTabularQueryColumn name(String name) { + this.name = name; + return this; + } + + /** + * Name of the column as projected by the SQL statement. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DdsqlTabularQueryColumn type(String type) { + this.type = type; + return this; + } + + /** + * DDSQL data type of the column's values, for example VARCHAR, BIGINT, + * DECIMAL, BOOLEAN, TIMESTAMP, JSON, or an + * array variant such as VARCHAR[]. See the DDSQL data-types reference + * for the full, up-to-date list. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public DdsqlTabularQueryColumn values(List values) { + this.values = values; + return this; + } + + public DdsqlTabularQueryColumn addValuesItem(Object valuesItem) { + this.values.add(valuesItem); + return this; + } + + /** + * Column values in row order. The element type matches the column's type; for + * example a VARCHAR column carries strings, a TIMESTAMP column carries + * Unix-millisecond integers. null is allowed for missing values. + * + * @return values + */ + @JsonProperty(JSON_PROPERTY_VALUES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryColumn + */ + @JsonAnySetter + public DdsqlTabularQueryColumn putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryColumn object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryColumn ddsqlTabularQueryColumn = (DdsqlTabularQueryColumn) o; + return Objects.equals(this.name, ddsqlTabularQueryColumn.name) + && Objects.equals(this.type, ddsqlTabularQueryColumn.type) + && Objects.equals(this.values, ddsqlTabularQueryColumn.values) + && Objects.equals(this.additionalProperties, ddsqlTabularQueryColumn.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, values, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryColumn {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequest.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequest.java new file mode 100644 index 00000000000..83aa387f146 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequest.java @@ -0,0 +1,150 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Wrapper for a DDSQL tabular query fetch request. */ +@JsonPropertyOrder({DdsqlTabularQueryFetchRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryFetchRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DdsqlTabularQueryFetchRequestData data; + + public DdsqlTabularQueryFetchRequest() {} + + @JsonCreator + public DdsqlTabularQueryFetchRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + DdsqlTabularQueryFetchRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public DdsqlTabularQueryFetchRequest data(DdsqlTabularQueryFetchRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * JSON:API resource object for a DDSQL tabular query fetch request. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryFetchRequestData getData() { + return data; + } + + public void setData(DdsqlTabularQueryFetchRequestData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryFetchRequest + */ + @JsonAnySetter + public DdsqlTabularQueryFetchRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryFetchRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryFetchRequest ddsqlTabularQueryFetchRequest = (DdsqlTabularQueryFetchRequest) o; + return Objects.equals(this.data, ddsqlTabularQueryFetchRequest.data) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryFetchRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryFetchRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestAttributes.java new file mode 100644 index 00000000000..5853add757b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestAttributes.java @@ -0,0 +1,147 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes describing which previously submitted DDSQL query to fetch. */ +@JsonPropertyOrder({DdsqlTabularQueryFetchRequestAttributes.JSON_PROPERTY_QUERY_ID}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryFetchRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_QUERY_ID = "query_id"; + private String queryId; + + public DdsqlTabularQueryFetchRequestAttributes() {} + + @JsonCreator + public DdsqlTabularQueryFetchRequestAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY_ID) String queryId) { + this.queryId = queryId; + } + + public DdsqlTabularQueryFetchRequestAttributes queryId(String queryId) { + this.queryId = queryId; + return this; + } + + /** + * Opaque token returned by an earlier execute or fetch response that carried state: running + * . Identifies the query to poll for results. + * + * @return queryId + */ + @JsonProperty(JSON_PROPERTY_QUERY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQueryId() { + return queryId; + } + + public void setQueryId(String queryId) { + this.queryId = queryId; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryFetchRequestAttributes + */ + @JsonAnySetter + public DdsqlTabularQueryFetchRequestAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryFetchRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryFetchRequestAttributes ddsqlTabularQueryFetchRequestAttributes = + (DdsqlTabularQueryFetchRequestAttributes) o; + return Objects.equals(this.queryId, ddsqlTabularQueryFetchRequestAttributes.queryId) + && Objects.equals( + this.additionalProperties, + ddsqlTabularQueryFetchRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(queryId, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryFetchRequestAttributes {\n"); + sb.append(" queryId: ").append(toIndentedString(queryId)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestData.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestData.java new file mode 100644 index 00000000000..9c240e3d0fa --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestData.java @@ -0,0 +1,189 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** JSON:API resource object for a DDSQL tabular query fetch request. */ +@JsonPropertyOrder({ + DdsqlTabularQueryFetchRequestData.JSON_PROPERTY_ATTRIBUTES, + DdsqlTabularQueryFetchRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryFetchRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DdsqlTabularQueryFetchRequestAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DdsqlTabularQueryFetchRequestType type = + DdsqlTabularQueryFetchRequestType.DDSQL_QUERY_FETCH_REQUEST; + + public DdsqlTabularQueryFetchRequestData() {} + + @JsonCreator + public DdsqlTabularQueryFetchRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DdsqlTabularQueryFetchRequestAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + DdsqlTabularQueryFetchRequestType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DdsqlTabularQueryFetchRequestData attributes( + DdsqlTabularQueryFetchRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes describing which previously submitted DDSQL query to fetch. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryFetchRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DdsqlTabularQueryFetchRequestAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public DdsqlTabularQueryFetchRequestData type(DdsqlTabularQueryFetchRequestType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * JSON:API resource type for a DDSQL tabular query fetch request. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryFetchRequestType getType() { + return type; + } + + public void setType(DdsqlTabularQueryFetchRequestType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryFetchRequestData + */ + @JsonAnySetter + public DdsqlTabularQueryFetchRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryFetchRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryFetchRequestData ddsqlTabularQueryFetchRequestData = + (DdsqlTabularQueryFetchRequestData) o; + return Objects.equals(this.attributes, ddsqlTabularQueryFetchRequestData.attributes) + && Objects.equals(this.type, ddsqlTabularQueryFetchRequestData.type) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryFetchRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryFetchRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestType.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestType.java new file mode 100644 index 00000000000..ff178832d5f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryFetchRequestType.java @@ -0,0 +1,58 @@ +/* + * 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.v2.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; + +/** JSON:API resource type for a DDSQL tabular query fetch request. */ +@JsonSerialize( + using = DdsqlTabularQueryFetchRequestType.DdsqlTabularQueryFetchRequestTypeSerializer.class) +public class DdsqlTabularQueryFetchRequestType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("ddsql_query_fetch_request")); + + public static final DdsqlTabularQueryFetchRequestType DDSQL_QUERY_FETCH_REQUEST = + new DdsqlTabularQueryFetchRequestType("ddsql_query_fetch_request"); + + DdsqlTabularQueryFetchRequestType(String value) { + super(value, allowedValues); + } + + public static class DdsqlTabularQueryFetchRequestTypeSerializer + extends StdSerializer { + public DdsqlTabularQueryFetchRequestTypeSerializer(Class t) { + super(t); + } + + public DdsqlTabularQueryFetchRequestTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DdsqlTabularQueryFetchRequestType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DdsqlTabularQueryFetchRequestType fromValue(String value) { + return new DdsqlTabularQueryFetchRequestType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequest.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequest.java new file mode 100644 index 00000000000..b7521b70369 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequest.java @@ -0,0 +1,149 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Wrapper for a DDSQL tabular query execution request. */ +@JsonPropertyOrder({DdsqlTabularQueryRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DdsqlTabularQueryRequestData data; + + public DdsqlTabularQueryRequest() {} + + @JsonCreator + public DdsqlTabularQueryRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + DdsqlTabularQueryRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public DdsqlTabularQueryRequest data(DdsqlTabularQueryRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * JSON:API resource object for a DDSQL tabular query execution request. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryRequestData getData() { + return data; + } + + public void setData(DdsqlTabularQueryRequestData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryRequest + */ + @JsonAnySetter + public DdsqlTabularQueryRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryRequest ddsqlTabularQueryRequest = (DdsqlTabularQueryRequest) o; + return Objects.equals(this.data, ddsqlTabularQueryRequest.data) + && Objects.equals(this.additionalProperties, ddsqlTabularQueryRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestAttributes.java new file mode 100644 index 00000000000..d3b6e2ab8a3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestAttributes.java @@ -0,0 +1,212 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes describing the DDSQL query to execute. */ +@JsonPropertyOrder({ + DdsqlTabularQueryRequestAttributes.JSON_PROPERTY_QUERY, + DdsqlTabularQueryRequestAttributes.JSON_PROPERTY_ROW_LIMIT, + DdsqlTabularQueryRequestAttributes.JSON_PROPERTY_TIME +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryRequestAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public static final String JSON_PROPERTY_ROW_LIMIT = "row_limit"; + private Long rowLimit; + + public static final String JSON_PROPERTY_TIME = "time"; + private DdsqlTabularQueryTimeWindow time; + + public DdsqlTabularQueryRequestAttributes() {} + + @JsonCreator + public DdsqlTabularQueryRequestAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query, + @JsonProperty(required = true, value = JSON_PROPERTY_TIME) DdsqlTabularQueryTimeWindow time) { + this.query = query; + this.time = time; + this.unparsed |= time.unparsed; + } + + public DdsqlTabularQueryRequestAttributes query(String query) { + this.query = query; + return this; + } + + /** + * The DDSQL statement to execute. DDSQL is Datadog's SQL dialect, which is a subset of + * PostgreSQL, scoped to Datadog data sources. + * + * @return query + */ + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public DdsqlTabularQueryRequestAttributes rowLimit(Long rowLimit) { + this.rowLimit = rowLimit; + return this; + } + + /** + * Cap on the number of rows returned. Defaults to 5,000 when omitted. Must be between 1 and + * 10,000 inclusive; values outside this range are rejected with 400. minimum: 1 maximum: 10000 + * + * @return rowLimit + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ROW_LIMIT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getRowLimit() { + return rowLimit; + } + + public void setRowLimit(Long rowLimit) { + this.rowLimit = rowLimit; + } + + public DdsqlTabularQueryRequestAttributes time(DdsqlTabularQueryTimeWindow time) { + this.time = time; + this.unparsed |= time.unparsed; + return this; + } + + /** + * Time window scoping the underlying data sources, expressed in Unix milliseconds since the + * epoch. Inclusive on from_timestamp, exclusive on to_timestamp. + * Results from static tables (for example, dd.hosts) are not affected by the time + * window, but the field must still be provided. + * + * @return time + */ + @JsonProperty(JSON_PROPERTY_TIME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryTimeWindow getTime() { + return time; + } + + public void setTime(DdsqlTabularQueryTimeWindow time) { + this.time = time; + if (time != null) { + this.unparsed |= time.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryRequestAttributes + */ + @JsonAnySetter + public DdsqlTabularQueryRequestAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryRequestAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryRequestAttributes ddsqlTabularQueryRequestAttributes = + (DdsqlTabularQueryRequestAttributes) o; + return Objects.equals(this.query, ddsqlTabularQueryRequestAttributes.query) + && Objects.equals(this.rowLimit, ddsqlTabularQueryRequestAttributes.rowLimit) + && Objects.equals(this.time, ddsqlTabularQueryRequestAttributes.time) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryRequestAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(query, rowLimit, time, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryRequestAttributes {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb.append(" rowLimit: ").append(toIndentedString(rowLimit)).append("\n"); + sb.append(" time: ").append(toIndentedString(time)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestData.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestData.java new file mode 100644 index 00000000000..10baac443ff --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestData.java @@ -0,0 +1,186 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** JSON:API resource object for a DDSQL tabular query execution request. */ +@JsonPropertyOrder({ + DdsqlTabularQueryRequestData.JSON_PROPERTY_ATTRIBUTES, + DdsqlTabularQueryRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DdsqlTabularQueryRequestAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DdsqlTabularQueryRequestType type = DdsqlTabularQueryRequestType.DDSQL_QUERY_REQUEST; + + public DdsqlTabularQueryRequestData() {} + + @JsonCreator + public DdsqlTabularQueryRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DdsqlTabularQueryRequestAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + DdsqlTabularQueryRequestType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DdsqlTabularQueryRequestData attributes(DdsqlTabularQueryRequestAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes describing the DDSQL query to execute. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryRequestAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DdsqlTabularQueryRequestAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public DdsqlTabularQueryRequestData type(DdsqlTabularQueryRequestType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * JSON:API resource type for a DDSQL tabular query request. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryRequestType getType() { + return type; + } + + public void setType(DdsqlTabularQueryRequestType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryRequestData + */ + @JsonAnySetter + public DdsqlTabularQueryRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryRequestData ddsqlTabularQueryRequestData = (DdsqlTabularQueryRequestData) o; + return Objects.equals(this.attributes, ddsqlTabularQueryRequestData.attributes) + && Objects.equals(this.type, ddsqlTabularQueryRequestData.type) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestType.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestType.java new file mode 100644 index 00000000000..2229f4f10ed --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryRequestType.java @@ -0,0 +1,57 @@ +/* + * 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.v2.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; + +/** JSON:API resource type for a DDSQL tabular query request. */ +@JsonSerialize(using = DdsqlTabularQueryRequestType.DdsqlTabularQueryRequestTypeSerializer.class) +public class DdsqlTabularQueryRequestType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("ddsql_query_request")); + + public static final DdsqlTabularQueryRequestType DDSQL_QUERY_REQUEST = + new DdsqlTabularQueryRequestType("ddsql_query_request"); + + DdsqlTabularQueryRequestType(String value) { + super(value, allowedValues); + } + + public static class DdsqlTabularQueryRequestTypeSerializer + extends StdSerializer { + public DdsqlTabularQueryRequestTypeSerializer(Class t) { + super(t); + } + + public DdsqlTabularQueryRequestTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DdsqlTabularQueryRequestType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DdsqlTabularQueryRequestType fromValue(String value) { + return new DdsqlTabularQueryRequestType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponse.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponse.java new file mode 100644 index 00000000000..fdd32070ca3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponse.java @@ -0,0 +1,190 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Response envelope for both the execute and fetch DDSQL tabular query endpoints. Carries the + * JSON:API primary resource and a top-level meta block with request-scoped + * observability handles. + */ +@JsonPropertyOrder({ + DdsqlTabularQueryResponse.JSON_PROPERTY_DATA, + DdsqlTabularQueryResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private DdsqlTabularQueryResponseData data; + + public static final String JSON_PROPERTY_META = "meta"; + private DdsqlTabularQueryResponseMeta meta; + + public DdsqlTabularQueryResponse() {} + + @JsonCreator + public DdsqlTabularQueryResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) DdsqlTabularQueryResponseData data, + @JsonProperty(required = true, value = JSON_PROPERTY_META) + DdsqlTabularQueryResponseMeta meta) { + this.data = data; + this.unparsed |= data.unparsed; + this.meta = meta; + this.unparsed |= meta.unparsed; + } + + public DdsqlTabularQueryResponse data(DdsqlTabularQueryResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * JSON:API resource object for a DDSQL tabular query response. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryResponseData getData() { + return data; + } + + public void setData(DdsqlTabularQueryResponseData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + public DdsqlTabularQueryResponse meta(DdsqlTabularQueryResponseMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Top-level JSON:API meta block accompanying every DDSQL tabular query response. Carries standard + * observability handles for client-side correlation. + * + * @return meta + */ + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryResponseMeta getMeta() { + return meta; + } + + public void setMeta(DdsqlTabularQueryResponseMeta meta) { + this.meta = meta; + if (meta != null) { + this.unparsed |= meta.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryResponse + */ + @JsonAnySetter + public DdsqlTabularQueryResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryResponse ddsqlTabularQueryResponse = (DdsqlTabularQueryResponse) o; + return Objects.equals(this.data, ddsqlTabularQueryResponse.data) + && Objects.equals(this.meta, ddsqlTabularQueryResponse.meta) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseAttributes.java new file mode 100644 index 00000000000..1b0b7b82c9b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseAttributes.java @@ -0,0 +1,271 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Attributes of a DDSQL tabular query response. query_id is set when state + * is running; columns is set when state is + * completed. + */ +@JsonPropertyOrder({ + DdsqlTabularQueryResponseAttributes.JSON_PROPERTY_COLUMNS, + DdsqlTabularQueryResponseAttributes.JSON_PROPERTY_QUERY_ID, + DdsqlTabularQueryResponseAttributes.JSON_PROPERTY_STATE, + DdsqlTabularQueryResponseAttributes.JSON_PROPERTY_WARNINGS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryResponseAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_COLUMNS = "columns"; + private List columns = null; + + public static final String JSON_PROPERTY_QUERY_ID = "query_id"; + private String queryId; + + public static final String JSON_PROPERTY_STATE = "state"; + private DdsqlTabularQueryState state; + + public static final String JSON_PROPERTY_WARNINGS = "warnings"; + private List warnings = null; + + public DdsqlTabularQueryResponseAttributes() {} + + @JsonCreator + public DdsqlTabularQueryResponseAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_STATE) DdsqlTabularQueryState state) { + this.state = state; + this.unparsed |= !state.isValid(); + } + + public DdsqlTabularQueryResponseAttributes columns(List columns) { + this.columns = columns; + if (columns != null) { + for (DdsqlTabularQueryColumn item : columns) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public DdsqlTabularQueryResponseAttributes addColumnsItem(DdsqlTabularQueryColumn columnsItem) { + if (this.columns == null) { + this.columns = new ArrayList<>(); + } + this.columns.add(columnsItem); + this.unparsed |= columnsItem.unparsed; + return this; + } + + /** + * Column-major result set. Each element carries one column's name, type, and values, with one + * value per row of the result. Set when state is completed. + * + * @return columns + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COLUMNS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getColumns() { + return columns; + } + + public void setColumns(List columns) { + this.columns = columns; + if (columns != null) { + for (DdsqlTabularQueryColumn item : columns) { + this.unparsed |= item.unparsed; + } + } + } + + public DdsqlTabularQueryResponseAttributes queryId(String queryId) { + this.queryId = queryId; + return this; + } + + /** + * Opaque token to pass to the fetch endpoint to poll for results. Set when state is + * running and absent when state is completed. + * + * @return queryId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_QUERY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getQueryId() { + return queryId; + } + + public void setQueryId(String queryId) { + this.queryId = queryId; + } + + public DdsqlTabularQueryResponseAttributes state(DdsqlTabularQueryState state) { + this.state = state; + this.unparsed |= !state.isValid(); + return this; + } + + /** + * Lifecycle state of a DDSQL tabular query response. running means the query is + * still executing and the client should poll the fetch endpoint with the returned query_id + * . completed means the result set is inlined in columns and no + * further polling is required. + * + * @return state + */ + @JsonProperty(JSON_PROPERTY_STATE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryState getState() { + return state; + } + + public void setState(DdsqlTabularQueryState state) { + if (!state.isValid()) { + this.unparsed = true; + } + this.state = state; + } + + public DdsqlTabularQueryResponseAttributes warnings(List warnings) { + this.warnings = warnings; + return this; + } + + public DdsqlTabularQueryResponseAttributes addWarningsItem(String warningsItem) { + if (this.warnings == null) { + this.warnings = new ArrayList<>(); + } + this.warnings.add(warningsItem); + return this; + } + + /** + * Non-fatal messages emitted by the query engine while serving this response. + * + * @return warnings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_WARNINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getWarnings() { + return warnings; + } + + public void setWarnings(List warnings) { + this.warnings = warnings; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryResponseAttributes + */ + @JsonAnySetter + public DdsqlTabularQueryResponseAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryResponseAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryResponseAttributes ddsqlTabularQueryResponseAttributes = + (DdsqlTabularQueryResponseAttributes) o; + return Objects.equals(this.columns, ddsqlTabularQueryResponseAttributes.columns) + && Objects.equals(this.queryId, ddsqlTabularQueryResponseAttributes.queryId) + && Objects.equals(this.state, ddsqlTabularQueryResponseAttributes.state) + && Objects.equals(this.warnings, ddsqlTabularQueryResponseAttributes.warnings) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryResponseAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(columns, queryId, state, warnings, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryResponseAttributes {\n"); + sb.append(" columns: ").append(toIndentedString(columns)).append("\n"); + sb.append(" queryId: ").append(toIndentedString(queryId)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).append("\n"); + sb.append(" warnings: ").append(toIndentedString(warnings)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseData.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseData.java new file mode 100644 index 00000000000..51b21ab10bf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseData.java @@ -0,0 +1,216 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** JSON:API resource object for a DDSQL tabular query response. */ +@JsonPropertyOrder({ + DdsqlTabularQueryResponseData.JSON_PROPERTY_ATTRIBUTES, + DdsqlTabularQueryResponseData.JSON_PROPERTY_ID, + DdsqlTabularQueryResponseData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryResponseData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private DdsqlTabularQueryResponseAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DdsqlTabularQueryResponseType type = DdsqlTabularQueryResponseType.DDSQL_QUERY_RESPONSE; + + public DdsqlTabularQueryResponseData() {} + + @JsonCreator + public DdsqlTabularQueryResponseData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + DdsqlTabularQueryResponseAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + DdsqlTabularQueryResponseType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DdsqlTabularQueryResponseData attributes(DdsqlTabularQueryResponseAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a DDSQL tabular query response. query_id is set when state + * is running; columns is set when state is + * completed. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryResponseAttributes getAttributes() { + return attributes; + } + + public void setAttributes(DdsqlTabularQueryResponseAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public DdsqlTabularQueryResponseData id(String id) { + this.id = id; + return this; + } + + /** + * Stable identifier for the query response resource. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public DdsqlTabularQueryResponseData type(DdsqlTabularQueryResponseType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * JSON:API resource type for a DDSQL tabular query response. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DdsqlTabularQueryResponseType getType() { + return type; + } + + public void setType(DdsqlTabularQueryResponseType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryResponseData + */ + @JsonAnySetter + public DdsqlTabularQueryResponseData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryResponseData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryResponseData ddsqlTabularQueryResponseData = (DdsqlTabularQueryResponseData) o; + return Objects.equals(this.attributes, ddsqlTabularQueryResponseData.attributes) + && Objects.equals(this.id, ddsqlTabularQueryResponseData.id) + && Objects.equals(this.type, ddsqlTabularQueryResponseData.type) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryResponseData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryResponseData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseMeta.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseMeta.java new file mode 100644 index 00000000000..966d9cd9b94 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseMeta.java @@ -0,0 +1,178 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Top-level JSON:API meta block accompanying every DDSQL tabular query response. Carries standard + * observability handles for client-side correlation. + */ +@JsonPropertyOrder({ + DdsqlTabularQueryResponseMeta.JSON_PROPERTY_ELAPSED, + DdsqlTabularQueryResponseMeta.JSON_PROPERTY_REQUEST_ID +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryResponseMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ELAPSED = "elapsed"; + private Long elapsed; + + public static final String JSON_PROPERTY_REQUEST_ID = "request_id"; + private String requestId; + + public DdsqlTabularQueryResponseMeta() {} + + @JsonCreator + public DdsqlTabularQueryResponseMeta( + @JsonProperty(required = true, value = JSON_PROPERTY_ELAPSED) Long elapsed, + @JsonProperty(required = true, value = JSON_PROPERTY_REQUEST_ID) String requestId) { + this.elapsed = elapsed; + this.requestId = requestId; + } + + public DdsqlTabularQueryResponseMeta elapsed(Long elapsed) { + this.elapsed = elapsed; + return this; + } + + /** + * Server-side time spent serving this request, in milliseconds. + * + * @return elapsed + */ + @JsonProperty(JSON_PROPERTY_ELAPSED) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getElapsed() { + return elapsed; + } + + public void setElapsed(Long elapsed) { + this.elapsed = elapsed; + } + + public DdsqlTabularQueryResponseMeta requestId(String requestId) { + this.requestId = requestId; + return this; + } + + /** + * Echo of the DD-Request-ID header assigned by Datadog's edge to this request, for + * support correlation. + * + * @return requestId + */ + @JsonProperty(JSON_PROPERTY_REQUEST_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryResponseMeta + */ + @JsonAnySetter + public DdsqlTabularQueryResponseMeta putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryResponseMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryResponseMeta ddsqlTabularQueryResponseMeta = (DdsqlTabularQueryResponseMeta) o; + return Objects.equals(this.elapsed, ddsqlTabularQueryResponseMeta.elapsed) + && Objects.equals(this.requestId, ddsqlTabularQueryResponseMeta.requestId) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryResponseMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(elapsed, requestId, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryResponseMeta {\n"); + sb.append(" elapsed: ").append(toIndentedString(elapsed)).append("\n"); + sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseType.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseType.java new file mode 100644 index 00000000000..264d7ff363a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryResponseType.java @@ -0,0 +1,57 @@ +/* + * 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.v2.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; + +/** JSON:API resource type for a DDSQL tabular query response. */ +@JsonSerialize(using = DdsqlTabularQueryResponseType.DdsqlTabularQueryResponseTypeSerializer.class) +public class DdsqlTabularQueryResponseType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("ddsql_query_response")); + + public static final DdsqlTabularQueryResponseType DDSQL_QUERY_RESPONSE = + new DdsqlTabularQueryResponseType("ddsql_query_response"); + + DdsqlTabularQueryResponseType(String value) { + super(value, allowedValues); + } + + public static class DdsqlTabularQueryResponseTypeSerializer + extends StdSerializer { + public DdsqlTabularQueryResponseTypeSerializer(Class t) { + super(t); + } + + public DdsqlTabularQueryResponseTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DdsqlTabularQueryResponseType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DdsqlTabularQueryResponseType fromValue(String value) { + return new DdsqlTabularQueryResponseType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryState.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryState.java new file mode 100644 index 00000000000..7ed29a201c5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryState.java @@ -0,0 +1,62 @@ +/* + * 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.v2.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; + +/** + * Lifecycle state of a DDSQL tabular query response. running means the query is still + * executing and the client should poll the fetch endpoint with the returned query_id. + * completed means the result set is inlined in columns and no further + * polling is required. + */ +@JsonSerialize(using = DdsqlTabularQueryState.DdsqlTabularQueryStateSerializer.class) +public class DdsqlTabularQueryState extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("running", "completed")); + + public static final DdsqlTabularQueryState RUNNING = new DdsqlTabularQueryState("running"); + public static final DdsqlTabularQueryState COMPLETED = new DdsqlTabularQueryState("completed"); + + DdsqlTabularQueryState(String value) { + super(value, allowedValues); + } + + public static class DdsqlTabularQueryStateSerializer + extends StdSerializer { + public DdsqlTabularQueryStateSerializer(Class t) { + super(t); + } + + public DdsqlTabularQueryStateSerializer() { + this(null); + } + + @Override + public void serialize( + DdsqlTabularQueryState value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DdsqlTabularQueryState fromValue(String value) { + return new DdsqlTabularQueryState(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryTimeWindow.java b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryTimeWindow.java new file mode 100644 index 00000000000..593b5329ee2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DdsqlTabularQueryTimeWindow.java @@ -0,0 +1,179 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Time window scoping the underlying data sources, expressed in Unix milliseconds since the epoch. + * Inclusive on from_timestamp, exclusive on to_timestamp. Results from + * static tables (for example, dd.hosts) are not affected by the time window, but the + * field must still be provided. + */ +@JsonPropertyOrder({ + DdsqlTabularQueryTimeWindow.JSON_PROPERTY_FROM_TIMESTAMP, + DdsqlTabularQueryTimeWindow.JSON_PROPERTY_TO_TIMESTAMP +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DdsqlTabularQueryTimeWindow { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FROM_TIMESTAMP = "from_timestamp"; + private Long fromTimestamp; + + public static final String JSON_PROPERTY_TO_TIMESTAMP = "to_timestamp"; + private Long toTimestamp; + + public DdsqlTabularQueryTimeWindow() {} + + @JsonCreator + public DdsqlTabularQueryTimeWindow( + @JsonProperty(required = true, value = JSON_PROPERTY_FROM_TIMESTAMP) Long fromTimestamp, + @JsonProperty(required = true, value = JSON_PROPERTY_TO_TIMESTAMP) Long toTimestamp) { + this.fromTimestamp = fromTimestamp; + this.toTimestamp = toTimestamp; + } + + public DdsqlTabularQueryTimeWindow fromTimestamp(Long fromTimestamp) { + this.fromTimestamp = fromTimestamp; + return this; + } + + /** + * Start of the query window (inclusive), in Unix milliseconds since the epoch. + * + * @return fromTimestamp + */ + @JsonProperty(JSON_PROPERTY_FROM_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getFromTimestamp() { + return fromTimestamp; + } + + public void setFromTimestamp(Long fromTimestamp) { + this.fromTimestamp = fromTimestamp; + } + + public DdsqlTabularQueryTimeWindow toTimestamp(Long toTimestamp) { + this.toTimestamp = toTimestamp; + return this; + } + + /** + * End of the query window (exclusive), in Unix milliseconds since the epoch. + * + * @return toTimestamp + */ + @JsonProperty(JSON_PROPERTY_TO_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getToTimestamp() { + return toTimestamp; + } + + public void setToTimestamp(Long toTimestamp) { + this.toTimestamp = toTimestamp; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return DdsqlTabularQueryTimeWindow + */ + @JsonAnySetter + public DdsqlTabularQueryTimeWindow putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this DdsqlTabularQueryTimeWindow object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DdsqlTabularQueryTimeWindow ddsqlTabularQueryTimeWindow = (DdsqlTabularQueryTimeWindow) o; + return Objects.equals(this.fromTimestamp, ddsqlTabularQueryTimeWindow.fromTimestamp) + && Objects.equals(this.toTimestamp, ddsqlTabularQueryTimeWindow.toTimestamp) + && Objects.equals( + this.additionalProperties, ddsqlTabularQueryTimeWindow.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(fromTimestamp, toTimestamp, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DdsqlTabularQueryTimeWindow {\n"); + sb.append(" fromTimestamp: ").append(toIndentedString(fromTimestamp)).append("\n"); + sb.append(" toTimestamp: ").append(toIndentedString(toTimestamp)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/ddsql.feature b/src/test/resources/com/datadog/api/client/v2/api/ddsql.feature new file mode 100644 index 00000000000..69d646eb2a0 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v2/api/ddsql.feature @@ -0,0 +1,44 @@ +@endpoint(ddsql) @endpoint(ddsql-v2) +Feature: DDSQL + Execute DDSQL queries against the Datadog data catalog and poll for their + results. Queries are dispatched asynchronously: the initial request may + return a `running` state with a `query_id`, and clients poll the fetch + endpoint until the response transitions to `completed` with a column-major + result set. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "DDSQL" API + + @generated @skip @team:DataDog/query-apis + Scenario: Execute a tabular DDSQL query returns "Bad Request" response + Given operation "ExecuteDdsqlTabularQuery" enabled + And new "ExecuteDdsqlTabularQuery" request + And body with value {"data": {"attributes": {"query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider", "row_limit": 1000, "time": {"from_timestamp": 1736942400000, "to_timestamp": 1736946000000}}, "type": "ddsql_query_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/query-apis + Scenario: Execute a tabular DDSQL query returns "OK" response + Given operation "ExecuteDdsqlTabularQuery" enabled + And new "ExecuteDdsqlTabularQuery" request + And body with value {"data": {"attributes": {"query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider", "row_limit": 1000, "time": {"from_timestamp": 1736942400000, "to_timestamp": 1736946000000}}, "type": "ddsql_query_request"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/query-apis + Scenario: Fetch the result of a DDSQL query returns "Bad Request" response + Given operation "FetchDdsqlTabularQuery" enabled + And new "FetchDdsqlTabularQuery" request + And body with value {"data": {"attributes": {"query_id": "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ=="}, "type": "ddsql_query_fetch_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/query-apis + Scenario: Fetch the result of a DDSQL query returns "OK" response + Given operation "FetchDdsqlTabularQuery" enabled + And new "FetchDdsqlTabularQuery" request + And body with value {"data": {"attributes": {"query_id": "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ=="}, "type": "ddsql_query_fetch_request"}} + When the request is sent + Then the response status is 200 OK diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index f7316aecda2..57e16ea1a64 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -2285,6 +2285,18 @@ "type": "idempotent" } }, + "ExecuteDdsqlTabularQuery": { + "tag": "DDSQL", + "undo": { + "type": "idempotent" + } + }, + "FetchDdsqlTabularQuery": { + "tag": "DDSQL", + "undo": { + "type": "safe" + } + }, "CreateDataDeletionRequest": { "tag": "Data Deletion", "undo": {