Skip to content

Commit 9a72039

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for projected-cost endpoint (#1735)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent ff46064 commit 9a72039

14 files changed

+475
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2023-11-15 20:43:38.292819",
8-
"spec_repo_commit": "d994bc85"
7+
"regenerated": "2023-11-16 09:45:01.256068",
8+
"spec_repo_commit": "974acd6e"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2023-11-15 20:43:38.348351",
13-
"spec_repo_commit": "d994bc85"
12+
"regenerated": "2023-11-16 09:45:01.272834",
13+
"spec_repo_commit": "974acd6e"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11747,6 +11747,62 @@ components:
1174711747
type: string
1174811748
x-enum-varnames:
1174911749
- PROCESS
11750+
ProjectedCost:
11751+
description: Projected Cost data.
11752+
properties:
11753+
attributes:
11754+
$ref: '#/components/schemas/ProjectedCostAttributes'
11755+
id:
11756+
description: Unique ID of the response.
11757+
type: string
11758+
type:
11759+
$ref: '#/components/schemas/ProjectedCostType'
11760+
type: object
11761+
ProjectedCostAttributes:
11762+
description: Projected Cost attributes data.
11763+
properties:
11764+
charges:
11765+
description: List of charges data reported for the requested month.
11766+
items:
11767+
$ref: '#/components/schemas/ChargebackBreakdown'
11768+
type: array
11769+
date:
11770+
description: The month requested.
11771+
format: date-time
11772+
type: string
11773+
org_name:
11774+
description: The organization name.
11775+
type: string
11776+
projected_total_cost:
11777+
description: The total projected cost of products for the month.
11778+
format: double
11779+
type: number
11780+
public_id:
11781+
description: The organization public ID.
11782+
type: string
11783+
region:
11784+
description: The region of the Datadog instance that the organization belongs
11785+
to.
11786+
type: string
11787+
type: object
11788+
ProjectedCostResponse:
11789+
description: Projected Cost response.
11790+
properties:
11791+
data:
11792+
description: Response containing Projected Cost.
11793+
items:
11794+
$ref: '#/components/schemas/ProjectedCost'
11795+
type: array
11796+
type: object
11797+
ProjectedCostType:
11798+
default: projected_cost
11799+
description: Type of cost data.
11800+
enum:
11801+
- projected_cost
11802+
example: projected_cost
11803+
type: string
11804+
x-enum-varnames:
11805+
- PROJECt_COST
1175011806
QueryFormula:
1175111807
description: A formula for calculation based on one or more queries.
1175211808
properties:
@@ -29935,6 +29991,57 @@ paths:
2993529991
summary: Get hourly usage for observability pipelines
2993629992
tags:
2993729993
- Usage Metering
29994+
/api/v2/usage/projected_cost:
29995+
get:
29996+
description: 'Get projected cost across multi-org and single root-org accounts.
29997+
29998+
Projected cost data is only available for the current month and becomes available
29999+
around the 12th of the month.
30000+
30001+
This endpoint requires the usage_read authorization scope.'
30002+
operationId: GetProjectedCost
30003+
parameters:
30004+
- description: String to specify whether cost is broken down at a parent-org
30005+
level or at the sub-org level. Available views are `summary` and `sub-org`.
30006+
Defaults to `summary`.
30007+
in: query
30008+
name: view
30009+
required: false
30010+
schema:
30011+
type: string
30012+
responses:
30013+
'200':
30014+
content:
30015+
application/json;datetime-format=rfc3339:
30016+
schema:
30017+
$ref: '#/components/schemas/ProjectedCostResponse'
30018+
description: OK
30019+
'400':
30020+
content:
30021+
application/json;datetime-format=rfc3339:
30022+
schema:
30023+
$ref: '#/components/schemas/APIErrorResponse'
30024+
description: Bad Request
30025+
'403':
30026+
content:
30027+
application/json;datetime-format=rfc3339:
30028+
schema:
30029+
$ref: '#/components/schemas/APIErrorResponse'
30030+
description: Forbidden - User is not authorized
30031+
'429':
30032+
content:
30033+
application/json;datetime-format=rfc3339:
30034+
schema:
30035+
$ref: '#/components/schemas/APIErrorResponse'
30036+
description: Too many requests
30037+
security:
30038+
- apiKeyAuth: []
30039+
appKeyAuth: []
30040+
- AuthZ:
30041+
- usage_read
30042+
summary: Get projected cost across your account
30043+
tags:
30044+
- Usage Metering
2993830045
/api/v2/user_invitations:
2993930046
post:
2994030047
description: Sends emails to one or more users inviting them to join the organization.

docs/datadog_api_client.v2.model.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5125,6 +5125,34 @@ process\_summary\_type
51255125
:members:
51265126
:show-inheritance:
51275127

5128+
projected\_cost
5129+
---------------
5130+
5131+
.. automodule:: datadog_api_client.v2.model.projected_cost
5132+
:members:
5133+
:show-inheritance:
5134+
5135+
projected\_cost\_attributes
5136+
---------------------------
5137+
5138+
.. automodule:: datadog_api_client.v2.model.projected_cost_attributes
5139+
:members:
5140+
:show-inheritance:
5141+
5142+
projected\_cost\_response
5143+
-------------------------
5144+
5145+
.. automodule:: datadog_api_client.v2.model.projected_cost_response
5146+
:members:
5147+
:show-inheritance:
5148+
5149+
projected\_cost\_type
5150+
---------------------
5151+
5152+
.. automodule:: datadog_api_client.v2.model.projected_cost_type
5153+
:members:
5154+
:show-inheritance:
5155+
51285156
query\_formula
51295157
--------------
51305158

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Get projected cost across your account returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
7+
8+
configuration = Configuration()
9+
with ApiClient(configuration) as api_client:
10+
api_instance = UsageMeteringApi(api_client)
11+
response = api_instance.get_projected_cost(
12+
view="sub-org",
13+
)
14+
15+
print(response)

src/datadog_api_client/v2/api/usage_metering_api.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from datadog_api_client.v2.model.hourly_usage_response import HourlyUsageResponse
2121
from datadog_api_client.v2.model.usage_lambda_traced_invocations_response import UsageLambdaTracedInvocationsResponse
2222
from datadog_api_client.v2.model.usage_observability_pipelines_response import UsageObservabilityPipelinesResponse
23+
from datadog_api_client.v2.model.projected_cost_response import ProjectedCostResponse
2324

2425

2526
class UsageMeteringApi:
@@ -207,6 +208,28 @@ def __init__(self, api_client=None):
207208
api_client=api_client,
208209
)
209210

