diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e6d194c15957..0cbaf7439c53 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.ts b/examples/v2/cloud-cost-management/CreateUnitCost.ts new file mode 100644 index 000000000000..1036d972754a --- /dev/null +++ b/examples/v2/cloud-cost-management/CreateUnitCost.ts @@ -0,0 +1,62 @@ +/** + * Create a unit cost returns "Created" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.createUnitCost"] = true; +const apiInstance = new v2.CloudCostManagementApi(configuration); + +const params: v2.CloudCostManagementApiCreateUnitCostRequest = { + body: { + data: { + attributes: { + denominatorQuery: { + 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", + numeratorQuery: { + formulas: [ + { + formula: "numerator", + }, + ], + queries: [ + { + data_source: "cloud_cost", + name: "numerator", + query: + "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)", + }, + ], + }, + unitLabel: "user", + }, + type: "unit_cost", + }, + }, +}; + +apiInstance + .createUnitCost(params) + .then((data: v2.UnitCostResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/cloud-cost-management/DeleteUnitCost.ts b/examples/v2/cloud-cost-management/DeleteUnitCost.ts new file mode 100644 index 000000000000..73a74c005ee3 --- /dev/null +++ b/examples/v2/cloud-cost-management/DeleteUnitCost.ts @@ -0,0 +1,22 @@ +/** + * Delete a unit cost returns "No Content" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.deleteUnitCost"] = true; +const apiInstance = new v2.CloudCostManagementApi(configuration); + +const params: v2.CloudCostManagementApiDeleteUnitCostRequest = { + unitCostId: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", +}; + +apiInstance + .deleteUnitCost(params) + .then((data: any) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/cloud-cost-management/GetUnitCost.ts b/examples/v2/cloud-cost-management/GetUnitCost.ts new file mode 100644 index 000000000000..c4bb465e715b --- /dev/null +++ b/examples/v2/cloud-cost-management/GetUnitCost.ts @@ -0,0 +1,22 @@ +/** + * Get a unit cost returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.getUnitCost"] = true; +const apiInstance = new v2.CloudCostManagementApi(configuration); + +const params: v2.CloudCostManagementApiGetUnitCostRequest = { + unitCostId: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", +}; + +apiInstance + .getUnitCost(params) + .then((data: v2.UnitCostResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/cloud-cost-management/ListUnitCosts.ts b/examples/v2/cloud-cost-management/ListUnitCosts.ts new file mode 100644 index 000000000000..4d62e17a4ce6 --- /dev/null +++ b/examples/v2/cloud-cost-management/ListUnitCosts.ts @@ -0,0 +1,18 @@ +/** + * List unit costs returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.listUnitCosts"] = true; +const apiInstance = new v2.CloudCostManagementApi(configuration); + +apiInstance + .listUnitCosts() + .then((data: v2.UnitCostsResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/cloud-cost-management/UpdateUnitCost.ts b/examples/v2/cloud-cost-management/UpdateUnitCost.ts new file mode 100644 index 000000000000..c68220cb8cc1 --- /dev/null +++ b/examples/v2/cloud-cost-management/UpdateUnitCost.ts @@ -0,0 +1,64 @@ +/** + * Update a unit cost returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +configuration.unstableOperations["v2.updateUnitCost"] = true; +const apiInstance = new v2.CloudCostManagementApi(configuration); + +const params: v2.CloudCostManagementApiUpdateUnitCostRequest = { + body: { + data: { + attributes: { + denominatorQuery: { + 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", + numeratorQuery: { + formulas: [ + { + formula: "numerator", + }, + ], + queries: [ + { + data_source: "cloud_cost", + name: "numerator", + query: + "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)", + }, + ], + }, + unitLabel: "user", + }, + id: "64aecd58-e355-4f07-9c3a-56ff6bda6cd8", + type: "unit_cost", + }, + }, + unitCostId: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", +}; + +apiInstance + .updateUnitCost(params) + .then((data: v2.UnitCostResponse) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/features/support/scenarios_model_mapping.ts b/features/support/scenarios_model_mapping.ts index 1d41a2d52405..202f14c13f88 100644 --- a/features/support/scenarios_model_mapping.ts +++ b/features/support/scenarios_model_mapping.ts @@ -8475,6 +8475,41 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "CostTagsResponse", }, + "v2.ListUnitCosts": { + "operationResponseType": "UnitCostsResponse", + }, + "v2.CreateUnitCost": { + "body": { + "type": "UnitCostCreateRequest", + "format": "", + }, + "operationResponseType": "UnitCostResponse", + }, + "v2.GetUnitCost": { + "unitCostId": { + "type": "string", + "format": "uuid", + }, + "operationResponseType": "UnitCostResponse", + }, + "v2.UpdateUnitCost": { + "unitCostId": { + "type": "string", + "format": "uuid", + }, + "body": { + "type": "UnitCostUpdateRequest", + "format": "", + }, + "operationResponseType": "UnitCostResponse", + }, + "v2.DeleteUnitCost": { + "unitCostId": { + "type": "string", + "format": "uuid", + }, + "operationResponseType": "{}", + }, "v2.ListTagPipelinesRulesets": { "operationResponseType": "RulesetRespArray", }, diff --git a/features/v2/cloud_cost_management.feature b/features/v2/cloud_cost_management.feature index 57849f54f3c7..5ee6a17dce0d 100644 --- a/features/v2/cloud_cost_management.feature +++ b/features/v2/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/features/v2/undo.json b/features/v2/undo.json index be4ddd2f98e6..a2d33ddd9441 100644 --- a/features/v2/undo.json +++ b/features/v2/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": { diff --git a/packages/datadog-api-client-common/configuration.ts b/packages/datadog-api-client-common/configuration.ts index b5ad62a056b9..8769adbcbc9f 100644 --- a/packages/datadog-api-client-common/configuration.ts +++ b/packages/datadog-api-client-common/configuration.ts @@ -428,6 +428,8 @@ export function createConfiguration( "v2.getCodeCoverageBranchSummary": false, "v2.getCodeCoverageCommitSummary": false, "v2.getRuleBasedView": false, + "v2.createUnitCost": false, + "v2.deleteUnitCost": false, "v2.getCommitmentsCommitmentList": false, "v2.getCommitmentsCoverageScalar": false, "v2.getCommitmentsCoverageTimeseries": false, @@ -438,13 +440,16 @@ export function createConfiguration( "v2.getCommitmentsUtilizationTimeseries": false, "v2.getCostAnomaly": false, "v2.getCostTagMetadataCurrency": false, + "v2.getUnitCost": false, "v2.listCostAnomalies": false, "v2.listCostTagKeySources": false, "v2.listCostTagMetadata": false, "v2.listCostTagMetadataMetrics": false, "v2.listCostTagMetadataMonths": false, "v2.listCostTagMetadataOrchestrators": false, + "v2.listUnitCosts": false, "v2.searchCostRecommendations": false, + "v2.updateUnitCost": false, "v2.createQuotas": false, "v2.deleteQuota": false, "v2.listQuotas": false, diff --git a/packages/datadog-api-client-v2/apis/CloudCostManagementApi.ts b/packages/datadog-api-client-v2/apis/CloudCostManagementApi.ts index 397e6af682fb..e96852b9aca5 100644 --- a/packages/datadog-api-client-v2/apis/CloudCostManagementApi.ts +++ b/packages/datadog-api-client-v2/apis/CloudCostManagementApi.ts @@ -85,6 +85,10 @@ import { RulesetStatusRespArray } from "../models/RulesetStatusRespArray"; import { RulesValidateQueryRequest } from "../models/RulesValidateQueryRequest"; import { RulesValidateQueryResponse } from "../models/RulesValidateQueryResponse"; import { UCConfigPair } from "../models/UCConfigPair"; +import { UnitCostCreateRequest } from "../models/UnitCostCreateRequest"; +import { UnitCostResponse } from "../models/UnitCostResponse"; +import { UnitCostsResponse } from "../models/UnitCostsResponse"; +import { UnitCostUpdateRequest } from "../models/UnitCostUpdateRequest"; import { UpdateRulesetRequest } from "../models/UpdateRulesetRequest"; import { ValidationResponse } from "../models/ValidationResponse"; @@ -324,6 +328,57 @@ export class CloudCostManagementApiRequestFactory extends BaseAPIRequestFactory return requestContext; } + public async createUnitCost( + body: UnitCostCreateRequest, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'createUnitCost'"); + if (!_config.unstableOperations["v2.createUnitCost"]) { + throw new Error("Unstable operation 'createUnitCost' is disabled"); + } + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "createUnitCost"); + } + + // Path Params + const localVarPath = "/api/v2/cost/unit_costs"; + + // Make Request Context + const requestContext = _config + .getServer("v2.CloudCostManagementApi.createUnitCost") + .makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set IaC header + if (_config.isIaC) { + requestContext.setHeaderParam("X-Datadog-Managed-By", "iac"); + } + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "UnitCostCreateRequest", ""), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async deleteBudget( budgetId: string, _options?: Configuration @@ -687,6 +742,49 @@ export class CloudCostManagementApiRequestFactory extends BaseAPIRequestFactory return requestContext; } + public async deleteUnitCost( + unitCostId: string, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'deleteUnitCost'"); + if (!_config.unstableOperations["v2.deleteUnitCost"]) { + throw new Error("Unstable operation 'deleteUnitCost' is disabled"); + } + + // verify required parameter 'unitCostId' is not null or undefined + if (unitCostId === null || unitCostId === undefined) { + throw new RequiredError("unitCostId", "deleteUnitCost"); + } + + // Path Params + const localVarPath = "/api/v2/cost/unit_costs/{unit_cost_id}".replace( + "{unit_cost_id}", + encodeURIComponent(String(unitCostId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.CloudCostManagementApi.deleteUnitCost") + .makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "*/*"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set IaC header + if (_config.isIaC) { + requestContext.setHeaderParam("X-Datadog-Managed-By", "iac"); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async generateCostTagDescriptionByKey( tagKey: string, _options?: Configuration @@ -2172,6 +2270,49 @@ export class CloudCostManagementApiRequestFactory extends BaseAPIRequestFactory return requestContext; } + public async getUnitCost( + unitCostId: string, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'getUnitCost'"); + if (!_config.unstableOperations["v2.getUnitCost"]) { + throw new Error("Unstable operation 'getUnitCost' is disabled"); + } + + // verify required parameter 'unitCostId' is not null or undefined + if (unitCostId === null || unitCostId === undefined) { + throw new RequiredError("unitCostId", "getUnitCost"); + } + + // Path Params + const localVarPath = "/api/v2/cost/unit_costs/{unit_cost_id}".replace( + "{unit_cost_id}", + encodeURIComponent(String(unitCostId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.CloudCostManagementApi.getUnitCost") + .makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set IaC header + if (_config.isIaC) { + requestContext.setHeaderParam("X-Datadog-Managed-By", "iac"); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async listBudgets(_options?: Configuration): Promise { const _config = _options || this.configuration; @@ -3131,6 +3272,40 @@ export class CloudCostManagementApiRequestFactory extends BaseAPIRequestFactory return requestContext; } + public async listUnitCosts( + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'listUnitCosts'"); + if (!_config.unstableOperations["v2.listUnitCosts"]) { + throw new Error("Unstable operation 'listUnitCosts' is disabled"); + } + + // Path Params + const localVarPath = "/api/v2/cost/unit_costs"; + + // Make Request Context + const requestContext = _config + .getServer("v2.CloudCostManagementApi.listUnitCosts") + .makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set IaC header + if (_config.isIaC) { + requestContext.setHeaderParam("X-Datadog-Managed-By", "iac"); + } + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async reorderCustomAllocationRules( body: ReorderRuleResourceArray, _options?: Configuration @@ -3637,6 +3812,66 @@ export class CloudCostManagementApiRequestFactory extends BaseAPIRequestFactory return requestContext; } + public async updateUnitCost( + unitCostId: string, + body: UnitCostUpdateRequest, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + logger.warn("Using unstable operation 'updateUnitCost'"); + if (!_config.unstableOperations["v2.updateUnitCost"]) { + throw new Error("Unstable operation 'updateUnitCost' is disabled"); + } + + // verify required parameter 'unitCostId' is not null or undefined + if (unitCostId === null || unitCostId === undefined) { + throw new RequiredError("unitCostId", "updateUnitCost"); + } + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "updateUnitCost"); + } + + // Path Params + const localVarPath = "/api/v2/cost/unit_costs/{unit_cost_id}".replace( + "{unit_cost_id}", + encodeURIComponent(String(unitCostId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.CloudCostManagementApi.updateUnitCost") + .makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set IaC header + if (_config.isIaC) { + requestContext.setHeaderParam("X-Datadog-Managed-By", "iac"); + } + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "UnitCostUpdateRequest", ""), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async uploadCustomCostsFile( body: Array, _options?: Configuration @@ -4252,6 +4487,87 @@ export class CloudCostManagementApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to createUnitCost + * @throws ApiException if the response code was not in [200, 299] + */ + public async createUnitCost( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 201) { + const body: UnitCostResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostResponse" + ) as UnitCostResponse; + return body; + } + if (response.httpStatusCode === 400 || response.httpStatusCode === 403) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: JSONAPIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "JSONAPIErrorResponse" + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException( + response.httpStatusCode, + body + ); + } + if (response.httpStatusCode === 429) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: UnitCostResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostResponse", + "" + ) as UnitCostResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -4711,6 +5027,80 @@ export class CloudCostManagementApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to deleteUnitCost + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteUnitCost(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 204) { + return; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: JSONAPIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "JSONAPIErrorResponse" + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException( + response.httpStatusCode, + body + ); + } + if (response.httpStatusCode === 429) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + return; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -6212,11 +6602,96 @@ export class CloudCostManagementApiResponseProcessor { // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const body: RulesetResp = ObjectSerializer.deserialize( + const body: RulesetResp = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "RulesetResp", + "" + ) as RulesetResp; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getUnitCost + * @throws ApiException if the response code was not in [200, 299] + */ + public async getUnitCost( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: UnitCostResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostResponse" + ) as UnitCostResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: JSONAPIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "JSONAPIErrorResponse" + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException( + response.httpStatusCode, + body + ); + } + if (response.httpStatusCode === 429) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: UnitCostResponse = ObjectSerializer.deserialize( ObjectSerializer.parse(await response.body.text(), contentType), - "RulesetResp", + "UnitCostResponse", "" - ) as RulesetResp; + ) as UnitCostResponse; return body; } @@ -7365,6 +7840,87 @@ export class CloudCostManagementApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to listUnitCosts + * @throws ApiException if the response code was not in [200, 299] + */ + public async listUnitCosts( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: UnitCostsResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostsResponse" + ) as UnitCostsResponse; + return body; + } + if (response.httpStatusCode === 403) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: JSONAPIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "JSONAPIErrorResponse" + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException( + response.httpStatusCode, + body + ); + } + if (response.httpStatusCode === 429) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: UnitCostsResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostsResponse", + "" + ) as UnitCostsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -7888,6 +8444,91 @@ export class CloudCostManagementApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to updateUnitCost + * @throws ApiException if the response code was not in [200, 299] + */ + public async updateUnitCost( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: UnitCostResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostResponse" + ) as UnitCostResponse; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 403 || + response.httpStatusCode === 404 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: JSONAPIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "JSONAPIErrorResponse" + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException( + response.httpStatusCode, + body + ); + } + if (response.httpStatusCode === 429) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "APIErrorResponse" + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: UnitCostResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "UnitCostResponse", + "" + ) as UnitCostResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -8337,6 +8978,13 @@ export interface CloudCostManagementApiCreateTagPipelinesRulesetRequest { body: CreateRulesetRequest; } +export interface CloudCostManagementApiCreateUnitCostRequest { + /** + * @type UnitCostCreateRequest + */ + body: UnitCostCreateRequest; +} + export interface CloudCostManagementApiDeleteBudgetRequest { /** * Budget id. @@ -8414,6 +9062,14 @@ export interface CloudCostManagementApiDeleteTagPipelinesRulesetRequest { rulesetId: string; } +export interface CloudCostManagementApiDeleteUnitCostRequest { + /** + * The UUID of the unit cost. + * @type string + */ + unitCostId: string; +} + export interface CloudCostManagementApiGenerateCostTagDescriptionByKeyRequest { /** * The tag key to generate an AI description for. @@ -8805,6 +9461,14 @@ export interface CloudCostManagementApiGetTagPipelinesRulesetRequest { rulesetId: string; } +export interface CloudCostManagementApiGetUnitCostRequest { + /** + * The UUID of the unit cost. + * @type string + */ + unitCostId: string; +} + export interface CloudCostManagementApiListCostAnomaliesRequest { /** * Start time as Unix milliseconds. Defaults to the start of the latest stable seven-day window. @@ -9131,6 +9795,18 @@ export interface CloudCostManagementApiUpdateTagPipelinesRulesetRequest { body: UpdateRulesetRequest; } +export interface CloudCostManagementApiUpdateUnitCostRequest { + /** + * The UUID of the unit cost. + * @type string + */ + unitCostId: string; + /** + * @type UnitCostUpdateRequest + */ + body: UnitCostUpdateRequest; +} + export interface CloudCostManagementApiUploadCustomCostsFileRequest { /** * @type Array @@ -9316,6 +9992,27 @@ export class CloudCostManagementApi { }); } + /** + * Create an ROI metric (unit cost) using the given numerator and denominator queries. + * @param param The request object + */ + public createUnitCost( + param: CloudCostManagementApiCreateUnitCostRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.createUnitCost( + param.body, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.createUnitCost(responseContext); + }); + }); + } + /** * Delete a budget * @param param The request object @@ -9516,6 +10213,27 @@ export class CloudCostManagementApi { }); } + /** + * Delete an ROI metric (unit cost). + * @param param The request object + */ + public deleteUnitCost( + param: CloudCostManagementApiDeleteUnitCostRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.deleteUnitCost( + param.unitCostId, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.deleteUnitCost(responseContext); + }); + }); + } + /** * Use AI to draft a Cloud Cost Management tag key description based on associated cost data. The generated description is returned in the response and is not persisted by this endpoint; follow up with `UpsertCostTagDescriptionByKey` to save it. * @param param The request object @@ -10058,6 +10776,27 @@ export class CloudCostManagementApi { }); } + /** + * Retrieve an ROI metric (unit cost) by UUID. + * @param param The request object + */ + public getUnitCost( + param: CloudCostManagementApiGetUnitCostRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.getUnitCost( + param.unitCostId, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.getUnitCost(responseContext); + }); + }); + } + /** * List budgets. * @param param The request object @@ -10476,6 +11215,21 @@ export class CloudCostManagementApi { }); } + /** + * List the ROI metrics (unit costs) for the authenticated organization. + * @param param The request object + */ + public listUnitCosts(options?: Configuration): Promise { + const requestContextPromise = this.requestFactory.listUnitCosts(options); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.listUnitCosts(responseContext); + }); + }); + } + /** * Reorder custom allocation rules - Change the execution order of custom allocation rules. * @@ -10706,6 +11460,28 @@ export class CloudCostManagementApi { }); } + /** + * Replace an ROI metric (unit cost) with a new set of attributes. + * @param param The request object + */ + public updateUnitCost( + param: CloudCostManagementApiUpdateUnitCostRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.updateUnitCost( + param.unitCostId, + param.body, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.updateUnitCost(responseContext); + }); + }); + } + /** * Upload a Custom Costs file. * @param param The request object diff --git a/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index 7dd4038114db..d0a3479d16c0 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -402,6 +402,7 @@ export { CloudCostManagementApiCreateCostGCPUsageCostConfigRequest, CloudCostManagementApiCreateCustomAllocationRuleRequest, CloudCostManagementApiCreateTagPipelinesRulesetRequest, + CloudCostManagementApiCreateUnitCostRequest, CloudCostManagementApiDeleteBudgetRequest, CloudCostManagementApiDeleteCostAWSCURConfigRequest, CloudCostManagementApiDeleteCostAzureUCConfigRequest, @@ -411,6 +412,7 @@ export { CloudCostManagementApiDeleteCustomCostsFileRequest, CloudCostManagementApiDeleteCustomForecastRequest, CloudCostManagementApiDeleteTagPipelinesRulesetRequest, + CloudCostManagementApiDeleteUnitCostRequest, CloudCostManagementApiGenerateCostTagDescriptionByKeyRequest, CloudCostManagementApiGetBudgetRequest, CloudCostManagementApiGetCommitmentsCommitmentListRequest, @@ -433,6 +435,7 @@ export { CloudCostManagementApiGetCustomCostsFileRequest, CloudCostManagementApiGetCustomForecastRequest, CloudCostManagementApiGetTagPipelinesRulesetRequest, + CloudCostManagementApiGetUnitCostRequest, CloudCostManagementApiListCostAnomaliesRequest, CloudCostManagementApiListCostTagDescriptionsRequest, CloudCostManagementApiListCostTagKeySourcesRequest, @@ -452,6 +455,7 @@ export { CloudCostManagementApiUpdateCostGCPUsageCostConfigRequest, CloudCostManagementApiUpdateCustomAllocationRuleRequest, CloudCostManagementApiUpdateTagPipelinesRulesetRequest, + CloudCostManagementApiUpdateUnitCostRequest, CloudCostManagementApiUploadCustomCostsFileRequest, CloudCostManagementApiUpsertBudgetRequest, CloudCostManagementApiUpsertCostTagDescriptionByKeyRequest, @@ -9417,6 +9421,17 @@ export { UnassignSeatsUserRequest } from "./models/UnassignSeatsUserRequest"; export { UnassignSeatsUserRequestData } from "./models/UnassignSeatsUserRequestData"; export { UnassignSeatsUserRequestDataAttributes } from "./models/UnassignSeatsUserRequestDataAttributes"; export { Unit } from "./models/Unit"; +export { UnitCostCreateRequest } from "./models/UnitCostCreateRequest"; +export { UnitCostCreateRequestData } from "./models/UnitCostCreateRequestData"; +export { UnitCostDataAttributesResponse } from "./models/UnitCostDataAttributesResponse"; +export { UnitCostDataResponse } from "./models/UnitCostDataResponse"; +export { UnitCostQueryDefinition } from "./models/UnitCostQueryDefinition"; +export { UnitCostRequestAttributes } from "./models/UnitCostRequestAttributes"; +export { UnitCostResponse } from "./models/UnitCostResponse"; +export { UnitCostsResponse } from "./models/UnitCostsResponse"; +export { UnitCostType } from "./models/UnitCostType"; +export { UnitCostUpdateRequest } from "./models/UnitCostUpdateRequest"; +export { UnitCostUpdateRequestData } from "./models/UnitCostUpdateRequestData"; export { UnpublishAppResponse } from "./models/UnpublishAppResponse"; export { UpdateActionConnectionRequest } from "./models/UpdateActionConnectionRequest"; export { UpdateActionConnectionResponse } from "./models/UpdateActionConnectionResponse"; diff --git a/packages/datadog-api-client-v2/models/ObjectSerializer.ts b/packages/datadog-api-client-v2/models/ObjectSerializer.ts index d7ab5132dfd1..28eee3602961 100644 --- a/packages/datadog-api-client-v2/models/ObjectSerializer.ts +++ b/packages/datadog-api-client-v2/models/ObjectSerializer.ts @@ -5712,6 +5712,16 @@ import { UnassignSeatsUserRequest } from "./UnassignSeatsUserRequest"; import { UnassignSeatsUserRequestData } from "./UnassignSeatsUserRequestData"; import { UnassignSeatsUserRequestDataAttributes } from "./UnassignSeatsUserRequestDataAttributes"; import { Unit } from "./Unit"; +import { UnitCostCreateRequest } from "./UnitCostCreateRequest"; +import { UnitCostCreateRequestData } from "./UnitCostCreateRequestData"; +import { UnitCostDataAttributesResponse } from "./UnitCostDataAttributesResponse"; +import { UnitCostDataResponse } from "./UnitCostDataResponse"; +import { UnitCostQueryDefinition } from "./UnitCostQueryDefinition"; +import { UnitCostRequestAttributes } from "./UnitCostRequestAttributes"; +import { UnitCostResponse } from "./UnitCostResponse"; +import { UnitCostUpdateRequest } from "./UnitCostUpdateRequest"; +import { UnitCostUpdateRequestData } from "./UnitCostUpdateRequestData"; +import { UnitCostsResponse } from "./UnitCostsResponse"; import { UnpublishAppResponse } from "./UnpublishAppResponse"; import { UpdateActionConnectionRequest } from "./UpdateActionConnectionRequest"; import { UpdateActionConnectionResponse } from "./UpdateActionConnectionResponse"; @@ -9099,6 +9109,7 @@ const enumsMap: { [key: string]: any[] } = { TriggerType: ["monitor_alert_trigger"], TriggerWorkflowAutomationActionType: ["workflow"], UCConfigPairDataType: ["azure_uc_configs"], + UnitCostType: ["unit_cost"], UpdateAppsDatastoreItemRequestDataType: ["items"], UpdateConnectionRequestDataType: ["connection_id"], UpdateEnvironmentDataType: ["environments"], @@ -16298,6 +16309,16 @@ const typeMap: { [index: string]: any } = { UnassignSeatsUserRequestDataAttributes: UnassignSeatsUserRequestDataAttributes, Unit: Unit, + UnitCostCreateRequest: UnitCostCreateRequest, + UnitCostCreateRequestData: UnitCostCreateRequestData, + UnitCostDataAttributesResponse: UnitCostDataAttributesResponse, + UnitCostDataResponse: UnitCostDataResponse, + UnitCostQueryDefinition: UnitCostQueryDefinition, + UnitCostRequestAttributes: UnitCostRequestAttributes, + UnitCostResponse: UnitCostResponse, + UnitCostUpdateRequest: UnitCostUpdateRequest, + UnitCostUpdateRequestData: UnitCostUpdateRequestData, + UnitCostsResponse: UnitCostsResponse, UnpublishAppResponse: UnpublishAppResponse, UpdateActionConnectionRequest: UpdateActionConnectionRequest, UpdateActionConnectionResponse: UpdateActionConnectionResponse, diff --git a/packages/datadog-api-client-v2/models/UnitCostCreateRequest.ts b/packages/datadog-api-client-v2/models/UnitCostCreateRequest.ts new file mode 100644 index 000000000000..d0ed94afc8f4 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostCreateRequest.ts @@ -0,0 +1,54 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostCreateRequestData } from "./UnitCostCreateRequestData"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A request to create a unit cost. + */ +export class UnitCostCreateRequest { + /** + * The data object of a unit cost create request. + */ + "data": UnitCostCreateRequestData; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "UnitCostCreateRequestData", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostCreateRequest.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostCreateRequestData.ts b/packages/datadog-api-client-v2/models/UnitCostCreateRequestData.ts new file mode 100644 index 000000000000..0a005703204c --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostCreateRequestData.ts @@ -0,0 +1,64 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostRequestAttributes } from "./UnitCostRequestAttributes"; +import { UnitCostType } from "./UnitCostType"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * The data object of a unit cost create request. + */ +export class UnitCostCreateRequestData { + /** + * The attributes of a unit cost create or replace request. + */ + "attributes": UnitCostRequestAttributes; + /** + * The JSON:API resource type for a unit cost. + */ + "type": UnitCostType; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + attributes: { + baseName: "attributes", + type: "UnitCostRequestAttributes", + required: true, + }, + type: { + baseName: "type", + type: "UnitCostType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostCreateRequestData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostDataAttributesResponse.ts b/packages/datadog-api-client-v2/models/UnitCostDataAttributesResponse.ts new file mode 100644 index 000000000000..230a43379161 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostDataAttributesResponse.ts @@ -0,0 +1,149 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + */ +import { UnitCostQueryDefinition } from "./UnitCostQueryDefinition"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * The attributes of a unit cost. + */ +export class UnitCostDataAttributesResponse { + /** + * The time the unit cost was created. + */ + "createdAt": Date; + /** + * The UUID of the user who created the unit cost. + */ + "createdBy": string; + /** + * A timeseries object containing `queries` and `formulas` arrays. + */ + "denominatorQuery": UnitCostQueryDefinition; + /** + * The data source of the denominator queries, or `multisource` when the denominator + * queries span more than one data source. + */ + "denominatorType": string; + /** + * The description of the unit cost. Omitted when the unit cost has no description. + */ + "description"?: string; + /** + * The name of the unit cost. + */ + "name": string; + /** + * A timeseries object containing `queries` and `formulas` arrays. + */ + "numeratorQuery": UnitCostQueryDefinition; + /** + * The ID of the organization the unit cost belongs to. + */ + "orgId": number; + /** + * The label describing the denominator unit. + */ + "unitLabel": string; + /** + * The time the unit cost was last updated. + */ + "updatedAt": Date; + /** + * The UUID of the user who last updated the unit cost. + */ + "updatedBy": string; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + createdAt: { + baseName: "created_at", + type: "Date", + required: true, + format: "date-time", + }, + createdBy: { + baseName: "created_by", + type: "string", + required: true, + format: "uuid", + }, + denominatorQuery: { + baseName: "denominator_query", + type: "UnitCostQueryDefinition", + required: true, + }, + denominatorType: { + baseName: "denominator_type", + type: "string", + required: true, + }, + description: { + baseName: "description", + type: "string", + }, + name: { + baseName: "name", + type: "string", + required: true, + }, + numeratorQuery: { + baseName: "numerator_query", + type: "UnitCostQueryDefinition", + required: true, + }, + orgId: { + baseName: "org_id", + type: "number", + required: true, + format: "int64", + }, + unitLabel: { + baseName: "unit_label", + type: "string", + required: true, + }, + updatedAt: { + baseName: "updated_at", + type: "Date", + required: true, + format: "date-time", + }, + updatedBy: { + baseName: "updated_by", + type: "string", + required: true, + format: "uuid", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostDataAttributesResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostDataResponse.ts b/packages/datadog-api-client-v2/models/UnitCostDataResponse.ts new file mode 100644 index 000000000000..2f378e815354 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostDataResponse.ts @@ -0,0 +1,74 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostDataAttributesResponse } from "./UnitCostDataAttributesResponse"; +import { UnitCostType } from "./UnitCostType"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * The data object of a unit cost response. + */ +export class UnitCostDataResponse { + /** + * The attributes of a unit cost. + */ + "attributes": UnitCostDataAttributesResponse; + /** + * The UUID of the unit cost. + */ + "id": string; + /** + * The JSON:API resource type for a unit cost. + */ + "type": UnitCostType; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + attributes: { + baseName: "attributes", + type: "UnitCostDataAttributesResponse", + required: true, + }, + id: { + baseName: "id", + type: "string", + required: true, + format: "uuid", + }, + type: { + baseName: "type", + type: "UnitCostType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostDataResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostQueryDefinition.ts b/packages/datadog-api-client-v2/models/UnitCostQueryDefinition.ts new file mode 100644 index 000000000000..b3e66cd047b9 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostQueryDefinition.ts @@ -0,0 +1,62 @@ +/** + * 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 2020-Present Datadog, Inc. + */ + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A timeseries object containing `queries` and `formulas` arrays. + */ +export class UnitCostQueryDefinition { + /** + * The list of formulas applied to the queries for this side of the ratio. + */ + "formulas": Array<{ [key: string]: any }>; + /** + * The list of queries evaluated for this side of the ratio. + */ + "queries": Array<{ [key: string]: any }>; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + formulas: { + baseName: "formulas", + type: "Array<{ [key: string]: any; }>", + required: true, + }, + queries: { + baseName: "queries", + type: "Array<{ [key: string]: any; }>", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostQueryDefinition.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostRequestAttributes.ts b/packages/datadog-api-client-v2/models/UnitCostRequestAttributes.ts new file mode 100644 index 000000000000..ffa4371b8abb --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostRequestAttributes.ts @@ -0,0 +1,89 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostQueryDefinition } from "./UnitCostQueryDefinition"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * The attributes of a unit cost create or replace request. + */ +export class UnitCostRequestAttributes { + /** + * A timeseries object containing `queries` and `formulas` arrays. + */ + "denominatorQuery": UnitCostQueryDefinition; + /** + * An optional description of the unit cost. At most 2000 characters. + */ + "description"?: string; + /** + * The name of the unit cost. At most 200 characters. + */ + "name": string; + /** + * A timeseries object containing `queries` and `formulas` arrays. + */ + "numeratorQuery": UnitCostQueryDefinition; + /** + * The label describing the denominator unit, for example `user`. At most 100 characters. + */ + "unitLabel": string; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + denominatorQuery: { + baseName: "denominator_query", + type: "UnitCostQueryDefinition", + required: true, + }, + description: { + baseName: "description", + type: "string", + }, + name: { + baseName: "name", + type: "string", + required: true, + }, + numeratorQuery: { + baseName: "numerator_query", + type: "UnitCostQueryDefinition", + required: true, + }, + unitLabel: { + baseName: "unit_label", + type: "string", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostRequestAttributes.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostResponse.ts b/packages/datadog-api-client-v2/models/UnitCostResponse.ts new file mode 100644 index 000000000000..ec5583a2c447 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostResponse.ts @@ -0,0 +1,54 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostDataResponse } from "./UnitCostDataResponse"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A response containing a single unit cost. + */ +export class UnitCostResponse { + /** + * The data object of a unit cost response. + */ + "data": UnitCostDataResponse; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "UnitCostDataResponse", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostResponse.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostType.ts b/packages/datadog-api-client-v2/models/UnitCostType.ts new file mode 100644 index 000000000000..e73a81702370 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostType.ts @@ -0,0 +1,14 @@ +/** + * 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 2020-Present Datadog, Inc. + */ + +import { UnparsedObject } from "../../datadog-api-client-common/util"; + +/** + * The JSON:API resource type for a unit cost. + */ + +export type UnitCostType = typeof UNIT_COST | UnparsedObject; +export const UNIT_COST = "unit_cost"; diff --git a/packages/datadog-api-client-v2/models/UnitCostUpdateRequest.ts b/packages/datadog-api-client-v2/models/UnitCostUpdateRequest.ts new file mode 100644 index 000000000000..e45e4059f79c --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostUpdateRequest.ts @@ -0,0 +1,54 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostUpdateRequestData } from "./UnitCostUpdateRequestData"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A request to replace a unit cost. + */ +export class UnitCostUpdateRequest { + /** + * The data object of a unit cost replace request. + */ + "data": UnitCostUpdateRequestData; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "UnitCostUpdateRequestData", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostUpdateRequest.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostUpdateRequestData.ts b/packages/datadog-api-client-v2/models/UnitCostUpdateRequestData.ts new file mode 100644 index 000000000000..5b170fad65b0 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostUpdateRequestData.ts @@ -0,0 +1,74 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostRequestAttributes } from "./UnitCostRequestAttributes"; +import { UnitCostType } from "./UnitCostType"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * The data object of a unit cost replace request. + */ +export class UnitCostUpdateRequestData { + /** + * The attributes of a unit cost create or replace request. + */ + "attributes": UnitCostRequestAttributes; + /** + * The UUID of the unit cost being replaced. Must match the `unit_cost_id` path parameter. + */ + "id": string; + /** + * The JSON:API resource type for a unit cost. + */ + "type": UnitCostType; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + attributes: { + baseName: "attributes", + type: "UnitCostRequestAttributes", + required: true, + }, + id: { + baseName: "id", + type: "string", + required: true, + format: "uuid", + }, + type: { + baseName: "type", + type: "UnitCostType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostUpdateRequestData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/UnitCostsResponse.ts b/packages/datadog-api-client-v2/models/UnitCostsResponse.ts new file mode 100644 index 000000000000..592740c1c119 --- /dev/null +++ b/packages/datadog-api-client-v2/models/UnitCostsResponse.ts @@ -0,0 +1,54 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { UnitCostDataResponse } from "./UnitCostDataResponse"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * A response containing a list of unit costs. + */ +export class UnitCostsResponse { + /** + * The list of unit costs. + */ + "data": Array; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return UnitCostsResponse.attributeTypeMap; + } + + public constructor() {} +}