From 35b7f0604137e6c45e536e0fbfc881728fb31454 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 11 Nov 2026 18:22:53 +0000 Subject: [PATCH] Regenerate client from commit 6082748 of spec repo --- .generator/schemas/v2/openapi.yaml | 109 +++++++++ .../UpdateCustomCostsFile.java | 41 ++++ .../client/v2/api/CloudCostManagementApi.java | 160 +++++++++++++ .../CustomCostsFileUpdateAttributes.java | 145 ++++++++++++ .../v2/model/CustomCostsFileUpdateData.java | 213 ++++++++++++++++++ .../model/CustomCostsFileUpdateRequest.java | 149 ++++++++++++ .../v2/model/CustomCostsFileUpdateType.java | 57 +++++ .../v2/api/cloud_cost_management.feature | 18 ++ .../com/datadog/api/client/v2/api/given.json | 12 + .../com/datadog/api/client/v2/api/undo.json | 6 + .../test-runner-data/manifest.json | 14 ++ ...costs-file-returns-not-found-response.json | 51 +++++ ...custom-costs-file-returns-ok-response.json | 51 +++++ .../v2/cloud-cost-management.json | 110 +++++++++ 14 files changed, 1136 insertions(+) create mode 100644 examples/v2/cloud-cost-management/UpdateCustomCostsFile.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateType.java create mode 100644 src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-not-found-response.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-ok-response.json diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 34b38251454..8f122e81fc1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -34837,6 +34837,49 @@ components: description: Type of the Custom Costs file metadata. type: string type: object + CustomCostsFileUpdateAttributes: + description: Attributes of a Custom Costs file that can be updated. + properties: + ai_provider: + description: Whether the Custom Costs file contains the costs of an AI provider. + example: true + type: boolean + required: + - ai_provider + type: object + CustomCostsFileUpdateData: + description: Custom Costs file to update. + properties: + attributes: + $ref: "#/components/schemas/CustomCostsFileUpdateAttributes" + id: + description: ID of the Custom Costs file. + example: "00000000-0000-0000-0000-000000000007" + type: string + type: + $ref: "#/components/schemas/CustomCostsFileUpdateType" + required: + - id + - type + - attributes + type: object + CustomCostsFileUpdateRequest: + description: Request for updating a Custom Costs file. + properties: + data: + $ref: "#/components/schemas/CustomCostsFileUpdateData" + required: + - data + type: object + CustomCostsFileUpdateType: + default: cost_metadata + description: Type of the Custom Costs file resource. + enum: + - cost_metadata + example: cost_metadata + type: string + x-enum-varnames: + - COST_METADATA CustomCostsFileUploadRequest: description: Request for uploading a Custom Costs file. items: @@ -172408,6 +172451,72 @@ paths: summary: Get Custom Costs file tags: - Cloud Cost Management + patch: + description: >- + Mark whether a Custom Costs file holds AI provider costs. Datadog then recomputes the costs for the months that the file covers. + operationId: UpdateCustomCostsFile + parameters: + - $ref: "#/components/parameters/FileID" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + ai_provider: true + id: 00000000-0000-0000-0000-000000000007 + type: cost_metadata + schema: + $ref: "#/components/schemas/CustomCostsFileUpdateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + billed_cost: 100.5 + billing_currency: USD + charge_period: + end: 1706745600000 + start: 1704067200000 + name: my_file.json + provider_names: + - my_provider + status: ACTIVE + uploaded_at: 1704067200000 + id: 00000000-0000-0000-0000-000000000007 + type: cost_metadata + meta: + version: "1.0" + schema: + $ref: "#/components/schemas/CustomCostsFileUploadResponse" + description: OK + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_write + summary: Update Custom Costs file + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_write /api/v2/cost/gcp_uc_config: get: description: List the Google Cloud Usage Cost configs. diff --git a/examples/v2/cloud-cost-management/UpdateCustomCostsFile.java b/examples/v2/cloud-cost-management/UpdateCustomCostsFile.java new file mode 100644 index 00000000000..bcf049322e0 --- /dev/null +++ b/examples/v2/cloud-cost-management/UpdateCustomCostsFile.java @@ -0,0 +1,41 @@ +// Update Custom Costs file returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.CloudCostManagementApi; +import com.datadog.api.client.v2.model.CustomCostsFileUpdateAttributes; +import com.datadog.api.client.v2.model.CustomCostsFileUpdateData; +import com.datadog.api.client.v2.model.CustomCostsFileUpdateRequest; +import com.datadog.api.client.v2.model.CustomCostsFileUpdateType; +import com.datadog.api.client.v2.model.CustomCostsFileUploadResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + CloudCostManagementApi apiInstance = new CloudCostManagementApi(defaultClient); + + // there is a valid "custom_costs_file" in the system + String CUSTOM_COSTS_FILE_DATA_ID = System.getenv("CUSTOM_COSTS_FILE_DATA_ID"); + + CustomCostsFileUpdateRequest body = + new CustomCostsFileUpdateRequest() + .data( + new CustomCostsFileUpdateData() + .attributes(new CustomCostsFileUpdateAttributes().aiProvider(true)) + .id(CUSTOM_COSTS_FILE_DATA_ID) + .type(CustomCostsFileUpdateType.COST_METADATA)); + + try { + CustomCostsFileUploadResponse result = + apiInstance.updateCustomCostsFile(CUSTOM_COSTS_FILE_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling CloudCostManagementApi#updateCustomCostsFile"); + 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/CloudCostManagementApi.java b/src/main/java/com/datadog/api/client/v2/api/CloudCostManagementApi.java index 9a6766d078e..979bb8c3c7d 100644 --- a/src/main/java/com/datadog/api/client/v2/api/CloudCostManagementApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/CloudCostManagementApi.java @@ -53,6 +53,7 @@ import com.datadog.api.client.v2.model.CustomCostsFileGetResponse; import com.datadog.api.client.v2.model.CustomCostsFileLineItem; import com.datadog.api.client.v2.model.CustomCostsFileListResponse; +import com.datadog.api.client.v2.model.CustomCostsFileUpdateRequest; import com.datadog.api.client.v2.model.CustomCostsFileUploadResponse; import com.datadog.api.client.v2.model.CustomForecastResponse; import com.datadog.api.client.v2.model.CustomForecastUpsertRequest; @@ -12491,6 +12492,165 @@ public ApiResponse updateCustomAllocationRuleWithHttpInfo new GenericType() {}); } + /** + * Update Custom Costs file. + * + *