211+
self._get_projected_cost_endpoint = _Endpoint(
212+
settings={
213+
"response_type": (ProjectedCostResponse,),
214+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
215+
"endpoint_path": "/api/v2/usage/projected_cost",
216+
"operation_id": "get_projected_cost",
217+
"http_method": "GET",
218+
"version": "v2",
219+
},
220+
params_map={
221+
"view": {
222+
"openapi_types": (str,),
223+
"attribute": "view",
224+
"location": "query",
225+
},
226+
},
227+
headers_map={
228+
"accept": ["application/json;datetime-format=rfc3339"],
229+
},
230+
api_client=api_client,
231+
)
232+
210233
self._get_usage_application_security_monitoring_endpoint = _Endpoint(
211234
settings={
212235
"response_type": (UsageApplicationSecurityMonitoringResponse,),
@@ -465,6 +488,27 @@ def get_hourly_usage(
465488

466489
return self._get_hourly_usage_endpoint.call_with_http_info(**kwargs)
467490

491+
def get_projected_cost(
492+
self,
493+
*,
494+
view: Union[str, UnsetType] = unset,
495+
) -> ProjectedCostResponse:
496+
"""Get projected cost across your account.
497+
498+
Get projected cost across multi-org and single root-org accounts.
499+
Projected cost data is only available for the current month and becomes available around the 12th of the month.
500+
This endpoint requires the usage_read authorization scope.
501+
502+
: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``.
503+
:type view: str, optional
504+
:rtype: ProjectedCostResponse
505+
"""
506+
kwargs: Dict[str, Any] = {}
507+
if view is not unset:
508+
kwargs["view"] = view
509+
510+
return self._get_projected_cost_endpoint.call_with_http_info(**kwargs)
511+
468512
def get_usage_application_security_monitoring(
469513
self,
470514
start_hr: datetime,
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.projected_cost_attributes import ProjectedCostAttributes
18+
from datadog_api_client.v2.model.projected_cost_type import ProjectedCostType
19+
20+
21+
class ProjectedCost(ModelNormal):
22+
@cached_property
23+
def openapi_types(_):
24+
from datadog_api_client.v2.model.projected_cost_attributes import ProjectedCostAttributes
25+
from datadog_api_client.v2.model.projected_cost_type import ProjectedCostType
26+
27+
return {
28+
"attributes": (ProjectedCostAttributes,),
29+
"id": (str,),
30+
"type": (ProjectedCostType,),
31+
}
32+
33+
attribute_map = {
34+
"attributes": "attributes",
35+
"id": "id",
36+
"type": "type",
37+
}
38+
39+
def __init__(
40+
self_,
41+
attributes: Union[ProjectedCostAttributes, UnsetType] = unset,
42+
id: Union[str, UnsetType] = unset,
43+
type: Union[ProjectedCostType, UnsetType] = unset,
44+
**kwargs,
45+
):
46+
"""
47+
Projected Cost data.
48+
49+
:param attributes: Projected Cost attributes data.
50+
:type attributes: ProjectedCostAttributes, optional
51+
52+
:param id: Unique ID of the response.
53+
:type id: str, optional
54+
55+
:param type: Type of cost data.
56+
:type type: ProjectedCostType, optional
57+
"""
58+
if attributes is not unset:
59+
kwargs["attributes"] = attributes
60+
if id is not unset:
61+
kwargs["id"] = id
62+
if type is not unset:
63+
kwargs["type"] = type
64+
super().__init__(kwargs)

0 commit comments

Comments
 (0)