diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6e4cbaacff9..aba68e52a57 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -6806,6 +6806,72 @@ components: required: - data type: object + BatchDeleteRowsRequestArray: + description: The request body for deleting multiple rows from a reference table. + properties: + data: + items: + $ref: '#/components/schemas/BatchDeleteRowsRequestData' + maxItems: 200 + type: array + required: + - data + type: object + BatchDeleteRowsRequestData: + description: Row resource containing a single row identifier for deletion. + properties: + id: + example: primary_key_value + type: string + type: + $ref: '#/components/schemas/TableRowResourceDataType' + required: + - type + - id + type: object + BatchUpsertRowsRequestArray: + description: The request body for creating or updating multiple rows into a + reference table. + properties: + data: + items: + $ref: '#/components/schemas/BatchUpsertRowsRequestData' + maxItems: 200 + type: array + required: + - data + type: object + BatchUpsertRowsRequestData: + description: Row resource containing a single row identifier and its column + values. + properties: + attributes: + $ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributes' + id: + example: primary_key_value + type: string + type: + $ref: '#/components/schemas/TableRowResourceDataType' + required: + - type + - id + type: object + BatchUpsertRowsRequestDataAttributes: + description: Attributes containing row data values for row creation or update + operations. + properties: + values: + additionalProperties: + x-required-field: true + description: Key-value pairs representing row data, where keys are field + names from the schema. + example: + example_key_value: primary_key_value + name: row_name + type: object + required: + - values + type: object BillConfig: description: Bill config. properties: @@ -74549,6 +74615,47 @@ paths: tags: - Reference Tables /api/v2/reference-tables/tables/{id}/rows: + delete: + description: Delete multiple rows from a Reference Table by their primary key + values. + operationId: DeleteRows + parameters: + - description: Unique identifier of the reference table to delete rows from + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BatchDeleteRowsRequestArray' + required: true + responses: + '200': + description: Rows deleted successfully + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete rows + tags: + - Reference Tables get: description: Get reference table rows by their primary key values. operationId: GetRowsByID @@ -74593,6 +74700,48 @@ paths: summary: Get rows by id tags: - Reference Tables + post: + description: Create or update rows in a Reference Table by their primary key + values. If a row with the specified primary key exists, it is updated; otherwise, + a new row is created. + operationId: UpsertRows + parameters: + - description: Unique identifier of the reference table to upsert rows into + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BatchUpsertRowsRequestArray' + required: true + responses: + '200': + description: Rows created or updated successfully + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Upsert rows + tags: + - Reference Tables /api/v2/reference-tables/uploads: post: description: Create a reference table upload for bulk data ingestion diff --git a/examples/v2/reference-tables/DeleteRows.java b/examples/v2/reference-tables/DeleteRows.java new file mode 100644 index 00000000000..55d2615ed0e --- /dev/null +++ b/examples/v2/reference-tables/DeleteRows.java @@ -0,0 +1,34 @@ +// Delete rows returns "Rows deleted successfully" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ReferenceTablesApi; +import com.datadog.api.client.v2.model.BatchDeleteRowsRequestArray; +import com.datadog.api.client.v2.model.BatchDeleteRowsRequestData; +import com.datadog.api.client.v2.model.TableRowResourceDataType; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient); + + BatchDeleteRowsRequestArray body = + new BatchDeleteRowsRequestArray() + .data( + Collections.singletonList( + new BatchDeleteRowsRequestData() + .id("primary_key_value") + .type(TableRowResourceDataType.ROW))); + + try { + apiInstance.deleteRows("id", body); + } catch (ApiException e) { + System.err.println("Exception when calling ReferenceTablesApi#deleteRows"); + 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/reference-tables/UpsertRows.java b/examples/v2/reference-tables/UpsertRows.java new file mode 100644 index 00000000000..c336192695f --- /dev/null +++ b/examples/v2/reference-tables/UpsertRows.java @@ -0,0 +1,42 @@ +// Upsert rows returns "Rows created or updated successfully" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ReferenceTablesApi; +import com.datadog.api.client.v2.model.BatchUpsertRowsRequestArray; +import com.datadog.api.client.v2.model.BatchUpsertRowsRequestData; +import com.datadog.api.client.v2.model.BatchUpsertRowsRequestDataAttributes; +import com.datadog.api.client.v2.model.TableRowResourceDataType; +import java.util.Collections; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient); + + BatchUpsertRowsRequestArray body = + new BatchUpsertRowsRequestArray() + .data( + Collections.singletonList( + new BatchUpsertRowsRequestData() + .attributes( + new BatchUpsertRowsRequestDataAttributes() + .values( + Map.ofEntries( + Map.entry("example_key_value", "primary_key_value"), + Map.entry("name", "row_name")))) + .id("primary_key_value") + .type(TableRowResourceDataType.ROW))); + + try { + apiInstance.upsertRows("id", body); + } catch (ApiException e) { + System.err.println("Exception when calling ReferenceTablesApi#upsertRows"); + 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/v2/api/ReferenceTablesApi.java b/src/main/java/com/datadog/api/client/v2/api/ReferenceTablesApi.java index 4361edb4ce5..58b2be6ec88 100644 --- a/src/main/java/com/datadog/api/client/v2/api/ReferenceTablesApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/ReferenceTablesApi.java @@ -4,6 +4,8 @@ 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.BatchDeleteRowsRequestArray; +import com.datadog.api.client.v2.model.BatchUpsertRowsRequestArray; import com.datadog.api.client.v2.model.CreateTableRequest; import com.datadog.api.client.v2.model.CreateUploadRequest; import com.datadog.api.client.v2.model.CreateUploadResponse; @@ -320,6 +322,157 @@ public ApiResponse createReferenceTableUploadWithHttpInfo( new GenericType() {}); } + /** + * Delete rows. + * + *

