Skip to content

Commit

Permalink
Regenerate client from commit 09b80450 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Jul 29, 2022
1 parent b498de4 commit 61c1037
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 43 deletions.
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.2",
"regenerated": "2022-07-29 13:43:05.545760",
"spec_repo_commit": "42e24f61"
"regenerated": "2022-07-29 14:31:44.499571",
"spec_repo_commit": "09b80450"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-07-29 13:43:05.557589",
"spec_repo_commit": "42e24f61"
"regenerated": "2022-07-29 14:31:44.511140",
"spec_repo_commit": "09b80450"
}
}
}
26 changes: 21 additions & 5 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13917,14 +13917,25 @@ paths:
x-menu-order: 5
x-undo:
type: safe
/api/v2/usage/estimated_cost_by_org:
/api/v2/usage/estimated_cost:
get:
description: Get estimated cost across multi-org account.
description: 'Get estimated cost across multi-org and single root-org accounts.
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.'
operationId: GetEstimatedCostByOrg
parameters:
- description: 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.
in: query
name: view
required: true
schema:
type: string
- description: '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.'
specified, but not both. (start_month cannot go beyond two months in the
past)'
in: query
name: start_month
required: false
Expand All @@ -13941,7 +13952,8 @@ paths:
type: string
- description: '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.'
specified, but not both. (start_date cannot go beyond two months in the
past)'
in: query
name: start_date
required: false
Expand Down Expand Up @@ -13986,12 +13998,16 @@ paths:
appKeyAuth: []
- AuthZ:
- usage_read
summary: Get estimated cost across multi-org account
summary: Get estimated cost across your account
tags:
- Usage Metering
x-menu-order: 39
x-undo:
type: safe
x-unstable: '**Note**: This endpoint is in public beta.
Only the sub-org view is available currently, the summary view will be released
at a later date.'
/api/v2/usage/hourly_usage:
get:
description: Get hourly usage by product family
Expand Down
7 changes: 5 additions & 2 deletions examples/v2/usage-metering/GetEstimatedCostByOrg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""
Get estimated cost across multi-org account returns "OK" response
Get estimated cost across your account 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_estimated_cost_by_org"] = True
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.get_estimated_cost_by_org()
response = api_instance.get_estimated_cost_by_org(
view="view",
)

print(response)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Get estimated cost across multi-org account with date returns "OK" response
GetEstimatedCostByOrg with start_date returns "OK" response
"""

from datetime import datetime
Expand All @@ -8,11 +8,12 @@
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
configuration.unstable_operations["get_estimated_cost_by_org"] = True
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.get_estimated_cost_by_org(
view="sub-org",
start_date=(datetime.now() + relativedelta(days=-5)),
end_date=(datetime.now() + relativedelta(days=-3)),
)

print(response)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Get estimated cost across multi-org account with month returns "OK" response
GetEstimatedCostByOrg with start_month returns "OK" response
"""

from datetime import datetime
Expand All @@ -8,11 +8,12 @@
from datadog_api_client.v2.api.usage_metering_api import UsageMeteringApi

configuration = Configuration()
configuration.unstable_operations["get_estimated_cost_by_org"] = True
with ApiClient(configuration) as api_client:
api_instance = UsageMeteringApi(api_client)
response = api_instance.get_estimated_cost_by_org(
view="sub-org",
start_month=(datetime.now() + relativedelta(days=-5)),
end_month=(datetime.now() + relativedelta(days=-3)),
)

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 @@ -245,6 +245,7 @@ def __init__(
"v2.get_incident_team": False,
"v2.list_incident_teams": False,
"v2.update_incident_team": False,
"v2.get_estimated_cost_by_org": False,
}
)

Expand Down
22 changes: 17 additions & 5 deletions src/datadog_api_client/v2/api/usage_metering_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,19 @@ def __init__(self, api_client=None):
settings={
"response_type": (CostByOrgResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/usage/estimated_cost_by_org",
"endpoint_path": "/api/v2/usage/estimated_cost",
"operation_id": "get_estimated_cost_by_org",
"http_method": "GET",
"version": "v2",
"servers": None,
},
params_map={
"view": {
"required": True,
"openapi_types": (str,),
"attribute": "view",
"location": "query",
},
"start_month": {
"openapi_types": (datetime,),
"attribute": "start_month",
Expand Down Expand Up @@ -284,27 +290,33 @@ def get_cost_by_org(

def get_estimated_cost_by_org(
self,
view: str,
*,
start_month: Union[datetime, UnsetType] = unset,
end_month: Union[datetime, UnsetType] = unset,
start_date: Union[datetime, UnsetType] = unset,
end_date: Union[datetime, UnsetType] = unset,
) -> CostByOrgResponse:
"""Get estimated cost across multi-org account.
"""Get estimated cost across your account.
Get estimated cost across multi-org account.
Get estimated cost across multi-org and single root-org accounts.
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.
: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.
: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.
:type view: str
: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)
:type start_month: datetime, optional
:param end_month: Datetime in ISO-8601 format, UTC, precise to month: ``[YYYY-MM]`` for cost ending this month.
:type end_month: datetime, optional
: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.
: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)
:type start_date: datetime, optional
:param end_date: Datetime in ISO-8601 format, UTC, precise to day: ``[YYYY-MM-DD]`` for cost ending this day.
:type end_date: datetime, optional
:rtype: CostByOrgResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["view"] = view

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-07-29T14:22:55.359Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interactions:
- request:
body: null
headers:
accept:
- application/json;datetime-format=rfc3339
method: GET
uri: https://api.datadoghq.com/api/v2/usage/estimated_cost?start_date=2022-07-24T14%3A22%3A55.359Z&view=sub-org
response:
body:
string: '{"data":[]}
'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
59 changes: 36 additions & 23 deletions tests/v2/features/usage_metering.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,19 @@ Feature: Usage Metering
When the request is sent
Then the response status is 200 OK

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

@generated @skip @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account returns "OK" response
Given new "GetEstimatedCostByOrg" request
When the request is sent
Then the response status is 200 OK

@replay-only @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account with date returns "OK" response
Given new "GetEstimatedCostByOrg" request
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_date" parameter with value "{{ timeISO('now - 3d') }}"
When the request is sent
Then the response status is 200 OK

@replay-only @team:DataDog/red-zone-revenue-query
Scenario: Get estimated cost across multi-org account with month returns "OK" response
Given new "GetEstimatedCostByOrg" request
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}"
Scenario: Get estimated cost across your account returns "OK" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "view" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK

Expand Down Expand Up @@ -164,3 +150,30 @@ Feature: Usage Metering
And request contains "start_hr" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK

@skip @team:DataDog/red-zone-revenue-query
Scenario: GetEstimatedCostByOrg with both start_month and start_date returns "Bad Request" response
Given new "GetEstimatedCostByOrg" request
And request contains "start_month" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "start_date" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "view" parameter with value "sub-org"
When the request is sent
Then the response status is 400 Bad Request

@replay-only @team:DataDog/red-zone-revenue-query
Scenario: GetEstimatedCostByOrg with start_date returns "OK" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "start_date" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "view" parameter with value "sub-org"
When the request is sent
Then the response status is 200 OK

@skip @team:DataDog/red-zone-revenue-query
Scenario: GetEstimatedCostByOrg with start_month returns "OK" response
Given operation "GetEstimatedCostByOrg" enabled
And new "GetEstimatedCostByOrg" request
And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "view" parameter with value "sub-org"
When the request is sent
Then the response status is 200 OK

0 comments on commit 61c1037

Please sign in to comment.