Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for beta /v2/usage/billing_dimension_mapping #2152

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-31 15:33:01.115259",
"spec_repo_commit": "a7602fa1"
"regenerated": "2024-10-31 16:03:55.015635",
"spec_repo_commit": "a11da7b5"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-31 15:33:01.133530",
"spec_repo_commit": "a7602fa1"
"regenerated": "2024-10-31 16:03:55.037697",
"spec_repo_commit": "a11da7b5"
}
}
}
132 changes: 132 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,74 @@ components:
- storage_account
- storage_container
type: object
BillingDimensionsMappingBody:
description: Billing dimensions mapping data.
items:
$ref: '#/components/schemas/BillingDimensionsMappingBodyItem'
type: array
BillingDimensionsMappingBodyItem:
description: The mapping data for each billing dimension.
properties:
attributes:
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributes'
id:
description: ID of the billing dimension.
type: string
type:
$ref: '#/components/schemas/ActiveBillingDimensionsType'
type: object
BillingDimensionsMappingBodyItemAttributes:
description: Mapping of billing dimensions to endpoint keys.
properties:
endpoints:
description: List of supported endpoints with their keys mapped to the billing_dimension.
items:
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItems'
type: array
in_app_label:
description: Label used for the billing dimension in the Plan & Usage charts.
example: APM Hosts
type: string
timestamp:
description: 'Month in ISO-8601 format, UTC, and precise to the second:
`[YYYY-MM-DDThh:mm:ss]`.'
format: date-time
type: string
type: object
BillingDimensionsMappingBodyItemAttributesEndpointsItems:
description: An endpoint's keys mapped to the billing_dimension.
properties:
id:
description: The URL for the endpoint.
example: api/v1/usage/billable-summary
type: string
keys:
description: The billing dimension.
example:
- apm_host_top99p
- apm_host_sum
items:
example: apm_host_top99p
type: string
type: array
status:
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus'
type: object
BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus:
description: Denotes whether mapping keys were available for this endpoint.
enum:
- OK
- NOT_FOUND
type: string
x-enum-varnames:
- OK
- NOT_FOUND
BillingDimensionsMappingResponse:
description: Billing dimensions mapping response.
properties:
data:
$ref: '#/components/schemas/BillingDimensionsMappingBody'
type: object
BulkMuteFindingsRequest:
description: The new bulk mute finding request.
properties:
Expand Down Expand Up @@ -41037,6 +41105,70 @@ paths:
operator: OR
permissions:
- usage_read
/api/v2/usage/billing_dimension_mapping:
get:
description: 'Get a mapping of billing dimensions to the corresponding keys
for the supported usage metering public API endpoints.

Mapping data is updated on a monthly cadence.


This endpoint is only accessible to [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/).'
operationId: GetBillingDimensionMapping
parameters:
- description: Datetime in ISO-8601 format, UTC, and for mappings beginning
this month. Defaults to the current month.
in: query
name: filter[month]
required: false
schema:
format: date-time
type: string
- description: String to specify whether to retrieve active billing dimension
mappings for the contract or for all available mappings. Allowed views have
the string `active` or `all`. Defaults to `active`.
in: query
name: filter[view]
required: false
schema:
default: active
type: string
responses:
'200':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/BillingDimensionsMappingResponse'
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 billing dimension mapping for usage endpoints
tags:
- Usage Metering
x-unstable: '**Note**: This endpoint is in Preview.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/usage/cost_by_org:
get:
deprecated: true
Expand Down
35 changes: 35 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,41 @@ datadog\_api\_client.v2.model.bill\_config module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.billing\_dimensions\_mapping\_body\_item module
-----------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.billing_dimensions_mapping_body_item
:members:
:show-inheritance:

datadog\_api\_client.v2.model.billing\_dimensions\_mapping\_body\_item\_attributes module
-----------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.billing_dimensions_mapping_body_item_attributes
:members:
:show-inheritance:

datadog\_api\_client.v2.model.billing\_dimensions\_mapping\_body\_item\_attributes\_endpoints\_items module
-----------------------------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.billing_dimensions_mapping_body_item_attributes_endpoints_items
:members:
:show-inheritance:

datadog\_api\_client.v2.model.billing\_dimensions\_mapping\_body\_item\_attributes\_endpoints\_items\_status module
-------------------------------------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.billing_dimensions_mapping_body_item_attributes_endpoints_items_status
:members:
:show-inheritance:

datadog\_api\_client.v2.model.billing\_dimensions\_mapping\_response module
---------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.billing_dimensions_mapping_response
:members:
:show-inheritance:

datadog\_api\_client.v2.model.bulk\_mute\_findings\_request module
------------------------------------------------------------------

Expand Down
14 changes: 14 additions & 0 deletions examples/v2/usage-metering/GetBillingDimensionMapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Get billing dimension mapping for usage endpoints returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
configuration.unstable_operations["get_billing_dimension_mapping"] = True
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.get_billing_dimension_mapping()

