Skip to content
Merged
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 @@ -34932,6 +34932,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 @@ -172651,6 +172694,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
32 changes: 32 additions & 0 deletions examples/v2/cloud-cost-management/UpdateCustomCostsFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Update Custom Costs file returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
from datadog_api_client.v2.model.custom_costs_file_update_attributes import CustomCostsFileUpdateAttributes
from datadog_api_client.v2.model.custom_costs_file_update_data import CustomCostsFileUpdateData
from datadog_api_client.v2.model.custom_costs_file_update_request import CustomCostsFileUpdateRequest
from datadog_api_client.v2.model.custom_costs_file_update_type import CustomCostsFileUpdateType

# there is a valid "custom_costs_file" in the system
CUSTOM_COSTS_FILE_DATA_ID = environ["CUSTOM_COSTS_FILE_DATA_ID"]

body = CustomCostsFileUpdateRequest(
data=CustomCostsFileUpdateData(
attributes=CustomCostsFileUpdateAttributes(
ai_provider=True,
),
id=CUSTOM_COSTS_FILE_DATA_ID,
type=CustomCostsFileUpdateType.COST_METADATA,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CloudCostManagementApi(api_client)
response = api_instance.update_custom_costs_file(file_id=CUSTOM_COSTS_FILE_DATA_ID, body=body)

print(response)
48 changes: 48 additions & 0 deletions src/datadog_api_client/v2/api/cloud_cost_management_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from datadog_api_client.v2.model.custom_costs_file_upload_response import CustomCostsFileUploadResponse
from datadog_api_client.v2.model.custom_costs_file_line_item import CustomCostsFileLineItem
from datadog_api_client.v2.model.custom_costs_file_get_response import CustomCostsFileGetResponse
from datadog_api_client.v2.model.custom_costs_file_update_request import CustomCostsFileUpdateRequest
from datadog_api_client.v2.model.gcp_usage_cost_configs_response import GCPUsageCostConfigsResponse
from datadog_api_client.v2.model.gcp_usage_cost_config_response import GCPUsageCostConfigResponse
from datadog_api_client.v2.model.gcp_usage_cost_config_post_request import GCPUsageCostConfigPostRequest
Expand Down Expand Up @@ -1989,6 +1990,32 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._update_custom_costs_file_endpoint = _Endpoint(
settings={
"response_type": (CustomCostsFileUploadResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/cost/custom_costs/{file_id}",
"operation_id": "update_custom_costs_file",
"http_method": "PATCH",
"version": "v2",
},
params_map={
"file_id": {
"required": True,
"openapi_types": (str,),
"attribute": "file_id",
"location": "path",
},
"body": {
"required": True,
"openapi_types": (CustomCostsFileUpdateRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

self._update_tag_pipelines_ruleset_endpoint = _Endpoint(
settings={
"response_type": (RulesetResp,),
Expand Down Expand Up @@ -3807,6 +3834,27 @@ def update_custom_allocation_rule(

return self._update_custom_allocation_rule_endpoint.call_with_http_info(**kwargs)

def update_custom_costs_file(
self,
file_id: str,
body: CustomCostsFileUpdateRequest,
) -> CustomCostsFileUploadResponse:
"""Update Custom Costs file.
Mark whether a Custom Costs file holds AI provider costs. Datadog then recomputes the costs for the months that the file covers.
:param file_id: File ID.
:type file_id: str
:type body: CustomCostsFileUpdateRequest
:rtype: CustomCostsFileUploadResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["file_id"] = file_id

kwargs["body"] = body

return self._update_custom_costs_file_endpoint.call_with_http_info(**kwargs)

def update_tag_pipelines_ruleset(
self,
ruleset_id: str,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


class CustomCostsFileUpdateAttributes(ModelNormal):
@cached_property
def openapi_types(_):
return {
"ai_provider": (bool,),
}

attribute_map = {
"ai_provider": "ai_provider",
}

def __init__(self_, ai_provider: bool, **kwargs):
"""
Attributes of a Custom Costs file that can be updated.
:param ai_provider: Whether the Custom Costs file contains the costs of an AI provider.
:type ai_provider: bool
"""
super().__init__(kwargs)

self_.ai_provider = ai_provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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.
from __future__ import annotations

from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.custom_costs_file_update_attributes import CustomCostsFileUpdateAttributes
from datadog_api_client.v2.model.custom_costs_file_update_type import CustomCostsFileUpdateType


class CustomCostsFileUpdateData(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.custom_costs_file_update_attributes import CustomCostsFileUpdateAttributes
from datadog_api_client.v2.model.custom_costs_file_update_type import CustomCostsFileUpdateType

return {
"attributes": (CustomCostsFileUpdateAttributes,),
"id": (str,),
"type": (CustomCostsFileUpdateType,),
}

attribute_map = {
"attributes": "attributes",
"id": "id",
"type": "type",
}

def __init__(
self_, attributes: CustomCostsFileUpdateAttributes, id: str, type: CustomCostsFileUpdateType, **kwargs
):
"""
Custom Costs file to update.
:param attributes: Attributes of a Custom Costs file that can be updated.
:type attributes: CustomCostsFileUpdateAttributes
:param id: ID of the Custom Costs file.
:type id: str
:param type: Type of the Custom Costs file resource.
:type type: CustomCostsFileUpdateType
"""
super().__init__(kwargs)

self_.attributes = attributes
self_.id = id
self_.type = type
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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.
from __future__ import annotations

from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.custom_costs_file_update_data import CustomCostsFileUpdateData


class CustomCostsFileUpdateRequest(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.custom_costs_file_update_data import CustomCostsFileUpdateData

return {
"data": (CustomCostsFileUpdateData,),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: CustomCostsFileUpdateData, **kwargs):
"""
Request for updating a Custom Costs file.
:param data: Custom Costs file to update.
:type data: CustomCostsFileUpdateData
"""
super().__init__(kwargs)

self_.data = data
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class CustomCostsFileUpdateType(ModelSimple):
"""
Type of the Custom Costs file resource.
:param value: If omitted defaults to "cost_metadata". Must be one of ["cost_metadata"].
:type value: str
"""

allowed_values = {
"cost_metadata",
}
COST_METADATA: ClassVar["CustomCostsFileUpdateType"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


CustomCostsFileUpdateType.COST_METADATA = CustomCostsFileUpdateType("cost_metadata")
Loading
Loading