Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
41 changes: 41 additions & 0 deletions examples/v2/cloud-cost-management/UpdateCustomCostsFile.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -12491,6 +12492,165 @@ public ApiResponse<ArbitraryRuleResponse> updateCustomAllocationRuleWithHttpInfo
new GenericType<ArbitraryRuleResponse>() {});
}

/**
* Update Custom Costs file.
*
* <p>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.
*
* <p>See {@link #updateCustomCostsFileWithHttpInfoAsync}.
*
* @param fileId File ID. (required)
* @param body (required)
* @return CompletableFuture&lt;CustomCostsFileUploadResponse&gt;
*/
public CompletableFuture<CustomCostsFileUploadResponse> 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&lt;CustomCostsFileUploadResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table border="1">
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<CustomCostsFileUploadResponse> 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<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder =
apiClient.createBuilder(
"v2.CloudCostManagementApi.updateCustomCostsFile",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
return apiClient.invokeAPI(
"PATCH",
builder,
localVarHeaderParams,
new String[] {"application/json"},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<CustomCostsFileUploadResponse>() {});
}

/**
* Update Custom Costs file.
*
* <p>See {@link #updateCustomCostsFileWithHttpInfo}.
*
* @param fileId File ID. (required)
* @param body (required)
* @return CompletableFuture&lt;ApiResponse&lt;CustomCostsFileUploadResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<CustomCostsFileUploadResponse>>
updateCustomCostsFileWithHttpInfoAsync(String fileId, CustomCostsFileUpdateRequest body) {
Object localVarPostBody = body;

// verify the required parameter 'fileId' is set
if (fileId == null) {
CompletableFuture<ApiResponse<CustomCostsFileUploadResponse>> 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<ApiResponse<CustomCostsFileUploadResponse>> 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<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.CloudCostManagementApi.updateCustomCostsFile",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
} catch (ApiException ex) {
CompletableFuture<ApiResponse<CustomCostsFileUploadResponse>> result =
new CompletableFuture<>();
result.completeExceptionally(ex);
return result;
}
return apiClient.invokeAPIAsync(
"PATCH",
builder,
localVarHeaderParams,
new String[] {"application/json"},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<CustomCostsFileUploadResponse>() {});
}

/**
* Update tag pipeline ruleset.
*
Expand Down
Loading
Loading