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
19 changes: 19 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29573,6 +29573,10 @@ components:
CustomCostsFileMetadata:
description: Schema of a Custom Costs metadata.
properties:
ai_provider:
description: Whether the Custom Costs file contains the costs of an AI provider.
example: false
type: boolean
billed_cost:
description: Total cost in the cost file.
example: 100.50
Expand Down Expand Up @@ -29622,6 +29626,10 @@ components:
CustomCostsFileMetadataWithContent:
description: Schema of a cost file's metadata.
properties:
ai_provider:
description: Whether the Custom Costs file contains the costs of an AI provider.
example: false
type: boolean
billed_cost:
description: Total cost in the cost file.
example: 100.50
Expand Down Expand Up @@ -162340,6 +162348,7 @@ paths:
value:
data:
- attributes:
ai_provider: false
billed_cost: 100.5
billing_currency: USD
charge_period:
Expand Down Expand Up @@ -162387,6 +162396,14 @@ paths:
put:
description: Upload a Custom Costs file.
operationId: UploadCustomCostsFile
parameters:
- description: Whether the uploaded file contains the costs of an AI provider.
in: query
name: ai_provider
required: false
schema:
default: false
type: boolean
requestBody:
content:
application/json:
Expand All @@ -162410,6 +162427,7 @@ paths:
value:
data:
attributes:
ai_provider: false
billed_cost: 100.5
billing_currency: USD
charge_period:
Expand Down Expand Up @@ -162498,6 +162516,7 @@ paths:
value:
data:
attributes:
ai_provider: false
billed_cost: 100.5
billing_currency: USD
charge_period:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Upload Custom Costs file marked as an AI provider file returns "Accepted" 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_line_item import CustomCostsFileLineItem

body = [
CustomCostsFileLineItem(
provider_name="my_ai_provider",
charge_period_start="2023-05-06",
charge_period_end="2023-06-06",
charge_description="my_description",
billed_cost=250.0,
billing_currency="USD",
),
]

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CloudCostManagementApi(api_client)
response = api_instance.upload_custom_costs_file(ai_provider=True, body=body)

