Skip to content

Commit abab47a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit a68d81e0 of spec repo (#1116)
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 b498de4 commit abab47a

10 files changed

+111
-43
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.2",
7-
"regenerated": "2022-07-29 13:43:05.545760",
8-
"spec_repo_commit": "42e24f61"
7+
"regenerated": "2022-07-29 18:24:30.284645",
8+
"spec_repo_commit": "a68d81e0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.2",
12-
"regenerated": "2022-07-29 13:43:05.557589",
13-
"spec_repo_commit": "42e24f61"
12+
"regenerated": "2022-07-29 18:24:30.301047",
13+
"spec_repo_commit": "a68d81e0"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13917,14 +13917,25 @@ paths:
1391713917
x-menu-order: 5
1391813918
x-undo:
1391913919
type: safe
13920-
/api/v2/usage/estimated_cost_by_org:
13920+
/api/v2/usage/estimated_cost:
1392113921
get:
13922-
description: Get estimated cost across multi-org account.
13922+
description: 'Get estimated cost across multi-org and single root-org accounts.
13923+
13924+
Estimated cost data is only available for the current month and previous month.
13925+
To access historical costs prior to this, use the /cost_by_org endpoint.'
1392313926
operationId: GetEstimatedCostByOrg
1392413927
parameters:
13928+
- description: String to specify whether cost is broken down at a parent-org
13929+
level or at the sub-org level. Currently, only the 'sub-org' view is supported.
13930+
in: query
13931+
name: view
13932+
required: true
13933+
schema:
13934+
type: string
1392513935
- description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]`
1392613936
for cost beginning this month. Either start_month or start_date should be
13927-
specified, but not both.'
13937+
specified, but not both. (start_month cannot go beyond two months in the
13938+
past)'
1392813939
in: query
1392913940
name: start_month
1393013941
required: false
@@ -13941,7 +13952,8 @@ paths:
1394113952
type: string
1394213953
- description: 'Datetime in ISO-8601 format, UTC, precise to day: `[YYYY-MM-DD]`
1394313954
for cost beginning this day. Either start_month or start_date should be
13944-
specified, but not both.'
13955+
specified, but not both. (start_date cannot go beyond two months in the
13956+
past)'
1394513957
in: query
1394613958
name: start_date
1394713959
required: false
@@ -13986,12 +13998,16 @@ paths:
1398613998
appKeyAuth: []
1398713999
- AuthZ:
1398814000
- usage_read
13989-
summary: Get estimated cost across multi-org account
14001+
summary: Get estimated cost across your account
1399014002
tags:
1399114003
- Usage Metering
1399214004
x-menu-order: 39
1399314005
x-undo:
1399414006
type: safe
14007+
x-unstable: '**Note**: This endpoint is in public beta.
14008+
14009+
Only the sub-org view is available currently, the summary view will be released
14010+
at a later date.'
1399514011
/api/v2/usage/hourly_usage:
1399614012
get:
1399714013
description: Get hourly usage by product family
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
"""
2-
Get estimated cost across multi-org account returns "OK" response
2+
Get estimated cost across your account returns "OK" response
33
"""
44

55
from datadog_api_client import ApiClient, Configuration
66
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
77

88
configuration = Configuration()
9+
configuration.unstable_operations["get_estimated_cost_by_org"] = True
910
with ApiClient(configuration) as api_client:
1011
api_instance = UsageMeteringApi(api_client)
11-
response = api_instance.get_estimated_cost_by_org()
12+
response = api_instance.get_estimated_cost_by_org(
13+
view="view",
14+
)
1215

1316
print(response)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Get estimated cost across multi-org account with date returns "OK" response
2+
GetEstimatedCostByOrg with start_date returns "OK" response
33
"""
44

55
from datetime import datetime
@@ -8,11 +8,12 @@
88
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
99

1010
configuration = Configuration()
11+
configuration.unstable_operations["get_estimated_cost_by_org"] = True
1112
with ApiClient(configuration) as api_client:
1213
api_instance = UsageMeteringApi(api_client)
1314
response = api_instance.get_estimated_cost_by_org(
15+
view="sub-org",
1416
start_date=(datetime.now() + relativedelta(days=-5)),
15-
end_date=(datetime.now() + relativedelta(days=-3)),
1617
)
1718

1819
print(response)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Get estimated cost across multi-org account with month returns "OK" response
2+
GetEstimatedCostByOrg with start_month returns "OK" response
33
"""
44

55
from datetime import datetime
@@ -8,11 +8,12 @@
88
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
99

1010
configuration = Configuration()
11+
configuration.unstable_operations["get_estimated_cost_by_org"] = True
1112
with ApiClient(configuration) as api_client:
1213
api_instance = UsageMeteringApi(api_client)
1314
response = api_instance.get_estimated_cost_by_org(
15+
view="sub-org",
1416
start_month=(datetime.now() + relativedelta(days=-5)),
15-
end_month=(datetime.now() + relativedelta(days=-3)),
1617
)
1718

1819
print(response)

src/datadog_api_client/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def __init__(
245245
"v2.get_incident_team": False,
246246
"v2.list_incident_teams": False,
247247
"v2.update_incident_team": False,
248+
"v2.get_estimated_cost_by_org": False,
248249
}
249250
)
250251

src/datadog_api_client/v2/api/usage_metering_api.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,19 @@ def __init__(self, api_client=None):
7373
settings={
7474
"response_type": (CostByOrgResponse,),
7575
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
76-
"endpoint_path": "/api/v2/usage/estimated_cost_by_org",
76+
"endpoint_path": "/api/v2/usage/estimated_cost",
7777
"operation_id": "get_estimated_cost_by_org",
7878
"http_method": "GET",
7979
"version": "v2",
8080
"servers": None,
8181
},
8282
params_map={
83+
"view": {
84+
"required": True,
85+
"openapi_types": (str,),
86+
"attribute": "view",
87+
"location": "query",
88+
},
8389
"start_month": {
8490
"openapi_types": (datetime,),
8591
"attribute": "start_month",
@@ -284,27 +290,33 @@ def get_cost_by_org(
284290

285291
def get_estimated_cost_by_org(
286292
self,
293+
view: str,
287294
*,
288295
start_month: Union[datetime, UnsetType] = unset,
289296
end_month: Union[datetime, UnsetType] = unset,
290297
start_date: Union[datetime, UnsetType] = unset,
291298
end_date: Union[datetime, UnsetType] = unset,
292299
) -> CostByOrgResponse:
293-
"""Get estimated cost across multi-org account.
300+
"""Get estimated cost across your account.
294301
295-
Get estimated cost across multi-org account.
302+
Get estimated cost across multi-org and single root-org accounts.
303+
Estimated cost data is only available for the current month and previous month. To access historical costs prior to this, use the /cost_by_org endpoint.
296304
297-
:param start_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost beginning this month. Either start_month or start_date should be specified, but not both.
305+
:param view: String to specify whether cost is broken down at a parent-org level or at the sub-org level. Currently, only the 'sub-org' view is supported.
306+
:type view: str
307+
:param start_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost beginning this month. Either start_month or start_date should be specified, but not both. (start_month cannot go beyond two months in the past)
298308
:type start_month: datetime, optional
299309
:param end_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost ending this month.
300310
:type end_month: datetime, optional
301-
:param start_date: Datetime in ISO-8601 format, UTC, precise to day: ``[YYYY-MM-DD]`` for cost beginning this day. Either start_month or start_date should be specified, but not both.
311+
:param start_date: Datetime in ISO-8601 format, UTC, precise to day: ``[YYYY-MM-DD]`` for cost beginning this day. Either start_month or start_date should be specified, but not both. (start_date cannot go beyond two months in the past)
302312
:type start_date: datetime, optional
303313
:param end_date: Datetime in ISO-8601 format, UTC, precise to day: ``[YYYY-MM-DD]`` for cost ending this day.
304314
:type end_date: datetime, optional
305315
:rtype: CostByOrgResponse
306316
"""
307317
kwargs: Dict[str, Any] = {}
318+
kwargs["view"] = view
319+
308320
if start_month is not unset:
309321
kwargs["start_month"] = start_month
310322

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2022-07-29T14:22:55.359Z
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
accept:
6+
- application/json;datetime-format=rfc3339
7+
method: GET
8+
uri: https://api.datadoghq.com/api/v2/usage/estimated_cost?start_date=2022-07-24T14%3A22%3A55.359Z&view=sub-org
9+
response:
10+
body:
11+
string: '{"data":[]}
12+
13+
'
14+
headers:
15+
content-type:
16+
- application/json
17+
status:
18+
code: 200
19+
message: OK
20+
version: 1

tests/v2/features/usage_metering.feature

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,19 @@ Feature: Usage Metering
2828
When the request is sent
2929
Then the response status is 200 OK
3030

31-
@skip @team:DataDog/red-zone-revenue-query
32-
Scenario: Get estimated cost across multi-org account returns "Bad Request" response
33-
Given new "GetEstimatedCostByOrg" request
34-
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
35-
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
31+
@generated @skip @team:DataDog/red-zone-revenue-query
32+
Scenario: Get estimated cost across your account returns "Bad Request" response
33+
Given operation "GetEstimatedCostByOrg" enabled
34+
And new "GetEstimatedCostByOrg" request
35+
And request contains "view" parameter from "REPLACE.ME"
3636
When the request is sent
3737
Then the response status is 400 Bad Request
3838

3939
@generated @skip @team:DataDog/red-zone-revenue-query
40-
Scenario: Get estimated cost across multi-org account returns "OK" response
41-
Given new "GetEstimatedCostByOrg" request
42-
When the request is sent
43-
Then the response status is 200 OK
44-
45-
@replay-only @team:DataDog/red-zone-revenue-query
46-
Scenario: Get estimated cost across multi-org account with date returns "OK" response
47-
Given new "GetEstimatedCostByOrg" request
48-
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
49-
And request contains "end_date" parameter with value "{{ timeISO('now - 3d') }}"
50-
When the request is sent
51-
Then the response status is 200 OK
52-
53-
@replay-only @team:DataDog/red-zone-revenue-query
54-
Scenario: Get estimated cost across multi-org account with month returns "OK" response
55-
Given new "GetEstimatedCostByOrg" request
56-
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
57-
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
40+
Scenario: Get estimated cost across your account returns "OK" response
41+
Given operation "GetEstimatedCostByOrg" enabled
42+
And new "GetEstimatedCostByOrg" request
43+
And request contains "view" parameter from "REPLACE.ME"
5844
When the request is sent
5945
Then the response status is 200 OK
6046

@@ -164,3 +150,30 @@ Feature: Usage Metering
164150
And request contains "start_hr" parameter from "REPLACE.ME"
165151
When the request is sent
166152
Then the response status is 200 OK
153+
154+
@skip @team:DataDog/red-zone-revenue-query
155+
Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response
156+
Given new "GetEstimatedCostByOrg" request
157+
And request contains "view" parameter with value "sub-org"
158+
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
159+
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
160+
When the request is sent
161+
Then the response status is 400 Bad Request
162+
163+
@replay-only @team:DataDog/red-zone-revenue-query
164+
Scenario: GetEstimatedCostByOrg with start_date returns "OK" response
165+
Given operation "GetEstimatedCostByOrg" enabled
166+
And new "GetEstimatedCostByOrg" request
167+
And request contains "view" parameter with value "sub-org"
168+
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
169+
When the request is sent
170+
Then the response status is 200 OK
171+
172+
@skip @team:DataDog/red-zone-revenue-query
173+
Scenario: GetEstimatedCostByOrg with start_month returns "OK" response
174+
Given operation "GetEstimatedCostByOrg" enabled
175+
And new "GetEstimatedCostByOrg" request
176+
And request contains "view" parameter with value "sub-org"
177+
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
178+
When the request is sent
179+
Then the response status is 200 OK

0 commit comments

Comments
 (0)