diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index afe196e102f..4a7716db162 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -22716,7 +22716,13 @@ components: $ref: "#/components/schemas/UsageSpecifiedCustomReportsMeta" type: object UsageSummaryDate: - description: Response with hourly report of all data billed by Datadog all organizations. + description: |- + Response with hourly report of all data billed by Datadog for all organizations. + + Newly added billing dimensions and usage types appear as untyped keys on the + `additionalProperties` map instead of as typed fields. Call + `GET /api/v2/usage/summary/available_fields` to enumerate every key returned + at this response level—both typed fields and `additionalProperties` keys. properties: agent_host_top99p: description: Shows the 99th percentile of all agent hosts over all hours in the current date for all organizations. @@ -23739,7 +23745,13 @@ components: type: integer type: object UsageSummaryDateOrg: - description: Global hourly report of all data billed by Datadog for a given organization. + description: |- + Global hourly report of all data billed by Datadog for a given organization. + + Newly added billing dimensions and usage types appear as untyped keys on the + `additionalProperties` map instead of as typed fields. Call + `GET /api/v2/usage/summary/available_fields` to enumerate every key returned + at this response level—both typed fields and `additionalProperties` keys. properties: account_name: description: The account name. @@ -24780,7 +24792,14 @@ components: type: integer type: object UsageSummaryResponse: - description: Response summarizing all usage aggregated across the months in the request for all organizations, and broken down by month and by organization. + description: |- + Response summarizing all usage aggregated across the months in the request for + all organizations, and broken down by month and by organization. + + Newly added billing dimensions and usage types appear as untyped keys on the + `additionalProperties` map instead of as typed fields. Call + `GET /api/v2/usage/summary/available_fields` to enumerate every key returned + at this response level—both typed fields and `additionalProperties` keys. properties: agent_host_top99p_sum: description: Shows the 99th percentile of all agent hosts over all hours in the current month for all organizations. @@ -42260,6 +42279,12 @@ paths: description: |- Get all usage across your account. + Newly added billing dimensions and usage types appear as untyped keys on the + `additionalProperties` map of `UsageSummaryResponse`, `UsageSummaryDate`, and + `UsageSummaryDateOrg` instead of as typed fields. Call + `GET /api/v2/usage/summary/available_fields` to enumerate every key returned + at each response level—both typed fields and `additionalProperties` keys. + This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/). operationId: GetUsageSummary parameters: diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c26a927e835..08de08468e7 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -96978,6 +96978,67 @@ components: $ref: "#/components/schemas/UsageDataObject" type: array type: object + UsageSummaryAvailableFieldsAttributes: + description: |- + The lists of field names returned by `GET /api/v1/usage/summary` at each + of its three response levels. Each list contains every key the data endpoint + emits—both typed fields declared in the OpenAPI spec and untyped keys + exposed through `additionalProperties`. + properties: + date_fields: + description: |- + Sorted list of every key returned inside each `UsageSummaryDate` + entry of `usage[]` (typed fields and `additionalProperties` keys + combined). + items: + type: string + type: array + date_org_fields: + description: |- + Sorted list of every key returned inside each `UsageSummaryDateOrg` + entry of `usage[].orgs[]` (typed fields and `additionalProperties` + keys combined). + items: + type: string + type: array + response_fields: + description: |- + Sorted list of every key returned as a direct property of + `UsageSummaryResponse` (typed fields and `additionalProperties` + keys combined). + items: + type: string + type: array + type: object + UsageSummaryAvailableFieldsBody: + description: Available-fields data. + properties: + attributes: + $ref: "#/components/schemas/UsageSummaryAvailableFieldsAttributes" + id: + description: The identifier for the discovery scope. Always `"all"`. + example: all + type: string + type: + $ref: "#/components/schemas/UsageSummaryAvailableFieldsType" + type: object + UsageSummaryAvailableFieldsResponse: + description: |- + Response listing every field name returned by `GET /api/v1/usage/summary` + at each of its three response levels. Includes both typed fields and untyped + `additionalProperties` keys. + properties: + data: + $ref: "#/components/schemas/UsageSummaryAvailableFieldsBody" + type: object + UsageSummaryAvailableFieldsType: + default: usage_summary_available_fields + description: Type of available-fields data. + enum: + - usage_summary_available_fields + type: string + x-enum-varnames: + - USAGE_SUMMARY_AVAILABLE_FIELDS UsageTimeSeriesObject: description: Usage timeseries data. properties: @@ -174018,6 +174079,67 @@ paths: permissions: - usage_read - billing_read + /api/v2/usage/summary/available_fields: + get: + description: |- + List the field names returned by `GET /api/v1/usage/summary` at each of its + three response levels. Each list contains every key the data endpoint + emits—both typed fields declared in the OpenAPI spec and untyped keys + exposed through `additionalProperties` (the latter used for billing + dimensions and usage types added after the v1 schema freeze). + + This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/). + operationId: GetUsageSummaryAvailableFields + responses: + "200": + content: + application/json;datetime-format=rfc3339: + examples: + default: + value: + data: + attributes: + date_fields: + - agent_host_top99p + - aws_host_top99p + - ccm_anthropic_spend_last + date_org_fields: + - agent_host_top99p + - aws_host_top99p + - ccm_anthropic_spend_last + response_fields: + - agent_host_top99p_sum + - aws_host_top99p_sum + - ccm_anthropic_spend_last_sum + id: all + type: usage_summary_available_fields + schema: + $ref: "#/components/schemas/UsageSummaryAvailableFieldsResponse" + description: OK. + "403": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden - User is not authorized. + "429": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Too many requests. + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - usage_read + summary: Get available fields for usage summary + tags: + - Usage Metering + "x-permission": + operator: OR + permissions: + - usage_read /api/v2/usage/usage-attribution-types: get: description: |- diff --git a/examples/v2/usage-metering/GetUsageSummaryAvailableFields.java b/examples/v2/usage-metering/GetUsageSummaryAvailableFields.java new file mode 100644 index 00000000000..d999b726140 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageSummaryAvailableFields.java @@ -0,0 +1,24 @@ +// Get available fields for usage summary returns "OK." response + +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.model.UsageSummaryAvailableFieldsResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + UsageSummaryAvailableFieldsResponse result = apiInstance.getUsageSummaryAvailableFields(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#getUsageSummaryAvailableFields"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/usage-metering/GetUsageSummaryAvailableFields_2682263043.java b/examples/v2/usage-metering/GetUsageSummaryAvailableFields_2682263043.java new file mode 100644 index 00000000000..6afd6c313c4 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageSummaryAvailableFields_2682263043.java @@ -0,0 +1,24 @@ +// Get available fields for usage summary returns "OK" response + +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.model.UsageSummaryAvailableFieldsResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + UsageSummaryAvailableFieldsResponse result = apiInstance.getUsageSummaryAvailableFields(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#getUsageSummaryAvailableFields"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/api/UsageMeteringApi.java b/src/main/java/com/datadog/api/client/v1/api/UsageMeteringApi.java index 5bdf391fb33..43c0042b0f6 100644 --- a/src/main/java/com/datadog/api/client/v1/api/UsageMeteringApi.java +++ b/src/main/java/com/datadog/api/client/v1/api/UsageMeteringApi.java @@ -7231,6 +7231,12 @@ public CompletableFuture getUsageSummaryAsync( /** * Get all usage across your account. * + *