See {@link #deleteRowsWithHttpInfo}. + * + * @param id Unique identifier of the reference table to delete rows from (required) + * @param body (required) + * @throws ApiException if fails to make API call + */ + public void deleteRows(String id, BatchDeleteRowsRequestArray body) throws ApiException { + deleteRowsWithHttpInfo(id, body); + } + + /** + * Delete rows. + * + *

See {@link #deleteRowsWithHttpInfoAsync}. + * + * @param id Unique identifier of the reference table to delete rows from (required) + * @param body (required) + * @return CompletableFuture + */ + public CompletableFuture deleteRowsAsync(String id, BatchDeleteRowsRequestArray body) { + return deleteRowsWithHttpInfoAsync(id, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Delete multiple rows from a Reference Table by their primary key values. + * + * @param id Unique identifier of the reference table to delete rows from (required) + * @param body (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 Rows deleted successfully -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
500 Internal Server Error -
+ */ + public ApiResponse deleteRowsWithHttpInfo(String id, BatchDeleteRowsRequestArray body) + throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException(400, "Missing the required parameter 'id' when calling deleteRows"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling deleteRows"); + } + // create path and map variables + String localVarPath = + "/api/v2/reference-tables/tables/{id}/rows" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ReferenceTablesApi.deleteRows", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete rows. + * + *

See {@link #deleteRowsWithHttpInfo}. + * + * @param id Unique identifier of the reference table to delete rows from (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteRowsWithHttpInfoAsync( + String id, BatchDeleteRowsRequestArray body) { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(400, "Missing the required parameter 'id' when calling deleteRows")); + return result; + } + + // 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 deleteRows")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/reference-tables/tables/{id}/rows" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ReferenceTablesApi.deleteRows", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** * Delete table. * @@ -1153,4 +1306,156 @@ public CompletableFuture> updateReferenceTableWithHttpInfoAsyn false, null); } + + /** + * Upsert rows. + * + *

See {@link #upsertRowsWithHttpInfo}. + * + * @param id Unique identifier of the reference table to upsert rows into (required) + * @param body (required) + * @throws ApiException if fails to make API call + */ + public void upsertRows(String id, BatchUpsertRowsRequestArray body) throws ApiException { + upsertRowsWithHttpInfo(id, body); + } + + /** + * Upsert rows. + * + *

See {@link #upsertRowsWithHttpInfoAsync}. + * + * @param id Unique identifier of the reference table to upsert rows into (required) + * @param body (required) + * @return CompletableFuture + */ + public CompletableFuture upsertRowsAsync(String id, BatchUpsertRowsRequestArray body) { + return upsertRowsWithHttpInfoAsync(id, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create or update rows in a Reference Table by their primary key values. If a row with the + * specified primary key exists, it is updated; otherwise, a new row is created. + * + * @param id Unique identifier of the reference table to upsert rows into (required) + * @param body (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 Rows created or updated successfully -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
500 Internal Server Error -
+ */ + public ApiResponse upsertRowsWithHttpInfo(String id, BatchUpsertRowsRequestArray body) + throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException(400, "Missing the required parameter 'id' when calling upsertRows"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling upsertRows"); + } + // create path and map variables + String localVarPath = + "/api/v2/reference-tables/tables/{id}/rows" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ReferenceTablesApi.upsertRows", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Upsert rows. + * + *

See {@link #upsertRowsWithHttpInfo}. + * + * @param id Unique identifier of the reference table to upsert rows into (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> upsertRowsWithHttpInfoAsync( + String id, BatchUpsertRowsRequestArray body) { + Object localVarPostBody = body; + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(400, "Missing the required parameter 'id' when calling upsertRows")); + return result; + } + + // 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 upsertRows")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/reference-tables/tables/{id}/rows" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ReferenceTablesApi.upsertRows", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } 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, + null); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/BatchDeleteRowsRequestArray.java b/src/main/java/com/datadog/api/client/v2/model/BatchDeleteRowsRequestArray.java new file mode 100644 index 00000000000..530204fc198 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/BatchDeleteRowsRequestArray.java @@ -0,0 +1,156 @@ +/* + * 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; + +/** The request body for deleting multiple rows from a reference table. */ +@JsonPropertyOrder({BatchDeleteRowsRequestArray.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class BatchDeleteRowsRequestArray { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public BatchDeleteRowsRequestArray() {} + + @JsonCreator + public BatchDeleteRowsRequestArray( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + List data) { + this.data = data; + } + + public BatchDeleteRowsRequestArray data(List data) { + this.data = data; + for (BatchDeleteRowsRequestData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public BatchDeleteRowsRequestArray addDataItem(BatchDeleteRowsRequestData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Getdata + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + /** + * 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 BatchDeleteRowsRequestArray + */ + @JsonAnySetter + public BatchDeleteRowsRequestArray 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 BatchDeleteRowsRequestArray object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchDeleteRowsRequestArray batchDeleteRowsRequestArray = (BatchDeleteRowsRequestArray) o; + return Objects.equals(this.data, batchDeleteRowsRequestArray.data) + && Objects.equals( + this.additionalProperties, batchDeleteRowsRequestArray.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchDeleteRowsRequestArray {\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/BatchDeleteRowsRequestData.java b/src/main/java/com/datadog/api/client/v2/model/BatchDeleteRowsRequestData.java new file mode 100644 index 00000000000..41a4270f1ef --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/BatchDeleteRowsRequestData.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; + +/** Row resource containing a single row identifier for deletion. */ +@JsonPropertyOrder({ + BatchDeleteRowsRequestData.JSON_PROPERTY_ID, + BatchDeleteRowsRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class BatchDeleteRowsRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private TableRowResourceDataType type = TableRowResourceDataType.ROW; + + public BatchDeleteRowsRequestData() {} + + @JsonCreator + public BatchDeleteRowsRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) TableRowResourceDataType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public BatchDeleteRowsRequestData id(String id) { + this.id = id; + return this; + } + + /** + * Getid + * + * @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 BatchDeleteRowsRequestData type(TableRowResourceDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Row resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TableRowResourceDataType getType() { + return type; + } + + public void setType(TableRowResourceDataType 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 BatchDeleteRowsRequestData + */ + @JsonAnySetter + public BatchDeleteRowsRequestData 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 BatchDeleteRowsRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchDeleteRowsRequestData batchDeleteRowsRequestData = (BatchDeleteRowsRequestData) o; + return Objects.equals(this.id, batchDeleteRowsRequestData.id) + && Objects.equals(this.type, batchDeleteRowsRequestData.type) + && Objects.equals( + this.additionalProperties, batchDeleteRowsRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchDeleteRowsRequestData {\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/BatchUpsertRowsRequestArray.java b/src/main/java/com/datadog/api/client/v2/model/BatchUpsertRowsRequestArray.java new file mode 100644 index 00000000000..29c653b7323 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/BatchUpsertRowsRequestArray.java @@ -0,0 +1,156 @@ +/* + * 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; + +/** The request body for creating or updating multiple rows into a reference table. */ +@JsonPropertyOrder({BatchUpsertRowsRequestArray.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class BatchUpsertRowsRequestArray { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public BatchUpsertRowsRequestArray() {} + + @JsonCreator + public BatchUpsertRowsRequestArray( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + List data) { + this.data = data; + } + + public BatchUpsertRowsRequestArray data(List data) { + this.data = data; + for (BatchUpsertRowsRequestData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public BatchUpsertRowsRequestArray addDataItem(BatchUpsertRowsRequestData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Getdata + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + /** + * 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 BatchUpsertRowsRequestArray + */ + @JsonAnySetter + public BatchUpsertRowsRequestArray 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 BatchUpsertRowsRequestArray object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchUpsertRowsRequestArray batchUpsertRowsRequestArray = (BatchUpsertRowsRequestArray) o; + return Objects.equals(this.data, batchUpsertRowsRequestArray.data) + && Objects.equals( + this.additionalProperties, batchUpsertRowsRequestArray.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchUpsertRowsRequestArray {\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/BatchUpsertRowsRequestData.java b/src/main/java/com/datadog/api/client/v2/model/BatchUpsertRowsRequestData.java new file mode 100644 index 00000000000..50c62f5a788 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/BatchUpsertRowsRequestData.java @@ -0,0 +1,207 @@ +/* + * 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; + +/** Row resource containing a single row identifier and its column values. */ +@JsonPropertyOrder({ + BatchUpsertRowsRequestData.JSON_PROPERTY_ATTRIBUTES, + BatchUpsertRowsRequestData.JSON_PROPERTY_ID, + BatchUpsertRowsRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class BatchUpsertRowsRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private BatchUpsertRowsRequestDataAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private TableRowResourceDataType type = TableRowResourceDataType.ROW; + + public BatchUpsertRowsRequestData() {} + + @JsonCreator + public BatchUpsertRowsRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) TableRowResourceDataType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public BatchUpsertRowsRequestData attributes(BatchUpsertRowsRequestDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes containing row data values for row creation or update operations. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BatchUpsertRowsRequestDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(BatchUpsertRowsRequestDataAttributes attributes) { + this.attributes = attributes; + } + + public BatchUpsertRowsRequestData id(String id) { + this.id = id; + return this; + } + + /** + * Getid + * + * @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 BatchUpsertRowsRequestData type(TableRowResourceDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Row resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TableRowResourceDataType getType() { + return type; + } + + public void setType(TableRowResourceDataType 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 BatchUpsertRowsRequestData + */ + @JsonAnySetter + public BatchUpsertRowsRequestData 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 BatchUpsertRowsRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchUpsertRowsRequestData batchUpsertRowsRequestData = (BatchUpsertRowsRequestData) o; + return Objects.equals(this.attributes, batchUpsertRowsRequestData.attributes) + && Objects.equals(this.id, batchUpsertRowsRequestData.id) + && Objects.equals(this.type, batchUpsertRowsRequestData.type) + && Objects.equals( + this.additionalProperties, batchUpsertRowsRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchUpsertRowsRequestData {\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/BatchUpsertRowsRequestDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/BatchUpsertRowsRequestDataAttributes.java new file mode 100644 index 00000000000..80d0068fd1f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/BatchUpsertRowsRequestDataAttributes.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; + +/** Attributes containing row data values for row creation or update operations. */ +@JsonPropertyOrder({BatchUpsertRowsRequestDataAttributes.JSON_PROPERTY_VALUES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class BatchUpsertRowsRequestDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_VALUES = "values"; + private Map values = new HashMap(); + + public BatchUpsertRowsRequestDataAttributes() {} + + @JsonCreator + public BatchUpsertRowsRequestDataAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_VALUES) Map values) { + this.values = values; + } + + public BatchUpsertRowsRequestDataAttributes values(Map values) { + this.values = values; + return this; + } + + public BatchUpsertRowsRequestDataAttributes putValuesItem(String key, Object valuesItem) { + this.values.put(key, valuesItem); + return this; + } + + /** + * Key-value pairs representing row data, where keys are field names from the schema. + * + * @return values + */ + @JsonProperty(JSON_PROPERTY_VALUES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Map getValues() { + return values; + } + + public void setValues(Map 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 BatchUpsertRowsRequestDataAttributes + */ + @JsonAnySetter + public BatchUpsertRowsRequestDataAttributes 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 BatchUpsertRowsRequestDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchUpsertRowsRequestDataAttributes batchUpsertRowsRequestDataAttributes = + (BatchUpsertRowsRequestDataAttributes) o; + return Objects.equals(this.values, batchUpsertRowsRequestDataAttributes.values) + && Objects.equals( + this.additionalProperties, batchUpsertRowsRequestDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(values, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchUpsertRowsRequestDataAttributes {\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/test/resources/com/datadog/api/client/v2/api/reference_tables.feature b/src/test/resources/com/datadog/api/client/v2/api/reference_tables.feature index fa3ea42360a..45a2861c15b 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/reference_tables.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/reference_tables.feature @@ -53,6 +53,30 @@ Feature: Reference Tables When the request is sent Then the response status is 400 Bad Request + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete rows returns "Bad Request" response + Given new "DeleteRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete rows returns "Not Found" response + Given new "DeleteRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete rows returns "Rows deleted successfully" response + Given new "DeleteRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 200 Rows deleted successfully + @generated @skip @team:DataDog/redapl-experiences Scenario: Delete table returns "Not Found" response Given new "DeleteTable" request @@ -119,3 +143,27 @@ Feature: Reference Tables And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "id", "type": "INT32"}, {"name": "name", "type": "STRING"}], "primary_keys": ["id"]}, "sync_enabled": false, "tags": ["test_tag"]}, "type": "reference_table"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Upsert rows returns "Bad Request" response + Given new "UpsertRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Upsert rows returns "Not Found" response + Given new "UpsertRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Upsert rows returns "Rows created or updated successfully" response + Given new "UpsertRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 200 Rows created or updated successfully 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 3799e64e630..35580ed3fcd 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 @@ -3089,12 +3089,26 @@ "type": "idempotent" } }, + "DeleteRows": { + "tag": "Reference Tables", + "undo": { + "type": "idempotent" + } + }, "GetRowsByID": { "tag": "Reference Tables", "undo": { "type": "safe" } }, + "UpsertRows": { + "tag": "Reference Tables", + "undo": { + "operationId": "DeleteRows", + "parameters": [], + "type": "unsafe" + } + }, "CreateReferenceTableUpload": { "tag": "Reference Tables", "undo": {