diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e6d194c159..0cbaf7439c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2122,6 +2122,15 @@ components: required: true schema: type: string + UnitCostID: + description: The UUID of the unit cost. + example: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + in: path + name: unit_cost_id + required: true + schema: + format: uuid + type: string UserAuthorizedClientId: description: The ID of the user authorized client. in: path @@ -121250,6 +121259,236 @@ components: example: min type: string type: object + UnitCostCreateRequest: + description: A request to create a unit cost. + properties: + data: + $ref: '#/components/schemas/UnitCostCreateRequestData' + required: + - data + type: object + UnitCostCreateRequestData: + description: The data object of a unit cost create request. + properties: + attributes: + $ref: '#/components/schemas/UnitCostRequestAttributes' + type: + $ref: '#/components/schemas/UnitCostType' + required: + - type + - attributes + type: object + UnitCostDataAttributesResponse: + description: The attributes of a unit cost. + properties: + created_at: + description: The time the unit cost was created. + example: "2026-09-01T18:46:15.933716Z" + format: date-time + type: string + created_by: + description: The UUID of the user who created the unit cost. + example: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + format: uuid + type: string + denominator_query: + $ref: '#/components/schemas/UnitCostQueryDefinition' + denominator_type: + description: |- + The data source of the denominator queries, or `multisource` when the denominator + queries span more than one data source. + example: metrics + type: string + description: + description: The description of the unit cost. Omitted when the unit cost has no description. + example: Amortized cloud spend divided by the number of active users. + nullable: true + type: string + name: + description: The name of the unit cost. + example: Cloud cost per active user + type: string + numerator_query: + $ref: '#/components/schemas/UnitCostQueryDefinition' + org_id: + description: The ID of the organization the unit cost belongs to. + example: 321813 + format: int64 + type: integer + unit_label: + description: The label describing the denominator unit. + example: user + type: string + updated_at: + description: The time the unit cost was last updated. + example: "2026-09-01T19:52:08.820536Z" + format: date-time + type: string + updated_by: + description: The UUID of the user who last updated the unit cost. + example: 13cc0adf-2595-479e-b448-5051c180dddb + format: uuid + type: string + required: + - org_id + - name + - numerator_query + - denominator_query + - denominator_type + - unit_label + - created_by + - updated_by + - created_at + - updated_at + type: object + UnitCostDataResponse: + description: The data object of a unit cost response. + properties: + attributes: + $ref: '#/components/schemas/UnitCostDataAttributesResponse' + id: + description: The UUID of the unit cost. + example: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + format: uuid + type: string + type: + $ref: '#/components/schemas/UnitCostType' + required: + - id + - type + - attributes + type: object + UnitCostDataResponseArray: + description: The list of unit costs. + items: + $ref: '#/components/schemas/UnitCostDataResponse' + type: array + UnitCostFormula: + additionalProperties: {} + description: |- + A formula combining the named queries into a single result, passed through to the + query engine unchanged. + example: + formula: numerator + type: object + UnitCostFormulaArray: + description: The list of formulas applied to the queries for this side of the ratio. + example: + - formula: numerator + items: + $ref: '#/components/schemas/UnitCostFormula' + type: array + UnitCostQuery: + additionalProperties: {} + description: |- + A single query contributing to a unit cost numerator or denominator. The accepted fields + depend on the data source the query targets, for example `cloud_cost`, `metrics`, `dora`, + or `ci_pipelines`, and are passed through to the query engine unchanged. + example: + data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + type: object + UnitCostQueryArray: + description: The list of queries evaluated for this side of the ratio. + example: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + items: + $ref: '#/components/schemas/UnitCostQuery' + type: array + UnitCostQueryDefinition: + additionalProperties: {} + description: A timeseries object containing `queries` and `formulas` arrays. + properties: + formulas: + $ref: '#/components/schemas/UnitCostFormulaArray' + queries: + $ref: '#/components/schemas/UnitCostQueryArray' + required: + - queries + - formulas + type: object + UnitCostRequestAttributes: + description: The attributes of a unit cost create or replace request. + properties: + denominator_query: + $ref: '#/components/schemas/UnitCostQueryDefinition' + description: + description: An optional description of the unit cost. At most 2000 characters. + example: Amortized cloud spend divided by the number of active users. + maxLength: 2000 + nullable: true + type: string + name: + description: The name of the unit cost. At most 200 characters. + example: Cloud cost per active user + maxLength: 200 + type: string + numerator_query: + $ref: '#/components/schemas/UnitCostQueryDefinition' + unit_label: + description: The label describing the denominator unit, for example `user`. At most 100 characters. + example: user + maxLength: 100 + type: string + required: + - name + - numerator_query + - denominator_query + - unit_label + type: object + UnitCostResponse: + description: A response containing a single unit cost. + properties: + data: + $ref: '#/components/schemas/UnitCostDataResponse' + required: + - data + type: object + UnitCostType: + default: unit_cost + description: The JSON:API resource type for a unit cost. + enum: + - unit_cost + example: unit_cost + type: string + x-enum-varnames: + - UNIT_COST + UnitCostUpdateRequest: + description: A request to replace a unit cost. + properties: + data: + $ref: '#/components/schemas/UnitCostUpdateRequestData' + required: + - data + type: object + UnitCostUpdateRequestData: + description: The data object of a unit cost replace request. + properties: + attributes: + $ref: '#/components/schemas/UnitCostRequestAttributes' + id: + description: The UUID of the unit cost being replaced. Must match the `unit_cost_id` path parameter. + example: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + format: uuid + type: string + type: + $ref: '#/components/schemas/UnitCostType' + required: + - id + - type + - attributes + type: object + UnitCostsResponse: + description: A response containing a list of unit costs. + properties: + data: + $ref: '#/components/schemas/UnitCostDataResponseArray' + required: + - data + type: object UnpublishAppResponse: description: The response object after an app is successfully unpublished. properties: @@ -143839,6 +144078,416 @@ paths: operator: OR permissions: - cloud_cost_management_read + /api/v2/cost/unit_costs: + get: + description: List the ROI metrics (unit costs) for the authenticated organization. + operationId: ListUnitCosts + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + created_at: "2026-09-01T18:46:15.933716Z" + created_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + denominator_query: + formulas: + - formula: denominator + queries: + - data_source: metrics + name: denominator + query: "avg:system.cpu.user{*}" + response_format: timeseries + denominator_type: metrics + name: Cloud cost per active user + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + response_format: timeseries + org_id: 321813 + unit_label: user + updated_at: "2026-09-01T19:52:08.820536Z" + updated_by: 13cc0adf-2595-479e-b448-5051c180dddb + id: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + type: unit_cost + - attributes: + created_at: "2026-09-02T00:59:12.708413Z" + created_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + denominator_query: + formulas: + - formula: denominator + queries: + - compute: + aggregation: count + data_source: ci_pipelines + group_by: [] + indexes: + - "*" + name: denominator + search: + query: "ci_level:pipeline @ci.status:success" + storage: hot + response_format: timeseries + denominator_type: ci_pipelines + name: Cloud cost per successful pipeline + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:custom.cost.amortized{*}.rollup(sum, daily)" + response_format: timeseries + org_id: 321813 + unit_label: pipeline + updated_at: "2026-09-02T01:00:05.709773Z" + updated_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + id: ab11677e-396e-4dce-8018-bbeb398315ae + type: unit_cost + schema: + $ref: '#/components/schemas/UnitCostsResponse' + description: OK + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List unit costs + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: Create an ROI metric (unit cost) using the given numerator and denominator queries. + operationId: CreateUnitCost + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + denominator_query: + formulas: + - formula: denominator + queries: + - data_source: metrics + name: denominator + query: "avg:system.cpu.user{*}" + response_format: timeseries + name: Cloud cost per active user + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + response_format: timeseries + unit_label: user + type: unit_cost + schema: + $ref: '#/components/schemas/UnitCostCreateRequest' + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-09-01T18:46:15.933716Z" + created_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + denominator_query: + formulas: + - formula: denominator + queries: + - data_source: metrics + name: denominator + query: "avg:system.cpu.user{*}" + response_format: timeseries + denominator_type: metrics + name: Cloud cost per active user + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + response_format: timeseries + org_id: 321813 + unit_label: user + updated_at: "2026-09-01T18:46:15.933716Z" + updated_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + id: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + type: unit_cost + schema: + $ref: '#/components/schemas/UnitCostResponse' + description: Created + headers: + Location: + description: The path of the newly created unit cost. + schema: + type: string + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create a unit cost + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/cost/unit_costs/{unit_cost_id}: + delete: + description: Delete an ROI metric (unit cost). + operationId: DeleteUnitCost + parameters: + - $ref: "#/components/parameters/UnitCostID" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete a unit cost + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: Retrieve an ROI metric (unit cost) by UUID. + operationId: GetUnitCost + parameters: + - $ref: "#/components/parameters/UnitCostID" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-09-01T18:46:15.933716Z" + created_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + denominator_query: + formulas: + - formula: denominator + queries: + - data_source: metrics + name: denominator + query: "avg:system.cpu.user{*}" + response_format: timeseries + denominator_type: metrics + name: Cloud cost per active user + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + response_format: timeseries + org_id: 321813 + unit_label: user + updated_at: "2026-09-01T19:52:08.820536Z" + updated_by: 13cc0adf-2595-479e-b448-5051c180dddb + id: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + type: unit_cost + schema: + $ref: '#/components/schemas/UnitCostResponse' + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a unit cost + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + put: + description: Replace an ROI metric (unit cost) with a new set of attributes. + operationId: UpdateUnitCost + parameters: + - $ref: "#/components/parameters/UnitCostID" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + denominator_query: + formulas: + - formula: denominator + queries: + - data_source: metrics + name: denominator + query: "avg:system.cpu.user{*}" + response_format: timeseries + name: Cloud cost per active user + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + response_format: timeseries + unit_label: user + id: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + type: unit_cost + schema: + $ref: '#/components/schemas/UnitCostUpdateRequest' + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-09-01T18:46:15.933716Z" + created_by: 36ea1610-8866-4bd3-bb6d-9bb9fc87cad2 + denominator_query: + formulas: + - formula: denominator + queries: + - data_source: metrics + name: denominator + query: "avg:system.cpu.user{*}" + response_format: timeseries + denominator_type: metrics + name: Cloud cost per active user + numerator_query: + formulas: + - formula: numerator + queries: + - data_source: cloud_cost + name: numerator + query: "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)" + response_format: timeseries + org_id: 321813 + unit_label: user + updated_at: "2026-09-01T19:52:08.820536Z" + updated_by: 13cc0adf-2595-479e-b448-5051c180dddb + id: 64aecd58-e355-4f07-9c3a-56ff6bda6cd8 + type: unit_cost + schema: + $ref: '#/components/schemas/UnitCostResponse' + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update a unit cost + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/cost_by_tag/active_billing_dimensions: get: description: |- diff --git a/examples/v2/cloud-cost-management/CreateUnitCost.py b/examples/v2/cloud-cost-management/CreateUnitCost.py new file mode 100644 index 0000000000..a0d68fa89d --- /dev/null +++ b/examples/v2/cloud-cost-management/CreateUnitCost.py @@ -0,0 +1,60 @@ +""" +Create a unit cost returns "Created" response +""" + +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.unit_cost_create_request import UnitCostCreateRequest +from datadog_api_client.v2.model.unit_cost_create_request_data import UnitCostCreateRequestData +from datadog_api_client.v2.model.unit_cost_formula import UnitCostFormula +from datadog_api_client.v2.model.unit_cost_query import UnitCostQuery +from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition +from datadog_api_client.v2.model.unit_cost_request_attributes import UnitCostRequestAttributes +from datadog_api_client.v2.model.unit_cost_type import UnitCostType + +body = UnitCostCreateRequest( + data=UnitCostCreateRequestData( + attributes=UnitCostRequestAttributes( + denominator_query=UnitCostQueryDefinition( + formulas=[ + UnitCostFormula([("formula", "numerator")]), + ], + queries=[ + UnitCostQuery( + [ + ("data_source", "cloud_cost"), + ("name", "numerator"), + ("query", "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"), + ] + ), + ], + ), + description="Amortized cloud spend divided by the number of active users.", + name="Cloud cost per active user", + numerator_query=UnitCostQueryDefinition( + formulas=[ + UnitCostFormula([("formula", "numerator")]), + ], + queries=[ + UnitCostQuery( + [ + ("data_source", "cloud_cost"), + ("name", "numerator"), + ("query", "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"), + ] + ), + ], + ), + unit_label="user", + ), + type=UnitCostType.UNIT_COST, + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_unit_cost"] = True +with ApiClient(configuration) as api_client: + api_instance = CloudCostManagementApi(api_client) + response = api_instance.create_unit_cost(body=body) + + print(response) diff --git a/examples/v2/cloud-cost-management/DeleteUnitCost.py b/examples/v2/cloud-cost-management/DeleteUnitCost.py new file mode 100644 index 0000000000..6e9884c286 --- /dev/null +++ b/examples/v2/cloud-cost-management/DeleteUnitCost.py @@ -0,0 +1,15 @@ +""" +Delete a unit cost returns "No Content" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi +from uuid import UUID + +configuration = Configuration() +configuration.unstable_operations["delete_unit_cost"] = True +with ApiClient(configuration) as api_client: + api_instance = CloudCostManagementApi(api_client) + api_instance.delete_unit_cost( + unit_cost_id=UUID("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), + ) diff --git a/examples/v2/cloud-cost-management/GetUnitCost.py b/examples/v2/cloud-cost-management/GetUnitCost.py new file mode 100644 index 0000000000..e4a3775a9f --- /dev/null +++ b/examples/v2/cloud-cost-management/GetUnitCost.py @@ -0,0 +1,17 @@ +""" +Get a unit cost returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi +from uuid import UUID + +configuration = Configuration() +configuration.unstable_operations["get_unit_cost"] = True +with ApiClient(configuration) as api_client: + api_instance = CloudCostManagementApi(api_client) + response = api_instance.get_unit_cost( + unit_cost_id=UUID("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), + ) + + print(response) diff --git a/examples/v2/cloud-cost-management/ListUnitCosts.py b/examples/v2/cloud-cost-management/ListUnitCosts.py new file mode 100644 index 0000000000..9585693e4e --- /dev/null +++ b/examples/v2/cloud-cost-management/ListUnitCosts.py @@ -0,0 +1,14 @@ +""" +List unit costs returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi + +configuration = Configuration() +configuration.unstable_operations["list_unit_costs"] = True +with ApiClient(configuration) as api_client: + api_instance = CloudCostManagementApi(api_client) + response = api_instance.list_unit_costs() + + print(response) diff --git a/examples/v2/cloud-cost-management/UpdateUnitCost.py b/examples/v2/cloud-cost-management/UpdateUnitCost.py new file mode 100644 index 0000000000..eda4b474d1 --- /dev/null +++ b/examples/v2/cloud-cost-management/UpdateUnitCost.py @@ -0,0 +1,62 @@ +""" +Update a unit cost returns "OK" response +""" + +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.unit_cost_formula import UnitCostFormula +from datadog_api_client.v2.model.unit_cost_query import UnitCostQuery +from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition +from datadog_api_client.v2.model.unit_cost_request_attributes import UnitCostRequestAttributes +from datadog_api_client.v2.model.unit_cost_type import UnitCostType +from datadog_api_client.v2.model.unit_cost_update_request import UnitCostUpdateRequest +from datadog_api_client.v2.model.unit_cost_update_request_data import UnitCostUpdateRequestData +from uuid import UUID + +body = UnitCostUpdateRequest( + data=UnitCostUpdateRequestData( + attributes=UnitCostRequestAttributes( + denominator_query=UnitCostQueryDefinition( + formulas=[ + UnitCostFormula([("formula", "numerator")]), + ], + queries=[ + UnitCostQuery( + [ + ("data_source", "cloud_cost"), + ("name", "numerator"), + ("query", "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"), + ] + ), + ], + ), + description="Amortized cloud spend divided by the number of active users.", + name="Cloud cost per active user", + numerator_query=UnitCostQueryDefinition( + formulas=[ + UnitCostFormula([("formula", "numerator")]), + ], + queries=[ + UnitCostQuery( + [ + ("data_source", "cloud_cost"), + ("name", "numerator"), + ("query", "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"), + ] + ), + ], + ), + unit_label="user", + ), + id=UUID("64aecd58-e355-4f07-9c3a-56ff6bda6cd8"), + type=UnitCostType.UNIT_COST, + ), +) + +configuration = Configuration() +configuration.unstable_operations["update_unit_cost"] = True +with ApiClient(configuration) as api_client: + api_instance = CloudCostManagementApi(api_client) + response = api_instance.update_unit_cost(unit_cost_id=UUID("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 0afdd78e66..7ed00d569e 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -454,6 +454,8 @@ def __init__( "v2.get_code_coverage_branch_summary": False, "v2.get_code_coverage_commit_summary": False, "v2.get_rule_based_view": False, + "v2.create_unit_cost": False, + "v2.delete_unit_cost": False, "v2.get_commitments_commitment_list": False, "v2.get_commitments_coverage_scalar": False, "v2.get_commitments_coverage_timeseries": False, @@ -464,13 +466,16 @@ def __init__( "v2.get_commitments_utilization_timeseries": False, "v2.get_cost_anomaly": False, "v2.get_cost_tag_metadata_currency": False, + "v2.get_unit_cost": False, "v2.list_cost_anomalies": False, "v2.list_cost_tag_key_sources": False, "v2.list_cost_tag_metadata": False, "v2.list_cost_tag_metadata_metrics": False, "v2.list_cost_tag_metadata_months": False, "v2.list_cost_tag_metadata_orchestrators": False, + "v2.list_unit_costs": False, "v2.search_cost_recommendations": False, + "v2.update_unit_cost": False, "v2.create_quotas": False, "v2.delete_quota": False, "v2.list_quotas": False, diff --git a/src/datadog_api_client/v2/api/cloud_cost_management_api.py b/src/datadog_api_client/v2/api/cloud_cost_management_api.py index f5922c4530..bc1f11cc63 100644 --- a/src/datadog_api_client/v2/api/cloud_cost_management_api.py +++ b/src/datadog_api_client/v2/api/cloud_cost_management_api.py @@ -10,6 +10,7 @@ from datadog_api_client.model_utils import ( UnsetType, unset, + UUID, ) from datadog_api_client.v2.model.account_filters_response import AccountFiltersResponse from datadog_api_client.v2.model.account_filters_patch_request import AccountFiltersPatchRequest @@ -76,6 +77,10 @@ from datadog_api_client.v2.model.cost_orchestrators_response import CostOrchestratorsResponse from datadog_api_client.v2.model.cost_tag_key_sources_response import CostTagKeySourcesResponse from datadog_api_client.v2.model.cost_tags_response import CostTagsResponse +from datadog_api_client.v2.model.unit_costs_response import UnitCostsResponse +from datadog_api_client.v2.model.unit_cost_response import UnitCostResponse +from datadog_api_client.v2.model.unit_cost_create_request import UnitCostCreateRequest +from datadog_api_client.v2.model.unit_cost_update_request import UnitCostUpdateRequest from datadog_api_client.v2.model.ruleset_resp_array import RulesetRespArray from datadog_api_client.v2.model.ruleset_resp import RulesetResp from datadog_api_client.v2.model.create_ruleset_request import CreateRulesetRequest @@ -196,6 +201,26 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._create_unit_cost_endpoint = _Endpoint( + settings={ + "response_type": (UnitCostResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/cost/unit_costs", + "operation_id": "create_unit_cost", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (UnitCostCreateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._delete_budget_endpoint = _Endpoint( settings={ "response_type": None, @@ -408,6 +433,29 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._delete_unit_cost_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/cost/unit_costs/{unit_cost_id}", + "operation_id": "delete_unit_cost", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "unit_cost_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "unit_cost_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + }, + api_client=api_client, + ) + self._generate_cost_tag_description_by_key_endpoint = _Endpoint( settings={ "response_type": (GenerateCostTagDescriptionResponse,), @@ -1156,6 +1204,29 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_unit_cost_endpoint = _Endpoint( + settings={ + "response_type": (UnitCostResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/cost/unit_costs/{unit_cost_id}", + "operation_id": "get_unit_cost", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "unit_cost_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "unit_cost_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._list_budgets_endpoint = _Endpoint( settings={ "response_type": (BudgetArray,), @@ -1673,6 +1744,22 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._list_unit_costs_endpoint = _Endpoint( + settings={ + "response_type": (UnitCostsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/cost/unit_costs", + "operation_id": "list_unit_costs", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._reorder_custom_allocation_rules_endpoint = _Endpoint( settings={ "response_type": None, @@ -1899,6 +1986,32 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._update_unit_cost_endpoint = _Endpoint( + settings={ + "response_type": (UnitCostResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/cost/unit_costs/{unit_cost_id}", + "operation_id": "update_unit_cost", + "http_method": "PUT", + "version": "v2", + }, + params_map={ + "unit_cost_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "unit_cost_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (UnitCostUpdateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._upload_custom_costs_file_endpoint = _Endpoint( settings={ "response_type": (CustomCostsFileUploadResponse,), @@ -2136,6 +2249,22 @@ def create_tag_pipelines_ruleset( return self._create_tag_pipelines_ruleset_endpoint.call_with_http_info(**kwargs) + def create_unit_cost( + self, + body: UnitCostCreateRequest, + ) -> UnitCostResponse: + """Create a unit cost. + + Create an ROI metric (unit cost) using the given numerator and denominator queries. + + :type body: UnitCostCreateRequest + :rtype: UnitCostResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_unit_cost_endpoint.call_with_http_info(**kwargs) + def delete_budget( self, budget_id: str, @@ -2296,6 +2425,23 @@ def delete_tag_pipelines_ruleset( return self._delete_tag_pipelines_ruleset_endpoint.call_with_http_info(**kwargs) + def delete_unit_cost( + self, + unit_cost_id: UUID, + ) -> None: + """Delete a unit cost. + + Delete an ROI metric (unit cost). + + :param unit_cost_id: The UUID of the unit cost. + :type unit_cost_id: UUID + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["unit_cost_id"] = unit_cost_id + + return self._delete_unit_cost_endpoint.call_with_http_info(**kwargs) + def generate_cost_tag_description_by_key( self, tag_key: str, @@ -2916,6 +3062,23 @@ def get_tag_pipelines_ruleset( return self._get_tag_pipelines_ruleset_endpoint.call_with_http_info(**kwargs) + def get_unit_cost( + self, + unit_cost_id: UUID, + ) -> UnitCostResponse: + """Get a unit cost. + + Retrieve an ROI metric (unit cost) by UUID. + + :param unit_cost_id: The UUID of the unit cost. + :type unit_cost_id: UUID + :rtype: UnitCostResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["unit_cost_id"] = unit_cost_id + + return self._get_unit_cost_endpoint.call_with_http_info(**kwargs) + def list_budgets( self, ) -> BudgetArray: @@ -3380,6 +3543,18 @@ def list_tag_pipelines_rulesets_status( kwargs: Dict[str, Any] = {} return self._list_tag_pipelines_rulesets_status_endpoint.call_with_http_info(**kwargs) + def list_unit_costs( + self, + ) -> UnitCostsResponse: + """List unit costs. + + List the ROI metrics (unit costs) for the authenticated organization. + + :rtype: UnitCostsResponse + """ + kwargs: Dict[str, Any] = {} + return self._list_unit_costs_endpoint.call_with_http_info(**kwargs) + def reorder_custom_allocation_rules( self, body: ReorderRuleResourceArray, @@ -3588,6 +3763,27 @@ def update_tag_pipelines_ruleset( return self._update_tag_pipelines_ruleset_endpoint.call_with_http_info(**kwargs) + def update_unit_cost( + self, + unit_cost_id: UUID, + body: UnitCostUpdateRequest, + ) -> UnitCostResponse: + """Update a unit cost. + + Replace an ROI metric (unit cost) with a new set of attributes. + + :param unit_cost_id: The UUID of the unit cost. + :type unit_cost_id: UUID + :type body: UnitCostUpdateRequest + :rtype: UnitCostResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["unit_cost_id"] = unit_cost_id + + kwargs["body"] = body + + return self._update_unit_cost_endpoint.call_with_http_info(**kwargs) + def upload_custom_costs_file( self, body: List[CustomCostsFileLineItem], diff --git a/src/datadog_api_client/v2/model/unit_cost_create_request.py b/src/datadog_api_client/v2/model/unit_cost_create_request.py new file mode 100644 index 0000000000..605f1d2f70 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_create_request.py @@ -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.unit_cost_create_request_data import UnitCostCreateRequestData + + +class UnitCostCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_create_request_data import UnitCostCreateRequestData + + return { + "data": (UnitCostCreateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: UnitCostCreateRequestData, **kwargs): + """ + A request to create a unit cost. + + :param data: The data object of a unit cost create request. + :type data: UnitCostCreateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/unit_cost_create_request_data.py b/src/datadog_api_client/v2/model/unit_cost_create_request_data.py new file mode 100644 index 0000000000..6c79a7227b --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_create_request_data.py @@ -0,0 +1,48 @@ +# 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.unit_cost_request_attributes import UnitCostRequestAttributes + from datadog_api_client.v2.model.unit_cost_type import UnitCostType + + +class UnitCostCreateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_request_attributes import UnitCostRequestAttributes + from datadog_api_client.v2.model.unit_cost_type import UnitCostType + + return { + "attributes": (UnitCostRequestAttributes,), + "type": (UnitCostType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: UnitCostRequestAttributes, type: UnitCostType, **kwargs): + """ + The data object of a unit cost create request. + + :param attributes: The attributes of a unit cost create or replace request. + :type attributes: UnitCostRequestAttributes + + :param type: The JSON:API resource type for a unit cost. + :type type: UnitCostType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/unit_cost_data_attributes_response.py b/src/datadog_api_client/v2/model/unit_cost_data_attributes_response.py new file mode 100644 index 0000000000..b9d79b3114 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_data_attributes_response.py @@ -0,0 +1,121 @@ +# 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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + none_type, + unset, + UnsetType, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition + + +class UnitCostDataAttributesResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition + + return { + "created_at": (datetime,), + "created_by": (UUID,), + "denominator_query": (UnitCostQueryDefinition,), + "denominator_type": (str,), + "description": (str, none_type), + "name": (str,), + "numerator_query": (UnitCostQueryDefinition,), + "org_id": (int,), + "unit_label": (str,), + "updated_at": (datetime,), + "updated_by": (UUID,), + } + + attribute_map = { + "created_at": "created_at", + "created_by": "created_by", + "denominator_query": "denominator_query", + "denominator_type": "denominator_type", + "description": "description", + "name": "name", + "numerator_query": "numerator_query", + "org_id": "org_id", + "unit_label": "unit_label", + "updated_at": "updated_at", + "updated_by": "updated_by", + } + + def __init__( + self_, + created_at: datetime, + created_by: UUID, + denominator_query: UnitCostQueryDefinition, + denominator_type: str, + name: str, + numerator_query: UnitCostQueryDefinition, + org_id: int, + unit_label: str, + updated_at: datetime, + updated_by: UUID, + description: Union[str, none_type, UnsetType] = unset, + **kwargs, + ): + """ + The attributes of a unit cost. + + :param created_at: The time the unit cost was created. + :type created_at: datetime + + :param created_by: The UUID of the user who created the unit cost. + :type created_by: UUID + + :param denominator_query: A timeseries object containing ``queries`` and ``formulas`` arrays. + :type denominator_query: UnitCostQueryDefinition + + :param denominator_type: The data source of the denominator queries, or ``multisource`` when the denominator + queries span more than one data source. + :type denominator_type: str + + :param description: The description of the unit cost. Omitted when the unit cost has no description. + :type description: str, none_type, optional + + :param name: The name of the unit cost. + :type name: str + + :param numerator_query: A timeseries object containing ``queries`` and ``formulas`` arrays. + :type numerator_query: UnitCostQueryDefinition + + :param org_id: The ID of the organization the unit cost belongs to. + :type org_id: int + + :param unit_label: The label describing the denominator unit. + :type unit_label: str + + :param updated_at: The time the unit cost was last updated. + :type updated_at: datetime + + :param updated_by: The UUID of the user who last updated the unit cost. + :type updated_by: UUID + """ + if description is not unset: + kwargs["description"] = description + super().__init__(kwargs) + + self_.created_at = created_at + self_.created_by = created_by + self_.denominator_query = denominator_query + self_.denominator_type = denominator_type + self_.name = name + self_.numerator_query = numerator_query + self_.org_id = org_id + self_.unit_label = unit_label + self_.updated_at = updated_at + self_.updated_by = updated_by diff --git a/src/datadog_api_client/v2/model/unit_cost_data_response.py b/src/datadog_api_client/v2/model/unit_cost_data_response.py new file mode 100644 index 0000000000..8ee4aae7cd --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_data_response.py @@ -0,0 +1,55 @@ +# 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, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.unit_cost_data_attributes_response import UnitCostDataAttributesResponse + from datadog_api_client.v2.model.unit_cost_type import UnitCostType + + +class UnitCostDataResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_data_attributes_response import UnitCostDataAttributesResponse + from datadog_api_client.v2.model.unit_cost_type import UnitCostType + + return { + "attributes": (UnitCostDataAttributesResponse,), + "id": (UUID,), + "type": (UnitCostType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: UnitCostDataAttributesResponse, id: UUID, type: UnitCostType, **kwargs): + """ + The data object of a unit cost response. + + :param attributes: The attributes of a unit cost. + :type attributes: UnitCostDataAttributesResponse + + :param id: The UUID of the unit cost. + :type id: UUID + + :param type: The JSON:API resource type for a unit cost. + :type type: UnitCostType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/unit_cost_formula.py b/src/datadog_api_client/v2/model/unit_cost_formula.py new file mode 100644 index 0000000000..096e958777 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_formula.py @@ -0,0 +1,18 @@ +# 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, +) + + +class UnitCostFormula(ModelNormal): + def __init__(self_, **kwargs): + """ + A formula combining the named queries into a single result, passed through to the + query engine unchanged. + """ + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/unit_cost_query.py b/src/datadog_api_client/v2/model/unit_cost_query.py new file mode 100644 index 0000000000..5b810829f7 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_query.py @@ -0,0 +1,19 @@ +# 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, +) + + +class UnitCostQuery(ModelNormal): + def __init__(self_, **kwargs): + """ + A single query contributing to a unit cost numerator or denominator. The accepted fields + depend on the data source the query targets, for example ``cloud_cost`` , ``metrics`` , ``dora`` , + or ``ci_pipelines`` , and are passed through to the query engine unchanged. + """ + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/unit_cost_query_definition.py b/src/datadog_api_client/v2/model/unit_cost_query_definition.py new file mode 100644 index 0000000000..8a30d74f9c --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_query_definition.py @@ -0,0 +1,48 @@ +# 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 List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.unit_cost_formula import UnitCostFormula + from datadog_api_client.v2.model.unit_cost_query import UnitCostQuery + + +class UnitCostQueryDefinition(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_formula import UnitCostFormula + from datadog_api_client.v2.model.unit_cost_query import UnitCostQuery + + return { + "formulas": ([UnitCostFormula],), + "queries": ([UnitCostQuery],), + } + + attribute_map = { + "formulas": "formulas", + "queries": "queries", + } + + def __init__(self_, formulas: List[UnitCostFormula], queries: List[UnitCostQuery], **kwargs): + """ + A timeseries object containing ``queries`` and ``formulas`` arrays. + + :param formulas: The list of formulas applied to the queries for this side of the ratio. + :type formulas: [UnitCostFormula] + + :param queries: The list of queries evaluated for this side of the ratio. + :type queries: [UnitCostQuery] + """ + super().__init__(kwargs) + + self_.formulas = formulas + self_.queries = queries diff --git a/src/datadog_api_client/v2/model/unit_cost_request_attributes.py b/src/datadog_api_client/v2/model/unit_cost_request_attributes.py new file mode 100644 index 0000000000..9b161e9ab6 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_request_attributes.py @@ -0,0 +1,88 @@ +# 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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition + + +class UnitCostRequestAttributes(ModelNormal): + validations = { + "description": { + "max_length": 2000, + }, + "name": { + "max_length": 200, + }, + "unit_label": { + "max_length": 100, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition + + return { + "denominator_query": (UnitCostQueryDefinition,), + "description": (str, none_type), + "name": (str,), + "numerator_query": (UnitCostQueryDefinition,), + "unit_label": (str,), + } + + attribute_map = { + "denominator_query": "denominator_query", + "description": "description", + "name": "name", + "numerator_query": "numerator_query", + "unit_label": "unit_label", + } + + def __init__( + self_, + denominator_query: UnitCostQueryDefinition, + name: str, + numerator_query: UnitCostQueryDefinition, + unit_label: str, + description: Union[str, none_type, UnsetType] = unset, + **kwargs, + ): + """ + The attributes of a unit cost create or replace request. + + :param denominator_query: A timeseries object containing ``queries`` and ``formulas`` arrays. + :type denominator_query: UnitCostQueryDefinition + + :param description: An optional description of the unit cost. At most 2000 characters. + :type description: str, none_type, optional + + :param name: The name of the unit cost. At most 200 characters. + :type name: str + + :param numerator_query: A timeseries object containing ``queries`` and ``formulas`` arrays. + :type numerator_query: UnitCostQueryDefinition + + :param unit_label: The label describing the denominator unit, for example ``user``. At most 100 characters. + :type unit_label: str + """ + if description is not unset: + kwargs["description"] = description + super().__init__(kwargs) + + self_.denominator_query = denominator_query + self_.name = name + self_.numerator_query = numerator_query + self_.unit_label = unit_label diff --git a/src/datadog_api_client/v2/model/unit_cost_response.py b/src/datadog_api_client/v2/model/unit_cost_response.py new file mode 100644 index 0000000000..e968872ed0 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_response.py @@ -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.unit_cost_data_response import UnitCostDataResponse + + +class UnitCostResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_data_response import UnitCostDataResponse + + return { + "data": (UnitCostDataResponse,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: UnitCostDataResponse, **kwargs): + """ + A response containing a single unit cost. + + :param data: The data object of a unit cost response. + :type data: UnitCostDataResponse + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/unit_cost_type.py b/src/datadog_api_client/v2/model/unit_cost_type.py new file mode 100644 index 0000000000..ec54e08cdb --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_type.py @@ -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 UnitCostType(ModelSimple): + """ + The JSON:API resource type for a unit cost. + + :param value: If omitted defaults to "unit_cost". Must be one of ["unit_cost"]. + :type value: str + """ + + allowed_values = { + "unit_cost", + } + UNIT_COST: ClassVar["UnitCostType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +UnitCostType.UNIT_COST = UnitCostType("unit_cost") diff --git a/src/datadog_api_client/v2/model/unit_cost_update_request.py b/src/datadog_api_client/v2/model/unit_cost_update_request.py new file mode 100644 index 0000000000..d5dc763541 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_update_request.py @@ -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.unit_cost_update_request_data import UnitCostUpdateRequestData + + +class UnitCostUpdateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_update_request_data import UnitCostUpdateRequestData + + return { + "data": (UnitCostUpdateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: UnitCostUpdateRequestData, **kwargs): + """ + A request to replace a unit cost. + + :param data: The data object of a unit cost replace request. + :type data: UnitCostUpdateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/unit_cost_update_request_data.py b/src/datadog_api_client/v2/model/unit_cost_update_request_data.py new file mode 100644 index 0000000000..933ca52470 --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_cost_update_request_data.py @@ -0,0 +1,55 @@ +# 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, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.unit_cost_request_attributes import UnitCostRequestAttributes + from datadog_api_client.v2.model.unit_cost_type import UnitCostType + + +class UnitCostUpdateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_request_attributes import UnitCostRequestAttributes + from datadog_api_client.v2.model.unit_cost_type import UnitCostType + + return { + "attributes": (UnitCostRequestAttributes,), + "id": (UUID,), + "type": (UnitCostType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: UnitCostRequestAttributes, id: UUID, type: UnitCostType, **kwargs): + """ + The data object of a unit cost replace request. + + :param attributes: The attributes of a unit cost create or replace request. + :type attributes: UnitCostRequestAttributes + + :param id: The UUID of the unit cost being replaced. Must match the ``unit_cost_id`` path parameter. + :type id: UUID + + :param type: The JSON:API resource type for a unit cost. + :type type: UnitCostType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/unit_costs_response.py b/src/datadog_api_client/v2/model/unit_costs_response.py new file mode 100644 index 0000000000..c5c1d3682e --- /dev/null +++ b/src/datadog_api_client/v2/model/unit_costs_response.py @@ -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 List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.unit_cost_data_response import UnitCostDataResponse + + +class UnitCostsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.unit_cost_data_response import UnitCostDataResponse + + return { + "data": ([UnitCostDataResponse],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: List[UnitCostDataResponse], **kwargs): + """ + A response containing a list of unit costs. + + :param data: The list of unit costs. + :type data: [UnitCostDataResponse] + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index d203176eda..e74ec67f7a 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -10876,6 +10876,19 @@ UnassignSeatsUserRequestDataAttributes, ) from datadog_api_client.v2.model.unit import Unit +from datadog_api_client.v2.model.unit_cost_create_request import UnitCostCreateRequest +from datadog_api_client.v2.model.unit_cost_create_request_data import UnitCostCreateRequestData +from datadog_api_client.v2.model.unit_cost_data_attributes_response import UnitCostDataAttributesResponse +from datadog_api_client.v2.model.unit_cost_data_response import UnitCostDataResponse +from datadog_api_client.v2.model.unit_cost_formula import UnitCostFormula +from datadog_api_client.v2.model.unit_cost_query import UnitCostQuery +from datadog_api_client.v2.model.unit_cost_query_definition import UnitCostQueryDefinition +from datadog_api_client.v2.model.unit_cost_request_attributes import UnitCostRequestAttributes +from datadog_api_client.v2.model.unit_cost_response import UnitCostResponse +from datadog_api_client.v2.model.unit_cost_type import UnitCostType +from datadog_api_client.v2.model.unit_cost_update_request import UnitCostUpdateRequest +from datadog_api_client.v2.model.unit_cost_update_request_data import UnitCostUpdateRequestData +from datadog_api_client.v2.model.unit_costs_response import UnitCostsResponse from datadog_api_client.v2.model.unpublish_app_response import UnpublishAppResponse from datadog_api_client.v2.model.update_action_connection_request import UpdateActionConnectionRequest from datadog_api_client.v2.model.update_action_connection_response import UpdateActionConnectionResponse @@ -18830,6 +18843,19 @@ "UnassignSeatsUserRequestData", "UnassignSeatsUserRequestDataAttributes", "Unit", + "UnitCostCreateRequest", + "UnitCostCreateRequestData", + "UnitCostDataAttributesResponse", + "UnitCostDataResponse", + "UnitCostFormula", + "UnitCostQuery", + "UnitCostQueryDefinition", + "UnitCostRequestAttributes", + "UnitCostResponse", + "UnitCostType", + "UnitCostUpdateRequest", + "UnitCostUpdateRequestData", + "UnitCostsResponse", "UnpublishAppResponse", "UpdateActionConnectionRequest", "UpdateActionConnectionResponse", diff --git a/tests/v2/features/cloud_cost_management.feature b/tests/v2/features/cloud_cost_management.feature index 57849f54f3..5ee6a17dce 100644 --- a/tests/v2/features/cloud_cost_management.feature +++ b/tests/v2/features/cloud_cost_management.feature @@ -58,6 +58,22 @@ Feature: Cloud Cost Management Then the response status is 200 OK And the response "data.attributes.account_id" is equal to "123456_A123BC_12AB34" + @generated @skip @team:DataDog/ccm-roi + Scenario: Create a unit cost returns "Bad Request" response + Given operation "CreateUnitCost" enabled + And new "CreateUnitCost" request + And body with value {"data": {"attributes": {"denominator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "description": "Amortized cloud spend divided by the number of active users.", "name": "Cloud cost per active user", "numerator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "unit_label": "user"}, "type": "unit_cost"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ccm-roi + Scenario: Create a unit cost returns "Created" response + Given operation "CreateUnitCost" enabled + And new "CreateUnitCost" request + And body with value {"data": {"attributes": {"denominator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "description": "Amortized cloud spend divided by the number of active users.", "name": "Cloud cost per active user", "numerator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "unit_label": "user"}, "type": "unit_cost"}} + When the request is sent + Then the response status is 201 Created + @replay-only @team:DataDog/cloud-cost-management Scenario: Create custom allocation rule returns "OK" response Given new "CreateCustomAllocationRule" request @@ -253,6 +269,30 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/ccm-roi + Scenario: Delete a unit cost returns "Bad Request" response + Given operation "DeleteUnitCost" enabled + And new "DeleteUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ccm-roi + Scenario: Delete a unit cost returns "No Content" response + Given operation "DeleteUnitCost" enabled + And new "DeleteUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/ccm-roi + Scenario: Delete a unit cost returns "Not Found" response + Given operation "DeleteUnitCost" enabled + And new "DeleteUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/cloud-cost-management Scenario: Delete budget returns "No Content" response Given new "DeleteBudget" request @@ -399,6 +439,30 @@ Feature: Cloud Cost Management And the response "data.type" is equal to "ruleset" And the response "data.attributes.name" is equal to "EVP Cost Tags" + @generated @skip @team:DataDog/ccm-roi + Scenario: Get a unit cost returns "Bad Request" response + Given operation "GetUnitCost" enabled + And new "GetUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ccm-roi + Scenario: Get a unit cost returns "Not Found" response + Given operation "GetUnitCost" enabled + And new "GetUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ccm-roi + Scenario: Get a unit cost returns "OK" response + Given operation "GetUnitCost" enabled + And new "GetUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management Scenario: Get account filters returns "Bad Request" response Given new "GetCostAccountFilters" request @@ -885,6 +949,13 @@ Feature: Cloud Cost Management Then the response status is 200 OK And the response "data[0].attributes.name" is equal to "New Ruleset" + @generated @skip @team:DataDog/ccm-roi + Scenario: List unit costs returns "OK" response + Given operation "ListUnitCosts" enabled + And new "ListUnitCosts" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management Scenario: Reorder custom allocation rules returns "Successfully reordered rules" response Given new "ReorderCustomAllocationRules" request @@ -974,6 +1045,33 @@ Feature: Cloud Cost Management Then the response status is 200 OK And the response "data.attributes.account_id" is equal to "123456_A123BC_12AB34" + @generated @skip @team:DataDog/ccm-roi + Scenario: Update a unit cost returns "Bad Request" response + Given operation "UpdateUnitCost" enabled + And new "UpdateUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"denominator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "description": "Amortized cloud spend divided by the number of active users.", "name": "Cloud cost per active user", "numerator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "unit_label": "user"}, "id": "64aecd58-e355-4f07-9c3a-56ff6bda6cd8", "type": "unit_cost"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ccm-roi + Scenario: Update a unit cost returns "Not Found" response + Given operation "UpdateUnitCost" enabled + And new "UpdateUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"denominator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "description": "Amortized cloud spend divided by the number of active users.", "name": "Cloud cost per active user", "numerator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "unit_label": "user"}, "id": "64aecd58-e355-4f07-9c3a-56ff6bda6cd8", "type": "unit_cost"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ccm-roi + Scenario: Update a unit cost returns "OK" response + Given operation "UpdateUnitCost" enabled + And new "UpdateUnitCost" request + And request contains "unit_cost_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"denominator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "description": "Amortized cloud spend divided by the number of active users.", "name": "Cloud cost per active user", "numerator_query": {"formulas": [{"formula": "numerator"}], "queries": [{"data_source": "cloud_cost", "name": "numerator", "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"}]}, "unit_label": "user"}, "id": "64aecd58-e355-4f07-9c3a-56ff6bda6cd8", "type": "unit_cost"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management Scenario: Update account filters returns "Bad Request" response Given new "UpdateCostAccountFilters" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index be4ddd2f98..a2d33ddd94 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1988,6 +1988,43 @@ "type": "safe" } }, + "ListUnitCosts": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "CreateUnitCost": { + "tag": "Cloud Cost Management", + "undo": { + "operationId": "DeleteUnitCost", + "parameters": [ + { + "name": "unit_cost_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteUnitCost": { + "tag": "Cloud Cost Management", + "undo": { + "type": "idempotent" + } + }, + "GetUnitCost": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "UpdateUnitCost": { + "tag": "Cloud Cost Management", + "undo": { + "type": "idempotent" + } + }, "GetActiveBillingDimensions": { "tag": "Usage Metering", "undo": {