Skip to content

Commit

Permalink
Mark Cost Attribution end_month parameter as not required (#2498)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Oct 17, 2024
1 parent 362c924 commit 5cf46b4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 51 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.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"
}
}
}
2 changes: 1 addition & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions examples/v2/usage-metering/GetMonthlyCostAttribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Expand Down
65 changes: 23 additions & 42 deletions src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1390,12 +1390,25 @@ public CompletableFuture<ApiResponse<HourlyUsageResponse>> 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: <code>[YYYY-MM]</code>
* for cost ending this month. (optional)
* @return GetMonthlyCostAttributionOptionalParameters
*/
public GetMonthlyCostAttributionOptionalParameters endMonth(OffsetDateTime endMonth) {
this.endMonth = endMonth;
return this;
}

/**
* Set sortDirection.
*
Expand Down Expand Up @@ -1466,8 +1479,6 @@ public GetMonthlyCostAttributionOptionalParameters includeDescendants(
*
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code>
* for cost beginning in this month. (required)
* @param endMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code> for
* cost ending this month. (required)
* @param fields Comma-separated list specifying cost types (e.g., <code>
* &lt;billing_dimension&gt;_on_demand_cost</code>, <code>
* &lt;billing_dimension&gt;_committed_cost</code>, <code>&lt;billing_dimension&gt;_total_cost
Expand All @@ -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();
}

Expand All @@ -1496,8 +1507,6 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters())
*
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code>
* for cost beginning in this month. (required)
* @param endMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code> for
* cost ending this month. (required)
* @param fields Comma-separated list specifying cost types (e.g., <code>
* &lt;billing_dimension&gt;_on_demand_cost</code>, <code>
* &lt;billing_dimension&gt;_committed_cost</code>, <code>&lt;billing_dimension&gt;_total_cost
Expand All @@ -1512,9 +1521,9 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters())
* @return CompletableFuture&lt;MonthlyCostAttributionResponse&gt;
*/
public CompletableFuture<MonthlyCostAttributionResponse> 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();
Expand All @@ -1528,8 +1537,6 @@ startMonth, endMonth, fields, new GetMonthlyCostAttributionOptionalParameters())
*
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code>
* for cost beginning in this month. (required)
* @param endMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code> for
* cost ending this month. (required)
* @param fields Comma-separated list specifying cost types (e.g., <code>
* &lt;billing_dimension&gt;_on_demand_cost</code>, <code>
* &lt;billing_dimension&gt;_committed_cost</code>, <code>&lt;billing_dimension&gt;_total_cost
Expand All @@ -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();
}

/**
Expand All @@ -1562,8 +1567,6 @@ public MonthlyCostAttributionResponse getMonthlyCostAttribution(
*
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code>
* for cost beginning in this month. (required)
* @param endMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code> for
* cost ending this month. (required)
* @param fields Comma-separated list specifying cost types (e.g., <code>
* &lt;billing_dimension&gt;_on_demand_cost</code>, <code>
* &lt;billing_dimension&gt;_committed_cost</code>, <code>&lt;billing_dimension&gt;_total_cost
Expand All @@ -1580,10 +1583,9 @@ public MonthlyCostAttributionResponse getMonthlyCostAttribution(
*/
public CompletableFuture<MonthlyCostAttributionResponse> 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();
Expand All @@ -1610,8 +1612,6 @@ public CompletableFuture<MonthlyCostAttributionResponse> getMonthlyCostAttributi
*
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code>
* for cost beginning in this month. (required)
* @param endMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code> for
* cost ending this month. (required)
* @param fields Comma-separated list specifying cost types (e.g., <code>
* &lt;billing_dimension&gt;_on_demand_cost</code>, <code>
* &lt;billing_dimension&gt;_committed_cost</code>, <code>&lt;billing_dimension&gt;_total_cost
Expand All @@ -1638,7 +1638,6 @@ public CompletableFuture<MonthlyCostAttributionResponse> getMonthlyCostAttributi
*/
public ApiResponse<MonthlyCostAttributionResponse> getMonthlyCostAttributionWithHttpInfo(
OffsetDateTime startMonth,
OffsetDateTime endMonth,
String fields,
GetMonthlyCostAttributionOptionalParameters parameters)
throws ApiException {
Expand All @@ -1658,17 +1657,12 @@ public ApiResponse<MonthlyCostAttributionResponse> 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;
Expand All @@ -1681,8 +1675,8 @@ public ApiResponse<MonthlyCostAttributionResponse> getMonthlyCostAttributionWith
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

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(
Expand Down Expand Up @@ -1718,8 +1712,6 @@ public ApiResponse<MonthlyCostAttributionResponse> getMonthlyCostAttributionWith
*
* @param startMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code>
* for cost beginning in this month. (required)
* @param endMonth Datetime in ISO-8601 format, UTC, precise to month: <code>[YYYY-MM]</code> for
* cost ending this month. (required)
* @param fields Comma-separated list specifying cost types (e.g., <code>
* &lt;billing_dimension&gt;_on_demand_cost</code>, <code>
* &lt;billing_dimension&gt;_committed_cost</code>, <code>&lt;billing_dimension&gt;_total_cost
Expand All @@ -1737,7 +1729,6 @@ public ApiResponse<MonthlyCostAttributionResponse> getMonthlyCostAttributionWith
public CompletableFuture<ApiResponse<MonthlyCostAttributionResponse>>
getMonthlyCostAttributionWithHttpInfoAsync(
OffsetDateTime startMonth,
OffsetDateTime endMonth,
String fields,
GetMonthlyCostAttributionOptionalParameters parameters) {
// Check if unstable operation is enabled
Expand Down Expand Up @@ -1765,17 +1756,6 @@ public ApiResponse<MonthlyCostAttributionResponse> getMonthlyCostAttributionWith
return result;
}

// verify the required parameter 'endMonth' is set
if (endMonth == null) {
CompletableFuture<ApiResponse<MonthlyCostAttributionResponse>> 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<ApiResponse<MonthlyCostAttributionResponse>> result =
Expand All @@ -1786,6 +1766,7 @@ public ApiResponse<MonthlyCostAttributionResponse> 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;
Expand All @@ -1798,8 +1779,8 @@ public ApiResponse<MonthlyCostAttributionResponse> getMonthlyCostAttributionWith
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 5cf46b4

Please sign in to comment.