Newly added billing dimensions and usage types appear as untyped keys on the + * additionalProperties map of UsageSummaryResponse, UsageSummaryDate + * , and UsageSummaryDateOrg instead of as typed fields. Call + * GET /api/v2/usage/summary/available_fields to enumerate every key returned at each + * response level—both typed fields and additionalProperties keys. + * *

This endpoint is only accessible for parent-level * organizations. diff --git a/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDate.java b/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDate.java index ede38ac27fe..238d27b0ea1 100644 --- a/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDate.java +++ b/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDate.java @@ -19,7 +19,14 @@ import java.util.Map; import java.util.Objects; -/** Response with hourly report of all data billed by Datadog all organizations. */ +/** + * Response with hourly report of all data billed by Datadog for all organizations. + * + *

Newly added billing dimensions and usage types appear as untyped keys on the + * additionalProperties map instead of as typed fields. Call + * GET /api/v2/usage/summary/available_fields to enumerate every key returned at this + * response level—both typed fields and additionalProperties keys. + */ @JsonPropertyOrder({ UsageSummaryDate.JSON_PROPERTY_AGENT_HOST_TOP99P, UsageSummaryDate.JSON_PROPERTY_APM_AZURE_APP_SERVICE_HOST_TOP99P, diff --git a/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDateOrg.java b/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDateOrg.java index d78a52697e5..f9bbadf3a8a 100644 --- a/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDateOrg.java +++ b/src/main/java/com/datadog/api/client/v1/model/UsageSummaryDateOrg.java @@ -16,7 +16,14 @@ import java.util.Map; import java.util.Objects; -/** Global hourly report of all data billed by Datadog for a given organization. */ +/** + * Global hourly report of all data billed by Datadog for a given organization. + * + *

Newly added billing dimensions and usage types appear as untyped keys on the + * additionalProperties map instead of as typed fields. Call + * GET /api/v2/usage/summary/available_fields to enumerate every key returned at this + * response level—both typed fields and additionalProperties keys. + */ @JsonPropertyOrder({ UsageSummaryDateOrg.JSON_PROPERTY_ACCOUNT_NAME, UsageSummaryDateOrg.JSON_PROPERTY_ACCOUNT_PUBLIC_ID, diff --git a/src/main/java/com/datadog/api/client/v1/model/UsageSummaryResponse.java b/src/main/java/com/datadog/api/client/v1/model/UsageSummaryResponse.java index f1452391540..e506f440f81 100644 --- a/src/main/java/com/datadog/api/client/v1/model/UsageSummaryResponse.java +++ b/src/main/java/com/datadog/api/client/v1/model/UsageSummaryResponse.java @@ -22,6 +22,11 @@ /** * Response summarizing all usage aggregated across the months in the request for all organizations, * and broken down by month and by organization. + * + *

Newly added billing dimensions and usage types appear as untyped keys on the + * additionalProperties map instead of as typed fields. Call + * GET /api/v2/usage/summary/available_fields to enumerate every key returned at this + * response level—both typed fields and additionalProperties keys. */ @JsonPropertyOrder({ UsageSummaryResponse.JSON_PROPERTY_AGENT_HOST_TOP99P_SUM, 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 9e0179eea88..6cfab791e39 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 @@ -16,6 +16,7 @@ import com.datadog.api.client.v2.model.UsageAttributionTypesResponse; import com.datadog.api.client.v2.model.UsageLambdaTracedInvocationsResponse; import com.datadog.api.client.v2.model.UsageObservabilityPipelinesResponse; +import com.datadog.api.client.v2.model.UsageSummaryAvailableFieldsResponse; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; import java.time.OffsetDateTime; @@ -3002,4 +3003,124 @@ public CompletableFuture getUsageObservabil false, new GenericType() {}); } + + /** + * Get available fields for usage summary. + * + *

See {@link #getUsageSummaryAvailableFieldsWithHttpInfo}. + * + * @return UsageSummaryAvailableFieldsResponse + * @throws ApiException if fails to make API call + */ + public UsageSummaryAvailableFieldsResponse getUsageSummaryAvailableFields() throws ApiException { + return getUsageSummaryAvailableFieldsWithHttpInfo().getData(); + } + + /** + * Get available fields for usage summary. + * + *

See {@link #getUsageSummaryAvailableFieldsWithHttpInfoAsync}. + * + * @return CompletableFuture<UsageSummaryAvailableFieldsResponse> + */ + public CompletableFuture + getUsageSummaryAvailableFieldsAsync() { + return getUsageSummaryAvailableFieldsWithHttpInfoAsync() + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List the field names returned by GET /api/v1/usage/summary at each of its three + * response levels. Each list contains every key the data endpoint emits—both typed fields + * declared in the OpenAPI spec and untyped keys exposed through additionalProperties + * (the latter used for billing dimensions and usage types added after the v1 schema freeze). + * + *

This endpoint is only accessible for parent-level + * organizations. + * + * @return ApiResponse<UsageSummaryAvailableFieldsResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK. -
403 Forbidden - User is not authorized. -
429 Too many requests. -
+ */ + public ApiResponse + getUsageSummaryAvailableFieldsWithHttpInfo() throws ApiException { + Object localVarPostBody = null; + // create path and map variables + String localVarPath = "/api/v2/usage/summary/available_fields"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.getUsageSummaryAvailableFields", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json;datetime-format=rfc3339"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get available fields for usage summary. + * + *

See {@link #getUsageSummaryAvailableFieldsWithHttpInfo}. + * + * @return CompletableFuture<ApiResponse<UsageSummaryAvailableFieldsResponse>> + */ + public CompletableFuture> + getUsageSummaryAvailableFieldsWithHttpInfoAsync() { + Object localVarPostBody = null; + // create path and map variables + String localVarPath = "/api/v2/usage/summary/available_fields"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.getUsageSummaryAvailableFields", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json;datetime-format=rfc3339"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsAttributes.java b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsAttributes.java new file mode 100644 index 00000000000..3393ce72a6d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsAttributes.java @@ -0,0 +1,226 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * The lists of field names returned by GET /api/v1/usage/summary at each of its three + * response levels. Each list contains every key the data endpoint emits—both typed fields declared + * in the OpenAPI spec and untyped keys exposed through additionalProperties. + */ +@JsonPropertyOrder({ + UsageSummaryAvailableFieldsAttributes.JSON_PROPERTY_DATE_FIELDS, + UsageSummaryAvailableFieldsAttributes.JSON_PROPERTY_DATE_ORG_FIELDS, + UsageSummaryAvailableFieldsAttributes.JSON_PROPERTY_RESPONSE_FIELDS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageSummaryAvailableFieldsAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATE_FIELDS = "date_fields"; + private List dateFields = null; + + public static final String JSON_PROPERTY_DATE_ORG_FIELDS = "date_org_fields"; + private List dateOrgFields = null; + + public static final String JSON_PROPERTY_RESPONSE_FIELDS = "response_fields"; + private List responseFields = null; + + public UsageSummaryAvailableFieldsAttributes dateFields(List dateFields) { + this.dateFields = dateFields; + return this; + } + + public UsageSummaryAvailableFieldsAttributes addDateFieldsItem(String dateFieldsItem) { + if (this.dateFields == null) { + this.dateFields = new ArrayList<>(); + } + this.dateFields.add(dateFieldsItem); + return this; + } + + /** + * Sorted list of every key returned inside each UsageSummaryDate entry of + * usage[] (typed fields and additionalProperties keys combined). + * + * @return dateFields + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDateFields() { + return dateFields; + } + + public void setDateFields(List dateFields) { + this.dateFields = dateFields; + } + + public UsageSummaryAvailableFieldsAttributes dateOrgFields(List dateOrgFields) { + this.dateOrgFields = dateOrgFields; + return this; + } + + public UsageSummaryAvailableFieldsAttributes addDateOrgFieldsItem(String dateOrgFieldsItem) { + if (this.dateOrgFields == null) { + this.dateOrgFields = new ArrayList<>(); + } + this.dateOrgFields.add(dateOrgFieldsItem); + return this; + } + + /** + * Sorted list of every key returned inside each UsageSummaryDateOrg entry of + * usage[].orgs[] (typed fields and additionalProperties keys combined). + * + * @return dateOrgFields + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE_ORG_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDateOrgFields() { + return dateOrgFields; + } + + public void setDateOrgFields(List dateOrgFields) { + this.dateOrgFields = dateOrgFields; + } + + public UsageSummaryAvailableFieldsAttributes responseFields(List responseFields) { + this.responseFields = responseFields; + return this; + } + + public UsageSummaryAvailableFieldsAttributes addResponseFieldsItem(String responseFieldsItem) { + if (this.responseFields == null) { + this.responseFields = new ArrayList<>(); + } + this.responseFields.add(responseFieldsItem); + return this; + } + + /** + * Sorted list of every key returned as a direct property of UsageSummaryResponse + * (typed fields and additionalProperties keys combined). + * + * @return responseFields + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RESPONSE_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getResponseFields() { + return responseFields; + } + + public void setResponseFields(List responseFields) { + this.responseFields = responseFields; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return UsageSummaryAvailableFieldsAttributes + */ + @JsonAnySetter + public UsageSummaryAvailableFieldsAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this UsageSummaryAvailableFieldsAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageSummaryAvailableFieldsAttributes usageSummaryAvailableFieldsAttributes = + (UsageSummaryAvailableFieldsAttributes) o; + return Objects.equals(this.dateFields, usageSummaryAvailableFieldsAttributes.dateFields) + && Objects.equals(this.dateOrgFields, usageSummaryAvailableFieldsAttributes.dateOrgFields) + && Objects.equals(this.responseFields, usageSummaryAvailableFieldsAttributes.responseFields) + && Objects.equals( + this.additionalProperties, usageSummaryAvailableFieldsAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(dateFields, dateOrgFields, responseFields, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageSummaryAvailableFieldsAttributes {\n"); + sb.append(" dateFields: ").append(toIndentedString(dateFields)).append("\n"); + sb.append(" dateOrgFields: ").append(toIndentedString(dateOrgFields)).append("\n"); + sb.append(" responseFields: ").append(toIndentedString(responseFields)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsBody.java b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsBody.java new file mode 100644 index 00000000000..6a8874e9233 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsBody.java @@ -0,0 +1,203 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Available-fields data. */ +@JsonPropertyOrder({ + UsageSummaryAvailableFieldsBody.JSON_PROPERTY_ATTRIBUTES, + UsageSummaryAvailableFieldsBody.JSON_PROPERTY_ID, + UsageSummaryAvailableFieldsBody.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageSummaryAvailableFieldsBody { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private UsageSummaryAvailableFieldsAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private UsageSummaryAvailableFieldsType type = + UsageSummaryAvailableFieldsType.USAGE_SUMMARY_AVAILABLE_FIELDS; + + public UsageSummaryAvailableFieldsBody attributes( + UsageSummaryAvailableFieldsAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * The lists of field names returned by GET /api/v1/usage/summary at each of its + * three response levels. Each list contains every key the data endpoint emits—both typed fields + * declared in the OpenAPI spec and untyped keys exposed through additionalProperties + * . + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsageSummaryAvailableFieldsAttributes getAttributes() { + return attributes; + } + + public void setAttributes(UsageSummaryAvailableFieldsAttributes attributes) { + this.attributes = attributes; + } + + public UsageSummaryAvailableFieldsBody id(String id) { + this.id = id; + return this; + } + + /** + * The identifier for the discovery scope. Always "all". + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public UsageSummaryAvailableFieldsBody type(UsageSummaryAvailableFieldsType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of available-fields data. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsageSummaryAvailableFieldsType getType() { + return type; + } + + public void setType(UsageSummaryAvailableFieldsType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return UsageSummaryAvailableFieldsBody + */ + @JsonAnySetter + public UsageSummaryAvailableFieldsBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this UsageSummaryAvailableFieldsBody object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageSummaryAvailableFieldsBody usageSummaryAvailableFieldsBody = + (UsageSummaryAvailableFieldsBody) o; + return Objects.equals(this.attributes, usageSummaryAvailableFieldsBody.attributes) + && Objects.equals(this.id, usageSummaryAvailableFieldsBody.id) + && Objects.equals(this.type, usageSummaryAvailableFieldsBody.type) + && Objects.equals( + this.additionalProperties, usageSummaryAvailableFieldsBody.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageSummaryAvailableFieldsBody {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsResponse.java b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsResponse.java new file mode 100644 index 00000000000..8847b7ebbb2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsResponse.java @@ -0,0 +1,142 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Response listing every field name returned by GET /api/v1/usage/summary at each of + * its three response levels. Includes both typed fields and untyped additionalProperties + * keys. + */ +@JsonPropertyOrder({UsageSummaryAvailableFieldsResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageSummaryAvailableFieldsResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private UsageSummaryAvailableFieldsBody data; + + public UsageSummaryAvailableFieldsResponse data(UsageSummaryAvailableFieldsBody data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Available-fields data. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UsageSummaryAvailableFieldsBody getData() { + return data; + } + + public void setData(UsageSummaryAvailableFieldsBody data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return UsageSummaryAvailableFieldsResponse + */ + @JsonAnySetter + public UsageSummaryAvailableFieldsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this UsageSummaryAvailableFieldsResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageSummaryAvailableFieldsResponse usageSummaryAvailableFieldsResponse = + (UsageSummaryAvailableFieldsResponse) o; + return Objects.equals(this.data, usageSummaryAvailableFieldsResponse.data) + && Objects.equals( + this.additionalProperties, usageSummaryAvailableFieldsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageSummaryAvailableFieldsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsType.java b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsType.java new file mode 100644 index 00000000000..29ba75c4bb1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageSummaryAvailableFieldsType.java @@ -0,0 +1,58 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Type of available-fields data. */ +@JsonSerialize( + using = UsageSummaryAvailableFieldsType.UsageSummaryAvailableFieldsTypeSerializer.class) +public class UsageSummaryAvailableFieldsType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("usage_summary_available_fields")); + + public static final UsageSummaryAvailableFieldsType USAGE_SUMMARY_AVAILABLE_FIELDS = + new UsageSummaryAvailableFieldsType("usage_summary_available_fields"); + + UsageSummaryAvailableFieldsType(String value) { + super(value, allowedValues); + } + + public static class UsageSummaryAvailableFieldsTypeSerializer + extends StdSerializer { + public UsageSummaryAvailableFieldsTypeSerializer(Class t) { + super(t); + } + + public UsageSummaryAvailableFieldsTypeSerializer() { + this(null); + } + + @Override + public void serialize( + UsageSummaryAvailableFieldsType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static UsageSummaryAvailableFieldsType fromValue(String value) { + return new UsageSummaryAvailableFieldsType(value); + } +} diff --git a/src/test/resources/cassettes/features/v2/Get_available_fields_for_usage_summary_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Get_available_fields_for_usage_summary_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..b7c8122e839 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_available_fields_for_usage_summary_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2026-06-02T19:26:31.725Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_available_fields_for_usage_summary_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Get_available_fields_for_usage_summary_returns_Bad_Request_response.json new file mode 100644 index 00000000000..c46c96dc355 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_available_fields_for_usage_summary_returns_Bad_Request_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/usage/summary/available_fields", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"id\":null,\"links\":null,\"status\":\"400\",\"code\":null,\"title\":\"Bad Request\",\"detail\":\"API called with non-parent org keys. Data is only available at the root level org\",\"source\":null,\"meta\":null}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d877ef2f-4ae0-ae60-4678-48aa4f88a764" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 211637b2390..759f88e06cf 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -8562,6 +8562,12 @@ "type": "safe" } }, + "GetUsageSummaryAvailableFields": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetUsageAttributionTypes": { "tag": "Usage Metering", "undo": { 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 aedd42d8d52..ca4cfbd6706 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 @@ -44,6 +44,29 @@ Feature: Usage Metering When the request is sent Then the response status is 200 OK + @team:DataDog/billing-hub + Scenario: Get available fields for usage summary returns "Bad Request" response + Given new "GetUsageSummaryAvailableFields" request + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/billing-hub + Scenario: Get available fields for usage summary returns "OK" response + Given new "GetUsageSummaryAvailableFields" request + When the request is sent + Then the response status is 200 OK + And the response "data.id" is equal to "all" + And the response "data.type" is equal to "usage_summary_available_fields" + And the response "data.attributes" has field "response_fields" + And the response "data.attributes" has field "date_fields" + And the response "data.attributes" has field "date_org_fields" + + @generated @skip @team:DataDog/billing-hub + Scenario: Get available fields for usage summary returns "OK." response + Given new "GetUsageSummaryAvailableFields" request + When the request is sent + Then the response status is 200 OK. + @team:DataDog/billing-hub Scenario: Get billing dimension mapping for usage endpoints returns "Bad Request" response Given new "GetBillingDimensionMapping" request