print(response)
12 changes: 12 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 @@ -2051,6 +2051,11 @@ def __init__(self, api_client=None):
"version": "v2",
},
params_map={
"ai_provider": {
"openapi_types": (bool,),
"attribute": "ai_provider",
"location": "query",
},
"body": {
"required": True,
"openapi_types": ([CustomCostsFileLineItem],),
Expand Down Expand Up @@ -3847,15 +3852,22 @@ def update_unit_cost(
def upload_custom_costs_file(
self,
body: List[CustomCostsFileLineItem],
*,
ai_provider: Union[bool, UnsetType] = unset,
) -> CustomCostsFileUploadResponse:
"""Upload Custom Costs file.

Upload a Custom Costs file.

:type body: [CustomCostsFileLineItem]
:param ai_provider: Whether the uploaded file contains the costs of an AI provider.
:type ai_provider: bool, optional
:rtype: CustomCostsFileUploadResponse
"""
kwargs: Dict[str, Any] = {}
if ai_provider is not unset:
kwargs["ai_provider"] = ai_provider

kwargs["body"] = body

return self._upload_custom_costs_file_endpoint.call_with_http_info(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def openapi_types(_):
from datadog_api_client.v2.model.custom_costs_user import CustomCostsUser

return {
"ai_provider": (bool,),
"billed_cost": (float,),
"billing_currency": (str,),
"charge_period": (CustomCostsFileUsageChargePeriod,),
Expand All @@ -36,6 +37,7 @@ def openapi_types(_):
}

attribute_map = {
"ai_provider": "ai_provider",
"billed_cost": "billed_cost",
"billing_currency": "billing_currency",
"charge_period": "charge_period",
Expand All @@ -48,6 +50,7 @@ def openapi_types(_):

def __init__(
self_,
ai_provider: Union[bool, UnsetType] = unset,
billed_cost: Union[float, UnsetType] = unset,
billing_currency: Union[str, UnsetType] = unset,
charge_period: Union[CustomCostsFileUsageChargePeriod, UnsetType] = unset,
Expand All @@ -61,6 +64,9 @@ def __init__(
"""
Schema of a Custom Costs metadata.

:param ai_provider: Whether the Custom Costs file contains the costs of an AI provider.
:type ai_provider: bool, optional

:param billed_cost: Total cost in the cost file.
:type billed_cost: float, optional

Expand All @@ -85,6 +91,8 @@ def __init__(
:param uploaded_by: Metadata of the user that has uploaded the Custom Costs file.
:type uploaded_by: CustomCostsUser, optional
"""
if ai_provider is not unset:
kwargs["ai_provider"] = ai_provider
if billed_cost is not unset:
kwargs["billed_cost"] = billed_cost
if billing_currency is not unset:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def openapi_types(_):
from datadog_api_client.v2.model.custom_costs_user import CustomCostsUser

return {
"ai_provider": (bool,),
"billed_cost": (float,),
"billing_currency": (str,),
"charge_period": (CustomCostsFileUsageChargePeriod,),
Expand All @@ -39,6 +40,7 @@ def openapi_types(_):
}

attribute_map = {
"ai_provider": "ai_provider",
"billed_cost": "billed_cost",
"billing_currency": "billing_currency",
"charge_period": "charge_period",
Expand All @@ -52,6 +54,7 @@ def openapi_types(_):

def __init__(
self_,
ai_provider: Union[bool, UnsetType] = unset,
billed_cost: Union[float, UnsetType] = unset,
billing_currency: Union[str, UnsetType] = unset,
charge_period: Union[CustomCostsFileUsageChargePeriod, UnsetType] = unset,
Expand All @@ -66,6 +69,9 @@ def __init__(
"""
Schema of a cost file's metadata.

:param ai_provider: Whether the Custom Costs file contains the costs of an AI provider.
:type ai_provider: bool, optional

:param billed_cost: Total cost in the cost file.
:type billed_cost: float, optional

Expand Down Expand Up @@ -93,6 +99,8 @@ def __init__(
:param uploaded_by: Metadata of the user that has uploaded the Custom Costs file.
:type uploaded_by: CustomCostsUser, optional
"""
if ai_provider is not unset:
kwargs["ai_provider"] = ai_provider
if billed_cost is not unset:
kwargs["billed_cost"] = billed_cost
if billing_currency is not unset:
Expand Down
7 changes: 7 additions & 0 deletions tests/generated-test/test-runner-data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4431,6 +4431,13 @@
"scenario": "Upload Custom Costs File returns \"Accepted\" response",
"version": "v2"
},
{
"feature": "Cloud Cost Management",
"feature_file": "../../v2/features/cloud_cost_management.feature",
"file": "v2/cloud-cost-management/upload-custom-costs-file-marked-as-an-ai-provider-file-returns-accepted-response.json",
"scenario": "Upload Custom Costs file marked as an AI provider file returns \"Accepted\" response",
"version": "v2"
},
{
"feature": "Cloud Cost Management",
"feature_file": "../../v2/features/cloud_cost_management.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"api": "CloudCostManagement",
"expected_status": 202,
"feature": "Cloud Cost Management",
"id": "v2/Cloud Cost Management/Upload Custom Costs file marked as an AI provider file returns \"Accepted\" response",
"operation_id": "UploadCustomCostsFile",
"request": {
"body": {
"schema": {
"format": null,
"items": {
"format": null,
"ref": "CustomCostsFileLineItem",
"type": "object"
},
"ref": "CustomCostsFileUploadRequest",
"type": "array"
},
"source": "inline",
"value": [
{
"BilledCost": 250,
"BillingCurrency": "USD",
"ChargeDescription": "my_description",
"ChargePeriodEnd": "2023-06-06",
"ChargePeriodStart": "2023-05-06",
"ProviderName": "my_ai_provider"
}
]
},
"content_type": "application/json",
"method": "PUT",
"pagination": false,
"parameters": [
{
"explode": null,
"in": "query",
"name": "ai_provider",
"required": false,
"schema": {
"format": null,
"ref": null,
"type": "boolean"
},
"source": {
"type": "literal",
"value": true
},
"style": null
}
],
"path": "/api/v2/cost/custom_costs"
},
"scenario": "Upload Custom Costs file marked as an AI provider file returns \"Accepted\" response",
"schema_version": 1,
"version": "v2"
}
9 changes: 9 additions & 0 deletions tests/v2/features/cloud_cost_management.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,15 @@ Feature: Cloud Cost Management
Then the response status is 202 Accepted
And the response "data.attributes.name" is equal to "data.json"

@team:ddoghq/cloud-cost-management
Scenario: Upload Custom Costs file marked as an AI provider file returns "Accepted" response
Given new "UploadCustomCostsFile" request
And request contains "ai_provider" parameter with value true
And body with value [{"ProviderName": "my_ai_provider", "ChargePeriodStart": "2023-05-06", "ChargePeriodEnd": "2023-06-06", "ChargeDescription": "my_description", "BilledCost": 250, "BillingCurrency": "USD"}]
When the request is sent
Then the response status is 202 Accepted
And the response "data.attributes.ai_provider" is equal to true

@generated @skip @team:ddoghq/cloud-cost-management
Scenario: Upload Custom Costs file returns "Accepted" response
Given new "UploadCustomCostsFile" request
Expand Down
Loading