print(response)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def __init__(
"v2.list_apis": False,
"v2.update_open_api": False,
"v2.get_active_billing_dimensions": False,
"v2.get_billing_dimension_mapping": False,
"v2.get_monthly_cost_attribution": False,
"v2.create_dora_deployment": False,
"v2.create_dora_incident": False,
Expand Down
56 changes: 56 additions & 0 deletions src/datadog_api_client/v2/api/usage_metering_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from datadog_api_client.v2.model.usage_application_security_monitoring_response import (
UsageApplicationSecurityMonitoringResponse,
)
from datadog_api_client.v2.model.billing_dimensions_mapping_response import BillingDimensionsMappingResponse
from datadog_api_client.v2.model.cost_by_org_response import CostByOrgResponse
from datadog_api_client.v2.model.hourly_usage_response import HourlyUsageResponse
from datadog_api_client.v2.model.usage_lambda_traced_invocations_response import UsageLambdaTracedInvocationsResponse
Expand Down Expand Up @@ -61,6 +62,33 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._get_billing_dimension_mapping_endpoint = _Endpoint(
settings={
"response_type": (BillingDimensionsMappingResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/billing_dimension_mapping",
"operation_id": "get_billing_dimension_mapping",
"http_method": "GET",
"version": "v2",
},
params_map={
"filter_month": {
"openapi_types": (datetime,),
"attribute": "filter[month]",
"location": "query",
},
"filter_view": {
"openapi_types": (str,),
"attribute": "filter[view]",
"location": "query",
},
},
headers_map={
"accept": ["application/json;datetime-format=rfc3339"],
},
api_client=api_client,
)

self._get_cost_by_org_endpoint = _Endpoint(
settings={
"response_type": (CostByOrgResponse,),
Expand Down Expand Up @@ -424,6 +452,34 @@ def get_active_billing_dimensions(
kwargs: Dict[str, Any] = {}
return self._get_active_billing_dimensions_endpoint.call_with_http_info(**kwargs)

def get_billing_dimension_mapping(
self,
*,
filter_month: Union[datetime, UnsetType] = unset,
filter_view: Union[str, UnsetType] = unset,
) -> BillingDimensionsMappingResponse:
"""Get billing dimension mapping for usage endpoints.

Get a mapping of billing dimensions to the corresponding keys for the supported usage metering public API endpoints.
Mapping data is updated on a monthly cadence.

This endpoint is only accessible to `parent-level organizations <https://docs.datadoghq.com/account_management/multi_organization/>`_.

:param filter_month: Datetime in ISO-8601 format, UTC, and for mappings beginning this month. Defaults to the current month.
:type filter_month: datetime, optional
:param filter_view: String to specify whether to retrieve active billing dimension mappings for the contract or for all available mappings. Allowed views have the string ``active`` or ``all``. Defaults to ``active``.
:type filter_view: str, optional
:rtype: BillingDimensionsMappingResponse
"""
kwargs: Dict[str, Any] = {}
if filter_month is not unset:
kwargs["filter_month"] = filter_month

if filter_view is not unset:
kwargs["filter_view"] = filter_view

return self._get_billing_dimension_mapping_endpoint.call_with_http_info(**kwargs)

def get_cost_by_org(
self,
start_month: datetime,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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.billing_dimensions_mapping_body_item_attributes import (
BillingDimensionsMappingBodyItemAttributes,
)
from datadog_api_client.v2.model.active_billing_dimensions_type import ActiveBillingDimensionsType


class BillingDimensionsMappingBodyItem(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.billing_dimensions_mapping_body_item_attributes import (
BillingDimensionsMappingBodyItemAttributes,
)
from datadog_api_client.v2.model.active_billing_dimensions_type import ActiveBillingDimensionsType

return {
"attributes": (BillingDimensionsMappingBodyItemAttributes,),
"id": (str,),
"type": (ActiveBillingDimensionsType,),
}

attribute_map = {
"attributes": "attributes",
"id": "id",
"type": "type",
}

def __init__(
self_,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Code Quality Violation

Suggested change
self_,
self,
first parameter of a class function should be self (...read more)

In a class method (that is not a class method nor a static method), the first argument must be self by convention.

Learn More

View in Datadog  Leave us feedback  Documentation

attributes: Union[BillingDimensionsMappingBodyItemAttributes, UnsetType] = unset,
id: Union[str, UnsetType] = unset,
type: Union[ActiveBillingDimensionsType, UnsetType] = unset,
**kwargs,
):
"""
The mapping data for each billing dimension.

:param attributes: Mapping of billing dimensions to endpoint keys.
:type attributes: BillingDimensionsMappingBodyItemAttributes, optional

:param id: ID of the billing dimension.
:type id: str, optional

:param type: Type of active billing dimensions data.
:type type: ActiveBillingDimensionsType, 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)
Loading
Loading