Skip to content

Commit 4bd5e59

Browse files
api-clients-generation-pipeline[bot]carolinekaufmanci.datadog-api-spec
authored
[RQ-990] Enumerate accepted values for fields parameter in usage attr requests (#813)
* Use enum field for attribution test * Regenerate client from commit 8d8238a of spec repo Co-authored-by: Caroline Kaufman <caroline.kaufman@datadoghq.com> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 0c15a0d commit 4bd5e59

File tree

8 files changed

+264
-17
lines changed

8 files changed

+264
-17
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.4.1.dev6",
7-
"regenerated": "2021-05-10 15:35:06.602106",
8-
"spec_repo_commit": "8176bfc"
7+
"regenerated": "2021-05-11 08:05:05.459261",
8+
"spec_repo_commit": "8d8238a"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev6",
12-
"regenerated": "2021-05-10 15:35:41.318760",
13-
"spec_repo_commit": "8176bfc"
12+
"regenerated": "2021-05-11 08:05:53.268797",
13+
"spec_repo_commit": "8d8238a"
1414
}
1515
}
1616
}

api_docs/v1/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ Class | Method | HTTP request | Description
600600
- [UsageAttributionPagination](UsageAttributionPagination.md)
601601
- [UsageAttributionResponse](UsageAttributionResponse.md)
602602
- [UsageAttributionSort](UsageAttributionSort.md)
603+
- [UsageAttributionSupportedMetrics](UsageAttributionSupportedMetrics.md)
603604
- [UsageAttributionValues](UsageAttributionValues.md)
604605
- [UsageBillableSummaryBody](UsageBillableSummaryBody.md)
605606
- [UsageBillableSummaryHour](UsageBillableSummaryHour.md)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
3+
# UsageAttributionSupportedMetrics
4+
5+
## Enum
6+
7+
8+
* `CUSTOM_TIMESERIES_USAGE` (value: `"custom_timeseries_usage"`)
9+
10+
* `CONTAINER_USAGE` (value: `"container_usage"`)
11+
12+
* `SNMP_PERCENTAGE` (value: `"snmp_percentage"`)
13+
14+
* `APM_HOST_USAGE` (value: `"apm_host_usage"`)
15+
16+
* `BROWSER_USAGE` (value: `"browser_usage"`)
17+
18+
* `NPM_HOST_PERCENTAGE` (value: `"npm_host_percentage"`)
19+
20+
* `INFRA_HOST_USAGE` (value: `"infra_host_usage"`)
21+
22+
* `CUSTOM_TIMESERIES_PERCENTAGE` (value: `"custom_timeseries_percentage"`)
23+
24+
* `CONTAINER_PERCENTAGE` (value: `"container_percentage"`)
25+
26+
* `LAMBDA_USAGE` (value: `"lambda_usage"`)
27+
28+
* `API_USAGE` (value: `"api_usage"`)
29+
30+
* `APM_HOST_PERCENTAGE` (value: `"apm_host_percentage"`)
31+
32+
* `INFRA_HOST_PERCENTAGE` (value: `"infra_host_percentage"`)
33+
34+
* `SNMP_USAGE` (value: `"snmp_usage"`)
35+
36+
* `BROWSER_PERCENTAGE` (value: `"browser_percentage"`)
37+
38+
* `API_PERCENTAGE` (value: `"api_percentage"`)
39+
40+
* `LAMBDA_PERCENTAGE` (value: `"lambda_percentage"`)
41+
42+
* `NPM_HOST_USAGE` (value: `"npm_host_usage"`)
43+
44+
* `LAMBDA_FUNCTIONS_USAGE` (value: `"lambda_functions_usage"`)
45+
46+
* `LAMBDA_FUNCTIONS_PERCENTAGE` (value: `"lambda_functions_percentage"`)
47+
48+
* `LAMBDA_INVOCATIONS_USAGE` (value: `"lambda_invocations_usage"`)
49+
50+
* `LAMBDA_INVOCATIONS_PERCENTAGE` (value: `"lambda_invocations_percentage"`)
51+
52+
* `FARGATE_USAGE` (value: `"fargate_usage"`)
53+
54+
* `FARGATE_PERCENTAGE` (value: `"fargate_percentage"`)
55+
56+
* `PROFILED_HOST_USAGE` (value: `"profiled_host_usage"`)
57+
58+
* `PROFILED_HOST_PERCENTAGE` (value: `"profiled_host_percentage"`)
59+
60+
* `PROFILED_CONTAINER_USAGE` (value: `"profiled_container_usage"`)
61+
62+
* `PROFILED_CONTAINER_PERCENTAGE` (value: `"profiled_container_percentage"`)
63+
64+
* `ALL` (value: `"*"`)
65+
66+
67+

