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

Add active billing dimensions to usage metering #1773

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": "2023-11-16 17:18:48.848152",
"spec_repo_commit": "0e97d7dd"
"regenerated": "2023-11-16 18:34:39.744523",
"spec_repo_commit": "973bd612"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-11-16 17:18:48.870273",
"spec_repo_commit": "0e97d7dd"
"regenerated": "2023-11-16 18:34:39.763563",
"spec_repo_commit": "973bd612"
}
}
}
82 changes: 82 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,47 @@ components:
type: string
x-enum-varnames:
- API_KEYS
ActiveBillingDimensionsAttributes:
description: List of active billing dimensions.
properties:
month:
description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]`.'
format: date-time
type: string
values:
description: 'List of active billing dimensions. Example: `[infra_host,
apm_host, serverless_infra]`.'
items:
description: A given billing dimension in a list.
example: infra_host
type: string
type: array
type: object
ActiveBillingDimensionsBody:
description: Active billing dimensions data.
properties:
attributes:
$ref: '#/components/schemas/ActiveBillingDimensionsAttributes'
id:
description: Unique ID of the response.
type: string
type:
$ref: '#/components/schemas/ActiveBillingDimensionsType'
type: object
ActiveBillingDimensionsResponse:
description: Active billing dimensions response.
properties:
data:
$ref: '#/components/schemas/ActiveBillingDimensionsBody'
type: object
ActiveBillingDimensionsType:
default: billing_dimensions
description: Type of active billing dimensions data.
enum:
- billing_dimensions
type: string
x-enum-varnames:
- BILLING_DIMENSIONS
ApmRetentionFilterType:
default: apm_retention_filter
description: The type of the resource.
Expand Down Expand Up @@ -20823,6 +20864,47 @@ paths:
resultsPath: data
x-unstable: '**Note**: This endpoint is in public beta.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/cost_by_tag/active_billing_dimensions:
get:
description: Get active billing dimensions for cost attribution. Cost data for
a given month becomes available no later than the 17th of the following month.
operationId: GetActiveBillingDimensions
responses:
'200':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/ActiveBillingDimensionsResponse'
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 active billing dimensions for cost attribution
tags:
- Usage Metering
x-unstable: '**Note**: This endpoint is in public beta.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/current_user/application_keys:
get:
Expand Down
28 changes: 28 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
datadog\_api\_client.v2.model
=============================

active\_billing\_dimensions\_attributes
---------------------------------------

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

active\_billing\_dimensions\_body
---------------------------------

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

active\_billing\_dimensions\_response
-------------------------------------

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

active\_billing\_dimensions\_type
---------------------------------

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

api\_error\_response
--------------------

Expand Down
14 changes: 14 additions & 0 deletions examples/v2/usage-metering/GetActiveBillingDimensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Get active billing dimensions for cost attribution 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_active_billing_dimensions"] = True
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.get_active_billing_dimensions()

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 @@ -239,6 +239,7 @@ def __init__(
"v2.create_ci_app_pipeline_event": False,
"v2.list_container_images": False,
"v2.list_containers": False,
"v2.get_active_billing_dimensions": False,
"v2.list_events": False,
"v2.search_events": False,
"v2.create_incident": False,
Expand Down
29 changes: 29 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 @@ -13,6 +13,7 @@
UnsetType,
unset,
)
from datadog_api_client.v2.model.active_billing_dimensions_response import ActiveBillingDimensionsResponse
from datadog_api_client.v2.model.usage_application_security_monitoring_response import (
UsageApplicationSecurityMonitoringResponse,
)
Expand Down Expand Up @@ -42,6 +43,22 @@ def __init__(self, api_client=None):
api_client = ApiClient(Configuration())
self.api_client = api_client

self._get_active_billing_dimensions_endpoint = _Endpoint(
settings={
"response_type": (ActiveBillingDimensionsResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/cost_by_tag/active_billing_dimensions",
"operation_id": "get_active_billing_dimensions",
"http_method": "GET",
"version": "v2",
},
params_map={},
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 @@ -314,6 +331,18 @@ def __init__(self, api_client=None):
api_client=api_client,
)

def get_active_billing_dimensions(
self,
) -> ActiveBillingDimensionsResponse:
"""Get active billing dimensions for cost attribution.

Get active billing dimensions for cost attribution. Cost data for a given month becomes available no later than the 17th of the following month.

:rtype: ActiveBillingDimensionsResponse
"""
kwargs: Dict[str, Any] = {}
return self._get_active_billing_dimensions_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,46 @@
# 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

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
datetime,
unset,
UnsetType,
)


class ActiveBillingDimensionsAttributes(ModelNormal):
@cached_property
def openapi_types(_):
return {
"month": (datetime,),
"values": ([str],),
}

attribute_map = {
"month": "month",
"values": "values",
}

def __init__(
self_, month: Union[datetime, UnsetType] = unset, values: Union[List[str], UnsetType] = unset, **kwargs
):
"""
List of active billing dimensions.

:param month: Datetime in ISO-8601 format, UTC, precise to hour: ``[YYYY-MM-DDThh]``.
:type month: datetime, optional

:param values: List of active billing dimensions. Example: ``[infra_host, apm_host, serverless_infra]``.
:type values: [str], optional
"""
if month is not unset:
kwargs["month"] = month
if values is not unset:
kwargs["values"] = values
super().__init__(kwargs)
Original file line number Diff line number Diff line change
@@ -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.active_billing_dimensions_attributes import ActiveBillingDimensionsAttributes
from datadog_api_client.v2.model.active_billing_dimensions_type import ActiveBillingDimensionsType


class ActiveBillingDimensionsBody(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.active_billing_dimensions_attributes import ActiveBillingDimensionsAttributes
from datadog_api_client.v2.model.active_billing_dimensions_type import ActiveBillingDimensionsType

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

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

def __init__(
self_,
attributes: Union[ActiveBillingDimensionsAttributes, UnsetType] = unset,
id: Union[str, UnsetType] = unset,
type: Union[ActiveBillingDimensionsType, UnsetType] = unset,
**kwargs,
):
"""
Active billing dimensions data.

:param attributes: List of active billing dimensions.
:type attributes: ActiveBillingDimensionsAttributes, optional

:param id: Unique ID of the response.
: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)
Original file line number Diff line number Diff line change
@@ -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.active_billing_dimensions_body import ActiveBillingDimensionsBody


class ActiveBillingDimensionsResponse(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.active_billing_dimensions_body import ActiveBillingDimensionsBody

return {
"data": (ActiveBillingDimensionsBody,),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: Union[ActiveBillingDimensionsBody, UnsetType] = unset, **kwargs):
"""
Active billing dimensions response.

:param data: Active billing dimensions data.
:type data: ActiveBillingDimensionsBody, optional
"""
if data is not unset:
kwargs["data"] = data
super().__init__(kwargs)
Loading
Loading