diff --git a/.apigentools-info b/.apigentools-info index fe93961a34d..b2343c9d8ca 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-10 19:45:58.829299", - "spec_repo_commit": "049920eb" + "regenerated": "2024-10-16 20:07:17.471714", + "spec_repo_commit": "86072741" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-10 19:45:58.847651", - "spec_repo_commit": "049920eb" + "regenerated": "2024-10-16 20:07:17.490312", + "spec_repo_commit": "86072741" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c592c7ff286..6efc200303c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -28730,7 +28730,7 @@ paths: for cost ending this month.' in: query name: end_month - required: true + required: false schema: format: date-time type: string diff --git a/examples/v2/usage-metering/GetMonthlyCostAttribution.java b/examples/v2/usage-metering/GetMonthlyCostAttribution.java index 275422f3e81..eae69943e7b 100644 --- a/examples/v2/usage-metering/GetMonthlyCostAttribution.java +++ b/examples/v2/usage-metering/GetMonthlyCostAttribution.java @@ -2,6 +2,7 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.v2.api.UsageMeteringApi; +import com.datadog.api.client.v2.api.UsageMeteringApi.GetMonthlyCostAttributionOptionalParameters; import com.datadog.api.client.v2.model.MonthlyCostAttributionResponse; import java.time.OffsetDateTime; @@ -15,8 +16,9 @@ public static void main(String[] args) { MonthlyCostAttributionResponse result = apiInstance.getMonthlyCostAttribution( OffsetDateTime.now().plusDays(-5), - OffsetDateTime.now().plusDays(-3), - "infra_host_total_cost"); + "infra_host_total_cost", + new GetMonthlyCostAttributionOptionalParameters() + .endMonth(OffsetDateTime.now().plusDays(-3))); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling UsageMeteringApi#getMonthlyCostAttribution"); diff --git a/src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java b/src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java index dd40f1b3815..a3120cc7adb 100644 --- a/src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java @@ -1390,12 +1390,25 @@ public CompletableFuture> getHourlyUsageWithHtt /** Manage optional parameters to getMonthlyCostAttribution. */ public static class GetMonthlyCostAttributionOptionalParameters { + private OffsetDateTime endMonth; private SortDirection sortDirection; private String sortName; private String tagBreakdownKeys; private String nextRecordId; private Boolean includeDescendants; + /** + * Set endMonth. + * + * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] + * for cost ending this month. (optional) + * @return GetMonthlyCostAttributionOptionalParameters + */ + public GetMonthlyCostAttributionOptionalParameters endMonth(OffsetDateTime endMonth) { + this.endMonth = endMonth; + return this; + } + /** * Set sortDirection. * @@ -1466,8 +1479,6 @@ public GetMonthlyCostAttributionOptionalParameters includeDescendants( * * @param startMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] * for cost beginning in this month. (required) - * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for - * cost ending this month. (required) * @param fields Comma-separated list specifying cost types (e.g., * <billing_dimension>_on_demand_cost, * <billing_dimension>_committed_cost, <billing_dimension>_total_cost @@ -1483,9 +1494,9 @@ public GetMonthlyCostAttributionOptionalParameters includeDescendants( * @throws ApiException if fails to make API call */ public MonthlyCostAttributionResponse getMonthlyCostAttribution( - OffsetDateTime startMonth, OffsetDateTime endMonth, String fields) throws ApiException { + OffsetDateTime startMonth, String fields) throws ApiException { return getMonthlyCostAttributionWithHttpInfo( - startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) + startMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) .getData(); } @@ -1496,8 +1507,6 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) * * @param startMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] * for cost beginning in this month. (required) - * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for - * cost ending this month. (required) * @param fields Comma-separated list specifying cost types (e.g., * <billing_dimension>_on_demand_cost, * <billing_dimension>_committed_cost, <billing_dimension>_total_cost @@ -1512,9 +1521,9 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) * @return CompletableFuture<MonthlyCostAttributionResponse> */ public CompletableFuture getMonthlyCostAttributionAsync( - OffsetDateTime startMonth, OffsetDateTime endMonth, String fields) { + OffsetDateTime startMonth, String fields) { return getMonthlyCostAttributionWithHttpInfoAsync( - startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) + startMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) .thenApply( response -> { return response.getData(); @@ -1528,8 +1537,6 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) * * @param startMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] * for cost beginning in this month. (required) - * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for - * cost ending this month. (required) * @param fields Comma-separated list specifying cost types (e.g., * <billing_dimension>_on_demand_cost, * <billing_dimension>_committed_cost, <billing_dimension>_total_cost @@ -1547,12 +1554,10 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters()) */ public MonthlyCostAttributionResponse getMonthlyCostAttribution( OffsetDateTime startMonth, - OffsetDateTime endMonth, String fields, GetMonthlyCostAttributionOptionalParameters parameters) throws ApiException { - return getMonthlyCostAttributionWithHttpInfo(startMonth, endMonth, fields, parameters) - .getData(); + return getMonthlyCostAttributionWithHttpInfo(startMonth, fields, parameters).getData(); } /** @@ -1562,8 +1567,6 @@ public MonthlyCostAttributionResponse getMonthlyCostAttribution( * * @param startMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] * for cost beginning in this month. (required) - * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for - * cost ending this month. (required) * @param fields Comma-separated list specifying cost types (e.g., * <billing_dimension>_on_demand_cost, * <billing_dimension>_committed_cost, <billing_dimension>_total_cost @@ -1580,10 +1583,9 @@ public MonthlyCostAttributionResponse getMonthlyCostAttribution( */ public CompletableFuture getMonthlyCostAttributionAsync( OffsetDateTime startMonth, - OffsetDateTime endMonth, String fields, GetMonthlyCostAttributionOptionalParameters parameters) { - return getMonthlyCostAttributionWithHttpInfoAsync(startMonth, endMonth, fields, parameters) + return getMonthlyCostAttributionWithHttpInfoAsync(startMonth, fields, parameters) .thenApply( response -> { return response.getData(); @@ -1610,8 +1612,6 @@ public CompletableFuture getMonthlyCostAttributi * * @param startMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] * for cost beginning in this month. (required) - * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for - * cost ending this month. (required) * @param fields Comma-separated list specifying cost types (e.g., * <billing_dimension>_on_demand_cost, * <billing_dimension>_committed_cost, <billing_dimension>_total_cost @@ -1638,7 +1638,6 @@ public CompletableFuture getMonthlyCostAttributi */ public ApiResponse getMonthlyCostAttributionWithHttpInfo( OffsetDateTime startMonth, - OffsetDateTime endMonth, String fields, GetMonthlyCostAttributionOptionalParameters parameters) throws ApiException { @@ -1658,17 +1657,12 @@ public ApiResponse getMonthlyCostAttributionWith "Missing the required parameter 'startMonth' when calling getMonthlyCostAttribution"); } - // verify the required parameter 'endMonth' is set - if (endMonth == null) { - throw new ApiException( - 400, "Missing the required parameter 'endMonth' when calling getMonthlyCostAttribution"); - } - // verify the required parameter 'fields' is set if (fields == null) { throw new ApiException( 400, "Missing the required parameter 'fields' when calling getMonthlyCostAttribution"); } + OffsetDateTime endMonth = parameters.endMonth; SortDirection sortDirection = parameters.sortDirection; String sortName = parameters.sortName; String tagBreakdownKeys = parameters.tagBreakdownKeys; @@ -1681,8 +1675,8 @@ public ApiResponse getMonthlyCostAttributionWith Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "start_month", startMonth)); - localVarQueryParams.addAll(apiClient.parameterToPairs("", "end_month", endMonth)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "fields", fields)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "end_month", endMonth)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort_direction", sortDirection)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort_name", sortName)); localVarQueryParams.addAll( @@ -1718,8 +1712,6 @@ public ApiResponse getMonthlyCostAttributionWith * * @param startMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] * for cost beginning in this month. (required) - * @param endMonth Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for - * cost ending this month. (required) * @param fields Comma-separated list specifying cost types (e.g., * <billing_dimension>_on_demand_cost, * <billing_dimension>_committed_cost, <billing_dimension>_total_cost @@ -1737,7 +1729,6 @@ public ApiResponse getMonthlyCostAttributionWith public CompletableFuture> getMonthlyCostAttributionWithHttpInfoAsync( OffsetDateTime startMonth, - OffsetDateTime endMonth, String fields, GetMonthlyCostAttributionOptionalParameters parameters) { // Check if unstable operation is enabled @@ -1765,17 +1756,6 @@ public ApiResponse getMonthlyCostAttributionWith return result; } - // verify the required parameter 'endMonth' is set - if (endMonth == null) { - CompletableFuture> result = - new CompletableFuture<>(); - result.completeExceptionally( - new ApiException( - 400, - "Missing the required parameter 'endMonth' when calling getMonthlyCostAttribution")); - return result; - } - // verify the required parameter 'fields' is set if (fields == null) { CompletableFuture> result = @@ -1786,6 +1766,7 @@ public ApiResponse getMonthlyCostAttributionWith "Missing the required parameter 'fields' when calling getMonthlyCostAttribution")); return result; } + OffsetDateTime endMonth = parameters.endMonth; SortDirection sortDirection = parameters.sortDirection; String sortName = parameters.sortName; String tagBreakdownKeys = parameters.tagBreakdownKeys; @@ -1798,8 +1779,8 @@ public ApiResponse getMonthlyCostAttributionWith Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "start_month", startMonth)); - localVarQueryParams.addAll(apiClient.parameterToPairs("", "end_month", endMonth)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "fields", fields)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "end_month", endMonth)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort_direction", sortDirection)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort_name", sortName)); localVarQueryParams.addAll( diff --git a/src/test/resources/com/datadog/api/client/v2/api/usage_metering.feature b/src/test/resources/com/datadog/api/client/v2/api/usage_metering.feature index b4c81950a91..4773ad01338 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/usage_metering.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/usage_metering.feature @@ -19,8 +19,8 @@ Feature: Usage Metering Given operation "GetMonthlyCostAttribution" enabled And new "GetMonthlyCostAttribution" request And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}" - And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}" And request contains "fields" parameter with value "not_a_product" + And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}" When the request is sent Then the response status is 400 Bad Request @@ -29,8 +29,8 @@ Feature: Usage Metering Given operation "GetMonthlyCostAttribution" enabled And new "GetMonthlyCostAttribution" request And request contains "start_month" parameter with value "{{ timeISO('now - 5d') }}" - And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}" And request contains "fields" parameter with value "infra_host_total_cost" + And request contains "end_month" parameter with value "{{ timeISO('now - 3d') }}" When the request is sent Then the response status is 200 OK