From eb532e37ee90bc2f225f73f8fb82120422e0fbd6 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 16 Nov 2026 19:22:06 +0000 Subject: [PATCH] Regenerate client from commit 9b02d90 of spec repo --- .generator/schemas/v2/openapi.yaml | 243 ++++++++++++++++++ .../GetUsageMonthlyResources.py | 21 ++ .../GetUsageMonthlyResources_1935480325.py | 21 ++ .../v2/api/usage_metering_api.py | 134 ++++++++++ .../v2/model/monthly_resource.py | 64 +++++ .../v2/model/monthly_resource_attributes.py | 97 +++++++ .../v2/model/monthly_resource_type.py | 35 +++ .../v2/model/monthly_resources_metadata.py | 42 +++ .../v2/model/monthly_resources_pagination.py | 37 +++ .../v2/model/monthly_resources_response.py | 56 ++++ .../v2/model/monthly_resources_view.py | 38 +++ src/datadog_api_client/v2/models/__init__.py | 14 + tests/v2/features/undo.json | 6 + tests/v2/features/usage_metering.feature | 36 +++ 14 files changed, 844 insertions(+) create mode 100644 examples/v2/usage-metering/GetUsageMonthlyResources.py create mode 100644 examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.py create mode 100644 src/datadog_api_client/v2/model/monthly_resource.py create mode 100644 src/datadog_api_client/v2/model/monthly_resource_attributes.py create mode 100644 src/datadog_api_client/v2/model/monthly_resource_type.py create mode 100644 src/datadog_api_client/v2/model/monthly_resources_metadata.py create mode 100644 src/datadog_api_client/v2/model/monthly_resources_pagination.py create mode 100644 src/datadog_api_client/v2/model/monthly_resources_response.py create mode 100644 src/datadog_api_client/v2/model/monthly_resources_view.py diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7a9926c3d3..c796079b65 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -92205,6 +92205,91 @@ components: meta: $ref: "#/components/schemas/MonthlyCostAttributionMeta" type: object + MonthlyResource: + description: A resource's usage for the requested billing dimension and month. + properties: + attributes: + $ref: "#/components/schemas/MonthlyResourceAttributes" + id: + description: Identifier for the resource usage record. Treat this value as opaque. + type: string + type: + $ref: "#/components/schemas/MonthlyResourceType" + type: object + MonthlyResourceAttributes: + description: Resource usage and organization details for the requested month. + properties: + data_date: + description: Date of the source usage data. May be empty when unavailable. + type: string + org_name: + description: Name of the organization that owns the resource. + type: string + public_id: + description: Public ID of the organization that owns the resource. + type: string + resource_name: + description: Name of the resource, such as a host name, metric name, or log index. + type: string + tags: + additionalProperties: + type: string + description: Resource tags when available. Empty for resource types without tag data. + type: object + timestamp: + description: Selected billing hour for percentile usage, or the first day of the month for monthly usage. May be empty when unavailable. + type: string + usage_type: + description: Usage type of the resource. Values depend on the billing dimension and are not limited to host types. + type: string + usage_value: + description: Usage attributed to the resource in the units of the requested billing dimension. Values can be fractional. + format: double + nullable: true + type: number + type: object + MonthlyResourceType: + default: monthly_resource + description: Type of a monthly resource usage record. + enum: + - monthly_resource + type: string + x-enum-varnames: + - MONTHLY_RESOURCE + MonthlyResourcesMetadata: + description: Metadata for monthly resource usage. + properties: + pagination: + $ref: "#/components/schemas/MonthlyResourcesPagination" + type: object + MonthlyResourcesPagination: + description: Pagination information for monthly resource usage. + properties: + next_record_id: + description: Cursor for the next request. Pass as `page[next_record_id]` with the same filters. Null when there are no more results. + nullable: true + type: string + type: object + MonthlyResourcesResponse: + description: Monthly usage for host and non-host resources. + properties: + data: + description: Resource usage records. Empty when no matching resources are available. + items: + $ref: "#/components/schemas/MonthlyResource" + type: array + meta: + $ref: "#/components/schemas/MonthlyResourcesMetadata" + type: object + MonthlyResourcesView: + description: Whether to return billable resources or the full monthly resource breakdown. + enum: + - billable + - all + type: string + x-enum-varnames: + - BILLABLE + - ALL MuteDataType: default: mute description: Mute resource type. @@ -270789,6 +270874,164 @@ paths: operator: OR permissions: - usage_read + /api/v2/usage/monthly_resources: + get: + description: |- + Get resource-level usage for a billing dimension and month, using the same + data as the resource breakdown in Plan & Usage. Supports all host and + non-host resource types available in that breakdown. Availability depends + on the billing dimension and the organization's usage data. + + Results are scoped to the authenticated organization. Set `filter[include_descendants]` + to `true` to also return usage from its descendant organizations in all regions. + + Set `filter[view]` to `billable` to return resources that contribute to billable usage. + For dimensions billed at the 99th percentile, this view returns resources at the + selected billing hour. For sum-based dimensions, it returns monthly resource usage. + Set `filter[view]` to `all` to return the full monthly resource breakdown. Requests + for unsupported billing dimensions, or dimensions configured with an unsupported + billing aggregation method, return a `400 Bad Request` error. + + To get the next page of results, pass the `meta.pagination.next_record_id` value + from the previous response as `page[next_record_id]`, and keep all filters unchanged. + A null cursor indicates the last page. Paginated responses contain at most + `page[limit]` resource records, including queries across descendant organizations. + + Exception: for any billing dimension billed at the 99th percentile, + `filter[view]=billable` returns the complete resource breakdown in one response, + including requested descendants. Eligibility depends on the organization's + billing configuration for the requested dimension and month, not on the product + name. For these queries, `page[limit]` and `page[next_record_id]` are ignored, and + `meta.pagination.next_record_id` is null. Sum-based usage and `filter[view]=all` + remain paginated. + operationId: GetUsageMonthlyResources + parameters: + - description: Billing dimension to retrieve, such as `infra_host`, `indexed_points`, or `logs_indexed_30day`. + example: infra_host + in: query + name: filter[billing_dimension] + required: true + schema: + type: string + - description: Month of usage to retrieve in `YYYY-MM` format. + example: "2026-04" + in: query + name: filter[month] + required: true + schema: + pattern: "^[0-9]{4}-(0[1-9]|1[0-2])$" + type: string + - description: |- + Set to `billable` to return resources that contribute to billable usage, or `all` + to return the full monthly resource breakdown. + example: billable + in: query + name: filter[view] + required: true + schema: + $ref: "#/components/schemas/MonthlyResourcesView" + - description: Include usage for descendant organizations of the authenticated organization. + in: query + name: filter[include_descendants] + required: false + schema: + default: false + type: boolean + - description: |- + Maximum number of resource records per paginated response. Must be a positive integer. + Values above 100,000 are capped at 100,000. Ignored for billable queries using + 99th-percentile billing, which return the complete result in one response. + in: query + name: page[limit] + required: false + schema: + default: 100000 + format: int64 + maximum: 100000 + minimum: 1 + type: integer + - description: |- + Opaque cursor from `meta.pagination.next_record_id` in the previous response. + Omit for the first request. Ignored for billable queries using 99th-percentile + billing, which always return the complete result. + in: query + name: page[next_record_id] + required: false + schema: + type: string + responses: + "200": + content: + application/json;datetime-format=rfc3339: + examples: + default: + value: + data: + - attributes: + data_date: "2026-04-30" + org_name: Example organization + public_id: abc123 + resource_name: host-1.prod + tags: + env: prod + timestamp: "2026-04-22 16:00:00+00:00" + usage_type: agent + usage_value: 1 + id: abc123_agent_host-1.prod + type: monthly_resource + meta: + pagination: + next_record_id: + non_host: + value: + data: + - attributes: + data_date: "2026-04-30" + org_name: Example organization + public_id: abc123 + resource_name: app.requests + tags: {} + timestamp: "2026-04-01" + usage_type: post_threshold_indexed + usage_value: 1250.5 + id: abc123_post_threshold_indexed_app.requests + type: monthly_resource + meta: + pagination: + next_record_id: + schema: + $ref: "#/components/schemas/MonthlyResourcesResponse" + description: OK + "400": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + 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 monthly usage by resource + tags: + - Usage Metering + "x-permission": + operator: OR + permissions: + - usage_read /api/v2/usage/observability_pipelines: get: deprecated: true diff --git a/examples/v2/usage-metering/GetUsageMonthlyResources.py b/examples/v2/usage-metering/GetUsageMonthlyResources.py new file mode 100644 index 0000000000..69b28a8d97 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageMonthlyResources.py @@ -0,0 +1,21 @@ +""" +Get monthly usage by resource returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi +from datadog_api_client.v2.model.monthly_resources_view import MonthlyResourcesView + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = UsageMeteringApi(api_client) + response = api_instance.get_usage_monthly_resources( + filter_billing_dimension="infra_host", + filter_month="2026-04", + filter_view=MonthlyResourcesView.ALL, + page_limit=1, + ) + + print(response) diff --git a/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.py b/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.py new file mode 100644 index 0000000000..96e0f33aba --- /dev/null +++ b/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.py @@ -0,0 +1,21 @@ +""" +Get monthly usage by resource supports non-host resources +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi +from datadog_api_client.v2.model.monthly_resources_view import MonthlyResourcesView + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = UsageMeteringApi(api_client) + response = api_instance.get_usage_monthly_resources( + filter_billing_dimension="indexed_points", + filter_month="2026-04", + filter_view=MonthlyResourcesView.ALL, + page_limit=1, + ) + + 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 0c4d5ffb36..b6ee78bb00 100644 --- a/src/datadog_api_client/v2/api/usage_metering_api.py +++ b/src/datadog_api_client/v2/api/usage_metering_api.py @@ -33,6 +33,8 @@ from datadog_api_client.v2.model.cost_aggregation_type import CostAggregationType 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.monthly_resources_response import MonthlyResourcesResponse +from datadog_api_client.v2.model.monthly_resources_view import MonthlyResourcesView from datadog_api_client.v2.model.usage_observability_pipelines_response import UsageObservabilityPipelinesResponse from datadog_api_client.v2.model.projected_cost_response import ProjectedCostResponse from datadog_api_client.v2.model.usage_quotas_list_response import UsageQuotasListResponse @@ -702,6 +704,61 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_usage_monthly_resources_endpoint = _Endpoint( + settings={ + "response_type": (MonthlyResourcesResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/usage/monthly_resources", + "operation_id": "get_usage_monthly_resources", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "filter_billing_dimension": { + "required": True, + "openapi_types": (str,), + "attribute": "filter[billing_dimension]", + "location": "query", + }, + "filter_month": { + "required": True, + "validation": {}, + "openapi_types": (str,), + "attribute": "filter[month]", + "location": "query", + }, + "filter_view": { + "required": True, + "openapi_types": (MonthlyResourcesView,), + "attribute": "filter[view]", + "location": "query", + }, + "filter_include_descendants": { + "openapi_types": (bool,), + "attribute": "filter[include_descendants]", + "location": "query", + }, + "page_limit": { + "validation": { + "inclusive_maximum": 100000, + "inclusive_minimum": 1, + }, + "openapi_types": (int,), + "attribute": "page[limit]", + "location": "query", + }, + "page_next_record_id": { + "openapi_types": (str,), + "attribute": "page[next_record_id]", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json;datetime-format=rfc3339"], + }, + api_client=api_client, + ) + self._get_usage_observability_pipelines_endpoint = _Endpoint( settings={ "response_type": (UsageObservabilityPipelinesResponse,), @@ -1595,6 +1652,83 @@ def get_usage_lambda_traced_invocations( warnings.warn("get_usage_lambda_traced_invocations is deprecated", DeprecationWarning, stacklevel=2) return self._get_usage_lambda_traced_invocations_endpoint.call_with_http_info(**kwargs) + def get_usage_monthly_resources( + self, + filter_billing_dimension: str, + filter_month: str, + filter_view: MonthlyResourcesView, + *, + filter_include_descendants: Union[bool, UnsetType] = unset, + page_limit: Union[int, UnsetType] = unset, + page_next_record_id: Union[str, UnsetType] = unset, + ) -> MonthlyResourcesResponse: + """Get monthly usage by resource. + + Get resource-level usage for a billing dimension and month, using the same + data as the resource breakdown in Plan & Usage. Supports all host and + non-host resource types available in that breakdown. Availability depends + on the billing dimension and the organization's usage data. + + Results are scoped to the authenticated organization. Set ``filter[include_descendants]`` + to ``true`` to also return usage from its descendant organizations in all regions. + + Set ``filter[view]`` to ``billable`` to return resources that contribute to billable usage. + For dimensions billed at the 99th percentile, this view returns resources at the + selected billing hour. For sum-based dimensions, it returns monthly resource usage. + Set ``filter[view]`` to ``all`` to return the full monthly resource breakdown. Requests + for unsupported billing dimensions, or dimensions configured with an unsupported + billing aggregation method, return a ``400 Bad Request`` error. + + To get the next page of results, pass the ``meta.pagination.next_record_id`` value + from the previous response as ``page[next_record_id]`` , and keep all filters unchanged. + A null cursor indicates the last page. Paginated responses contain at most + ``page[limit]`` resource records, including queries across descendant organizations. + + Exception: for any billing dimension billed at the 99th percentile, + ``filter[view]=billable`` returns the complete resource breakdown in one response, + including requested descendants. Eligibility depends on the organization's + billing configuration for the requested dimension and month, not on the product + name. For these queries, ``page[limit]`` and ``page[next_record_id]`` are ignored, and + ``meta.pagination.next_record_id`` is null. Sum-based usage and ``filter[view]=all`` + remain paginated. + + :param filter_billing_dimension: Billing dimension to retrieve, such as ``infra_host`` , ``indexed_points`` , or ``logs_indexed_30day``. + :type filter_billing_dimension: str + :param filter_month: Month of usage to retrieve in ``YYYY-MM`` format. + :type filter_month: str + :param filter_view: Set to ``billable`` to return resources that contribute to billable usage, or ``all`` + to return the full monthly resource breakdown. + :type filter_view: MonthlyResourcesView + :param filter_include_descendants: Include usage for descendant organizations of the authenticated organization. + :type filter_include_descendants: bool, optional + :param page_limit: Maximum number of resource records per paginated response. Must be a positive integer. + Values above 100,000 are capped at 100,000. Ignored for billable queries using + 99th-percentile billing, which return the complete result in one response. + :type page_limit: int, optional + :param page_next_record_id: Opaque cursor from ``meta.pagination.next_record_id`` in the previous response. + Omit for the first request. Ignored for billable queries using 99th-percentile + billing, which always return the complete result. + :type page_next_record_id: str, optional + :rtype: MonthlyResourcesResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["filter_billing_dimension"] = filter_billing_dimension + + kwargs["filter_month"] = filter_month + + kwargs["filter_view"] = filter_view + + if filter_include_descendants is not unset: + kwargs["filter_include_descendants"] = filter_include_descendants + + if page_limit is not unset: + kwargs["page_limit"] = page_limit + + if page_next_record_id is not unset: + kwargs["page_next_record_id"] = page_next_record_id + + return self._get_usage_monthly_resources_endpoint.call_with_http_info(**kwargs) + def get_usage_observability_pipelines( self, start_hr: datetime, diff --git a/src/datadog_api_client/v2/model/monthly_resource.py b/src/datadog_api_client/v2/model/monthly_resource.py new file mode 100644 index 0000000000..665cb97ba1 --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resource.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.monthly_resource_attributes import MonthlyResourceAttributes + from datadog_api_client.v2.model.monthly_resource_type import MonthlyResourceType + + +class MonthlyResource(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monthly_resource_attributes import MonthlyResourceAttributes + from datadog_api_client.v2.model.monthly_resource_type import MonthlyResourceType + + return { + "attributes": (MonthlyResourceAttributes,), + "id": (str,), + "type": (MonthlyResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: Union[MonthlyResourceAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + type: Union[MonthlyResourceType, UnsetType] = unset, + **kwargs, + ): + """ + A resource's usage for the requested billing dimension and month. + + :param attributes: Resource usage and organization details for the requested month. + :type attributes: MonthlyResourceAttributes, optional + + :param id: Identifier for the resource usage record. Treat this value as opaque. + :type id: str, optional + + :param type: Type of a monthly resource usage record. + :type type: MonthlyResourceType, 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/monthly_resource_attributes.py b/src/datadog_api_client/v2/model/monthly_resource_attributes.py new file mode 100644 index 0000000000..a021b56c22 --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resource_attributes.py @@ -0,0 +1,97 @@ +# 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 Dict, Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class MonthlyResourceAttributes(ModelNormal): + @cached_property + def openapi_types(_): + return { + "data_date": (str,), + "org_name": (str,), + "public_id": (str,), + "resource_name": (str,), + "tags": ({str: (str,)},), + "timestamp": (str,), + "usage_type": (str,), + "usage_value": (float, none_type), + } + + attribute_map = { + "data_date": "data_date", + "org_name": "org_name", + "public_id": "public_id", + "resource_name": "resource_name", + "tags": "tags", + "timestamp": "timestamp", + "usage_type": "usage_type", + "usage_value": "usage_value", + } + + def __init__( + self_, + data_date: Union[str, UnsetType] = unset, + org_name: Union[str, UnsetType] = unset, + public_id: Union[str, UnsetType] = unset, + resource_name: Union[str, UnsetType] = unset, + tags: Union[Dict[str, str], UnsetType] = unset, + timestamp: Union[str, UnsetType] = unset, + usage_type: Union[str, UnsetType] = unset, + usage_value: Union[float, none_type, UnsetType] = unset, + **kwargs, + ): + """ + Resource usage and organization details for the requested month. + + :param data_date: Date of the source usage data. May be empty when unavailable. + :type data_date: str, optional + + :param org_name: Name of the organization that owns the resource. + :type org_name: str, optional + + :param public_id: Public ID of the organization that owns the resource. + :type public_id: str, optional + + :param resource_name: Name of the resource, such as a host name, metric name, or log index. + :type resource_name: str, optional + + :param tags: Resource tags when available. Empty for resource types without tag data. + :type tags: {str: (str,)}, optional + + :param timestamp: Selected billing hour for percentile usage, or the first day of the month for monthly usage. May be empty when unavailable. + :type timestamp: str, optional + + :param usage_type: Usage type of the resource. Values depend on the billing dimension and are not limited to host types. + :type usage_type: str, optional + + :param usage_value: Usage attributed to the resource in the units of the requested billing dimension. Values can be fractional. + :type usage_value: float, none_type, optional + """ + if data_date is not unset: + kwargs["data_date"] = data_date + if org_name is not unset: + kwargs["org_name"] = org_name + if public_id is not unset: + kwargs["public_id"] = public_id + if resource_name is not unset: + kwargs["resource_name"] = resource_name + if tags is not unset: + kwargs["tags"] = tags + if timestamp is not unset: + kwargs["timestamp"] = timestamp + if usage_type is not unset: + kwargs["usage_type"] = usage_type + if usage_value is not unset: + kwargs["usage_value"] = usage_value + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monthly_resource_type.py b/src/datadog_api_client/v2/model/monthly_resource_type.py new file mode 100644 index 0000000000..bca2bca8c8 --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resource_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class MonthlyResourceType(ModelSimple): + """ + Type of a monthly resource usage record. + + :param value: If omitted defaults to "monthly_resource". Must be one of ["monthly_resource"]. + :type value: str + """ + + allowed_values = { + "monthly_resource", + } + MONTHLY_RESOURCE: ClassVar["MonthlyResourceType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +MonthlyResourceType.MONTHLY_RESOURCE = MonthlyResourceType("monthly_resource") diff --git a/src/datadog_api_client/v2/model/monthly_resources_metadata.py b/src/datadog_api_client/v2/model/monthly_resources_metadata.py new file mode 100644 index 0000000000..b06d0ea684 --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resources_metadata.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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.monthly_resources_pagination import MonthlyResourcesPagination + + +class MonthlyResourcesMetadata(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monthly_resources_pagination import MonthlyResourcesPagination + + return { + "pagination": (MonthlyResourcesPagination,), + } + + attribute_map = { + "pagination": "pagination", + } + + def __init__(self_, pagination: Union[MonthlyResourcesPagination, UnsetType] = unset, **kwargs): + """ + Metadata for monthly resource usage. + + :param pagination: Pagination information for monthly resource usage. + :type pagination: MonthlyResourcesPagination, optional + """ + if pagination is not unset: + kwargs["pagination"] = pagination + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monthly_resources_pagination.py b/src/datadog_api_client/v2/model/monthly_resources_pagination.py new file mode 100644 index 0000000000..872e064aa7 --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resources_pagination.py @@ -0,0 +1,37 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class MonthlyResourcesPagination(ModelNormal): + @cached_property + def openapi_types(_): + return { + "next_record_id": (str, none_type), + } + + attribute_map = { + "next_record_id": "next_record_id", + } + + def __init__(self_, next_record_id: Union[str, none_type, UnsetType] = unset, **kwargs): + """ + Pagination information for monthly resource usage. + + :param next_record_id: Cursor for the next request. Pass as ``page[next_record_id]`` with the same filters. Null when there are no more results. + :type next_record_id: str, none_type, optional + """ + if next_record_id is not unset: + kwargs["next_record_id"] = next_record_id + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monthly_resources_response.py b/src/datadog_api_client/v2/model/monthly_resources_response.py new file mode 100644 index 0000000000..eb0a8d2948 --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resources_response.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import 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.monthly_resource import MonthlyResource + from datadog_api_client.v2.model.monthly_resources_metadata import MonthlyResourcesMetadata + + +class MonthlyResourcesResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monthly_resource import MonthlyResource + from datadog_api_client.v2.model.monthly_resources_metadata import MonthlyResourcesMetadata + + return { + "data": ([MonthlyResource],), + "meta": (MonthlyResourcesMetadata,), + } + + attribute_map = { + "data": "data", + "meta": "meta", + } + + def __init__( + self_, + data: Union[List[MonthlyResource], UnsetType] = unset, + meta: Union[MonthlyResourcesMetadata, UnsetType] = unset, + **kwargs, + ): + """ + Monthly usage for host and non-host resources. + + :param data: Resource usage records. Empty when no matching resources are available. + :type data: [MonthlyResource], optional + + :param meta: Metadata for monthly resource usage. + :type meta: MonthlyResourcesMetadata, optional + """ + if data is not unset: + kwargs["data"] = data + if meta is not unset: + kwargs["meta"] = meta + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monthly_resources_view.py b/src/datadog_api_client/v2/model/monthly_resources_view.py new file mode 100644 index 0000000000..43501041ef --- /dev/null +++ b/src/datadog_api_client/v2/model/monthly_resources_view.py @@ -0,0 +1,38 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class MonthlyResourcesView(ModelSimple): + """ + Whether to return billable resources or the full monthly resource breakdown. + + :param value: Must be one of ["billable", "all"]. + :type value: str + """ + + allowed_values = { + "billable", + "all", + } + BILLABLE: ClassVar["MonthlyResourcesView"] + ALL: ClassVar["MonthlyResourcesView"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +MonthlyResourcesView.BILLABLE = MonthlyResourcesView("billable") +MonthlyResourcesView.ALL = MonthlyResourcesView("all") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 24dc39251c..ee1003a6d0 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -7339,6 +7339,13 @@ from datadog_api_client.v2.model.monthly_cost_attribution_meta import MonthlyCostAttributionMeta from datadog_api_client.v2.model.monthly_cost_attribution_pagination import MonthlyCostAttributionPagination from datadog_api_client.v2.model.monthly_cost_attribution_response import MonthlyCostAttributionResponse +from datadog_api_client.v2.model.monthly_resource import MonthlyResource +from datadog_api_client.v2.model.monthly_resource_attributes import MonthlyResourceAttributes +from datadog_api_client.v2.model.monthly_resource_type import MonthlyResourceType +from datadog_api_client.v2.model.monthly_resources_metadata import MonthlyResourcesMetadata +from datadog_api_client.v2.model.monthly_resources_pagination import MonthlyResourcesPagination +from datadog_api_client.v2.model.monthly_resources_response import MonthlyResourcesResponse +from datadog_api_client.v2.model.monthly_resources_view import MonthlyResourcesView from datadog_api_client.v2.model.mute_data_type import MuteDataType from datadog_api_client.v2.model.mute_findings_mute_attributes import MuteFindingsMuteAttributes from datadog_api_client.v2.model.mute_findings_reason import MuteFindingsReason @@ -19208,6 +19215,13 @@ "MonthlyCostAttributionMeta", "MonthlyCostAttributionPagination", "MonthlyCostAttributionResponse", + "MonthlyResource", + "MonthlyResourceAttributes", + "MonthlyResourceType", + "MonthlyResourcesMetadata", + "MonthlyResourcesPagination", + "MonthlyResourcesResponse", + "MonthlyResourcesView", "MuteDataType", "MuteFindingsMuteAttributes", "MuteFindingsReason", diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 0d9b33aa46..481c29dd47 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -11713,6 +11713,12 @@ "type": "safe" } }, + "GetUsageMonthlyResources": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetUsageObservabilityPipelines": { "tag": "Usage Metering", "undo": { diff --git a/tests/v2/features/usage_metering.feature b/tests/v2/features/usage_metering.feature index 67ba7beace..783eab95a1 100644 --- a/tests/v2/features/usage_metering.feature +++ b/tests/v2/features/usage_metering.feature @@ -451,6 +451,42 @@ 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" + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource returns "Bad Request" response + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "infra_host" + And request contains "filter[month]" parameter with value "not-a-month" + And request contains "filter[view]" parameter with value "all" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors[0].status" is equal to "400" + And the response "errors[0].title" is equal to "Bad Request" + And the response "errors[0]" has field "detail" + + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource returns "OK" response + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "infra_host" + And request contains "filter[month]" parameter with value "2026-04" + And request contains "filter[view]" parameter with value "all" + And request contains "page[limit]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "meta" has field "pagination" + And the response "meta.pagination" has field "next_record_id" + + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource supports non-host resources + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "indexed_points" + And request contains "filter[month]" parameter with value "2026-04" + And request contains "filter[view]" parameter with value "all" + And request contains "page[limit]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "meta" has field "pagination" + And the response "meta.pagination" has field "next_record_id" + @generated @skip @team:ddoghq/billing-hub Scenario: Get projected cost across your account returns "Bad Request" response Given new "GetProjectedCost" request