Skip to content

Commit e2a2d2a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit d7ce271f of spec repo (#910)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 3ba20b1 commit e2a2d2a

13 files changed

+174
-18
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-04-04 09:25:03.516890",
8-
"spec_repo_commit": "e6337d88"
7+
"regenerated": "2022-04-04 14:19:26.161385",
8+
"spec_repo_commit": "d7ce271f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.2",
12-
"regenerated": "2022-04-04 09:25:03.528785",
13-
"spec_repo_commit": "e6337d88"
12+
"regenerated": "2022-04-04 14:19:26.172967",
13+
"spec_repo_commit": "d7ce271f"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,6 +3454,7 @@ components:
34543454
next_record_id:
34553455
description: The cursor to get the next results (if any). To make the next
34563456
request, use the same parameters and add `next_record_id`.
3457+
nullable: true
34573458
type: string
34583459
type: object
34593460
HourlyUsageAttributionResponse:
@@ -6628,6 +6629,7 @@ components:
66286629
next_record_id:
66296630
description: The cursor to use to get the next results, if any. To make
66306631
the next request, use the same parameters with the addition of the `next_record_id`.
6632+
nullable: true
66316633
type: string
66326634
type: object
66336635
MonthlyUsageAttributionResponse:
@@ -15495,6 +15497,7 @@ components:
1549515497
next_record_id:
1549615498
description: The cursor to get the next results (if any). To make the next
1549715499
request, use the same parameters and add `next_record_id`.
15500+
nullable: true
1549815501
type: string
1549915502
total_number_of_records:
1550015503
description: Total number of records.
@@ -26151,7 +26154,13 @@ paths:
2615126154
type: safe
2615226155
/api/v1/usage/hourly-attribution:
2615326156
get:
26154-
description: Get Hourly Usage Attribution.
26157+
description: "Get Hourly Usage Attribution.\n\nThis API endpoint is paginated.
26158+
To make sure you receive all records, check if the value of `next_record_id`
26159+
is\nset in the response. If it is, make another request and pass `next_record_id`
26160+
as a parameter.\nPseudo code example:\n\n```\nresponse := GetHourlyUsageAttribution(start_month)\ncursor
26161+
:= response.metadata.pagination.next_record_id\nWHILE cursor != null BEGIN\n
26162+
\ sleep(5 seconds) # Avoid running into rate limit\n response := GetHourlyUsageAttribution(start_month,
26163+
next_record_id=cursor)\n cursor := response.metadata.pagination.next_record_id\nEND\n```"
2615526164
operationId: GetHourlyUsageAttribution
2615626165
parameters:
2615726166
- description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]`
@@ -26185,8 +26194,12 @@ paths:
2618526194
required: false
2618626195
schema:
2618726196
type: string
26188-
- description: Comma separated list of tags used to group usage. If no value
26197+
- description: 'Comma separated list of tags used to group usage. If no value
2618926198
is provided the usage will not be broken down by tags.
26199+
26200+
26201+
To see which tags are available, look for the value of `tag_config_source`
26202+
in the API response.'
2619026203
in: query
2619126204
name: tag_breakdown_keys
2619226205
required: false
@@ -26641,7 +26654,13 @@ paths:
2664126654
type: safe
2664226655
/api/v1/usage/monthly-attribution:
2664326656
get:
26644-
description: Get Monthly Usage Attribution.
26657+
description: "Get Monthly Usage Attribution.\n\nThis API endpoint is paginated.
26658+
To make sure you receive all records, check if the value of `next_record_id`
26659+
is\nset in the response. If it is, make another request and pass `next_record_id`
26660+
as a parameter.\nPseudo code example:\n\n```\nresponse := GetMonthlyUsageAttribution(start_month)\ncursor
26661+
:= response.metadata.pagination.next_record_id\nWHILE cursor != null BEGIN\n
26662+
\ sleep(5 seconds) # Avoid running into rate limit\n response := GetMonthlyUsageAttribution(start_month,
26663+
next_record_id=cursor)\n cursor := response.metadata.pagination.next_record_id\nEND\n```"
2664526664
operationId: GetMonthlyUsageAttribution
2664626665
parameters:
2664726666
- description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]`
@@ -26681,8 +26700,12 @@ paths:
2668126700
required: false
2668226701
schema:
2668326702
$ref: '#/components/schemas/MonthlyUsageAttributionSupportedMetrics'
26684-
- description: Comma separated list of tags used to group usage. If no value
26685-
is provided the usage will not be broken down by tags.
26703+
- description: 'Comma separated list of tag keys used to group usage. If no
26704+
value is provided the usage will not be broken down by tags.
26705+
26706+
26707+
To see which tags are available, look for the value of `tag_config_source`
26708+
in the API response.'
2668626709
in: query
2668726710
name: tag_breakdown_keys
2668826711
required: false
@@ -26722,6 +26745,14 @@ paths:
2672226745
summary: Get Monthly Usage Attribution
2672326746
tags:
2672426747
- Usage Metering
26748+
x-given:
26749+
monthly_usage_attribution:
26750+
parameters:
26751+
- name: start_month
26752+
value: '"{{ timeISO(''now - 3d'') }}"'
26753+
- name: fields
26754+
value: '"infra_host_usage"'
26755+
step: there is a valid "monthly_usage_attribution" response
2672526756
x-menu-order: 31
2672626757
x-undo:
2672726758
type: safe
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Paginate Monthly Usage Attribution
3+
"""
4+
5+
from datetime import datetime
6+
from dateutil.relativedelta import relativedelta
7+
from os import environ
8+
from datadog_api_client.v1 import ApiClient, Configuration
9+
from datadog_api_client.v1.api.usage_metering_api import UsageMeteringApi
10+
from datadog_api_client.v1.model.monthly_usage_attribution_supported_metrics import (
11+
MonthlyUsageAttributionSupportedMetrics,
12+
)
13+
14+
# there is a valid "monthly_usage_attribution" response
15+
MONTHLY_USAGE_ATTRIBUTION_METADATA_PAGINATION_NEXT_RECORD_ID = environ[
16+
"MONTHLY_USAGE_ATTRIBUTION_METADATA_PAGINATION_NEXT_RECORD_ID"
17+
]
18+
19+
configuration = Configuration()
20+
with ApiClient(configuration) as api_client:
21+
api_instance = UsageMeteringApi(api_client)
22+
response = api_instance.get_monthly_usage_attribution(
23+
start_month=(datetime.now() + relativedelta(days=-3)).isoformat(timespec="seconds"),
24+
fields=MonthlyUsageAttributionSupportedMetrics("infra_host_usage"),
25+
next_record_id=MONTHLY_USAGE_ATTRIBUTION_METADATA_PAGINATION_NEXT_RECORD_ID,
26+
)
27+
28+
print(response)

src/datadog_api_client/v1/api/usage_metering_api.py

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v1/model/hourly_usage_attribution_pagination.py

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v1/model/monthly_usage_attribution_pagination.py

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datadog_api_client/v1/model/usage_top_avg_metrics_pagination.py

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2022-03-29T15:05:25.629Z
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/v1/usage/monthly-attribution?start_month=2022-03-26T15%3A05%3A25.629Z&fields=infra_host_usage
9+
response:
10+
body:
11+
string: '{"usage":[{"org_name":"DD Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","tag_config_source":"DD
12+
Integration Tests (321813):::project","tags":null,"updated_at":"2022-03-28T23:02:55Z","month":"2022-03-01T00:00:00+00:00","values":{"infra_host_usage":15}}],"metadata":{"pagination":{"next_record_id":null},"aggregates":[{"field":"infra_host_usage","value":15.0,"agg_type":"sum"}]}}'
13+
headers:
14+
content-type:
15+
- application/json
16+
status:
17+
code: 200
18+
message: OK
19+
- request:
20+
body: null
21+
headers:
22+
accept:
23+
- application/json;datetime-format=rfc3339
24+
method: GET
25+
uri: https://api.datadoghq.com/api/v1/usage/monthly-attribution?next_record_id=null&start_month=2022-03-26T15%3A05%3A25.629Z&fields=infra_host_usage
26+
response:
27+
body:
28+
string: '{"usage":[],"metadata":{"pagination":{"next_record_id":null},"aggregates":[{"field":"infra_host_usage","value":15.0,"agg_type":"sum"}]}}'
29+
headers:
30+
content-type:
31+
- application/json
32+
status:
33+
code: 200
34+
message: OK
35+
version: 1

tests/v1/features/given.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,21 @@
166166
"key": "synthetics_api_test_with_wrong_dns_result",
167167
"tag": "Synthetics",
168168
"operationId": "TriggerTests"
169+
},
170+
{
171+
"parameters": [
172+
{
173+
"name": "start_month",
174+
"value": "\"{{ timeISO('now - 3d') }}\""
175+
},
176+
{
177+
"name": "fields",
178+
"value": "\"infra_host_usage\""
179+
}
180+
],
181+
"step": "there is a valid \"monthly_usage_attribution\" response",
182+
"key": "monthly_usage_attribution",
183+
"tag": "Usage Metering",
184+
"operationId": "GetMonthlyUsageAttribution"
169185
}
170186
]

0 commit comments

Comments
 (0)