diff --git a/.apigentools-info b/.apigentools-info index fcf139747d..57b734c9f6 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-11-14 15:18:19.873863", - "spec_repo_commit": "b95546fe" + "regenerated": "2023-11-15 13:47:31.744350", + "spec_repo_commit": "f39beecd" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-11-14 15:18:19.888396", - "spec_repo_commit": "b95546fe" + "regenerated": "2023-11-15 13:47:31.784212", + "spec_repo_commit": "f39beecd" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2c1cf38a93..c46fc636ed 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -11747,6 +11747,53 @@ components: type: string x-enum-varnames: - PROCESS + ProjectedCost: + description: Projected Cost data. + properties: + attributes: + $ref: '#/components/schemas/ProjectedCostAttributes' + id: + description: Unique ID of the response. + type: string + type: + $ref: '#/components/schemas/CostByOrgType' + type: object + ProjectedCostAttributes: + description: Projected Cost attributes data. + properties: + charges: + description: List of charges data reported for the requested month. + items: + $ref: '#/components/schemas/ChargebackBreakdown' + type: array + date: + description: The month requested. + format: date-time + type: string + org_name: + description: The organization name. + type: string + projected_total_cost: + description: The total projected cost of products for the month. + format: double + type: number + public_id: + description: The organization public ID. + type: string + region: + description: The region of the Datadog instance that the organization belongs + to. + type: string + type: object + ProjectedCostResponse: + description: Projected Cost response. + properties: + data: + description: Response containing Projected Cost. + items: + $ref: '#/components/schemas/ProjectedCost' + type: array + type: object QueryFormula: description: A formula for calculation based on one or more queries. properties: @@ -29935,6 +29982,57 @@ paths: summary: Get hourly usage for observability pipelines tags: - Usage Metering + /api/v2/usage/projected_cost: + get: + description: 'Get projected cost across multi-org and single root-org accounts. + + Projected cost data is only available for the current month and becomes available + around the 12th of the month. + + This endpoint requires the usage_read authorization scope.' + operationId: GetProjectedCost + parameters: + - description: String to specify whether cost is broken down at a parent-org + level or at the sub-org level. Available views are `summary` and `sub-org`. + Defaults to `summary`. + in: query + name: view + required: false + schema: + type: string + responses: + '200': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/ProjectedCostResponse' + description: OK + '400': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden - User is not authorized + '429': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Too many requests + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - usage_read + summary: Get projected cost across your account + tags: + - Usage Metering /api/v2/user_invitations: post: description: Sends emails to one or more users inviting them to join the organization. diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index afd9ad55a6..a200fd7f6e 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -5125,6 +5125,27 @@ process\_summary\_type :members: :show-inheritance: +projected\_cost +--------------- + +.. automodule:: datadog_api_client.v2.model.projected_cost + :members: + :show-inheritance: + +projected\_cost\_attributes +--------------------------- + +.. automodule:: datadog_api_client.v2.model.projected_cost_attributes + :members: + :show-inheritance: + +projected\_cost\_response +------------------------- + +.. automodule:: datadog_api_client.v2.model.projected_cost_response + :members: + :show-inheritance: + query\_formula -------------- diff --git a/examples/v2/usage-metering/GetProjectedCost.py b/examples/v2/usage-metering/GetProjectedCost.py new file mode 100644 index 0000000000..f950f0e6c0 --- /dev/null +++ b/examples/v2/usage-metering/GetProjectedCost.py @@ -0,0 +1,15 @@ +""" +Get projected cost across your account returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = UsageMeteringApi(api_client) + response = api_instance.get_projected_cost( + view="sub-org", + ) + + print(response) diff --git a/src/datadog_api_client/v2/api/usage_metering_api.py b/src/datadog_api_client/v2/api/usage_metering_api.py index b26bbe7dff..ba44c6aed9 100644 --- a/src/datadog_api_client/v2/api/usage_metering_api.py +++ b/src/datadog_api_client/v2/api/usage_metering_api.py @@ -20,6 +20,7 @@ from datadog_api_client.v2.model.hourly_usage_response import HourlyUsageResponse from datadog_api_client.v2.model.usage_lambda_traced_invocations_response import UsageLambdaTracedInvocationsResponse from datadog_api_client.v2.model.usage_observability_pipelines_response import UsageObservabilityPipelinesResponse +from datadog_api_client.v2.model.projected_cost_response import ProjectedCostResponse class UsageMeteringApi: @@ -207,6 +208,28 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_projected_cost_endpoint = _Endpoint( + settings={ + "response_type": (ProjectedCostResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/usage/projected_cost", + "operation_id": "get_projected_cost", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "view": { + "openapi_types": (str,), + "attribute": "view", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json;datetime-format=rfc3339"], + }, + api_client=api_client, + ) + self._get_usage_application_security_monitoring_endpoint = _Endpoint( settings={ "response_type": (UsageApplicationSecurityMonitoringResponse,), @@ -465,6 +488,27 @@ def get_hourly_usage( return self._get_hourly_usage_endpoint.call_with_http_info(**kwargs) + def get_projected_cost( + self, + *, + view: Union[str, UnsetType] = unset, + ) -> ProjectedCostResponse: + """Get projected cost across your account. + + Get projected cost across multi-org and single root-org accounts. + Projected cost data is only available for the current month and becomes available around the 12th of the month. + This endpoint requires the usage_read authorization scope. + + :param view: String to specify whether cost is broken down at a parent-org level or at the sub-org level. Available views are ``summary`` and ``sub-org``. Defaults to ``summary``. + :type view: str, optional + :rtype: ProjectedCostResponse + """ + kwargs: Dict[str, Any] = {} + if view is not unset: + kwargs["view"] = view + + return self._get_projected_cost_endpoint.call_with_http_info(**kwargs) + def get_usage_application_security_monitoring( self, start_hr: datetime, diff --git a/src/datadog_api_client/v2/model/projected_cost.py b/src/datadog_api_client/v2/model/projected_cost.py new file mode 100644 index 0000000000..c1deb05eeb --- /dev/null +++ b/src/datadog_api_client/v2/model/projected_cost.py @@ -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 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.projected_cost_attributes import ProjectedCostAttributes + from datadog_api_client.v2.model.cost_by_org_type import CostByOrgType + + +class ProjectedCost(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.projected_cost_attributes import ProjectedCostAttributes + from datadog_api_client.v2.model.cost_by_org_type import CostByOrgType + + return { + "attributes": (ProjectedCostAttributes,), + "id": (str,), + "type": (CostByOrgType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: Union[ProjectedCostAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + type: Union[CostByOrgType, UnsetType] = unset, + **kwargs, + ): + """ + Projected Cost data. + + :param attributes: Projected Cost attributes data. + :type attributes: ProjectedCostAttributes, optional + + :param id: Unique ID of the response. + :type id: str, optional + + :param type: Type of cost data. + :type type: CostByOrgType, optional + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/projected_cost_attributes.py b/src/datadog_api_client/v2/model/projected_cost_attributes.py new file mode 100644 index 0000000000..b759c84cd0 --- /dev/null +++ b/src/datadog_api_client/v2/model/projected_cost_attributes.py @@ -0,0 +1,87 @@ +# 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, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.chargeback_breakdown import ChargebackBreakdown + + +class ProjectedCostAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.chargeback_breakdown import ChargebackBreakdown + + return { + "charges": ([ChargebackBreakdown],), + "date": (datetime,), + "org_name": (str,), + "projected_total_cost": (float,), + "public_id": (str,), + "region": (str,), + } + + attribute_map = { + "charges": "charges", + "date": "date", + "org_name": "org_name", + "projected_total_cost": "projected_total_cost", + "public_id": "public_id", + "region": "region", + } + + def __init__( + self_, + charges: Union[List[ChargebackBreakdown], UnsetType] = unset, + date: Union[datetime, UnsetType] = unset, + org_name: Union[str, UnsetType] = unset, + projected_total_cost: Union[float, UnsetType] = unset, + public_id: Union[str, UnsetType] = unset, + region: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Projected Cost attributes data. + + :param charges: List of charges data reported for the requested month. + :type charges: [ChargebackBreakdown], optional + + :param date: The month requested. + :type date: datetime, optional + + :param org_name: The organization name. + :type org_name: str, optional + + :param projected_total_cost: The total projected cost of products for the month. + :type projected_total_cost: float, optional + + :param public_id: The organization public ID. + :type public_id: str, optional + + :param region: The region of the Datadog instance that the organization belongs to. + :type region: str, optional + """ + if charges is not unset: + kwargs["charges"] = charges + if date is not unset: + kwargs["date"] = date + if org_name is not unset: + kwargs["org_name"] = org_name + if projected_total_cost is not unset: + kwargs["projected_total_cost"] = projected_total_cost + if public_id is not unset: + kwargs["public_id"] = public_id + if region is not unset: + kwargs["region"] = region + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/projected_cost_response.py b/src/datadog_api_client/v2/model/projected_cost_response.py new file mode 100644 index 0000000000..e6b930bb34 --- /dev/null +++ b/src/datadog_api_client/v2/model/projected_cost_response.py @@ -0,0 +1,42 @@ +# 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, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.projected_cost import ProjectedCost + + +class ProjectedCostResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.projected_cost import ProjectedCost + + return { + "data": ([ProjectedCost],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[List[ProjectedCost], UnsetType] = unset, **kwargs): + """ + Projected Cost response. + + :param data: Response containing Projected Cost. + :type data: [ProjectedCost], optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 134b4806a5..067c1ad8c4 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -844,6 +844,9 @@ from datadog_api_client.v2.model.process_summary import ProcessSummary from datadog_api_client.v2.model.process_summary_attributes import ProcessSummaryAttributes from datadog_api_client.v2.model.process_summary_type import ProcessSummaryType +from datadog_api_client.v2.model.projected_cost import ProjectedCost +from datadog_api_client.v2.model.projected_cost_attributes import ProjectedCostAttributes +from datadog_api_client.v2.model.projected_cost_response import ProjectedCostResponse from datadog_api_client.v2.model.query_formula import QueryFormula from datadog_api_client.v2.model.query_sort_order import QuerySortOrder from datadog_api_client.v2.model.rum_aggregate_bucket_value import RUMAggregateBucketValue @@ -2194,6 +2197,9 @@ "ProcessSummary", "ProcessSummaryAttributes", "ProcessSummaryType", + "ProjectedCost", + "ProjectedCostAttributes", + "ProjectedCostResponse", "QueryFormula", "QuerySortOrder", "RUMAggregateBucketValue", diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 1e1bd2a6a4..da720f58d7 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1884,6 +1884,12 @@ "type": "safe" } }, + "GetProjectedCost": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "SendInvitations": { "tag": "Users", "undo": { diff --git a/tests/v2/features/usage_metering.feature b/tests/v2/features/usage_metering.feature index 9c393c3f9e..5ab6025b59 100644 --- a/tests/v2/features/usage_metering.feature +++ b/tests/v2/features/usage_metering.feature @@ -149,6 +149,19 @@ Feature: Usage Metering And the response "data[0].type" is equal to "usage_timeseries" And the response "data[0].attributes.product_family" is equal to "observability-pipelines" + @generated @skip @team:DataDog/red-zone-revenue-query + Scenario: Get projected cost across your account returns "Bad Request" response + Given new "GetProjectedCost" request + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/red-zone-revenue-query + Scenario: Get projected cost across your account returns "OK" response + Given new "GetProjectedCost" request + And request contains "view" parameter with value "sub-org" + When the request is sent + Then the response status is 200 OK + @team:DataDog/red-zone-revenue-query Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response Given new "GetEstimatedCostByOrg" request