Skip to content

Commit 9698065

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update example for GetEstimatedCostByOrg (#1226)
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 0f9d03d commit 9698065

10 files changed

+35
-38
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.4",
7-
"regenerated": "2022-11-02 20:10:39.169455",
8-
"spec_repo_commit": "7c5579df"
7+
"regenerated": "2022-11-04 18:42:27.825188",
8+
"spec_repo_commit": "af3f11fc"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-11-02 20:10:39.181527",
13-
"spec_repo_commit": "7c5579df"
12+
"regenerated": "2022-11-04 18:42:27.839660",
13+
"spec_repo_commit": "af3f11fc"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16461,7 +16461,9 @@ paths:
1646116461
get:
1646216462
description: 'Get estimated cost across multi-org and single root-org accounts.
1646316463

16464-
Estimated cost data is only available for the current month and previous month.
16464+
Estimated cost data is only available for the current month and previous month
16465+
16466+
and is delayed by up to 72 hours from when it was incurred.
1646516467

1646616468
To access historical costs prior to this, use the `/historical_cost` endpoint.'
1646716469
operationId: GetEstimatedCostByOrg

examples/v2/usage-metering/GetEstimatedCostByOrg_2734954020.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/v2/usage-metering/GetEstimatedCostByOrg_3186693804.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
from datetime import datetime
6-
from dateutil.relativedelta import relativedelta
76
from datadog_api_client import ApiClient, Configuration
87
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi
98

@@ -12,7 +11,7 @@
1211
api_instance = UsageMeteringApi(api_client)
1312
response = api_instance.get_estimated_cost_by_org(
1413
view="sub-org",
15-
start_month=(datetime.now() + relativedelta(days=-5)),
14+
start_month=datetime.now(),
1615
)
1716

1817
print(response)

src/datadog_api_client/v2/api/usage_metering_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ def get_estimated_cost_by_org(
340340
"""Get estimated cost across your account.
341341
342342
Get estimated cost across multi-org and single root-org accounts.
343-
Estimated cost data is only available for the current month and previous month.
343+
Estimated cost data is only available for the current month and previous month
344+
and is delayed by up to 72 hours from when it was incurred.
344345
To access historical costs prior to this, use the ``/historical_cost`` endpoint.
345346
346347
: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``.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-09-23T14:04:15.545Z
1+
2022-11-03T21:08:41.229Z

tests/v2/cassettes/test_scenarios/test_getestimatedcostbyorg_with_both_start_month_and_start_date_returns_bad_request_response.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interactions:
55
accept:
66
- application/json;datetime-format=rfc3339
77
method: GET
8-
uri: https://api.datadoghq.com/api/v2/usage/estimated_cost?view=sub-org&start_month=2022-09-20T14%3A04%3A15.545Z&start_date=2022-09-20T14%3A04%3A15.545Z
8+
uri: https://api.datadoghq.com/api/v2/usage/estimated_cost?view=sub-org&start_month=2022-11-03T21%3A08%3A41.229Z&start_date=2022-10-31T21%3A08%3A41.229Z
99
response:
1010
body:
1111
string: '{"errors":["API called with non-parent org keys. Data is only available
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2022-11-04T18:40:14.021Z
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?view=sub-org&start_month=2022-11-04T18%3A40%3A14.021Z
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: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,15 @@ Feature: Usage Metering
166166
Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response
167167
Given new "GetEstimatedCostByOrg" request
168168
And request contains "view" parameter with value "sub-org"
169-
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
169+
And request contains "start_month" parameter with value "{{ timeISO('now') }}"
170170
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
171171
When the request is sent
172172
Then the response status is 400 Bad Request
173173

174174
@replay-only @team:DataDog/red-zone-revenue-query
175-
Scenario: GetEstimatedCostByOrg with start_date returns "OK" response
176-
Given new "GetEstimatedCostByOrg" request
177-
And request contains "view" parameter with value "sub-org"
178-
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
179-
When the request is sent
180-
Then the response status is 200 OK
181-
182-
@skip @team:DataDog/red-zone-revenue-query
183175
Scenario: GetEstimatedCostByOrg with start_month returns "OK" response
184176
Given new "GetEstimatedCostByOrg" request
185177
And request contains "view" parameter with value "sub-org"
186-
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
178+
And request contains "start_month" parameter with value "{{ timeISO('now') }}"
187179
When the request is sent
188180
Then the response status is 200 OK

0 commit comments

Comments
 (0)