See {@link #updateCustomCostsFileWithHttpInfo}. + * + * @param fileId File ID. (required) + * @param body (required) + * @return CustomCostsFileUploadResponse + * @throws ApiException if fails to make API call + */ + public CustomCostsFileUploadResponse updateCustomCostsFile( + String fileId, CustomCostsFileUpdateRequest body) throws ApiException { + return updateCustomCostsFileWithHttpInfo(fileId, body).getData(); + } + + /** + * Update Custom Costs file. + * + *

See {@link #updateCustomCostsFileWithHttpInfoAsync}. + * + * @param fileId File ID. (required) + * @param body (required) + * @return CompletableFuture<CustomCostsFileUploadResponse> + */ + public CompletableFuture updateCustomCostsFileAsync( + String fileId, CustomCostsFileUpdateRequest body) { + return updateCustomCostsFileWithHttpInfoAsync(fileId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Mark whether a Custom Costs file holds AI provider costs. Datadog then recomputes the costs for + * the months that the file covers. + * + * @param fileId File ID. (required) + * @param body (required) + * @return ApiResponse<CustomCostsFileUploadResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse updateCustomCostsFileWithHttpInfo( + String fileId, CustomCostsFileUpdateRequest body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'fileId' is set + if (fileId == null) { + throw new ApiException( + 400, "Missing the required parameter 'fileId' when calling updateCustomCostsFile"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateCustomCostsFile"); + } + // create path and map variables + String localVarPath = + "/api/v2/cost/custom_costs/{file_id}" + .replaceAll("\\{" + "file_id" + "\\}", apiClient.escapeString(fileId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.CloudCostManagementApi.updateCustomCostsFile", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update Custom Costs file. + * + *

See {@link #updateCustomCostsFileWithHttpInfo}. + * + * @param fileId File ID. (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<CustomCostsFileUploadResponse>> + */ + public CompletableFuture> + updateCustomCostsFileWithHttpInfoAsync(String fileId, CustomCostsFileUpdateRequest body) { + Object localVarPostBody = body; + + // verify the required parameter 'fileId' is set + if (fileId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'fileId' when calling updateCustomCostsFile")); + 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 updateCustomCostsFile")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/cost/custom_costs/{file_id}" + .replaceAll("\\{" + "file_id" + "\\}", apiClient.escapeString(fileId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.CloudCostManagementApi.updateCustomCostsFile", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Update tag pipeline ruleset. * diff --git a/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateAttributes.java new file mode 100644 index 00000000000..5389836035d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateAttributes.java @@ -0,0 +1,145 @@ +/* + * 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 of a Custom Costs file that can be updated. */ +@JsonPropertyOrder({CustomCostsFileUpdateAttributes.JSON_PROPERTY_AI_PROVIDER}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CustomCostsFileUpdateAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_AI_PROVIDER = "ai_provider"; + private Boolean aiProvider; + + public CustomCostsFileUpdateAttributes() {} + + @JsonCreator + public CustomCostsFileUpdateAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_AI_PROVIDER) Boolean aiProvider) { + this.aiProvider = aiProvider; + } + + public CustomCostsFileUpdateAttributes aiProvider(Boolean aiProvider) { + this.aiProvider = aiProvider; + return this; + } + + /** + * Whether the Custom Costs file contains the costs of an AI provider. + * + * @return aiProvider + */ + @JsonProperty(JSON_PROPERTY_AI_PROVIDER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getAiProvider() { + return aiProvider; + } + + public void setAiProvider(Boolean aiProvider) { + this.aiProvider = aiProvider; + } + + /** + * 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 CustomCostsFileUpdateAttributes + */ + @JsonAnySetter + public CustomCostsFileUpdateAttributes 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 CustomCostsFileUpdateAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomCostsFileUpdateAttributes customCostsFileUpdateAttributes = + (CustomCostsFileUpdateAttributes) o; + return Objects.equals(this.aiProvider, customCostsFileUpdateAttributes.aiProvider) + && Objects.equals( + this.additionalProperties, customCostsFileUpdateAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(aiProvider, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CustomCostsFileUpdateAttributes {\n"); + sb.append(" aiProvider: ").append(toIndentedString(aiProvider)).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/CustomCostsFileUpdateData.java b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateData.java new file mode 100644 index 00000000000..a45bd63c236 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateData.java @@ -0,0 +1,213 @@ +/* + * 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; + +/** Custom Costs file to update. */ +@JsonPropertyOrder({ + CustomCostsFileUpdateData.JSON_PROPERTY_ATTRIBUTES, + CustomCostsFileUpdateData.JSON_PROPERTY_ID, + CustomCostsFileUpdateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CustomCostsFileUpdateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private CustomCostsFileUpdateAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private CustomCostsFileUpdateType type = CustomCostsFileUpdateType.COST_METADATA; + + public CustomCostsFileUpdateData() {} + + @JsonCreator + public CustomCostsFileUpdateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + CustomCostsFileUpdateAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) CustomCostsFileUpdateType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public CustomCostsFileUpdateData attributes(CustomCostsFileUpdateAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a Custom Costs file that can be updated. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CustomCostsFileUpdateAttributes getAttributes() { + return attributes; + } + + public void setAttributes(CustomCostsFileUpdateAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public CustomCostsFileUpdateData id(String id) { + this.id = id; + return this; + } + + /** + * ID of the Custom Costs file. + * + * @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 CustomCostsFileUpdateData type(CustomCostsFileUpdateType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of the Custom Costs file resource. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CustomCostsFileUpdateType getType() { + return type; + } + + public void setType(CustomCostsFileUpdateType 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 CustomCostsFileUpdateData + */ + @JsonAnySetter + public CustomCostsFileUpdateData 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 CustomCostsFileUpdateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomCostsFileUpdateData customCostsFileUpdateData = (CustomCostsFileUpdateData) o; + return Objects.equals(this.attributes, customCostsFileUpdateData.attributes) + && Objects.equals(this.id, customCostsFileUpdateData.id) + && Objects.equals(this.type, customCostsFileUpdateData.type) + && Objects.equals( + this.additionalProperties, customCostsFileUpdateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CustomCostsFileUpdateData {\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/CustomCostsFileUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateRequest.java new file mode 100644 index 00000000000..0129794634f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateRequest.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; + +/** Request for updating a Custom Costs file. */ +@JsonPropertyOrder({CustomCostsFileUpdateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class CustomCostsFileUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private CustomCostsFileUpdateData data; + + public CustomCostsFileUpdateRequest() {} + + @JsonCreator + public CustomCostsFileUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) CustomCostsFileUpdateData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public CustomCostsFileUpdateRequest data(CustomCostsFileUpdateData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Custom Costs file to update. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public CustomCostsFileUpdateData getData() { + return data; + } + + public void setData(CustomCostsFileUpdateData 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 CustomCostsFileUpdateRequest + */ + @JsonAnySetter + public CustomCostsFileUpdateRequest 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 CustomCostsFileUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomCostsFileUpdateRequest customCostsFileUpdateRequest = (CustomCostsFileUpdateRequest) o; + return Objects.equals(this.data, customCostsFileUpdateRequest.data) + && Objects.equals( + this.additionalProperties, customCostsFileUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CustomCostsFileUpdateRequest {\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/CustomCostsFileUpdateType.java b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateType.java new file mode 100644 index 00000000000..2d70e751114 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CustomCostsFileUpdateType.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; + +/** Type of the Custom Costs file resource. */ +@JsonSerialize(using = CustomCostsFileUpdateType.CustomCostsFileUpdateTypeSerializer.class) +public class CustomCostsFileUpdateType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("cost_metadata")); + + public static final CustomCostsFileUpdateType COST_METADATA = + new CustomCostsFileUpdateType("cost_metadata"); + + CustomCostsFileUpdateType(String value) { + super(value, allowedValues); + } + + public static class CustomCostsFileUpdateTypeSerializer + extends StdSerializer { + public CustomCostsFileUpdateTypeSerializer(Class t) { + super(t); + } + + public CustomCostsFileUpdateTypeSerializer() { + this(null); + } + + @Override + public void serialize( + CustomCostsFileUpdateType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static CustomCostsFileUpdateType fromValue(String value) { + return new CustomCostsFileUpdateType(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/cloud_cost_management.feature b/src/test/resources/com/datadog/api/client/v2/api/cloud_cost_management.feature index fbcb675f81e..5f4cbc46c0b 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/cloud_cost_management.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/cloud_cost_management.feature @@ -1082,6 +1082,24 @@ Feature: Cloud Cost Management Then the response status is 200 OK And the response "data.type" is equal to "azure_uc_configs" + @team:ddoghq/cloud-cost-management + Scenario: Update Custom Costs file returns "Not Found" response + Given new "UpdateCustomCostsFile" request + And request contains "file_id" parameter with value "00000000-0000-0000-0000-000000000000" + And body with value {"data": {"attributes": {"ai_provider": true}, "id": "00000000-0000-0000-0000-000000000000", "type": "cost_metadata"}} + When the request is sent + Then the response status is 404 Not Found + + @team:ddoghq/cloud-cost-management + Scenario: Update Custom Costs file returns "OK" response + Given there is a valid "custom_costs_file" in the system + And new "UpdateCustomCostsFile" request + And request contains "file_id" parameter from "custom_costs_file.data.id" + And body with value {"data": {"attributes": {"ai_provider": true}, "id": "{{ custom_costs_file.data.id }}", "type": "cost_metadata"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.ai_provider" is equal to true + @generated @skip @team:ddoghq/cloud-cost-management Scenario: Update Google Cloud Usage Cost config returns "Bad Request" response Given new "UpdateCostGCPUsageCostConfig" request diff --git a/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index 2d3ed35caf2..573d99e0fdd 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -337,6 +337,18 @@ "tag": "Security Monitoring", "operationId": "CreateCustomFramework" }, + { + "parameters": [ + { + "name": "body", + "value": "[{\"ProviderName\": \"my_provider\", \"ChargePeriodStart\": \"2026-10-01\", \"ChargePeriodEnd\": \"2026-10-31\", \"ChargeDescription\": \"my_description\", \"BilledCost\": 250, \"BillingCurrency\": \"USD\"}]" + } + ], + "step": "there is a valid \"custom_costs_file\" in the system", + "key": "custom_costs_file", + "tag": "Cloud Cost Management", + "operationId": "UploadCustomCostsFile" + }, { "parameters": [ { 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 2f7556080ed..84ea9502bdc 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 @@ -1939,6 +1939,12 @@ "type": "safe" } }, + "UpdateCustomCostsFile": { + "tag": "Cloud Cost Management", + "undo": { + "type": "idempotent" + } + }, "ListCostGCPUsageCostConfigs": { "tag": "Cloud Cost Management", "undo": { diff --git a/src/test/resources/generated-test/test-runner-data/manifest.json b/src/test/resources/generated-test/test-runner-data/manifest.json index caa6c8ef32d..052deee7d58 100644 --- a/src/test/resources/generated-test/test-runner-data/manifest.json +++ b/src/test/resources/generated-test/test-runner-data/manifest.json @@ -4634,6 +4634,20 @@ "scenario": "Update Cloud Cost Management Azure config returns \"OK\" response", "version": "v2" }, + { + "feature": "Cloud Cost Management", + "feature_file": "../../com/datadog/api/client/v2/api/cloud_cost_management.feature", + "file": "v2/cloud-cost-management/update-custom-costs-file-returns-not-found-response.json", + "scenario": "Update Custom Costs file returns \"Not Found\" response", + "version": "v2" + }, + { + "feature": "Cloud Cost Management", + "feature_file": "../../com/datadog/api/client/v2/api/cloud_cost_management.feature", + "file": "v2/cloud-cost-management/update-custom-costs-file-returns-ok-response.json", + "scenario": "Update Custom Costs file returns \"OK\" response", + "version": "v2" + }, { "feature": "Cloud Cost Management", "feature_file": "../../com/datadog/api/client/v2/api/cloud_cost_management.feature", diff --git a/src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-not-found-response.json b/src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-not-found-response.json new file mode 100644 index 00000000000..b8e437a4c2f --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-not-found-response.json @@ -0,0 +1,51 @@ +{ + "api": "CloudCostManagement", + "expected_status": 404, + "feature": "Cloud Cost Management", + "id": "v2/Cloud Cost Management/Update Custom Costs file returns \"Not Found\" response", + "operation_id": "UpdateCustomCostsFile", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CustomCostsFileUpdateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "ai_provider": true + }, + "id": "00000000-0000-0000-0000-000000000000", + "type": "cost_metadata" + } + } + }, + "content_type": "application/json", + "method": "PATCH", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "type": "literal", + "value": "00000000-0000-0000-0000-000000000000" + }, + "style": null + } + ], + "path": "/api/v2/cost/custom_costs/{file_id}" + }, + "scenario": "Update Custom Costs file returns \"Not Found\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-ok-response.json b/src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-ok-response.json new file mode 100644 index 00000000000..73fe6178bdd --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/cloud-cost-management/update-custom-costs-file-returns-ok-response.json @@ -0,0 +1,51 @@ +{ + "api": "CloudCostManagement", + "expected_status": 200, + "feature": "Cloud Cost Management", + "id": "v2/Cloud Cost Management/Update Custom Costs file returns \"OK\" response", + "operation_id": "UpdateCustomCostsFile", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CustomCostsFileUpdateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "ai_provider": true + }, + "id": "{{ custom_costs_file.data.id }}", + "type": "cost_metadata" + } + } + }, + "content_type": "application/json", + "method": "PATCH", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "custom_costs_file.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/cost/custom_costs/{file_id}" + }, + "scenario": "Update Custom Costs file returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-server-data/v2/cloud-cost-management.json b/src/test/resources/generated-test/test-server-data/v2/cloud-cost-management.json index 13b50e61490..29d24465e8e 100644 --- a/src/test/resources/generated-test/test-server-data/v2/cloud-cost-management.json +++ b/src/test/resources/generated-test/test-server-data/v2/cloud-cost-management.json @@ -1836,6 +1836,116 @@ "scenario": "Update Cloud Cost Management GCP Usage Cost config returns \"Bad Request\" response", "version": "v2" }, + { + "feature": "Cloud Cost Management", + "frozen_at": "2026-11-09T15:50:58.386Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "ai_provider": true + }, + "id": "00000000-0000-0000-0000-000000000000", + "type": "cost_metadata" + } + } + }, + "content_type": "application/json", + "method": "PATCH", + "path": "/api/v2/cost/custom_costs/00000000-0000-0000-0000-000000000000", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"file not found: 00000000-0000-0000-0000-000000000000\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Not Found", + "status": 404 + } + } + ], + "scenario": "Update Custom Costs file returns \"Not Found\" response", + "version": "v2" + }, + { + "feature": "Cloud Cost Management", + "frozen_at": "2026-11-09T15:50:59.765Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": [ + { + "BilledCost": 250, + "BillingCurrency": "USD", + "ChargeDescription": "my_description", + "ChargePeriodEnd": "2026-10-31", + "ChargePeriodStart": "2026-10-01", + "ProviderName": "my_provider" + } + ] + }, + "content_type": "application/json", + "method": "PUT", + "path": "/api/v2/cost/custom_costs", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"565b55e5-0fe7-4c65-93b0-0eb9046150ea\",\"type\":\"cost_metadata\",\"attributes\":{\"ai_provider\":false,\"billed_cost\":250,\"billing_currency\":\"USD\",\"charge_period\":{\"start\":1790812800000,\"end\":1793404800000},\"name\":\"data.json\",\"provider_names\":[\"my_provider\"],\"status\":\"UPLOADING\",\"uploaded_at\":1794239459982,\"uploaded_by\":{\"name\":\"C\u00e9dric Van Rompay\",\"icon\":\"https://secure.gravatar.com/avatar/fb5991514ab909a799dd362ad990f4f8?d=retro\\u0026s=48\",\"email\":\"cedric.vanrompay@datadoghq.com\"}}},\"meta\":{\"version\":\"1.0\"}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Accepted", + "status": 202 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "ai_provider": true + }, + "id": "565b55e5-0fe7-4c65-93b0-0eb9046150ea", + "type": "cost_metadata" + } + } + }, + "content_type": "application/json", + "method": "PATCH", + "path": "/api/v2/cost/custom_costs/565b55e5-0fe7-4c65-93b0-0eb9046150ea", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"565b55e5-0fe7-4c65-93b0-0eb9046150ea\",\"type\":\"cost_metadata\",\"attributes\":{\"ai_provider\":true,\"billed_cost\":250,\"billing_currency\":\"USD\",\"charge_period\":{\"start\":1790812800000,\"end\":1793404800000},\"name\":\"data.json\",\"provider_names\":[\"my_provider\"],\"status\":\"PROCESSING\",\"uploaded_at\":1794239459982,\"uploaded_by\":{\"name\":\"C\u00e9dric Van Rompay\",\"icon\":\"https://secure.gravatar.com/avatar/fb5991514ab909a799dd362ad990f4f8?d=retro\\u0026s=48\",\"email\":\"cedric.vanrompay@datadoghq.com\"}}},\"meta\":{\"version\":\"1.0\"}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Update Custom Costs file returns \"OK\" response", + "version": "v2" + }, { "feature": "Cloud Cost Management", "frozen_at": "2025-06-23T12:09:42.232Z",