api_docs/v1/UsageMeteringApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public class Example {
646646

647647
UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient);
648648
OffsetDateTime startMonth = OffsetDateTime.now(); // OffsetDateTime | Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage beginning in this month. Maximum of 15 months ago.
649-
String fields = "fields_example"; // String | The specified field to search results for.
649+
UsageAttributionSupportedMetrics fields = UsageAttributionSupportedMetrics.fromValue("custom_timeseries_usage"); // UsageAttributionSupportedMetrics | Comma-separated list of usage types to return, or `*` for all usage types.
650650
OffsetDateTime endMonth = OffsetDateTime.now(); // OffsetDateTime | Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage ending this month.
651651
UsageSortDirection sortDirection = UsageSortDirection.fromValue("desc"); // UsageSortDirection | The direction to sort by: `[desc, asc]`.
652652
UsageAttributionSort sortName = UsageAttributionSort.fromValue("api_percentage"); // UsageAttributionSort | The field to sort by.
@@ -673,7 +673,7 @@ public class Example {
673673
Name | Type | Description | Notes
674674
------------- | ------------- | ------------- | -------------
675675
**startMonth** | **OffsetDateTime**| Datetime in ISO-8601 format, UTC, precise to month: &#x60;[YYYY-MM]&#x60; for usage beginning in this month. Maximum of 15 months ago. |
676-
**fields** | **String**| The specified field to search results for. |
676+
**fields** | **UsageAttributionSupportedMetrics**| Comma-separated list of usage types to return, or &#x60;*&#x60; for all usage types. | [enum: custom_timeseries_usage, container_usage, snmp_percentage, apm_host_usage, browser_usage, npm_host_percentage, infra_host_usage, custom_timeseries_percentage, container_percentage, lambda_usage, api_usage, apm_host_percentage, infra_host_percentage, snmp_usage, browser_percentage, api_percentage, lambda_percentage, npm_host_usage, lambda_functions_usage, lambda_functions_percentage, lambda_invocations_usage, lambda_invocations_percentage, fargate_usage, fargate_percentage, profiled_host_usage, profiled_host_percentage, profiled_container_usage, profiled_container_percentage, *]
677677
**endMonth** | **OffsetDateTime**| Datetime in ISO-8601 format, UTC, precise to month: &#x60;[YYYY-MM]&#x60; for usage ending this month. | [optional]
678678
**sortDirection** | **UsageSortDirection**| The direction to sort by: &#x60;[desc, asc]&#x60;. | [optional] [enum: desc, asc]
679679
**sortName** | **UsageAttributionSort**| The field to sort by. | [optional] [enum: api_percentage, snmp_usage, apm_host_usage, api_usage, container_usage, custom_timeseries_percentage, container_percentage, apm_host_percentage, npm_host_percentage, browser_percentage, browser_usage, infra_host_percentage, snmp_percentage, npm_host_usage, infra_host_usage, custom_timeseries_usage, lambda_functions_usage, lambda_functions_percentage, lambda_invocations_usage, lambda_invocations_percentage, lambda_usage, lambda_percentage]

src/main/java/com/datadog/api/v1/client/api/UsageMeteringApi.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.datadog.api.v1.client.model.UsageAnalyzedLogsResponse;
99
import com.datadog.api.v1.client.model.UsageAttributionResponse;
1010
import com.datadog.api.v1.client.model.UsageAttributionSort;
11+
import com.datadog.api.v1.client.model.UsageAttributionSupportedMetrics;
1112
import com.datadog.api.v1.client.model.UsageBillableSummaryResponse;
1213
import com.datadog.api.v1.client.model.UsageComplianceResponse;
1314
import com.datadog.api.v1.client.model.UsageCustomReportsResponse;
@@ -1133,7 +1134,8 @@ public GetUsageAttributionOptionalParameters sortName(UsageAttributionSort sortN
11331134
*
11341135
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: &#x60;[YYYY-MM]&#x60; for
11351136
* usage beginning in this month. Maximum of 15 months ago. (required)
1136-
* @param fields The specified field to search results for. (required)
1137+
* @param fields Comma-separated list of usage types to return, or &#x60;*&#x60; for all usage
1138+
* types. (required)
11371139
* @return UsageAttributionResponse
11381140
* @throws ApiException if fails to make API call
11391141
* @http.response.details
@@ -1143,8 +1145,8 @@ public GetUsageAttributionOptionalParameters sortName(UsageAttributionSort sortN
11431145
* <tr><td> 403 </td><td> Forbidden - User is not authorized </td><td> - </td></tr>
11441146
* </table>
11451147
*/
1146-
public UsageAttributionResponse getUsageAttribution(OffsetDateTime startMonth, String fields)
1147-
throws ApiException {
1148+
public UsageAttributionResponse getUsageAttribution(
1149+
OffsetDateTime startMonth, UsageAttributionSupportedMetrics fields) throws ApiException {
11481150
return getUsageAttributionWithHttpInfo(
11491151
startMonth, fields, new GetUsageAttributionOptionalParameters())
11501152
.getData();
@@ -1155,7 +1157,8 @@ startMonth, fields, new GetUsageAttributionOptionalParameters())
11551157
*
11561158
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: &#x60;[YYYY-MM]&#x60; for
11571159
* usage beginning in this month. Maximum of 15 months ago. (required)
1158-
* @param fields The specified field to search results for. (required)
1160+
* @param fields Comma-separated list of usage types to return, or &#x60;*&#x60; for all usage
1161+
* types. (required)
11591162
* @param parameters Optional parameters for the request.
11601163
* @return UsageAttributionResponse
11611164
* @throws ApiException if fails to make API call
@@ -1167,7 +1170,9 @@ startMonth, fields, new GetUsageAttributionOptionalParameters())
11671170
* </table>
11681171
*/
11691172
public UsageAttributionResponse getUsageAttribution(
1170-
OffsetDateTime startMonth, String fields, GetUsageAttributionOptionalParameters parameters)
1173+
OffsetDateTime startMonth,
1174+
UsageAttributionSupportedMetrics fields,
1175+
GetUsageAttributionOptionalParameters parameters)
11711176
throws ApiException {
11721177
return getUsageAttributionWithHttpInfo(startMonth, fields, parameters).getData();
11731178
}
@@ -1177,7 +1182,8 @@ public UsageAttributionResponse getUsageAttribution(
11771182
*
11781183
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: &#x60;[YYYY-MM]&#x60; for
11791184
* usage beginning in this month. Maximum of 15 months ago. (required)
1180-
* @param fields The specified field to search results for. (required)
1185+
* @param fields Comma-separated list of usage types to return, or &#x60;*&#x60; for all usage
1186+
* types. (required)
11811187
* @param parameters Optional parameters for the request.
11821188
* @return ApiResponse&lt;UsageAttributionResponse&gt;
11831189
* @throws ApiException if fails to make API call
@@ -1189,7 +1195,9 @@ public UsageAttributionResponse getUsageAttribution(
11891195
* </table>
11901196
*/
11911197
public ApiResponse<UsageAttributionResponse> getUsageAttributionWithHttpInfo(
1192-
OffsetDateTime startMonth, String fields, GetUsageAttributionOptionalParameters parameters)
1198+
OffsetDateTime startMonth,
1199+
UsageAttributionSupportedMetrics fields,
1200+
GetUsageAttributionOptionalParameters parameters)
11931201
throws ApiException {
11941202
Object localVarPostBody = null;
11951203

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2019-Present Datadog, Inc.
5+
*
6+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
7+
* https://openapi-generator.tech
8+
* Do not edit the class manually.
9+
*/
10+
11+
package com.datadog.api.v1.client.model;
12+
13+
14+
import com.fasterxml.jackson.annotation.JsonCreator;
15+
import com.fasterxml.jackson.annotation.JsonValue;
16+
17+
/**
18+
* Supported fields for usage attribution requests (valid requests contain one or more metrics, or
19+
* &#x60;*&#x60; for all).
20+
*/
21+
public enum UsageAttributionSupportedMetrics {
22+
CUSTOM_TIMESERIES_USAGE("custom_timeseries_usage"),
23+
24+
CONTAINER_USAGE("container_usage"),
25+
26+
SNMP_PERCENTAGE("snmp_percentage"),
27+
28+
APM_HOST_USAGE("apm_host_usage"),
29+
30+
BROWSER_USAGE("browser_usage"),
31+
32+
NPM_HOST_PERCENTAGE("npm_host_percentage"),
33+
34+
INFRA_HOST_USAGE("infra_host_usage"),
35+
36+
CUSTOM_TIMESERIES_PERCENTAGE("custom_timeseries_percentage"),
37+
38+
CONTAINER_PERCENTAGE("container_percentage"),
39+
40+
LAMBDA_USAGE("lambda_usage"),
41+
42+
API_USAGE("api_usage"),
43+
44+
APM_HOST_PERCENTAGE("apm_host_percentage"),
45+
46+
INFRA_HOST_PERCENTAGE("infra_host_percentage"),
47+
48+
SNMP_USAGE("snmp_usage"),
49+
50+
BROWSER_PERCENTAGE("browser_percentage"),
51+
52+
API_PERCENTAGE("api_percentage"),
53+
54+
LAMBDA_PERCENTAGE("lambda_percentage"),
55+
56+
NPM_HOST_USAGE("npm_host_usage"),
57+
58+
LAMBDA_FUNCTIONS_USAGE("lambda_functions_usage"),
59+
60+
LAMBDA_FUNCTIONS_PERCENTAGE("lambda_functions_percentage"),
61+
62+
LAMBDA_INVOCATIONS_USAGE("lambda_invocations_usage"),
63+
64+
LAMBDA_INVOCATIONS_PERCENTAGE("lambda_invocations_percentage"),
65+
66+
FARGATE_USAGE("fargate_usage"),
67+
68+
FARGATE_PERCENTAGE("fargate_percentage"),
69+
70+
PROFILED_HOST_USAGE("profiled_host_usage"),
71+
72+
PROFILED_HOST_PERCENTAGE("profiled_host_percentage"),
73+
74+
PROFILED_CONTAINER_USAGE("profiled_container_usage"),
75+
76+
PROFILED_CONTAINER_PERCENTAGE("profiled_container_percentage"),
77+
78+
ALL("*");
79+
80+
private String value;
81+
82+
UsageAttributionSupportedMetrics(String value) {
83+
this.value = value;
84+
}
85+
86+
@JsonValue
87+
public String getValue() {
88+
return value;
89+
}
90+
91+
@Override
92+
public String toString() {
93+
return String.valueOf(value);
94+
}
95+
96+
@JsonCreator
97+
public static UsageAttributionSupportedMetrics fromValue(String value) {
98+
for (UsageAttributionSupportedMetrics b : UsageAttributionSupportedMetrics.values()) {
99+
if (b.value.equals(value)) {
100+
return b;
101+
}
102+
}
103+
throw new IllegalArgumentException("Unexpected value '" + value + "'");
104+
}
105+
}

src/main/java/com/datadog/api/v1/openapi.yaml

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7571,13 +7571,14 @@ paths:
75717571
format: date-time
75727572
type: string
75737573
style: form
7574-
- description: The specified field to search results for.
7574+
- description: Comma-separated list of usage types to return, or `*` for all
7575+
usage types.
75757576
explode: true
75767577
in: query
75777578
name: fields
75787579
required: true
75797580
schema:
7580-
type: string
7581+
$ref: '#/components/schemas/UsageAttributionSupportedMetrics'
75817582
style: form
75827583
- description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]`
75837584
for usage ending this month.'
@@ -21270,6 +21271,70 @@ components:
2127021271
- LAMBDA_INVOCATIONS_PERCENTAGE
2127121272
- LAMBDA_USAGE
2127221273
- LAMBDA_PERCENTAGE
21274+
UsageAttributionSupportedMetrics:
21275+
description: Supported fields for usage attribution requests (valid requests
21276+
contain one or more metrics, or `*` for all).
21277+
enum:
21278+
- custom_timeseries_usage
21279+
- container_usage
21280+
- snmp_percentage
21281+
- apm_host_usage
21282+
- browser_usage
21283+
- npm_host_percentage
21284+
- infra_host_usage
21285+
- custom_timeseries_percentage
21286+
- container_percentage
21287+
- lambda_usage
21288+
- api_usage
21289+
- apm_host_percentage
21290+
- infra_host_percentage
21291+
- snmp_usage
21292+
- browser_percentage
21293+
- api_percentage
21294+
- lambda_percentage
21295+
- npm_host_usage
21296+
- lambda_functions_usage
21297+
- lambda_functions_percentage
21298+
- lambda_invocations_usage
21299+
- lambda_invocations_percentage
21300+
- fargate_usage
21301+
- fargate_percentage
21302+
- profiled_host_usage
21303+
- profiled_host_percentage
21304+
- profiled_container_usage
21305+
- profiled_container_percentage
21306+
- '*'
21307+
type: string
21308+
x-enum-varnames:
21309+
- CUSTOM_TIMESERIES_USAGE
21310+
- CONTAINER_USAGE
21311+
- SNMP_PERCENTAGE
21312+
- APM_HOST_USAGE
21313+
- BROWSER_USAGE
21314+
- NPM_HOST_PERCENTAGE
21315+
- INFRA_HOST_USAGE
21316+
- CUSTOM_TIMESERIES_PERCENTAGE
21317+
- CONTAINER_PERCENTAGE
21318+
- LAMBDA_USAGE
21319+
- API_USAGE
21320+
- APM_HOST_PERCENTAGE
21321+
- INFRA_HOST_PERCENTAGE
21322+
- SNMP_USAGE
21323+
- BROWSER_PERCENTAGE
21324+
- API_PERCENTAGE
21325+
- LAMBDA_PERCENTAGE
21326+
- NPM_HOST_USAGE
21327+
- LAMBDA_FUNCTIONS_USAGE
21328+
- LAMBDA_FUNCTIONS_PERCENTAGE
21329+
- LAMBDA_INVOCATIONS_USAGE
21330+
- LAMBDA_INVOCATIONS_PERCENTAGE
21331+
- FARGATE_USAGE
21332+
- FARGATE_PERCENTAGE
21333+
- PROFILED_HOST_USAGE
21334+
- PROFILED_HOST_PERCENTAGE
21335+
- PROFILED_CONTAINER_USAGE
21336+
- PROFILED_CONTAINER_PERCENTAGE
21337+
- ALL
2127321338
UsageAttributionTagNames:
2127421339
additionalProperties:
2127521340
description: A list of tag values.

src/test/java/com/datadog/api/v1/client/api/UsageMeteringApiTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ public void getUsageLambdaTest() throws ApiException {
472472
@Test
473473
public void getUsageAttributionTest() throws ApiException {
474474
generalApiClient.setUnstableOperationEnabled("getUsageAttribution", true);
475-
UsageAttributionResponse usage = api.getUsageAttribution(startMonth, "*");
475+
UsageAttributionResponse usage =
476+
api.getUsageAttribution(startMonth, UsageAttributionSupportedMetrics.ALL);
476477

477478
assertNotNull(usage.getUsage());
478479
assertNotNull(usage.getMetadata());
@@ -1019,7 +1020,7 @@ public void getUsageIncidentManagementErrorsTest() throws IOException {
10191020
public void getUsageAttributionErrorsTest() throws IOException {
10201021
try {
10211022
generalFakeAuthApiClient.setUnstableOperationEnabled("getUsageAttribution", true);
1022-
fakeAuthApi.getUsageAttribution(startMonth, "*");
1023+
fakeAuthApi.getUsageAttribution(startMonth, UsageAttributionSupportedMetrics.ALL);
10231024
fail("Expected ApiException not thrown");
10241025
} catch (ApiException e) {
10251026
assertEquals(403, e.getCode());

0 commit comments

Comments
 (0)