diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c5df769feb9..54bf1c8bf5a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -90741,6 +90741,85 @@ components: meta: $ref: "#/components/schemas/MonthlyCostAttributionMeta" type: object + MonthlyResource: + description: A resource's usage for the requested billing dimension and month. + properties: + attributes: + $ref: "#/components/schemas/MonthlyResourceAttributes" + id: + description: Identifier for the resource usage record. Treat this value as opaque. + type: string + type: + $ref: "#/components/schemas/MonthlyResourceType" + type: object + MonthlyResourceAttributes: + description: Resource usage and organization details for the requested month. + properties: + data_date: + description: Date of the source usage data. May be empty when unavailable. + type: string + org_name: + description: Name of the organization that owns the resource. + type: string + public_id: + description: Public ID of the organization that owns the resource. + type: string + resource_name: + description: Name of the resource, such as a host name, metric name, or log index. + type: string + resource_type: + description: Usage type of the resource. Values depend on the billing dimension and are not limited to host types. + type: string + tags: + additionalProperties: + type: string + description: Resource tags when available. Empty for resource types without tag data. + type: object + timestamp: + description: Selected billing hour for percentile usage, or the first day of the month for monthly usage. May be empty when unavailable. + type: string + usage_value: + description: Usage attributed to the resource in the units of the requested billing dimension. Values can be fractional. + format: double + nullable: true + type: number + type: object + MonthlyResourceType: + default: monthly_resource + description: Type of a monthly resource usage record. + enum: + - monthly_resource + type: string + x-enum-varnames: + - MONTHLY_RESOURCE + MonthlyResourcesMetadata: + description: Metadata for monthly resource usage. + properties: + pagination: + $ref: "#/components/schemas/MonthlyResourcesPagination" + type: object + MonthlyResourcesPagination: + description: Pagination information for monthly resource usage. + properties: + next_record_id: + description: Cursor for the next request. Pass as `page[next_record_id]` with the same filters. Null when there are no more results. + nullable: true + type: string + sort_direction: + description: Direction used to order the results, either `ASC` or `DESC`. Ordering depends on the billing dimension. + type: string + type: object + MonthlyResourcesResponse: + description: Monthly usage for host and non-host resources. + properties: + data: + description: Resource usage records. Empty when no matching resources are available. + items: + $ref: "#/components/schemas/MonthlyResource" + type: array + meta: + $ref: "#/components/schemas/MonthlyResourcesMetadata" + type: object MuteDataType: default: mute description: Mute resource type. @@ -268603,6 +268682,154 @@ paths: operator: OR permissions: - usage_read + /api/v2/usage/monthly_resources: + get: + description: |- + Get resource-level usage for a billing dimension and month, using the same + data as the resource breakdown in Plan & Usage. Supports all host and + non-host resource types available in that breakdown. Availability depends + on the billing dimension and the organization's usage data. + + Results are scoped to the authenticated organization. Set `filter[include_descendants]` + to `true` to also return usage from its descendant organizations in all regions. + + Set `filter[view]` to `billable` to return resources that contribute to billable usage. + For dimensions billed at the 99th percentile, this view returns resources at the + selected billing hour. For sum-based dimensions, it returns monthly resource usage. + Set `filter[view]` to `all` to return the full monthly resource breakdown. Requests + for unsupported billing dimensions, or dimensions configured with an unsupported + billing aggregation method, return a `400 Bad Request` error. + + To get the next page of results, pass the `meta.pagination.next_record_id` value + from the previous response as `page[next_record_id]`, and keep all filters unchanged. + A null cursor indicates the last page. Each response contains at most `page[limit]` + resource records. This limit applies to all queries, including billable queries and + queries across descendant organizations. + operationId: GetUsageMonthlyResources + parameters: + - description: Billing dimension to retrieve, such as `infra_host`, `indexed_points`, or `logs_indexed_30day`. + example: infra_host + in: query + name: filter[billing_dimension] + required: true + schema: + type: string + - description: Month of usage to retrieve in `YYYY-MM` format. + example: "2026-04" + in: query + name: filter[month] + required: true + schema: + type: string + - description: |- + Set to `billable` to return resources that contribute to billable usage, or `all` + to return the full monthly resource breakdown. + example: billable + in: query + name: filter[view] + required: true + schema: + type: string + - description: Include usage for descendant organizations of the authenticated organization. + in: query + name: filter[include_descendants] + required: false + schema: + default: false + type: boolean + - description: |- + Maximum number of resource records per response. Must be a positive integer. + Values above 100,000 are capped at 100,000. + in: query + name: page[limit] + required: false + schema: + default: 100000 + format: int64 + maximum: 100000 + minimum: 1 + type: integer + - description: Opaque cursor from `meta.pagination.next_record_id` in the previous response. Omit for the first request. + in: query + name: page[next_record_id] + required: false + schema: + type: string + responses: + "200": + content: + application/json;datetime-format=rfc3339: + examples: + default: + value: + data: + - attributes: + data_date: "2026-04-30" + org_name: Example organization + public_id: abc123 + resource_name: host-1.prod + resource_type: agent + tags: + env: prod + timestamp: "2026-04-22 16:00:00+00:00" + usage_value: 1 + id: abc123_agent_host-1.prod + type: monthly_resource + meta: + pagination: + next_record_id: + sort_direction: ASC + non_host: + value: + data: + - attributes: + data_date: "2026-04-30" + org_name: Example organization + public_id: abc123 + resource_name: app.requests + resource_type: post_threshold_indexed + tags: {} + timestamp: "2026-04-01" + usage_value: 1250.5 + id: abc123_post_threshold_indexed_app.requests + type: monthly_resource + meta: + pagination: + next_record_id: + sort_direction: DESC + schema: + $ref: "#/components/schemas/MonthlyResourcesResponse" + description: OK + "400": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "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 monthly usage by resource + tags: + - Usage Metering + "x-permission": + operator: OR + permissions: + - usage_read /api/v2/usage/observability_pipelines: get: deprecated: true diff --git a/examples/v2/usage-metering/GetUsageMonthlyResources.java b/examples/v2/usage-metering/GetUsageMonthlyResources.java new file mode 100644 index 00000000000..d5538ef8407 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageMonthlyResources.java @@ -0,0 +1,31 @@ +// Get monthly usage by resource 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.api.UsageMeteringApi.GetUsageMonthlyResourcesOptionalParameters; +import com.datadog.api.client.v2.model.MonthlyResourcesResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + MonthlyResourcesResponse result = + apiInstance.getUsageMonthlyResources( + "infra_host", + "2026-04", + "all", + new GetUsageMonthlyResourcesOptionalParameters().pageLimit(1L)); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#getUsageMonthlyResources"); + 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/GetUsageMonthlyResources_1935480325.java b/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.java new file mode 100644 index 00000000000..bf1fee8d4f2 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.java @@ -0,0 +1,31 @@ +// Get monthly usage by resource supports non-host resources + +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.GetUsageMonthlyResourcesOptionalParameters; +import com.datadog.api.client.v2.model.MonthlyResourcesResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + MonthlyResourcesResponse result = + apiInstance.getUsageMonthlyResources( + "indexed_points", + "2026-04", + "all", + new GetUsageMonthlyResourcesOptionalParameters().pageLimit(1L)); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#getUsageMonthlyResources"); + 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/v2/api/UsageMeteringApi.java b/src/main/java/com/datadog/api/client/v2/api/UsageMeteringApi.java index 5987c4a4bfc..0c3a1fb6cd6 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 @@ -11,6 +11,7 @@ import com.datadog.api.client.v2.model.CostByOrgResponse; import com.datadog.api.client.v2.model.HourlyUsageResponse; import com.datadog.api.client.v2.model.MonthlyCostAttributionResponse; +import com.datadog.api.client.v2.model.MonthlyResourcesResponse; import com.datadog.api.client.v2.model.ProjectedCostResponse; import com.datadog.api.client.v2.model.SortDirection; import com.datadog.api.client.v2.model.TemporaryGrantRequestCreateRequest; @@ -4733,6 +4734,354 @@ public UsageLambdaTracedInvocationsResponse getUsageLambdaTracedInvocations( new GenericType() {}); } + /** Manage optional parameters to getUsageMonthlyResources. */ + public static class GetUsageMonthlyResourcesOptionalParameters { + private Boolean filterIncludeDescendants; + private Long pageLimit; + private String pageNextRecordId; + + /** + * Set filterIncludeDescendants. + * + * @param filterIncludeDescendants Include usage for descendant organizations of the + * authenticated organization. (optional, default to false) + * @return GetUsageMonthlyResourcesOptionalParameters + */ + public GetUsageMonthlyResourcesOptionalParameters filterIncludeDescendants( + Boolean filterIncludeDescendants) { + this.filterIncludeDescendants = filterIncludeDescendants; + return this; + } + + /** + * Set pageLimit. + * + * @param pageLimit Maximum number of resource records per response. Must be a positive integer. + * Values above 100,000 are capped at 100,000. (optional, default to 100000) + * @return GetUsageMonthlyResourcesOptionalParameters + */ + public GetUsageMonthlyResourcesOptionalParameters pageLimit(Long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set pageNextRecordId. + * + * @param pageNextRecordId Opaque cursor from meta.pagination.next_record_id in the + * previous response. Omit for the first request. (optional) + * @return GetUsageMonthlyResourcesOptionalParameters + */ + public GetUsageMonthlyResourcesOptionalParameters pageNextRecordId(String pageNextRecordId) { + this.pageNextRecordId = pageNextRecordId; + return this; + } + } + + /** + * Get monthly usage by resource. + * + *

See {@link #getUsageMonthlyResourcesWithHttpInfo}. + * + * @param filterBillingDimension Billing dimension to retrieve, such as infra_host, + * indexed_points, or logs_indexed_30day. (required) + * @param filterMonth Month of usage to retrieve in YYYY-MM format. (required) + * @param filterView Set to billable to return resources that contribute to billable + * usage, or all to return the full monthly resource breakdown. (required) + * @return MonthlyResourcesResponse + * @throws ApiException if fails to make API call + */ + public MonthlyResourcesResponse getUsageMonthlyResources( + String filterBillingDimension, String filterMonth, String filterView) throws ApiException { + return getUsageMonthlyResourcesWithHttpInfo( + filterBillingDimension, + filterMonth, + filterView, + new GetUsageMonthlyResourcesOptionalParameters()) + .getData(); + } + + /** + * Get monthly usage by resource. + * + *

See {@link #getUsageMonthlyResourcesWithHttpInfoAsync}. + * + * @param filterBillingDimension Billing dimension to retrieve, such as infra_host, + * indexed_points, or logs_indexed_30day. (required) + * @param filterMonth Month of usage to retrieve in YYYY-MM format. (required) + * @param filterView Set to billable to return resources that contribute to billable + * usage, or all to return the full monthly resource breakdown. (required) + * @return CompletableFuture<MonthlyResourcesResponse> + */ + public CompletableFuture getUsageMonthlyResourcesAsync( + String filterBillingDimension, String filterMonth, String filterView) { + return getUsageMonthlyResourcesWithHttpInfoAsync( + filterBillingDimension, + filterMonth, + filterView, + new GetUsageMonthlyResourcesOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get monthly usage by resource. + * + *

See {@link #getUsageMonthlyResourcesWithHttpInfo}. + * + * @param filterBillingDimension Billing dimension to retrieve, such as infra_host, + * indexed_points, or logs_indexed_30day. (required) + * @param filterMonth Month of usage to retrieve in YYYY-MM format. (required) + * @param filterView Set to billable to return resources that contribute to billable + * usage, or all to return the full monthly resource breakdown. (required) + * @param parameters Optional parameters for the request. + * @return MonthlyResourcesResponse + * @throws ApiException if fails to make API call + */ + public MonthlyResourcesResponse getUsageMonthlyResources( + String filterBillingDimension, + String filterMonth, + String filterView, + GetUsageMonthlyResourcesOptionalParameters parameters) + throws ApiException { + return getUsageMonthlyResourcesWithHttpInfo( + filterBillingDimension, filterMonth, filterView, parameters) + .getData(); + } + + /** + * Get monthly usage by resource. + * + *

See {@link #getUsageMonthlyResourcesWithHttpInfoAsync}. + * + * @param filterBillingDimension Billing dimension to retrieve, such as infra_host, + * indexed_points, or logs_indexed_30day. (required) + * @param filterMonth Month of usage to retrieve in YYYY-MM format. (required) + * @param filterView Set to billable to return resources that contribute to billable + * usage, or all to return the full monthly resource breakdown. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<MonthlyResourcesResponse> + */ + public CompletableFuture getUsageMonthlyResourcesAsync( + String filterBillingDimension, + String filterMonth, + String filterView, + GetUsageMonthlyResourcesOptionalParameters parameters) { + return getUsageMonthlyResourcesWithHttpInfoAsync( + filterBillingDimension, filterMonth, filterView, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get resource-level usage for a billing dimension and month, using the same data as the resource + * breakdown in Plan & Usage. Supports all host and non-host resource types available in that + * breakdown. Availability depends on the billing dimension and the organization's usage data. + * + *

Results are scoped to the authenticated organization. Set filter[include_descendants] + * to true to also return usage from its descendant organizations in all + * regions. + * + *

Set filter[view] to billable to return resources that contribute + * to billable usage. For dimensions billed at the 99th percentile, this view returns resources at + * the selected billing hour. For sum-based dimensions, it returns monthly resource usage. Set + * filter[view] to all to return the full monthly resource breakdown. + * Requests for unsupported billing dimensions, or dimensions configured with an unsupported + * billing aggregation method, return a 400 Bad Request error. + * + *

To get the next page of results, pass the meta.pagination.next_record_id value + * from the previous response as page[next_record_id], and keep all filters + * unchanged. A null cursor indicates the last page. Each response contains at most + * page[limit] resource records. This limit applies to all queries, including billable + * queries and queries across descendant organizations. + * + * @param filterBillingDimension Billing dimension to retrieve, such as infra_host, + * indexed_points, or logs_indexed_30day. (required) + * @param filterMonth Month of usage to retrieve in YYYY-MM format. (required) + * @param filterView Set to billable to return resources that contribute to billable + * usage, or all to return the full monthly resource breakdown. (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<MonthlyResourcesResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden - User is not authorized -
429 Too many requests -
+ */ + public ApiResponse getUsageMonthlyResourcesWithHttpInfo( + String filterBillingDimension, + String filterMonth, + String filterView, + GetUsageMonthlyResourcesOptionalParameters parameters) + throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'filterBillingDimension' is set + if (filterBillingDimension == null) { + throw new ApiException( + 400, + "Missing the required parameter 'filterBillingDimension' when calling" + + " getUsageMonthlyResources"); + } + + // verify the required parameter 'filterMonth' is set + if (filterMonth == null) { + throw new ApiException( + 400, + "Missing the required parameter 'filterMonth' when calling getUsageMonthlyResources"); + } + + // verify the required parameter 'filterView' is set + if (filterView == null) { + throw new ApiException( + 400, "Missing the required parameter 'filterView' when calling getUsageMonthlyResources"); + } + Boolean filterIncludeDescendants = parameters.filterIncludeDescendants; + Long pageLimit = parameters.pageLimit; + String pageNextRecordId = parameters.pageNextRecordId; + // create path and map variables + String localVarPath = "/api/v2/usage/monthly_resources"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "filter[billing_dimension]", filterBillingDimension)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[month]", filterMonth)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[view]", filterView)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "filter[include_descendants]", filterIncludeDescendants)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[limit]", pageLimit)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "page[next_record_id]", pageNextRecordId)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.getUsageMonthlyResources", + localVarPath, + localVarQueryParams, + 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 monthly usage by resource. + * + *

See {@link #getUsageMonthlyResourcesWithHttpInfo}. + * + * @param filterBillingDimension Billing dimension to retrieve, such as infra_host, + * indexed_points, or logs_indexed_30day. (required) + * @param filterMonth Month of usage to retrieve in YYYY-MM format. (required) + * @param filterView Set to billable to return resources that contribute to billable + * usage, or all to return the full monthly resource breakdown. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<MonthlyResourcesResponse>> + */ + public CompletableFuture> + getUsageMonthlyResourcesWithHttpInfoAsync( + String filterBillingDimension, + String filterMonth, + String filterView, + GetUsageMonthlyResourcesOptionalParameters parameters) { + Object localVarPostBody = null; + + // verify the required parameter 'filterBillingDimension' is set + if (filterBillingDimension == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'filterBillingDimension' when calling" + + " getUsageMonthlyResources")); + return result; + } + + // verify the required parameter 'filterMonth' is set + if (filterMonth == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'filterMonth' when calling" + + " getUsageMonthlyResources")); + return result; + } + + // verify the required parameter 'filterView' is set + if (filterView == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'filterView' when calling getUsageMonthlyResources")); + return result; + } + Boolean filterIncludeDescendants = parameters.filterIncludeDescendants; + Long pageLimit = parameters.pageLimit; + String pageNextRecordId = parameters.pageNextRecordId; + // create path and map variables + String localVarPath = "/api/v2/usage/monthly_resources"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "filter[billing_dimension]", filterBillingDimension)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[month]", filterMonth)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[view]", filterView)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "filter[include_descendants]", filterIncludeDescendants)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[limit]", pageLimit)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "page[next_record_id]", pageNextRecordId)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.getUsageMonthlyResources", + localVarPath, + localVarQueryParams, + 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() {}); + } + /** Manage optional parameters to getUsageObservabilityPipelines. */ public static class GetUsageObservabilityPipelinesOptionalParameters { private OffsetDateTime endHr; diff --git a/src/main/java/com/datadog/api/client/v2/model/MonthlyResource.java b/src/main/java/com/datadog/api/client/v2/model/MonthlyResource.java new file mode 100644 index 00000000000..85a9ae2f78c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonthlyResource.java @@ -0,0 +1,199 @@ +/* + * 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; + +/** A resource's usage for the requested billing dimension and month. */ +@JsonPropertyOrder({ + MonthlyResource.JSON_PROPERTY_ATTRIBUTES, + MonthlyResource.JSON_PROPERTY_ID, + MonthlyResource.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonthlyResource { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private MonthlyResourceAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private MonthlyResourceType type = MonthlyResourceType.MONTHLY_RESOURCE; + + public MonthlyResource attributes(MonthlyResourceAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Resource usage and organization details for the requested month. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MonthlyResourceAttributes getAttributes() { + return attributes; + } + + public void setAttributes(MonthlyResourceAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public MonthlyResource id(String id) { + this.id = id; + return this; + } + + /** + * Identifier for the resource usage record. Treat this value as opaque. + * + * @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 MonthlyResource type(MonthlyResourceType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of a monthly resource usage record. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MonthlyResourceType getType() { + return type; + } + + public void setType(MonthlyResourceType 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 MonthlyResource + */ + @JsonAnySetter + public MonthlyResource 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 MonthlyResource object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonthlyResource monthlyResource = (MonthlyResource) o; + return Objects.equals(this.attributes, monthlyResource.attributes) + && Objects.equals(this.id, monthlyResource.id) + && Objects.equals(this.type, monthlyResource.type) + && Objects.equals(this.additionalProperties, monthlyResource.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonthlyResource {\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/MonthlyResourceAttributes.java b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourceAttributes.java new file mode 100644 index 00000000000..bb7b3405e0e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourceAttributes.java @@ -0,0 +1,358 @@ +/* + * 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; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Resource usage and organization details for the requested month. */ +@JsonPropertyOrder({ + MonthlyResourceAttributes.JSON_PROPERTY_DATA_DATE, + MonthlyResourceAttributes.JSON_PROPERTY_ORG_NAME, + MonthlyResourceAttributes.JSON_PROPERTY_PUBLIC_ID, + MonthlyResourceAttributes.JSON_PROPERTY_RESOURCE_NAME, + MonthlyResourceAttributes.JSON_PROPERTY_RESOURCE_TYPE, + MonthlyResourceAttributes.JSON_PROPERTY_TAGS, + MonthlyResourceAttributes.JSON_PROPERTY_TIMESTAMP, + MonthlyResourceAttributes.JSON_PROPERTY_USAGE_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonthlyResourceAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA_DATE = "data_date"; + private String dataDate; + + public static final String JSON_PROPERTY_ORG_NAME = "org_name"; + private String orgName; + + public static final String JSON_PROPERTY_PUBLIC_ID = "public_id"; + private String publicId; + + public static final String JSON_PROPERTY_RESOURCE_NAME = "resource_name"; + private String resourceName; + + public static final String JSON_PROPERTY_RESOURCE_TYPE = "resource_type"; + private String resourceType; + + public static final String JSON_PROPERTY_TAGS = "tags"; + private Map tags = null; + + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private String timestamp; + + public static final String JSON_PROPERTY_USAGE_VALUE = "usage_value"; + private JsonNullable usageValue = JsonNullable.undefined(); + + public MonthlyResourceAttributes dataDate(String dataDate) { + this.dataDate = dataDate; + return this; + } + + /** + * Date of the source usage data. May be empty when unavailable. + * + * @return dataDate + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDataDate() { + return dataDate; + } + + public void setDataDate(String dataDate) { + this.dataDate = dataDate; + } + + public MonthlyResourceAttributes orgName(String orgName) { + this.orgName = orgName; + return this; + } + + /** + * Name of the organization that owns the resource. + * + * @return orgName + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ORG_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public MonthlyResourceAttributes publicId(String publicId) { + this.publicId = publicId; + return this; + } + + /** + * Public ID of the organization that owns the resource. + * + * @return publicId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PUBLIC_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPublicId() { + return publicId; + } + + public void setPublicId(String publicId) { + this.publicId = publicId; + } + + public MonthlyResourceAttributes resourceName(String resourceName) { + this.resourceName = resourceName; + return this; + } + + /** + * Name of the resource, such as a host name, metric name, or log index. + * + * @return resourceName + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RESOURCE_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public MonthlyResourceAttributes resourceType(String resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + * Usage type of the resource. Values depend on the billing dimension and are not limited to host + * types. + * + * @return resourceType + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RESOURCE_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public MonthlyResourceAttributes tags(Map tags) { + this.tags = tags; + return this; + } + + public MonthlyResourceAttributes putTagsItem(String key, String tagsItem) { + if (this.tags == null) { + this.tags = new HashMap<>(); + } + this.tags.put(key, tagsItem); + return this; + } + + /** + * Resource tags when available. Empty for resource types without tag data. + * + * @return tags + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getTags() { + return tags; + } + + public void setTags(Map tags) { + this.tags = tags; + } + + public MonthlyResourceAttributes timestamp(String timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Selected billing hour for percentile usage, or the first day of the month for monthly usage. + * May be empty when unavailable. + * + * @return timestamp + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public MonthlyResourceAttributes usageValue(Double usageValue) { + this.usageValue = JsonNullable.of(usageValue); + return this; + } + + /** + * Usage attributed to the resource in the units of the requested billing dimension. Values can be + * fractional. + * + * @return usageValue + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Double getUsageValue() { + return usageValue.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_USAGE_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getUsageValue_JsonNullable() { + return usageValue; + } + + @JsonProperty(JSON_PROPERTY_USAGE_VALUE) + public void setUsageValue_JsonNullable(JsonNullable usageValue) { + this.usageValue = usageValue; + } + + public void setUsageValue(Double usageValue) { + this.usageValue = JsonNullable.of(usageValue); + } + + /** + * 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 MonthlyResourceAttributes + */ + @JsonAnySetter + public MonthlyResourceAttributes 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 MonthlyResourceAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonthlyResourceAttributes monthlyResourceAttributes = (MonthlyResourceAttributes) o; + return Objects.equals(this.dataDate, monthlyResourceAttributes.dataDate) + && Objects.equals(this.orgName, monthlyResourceAttributes.orgName) + && Objects.equals(this.publicId, monthlyResourceAttributes.publicId) + && Objects.equals(this.resourceName, monthlyResourceAttributes.resourceName) + && Objects.equals(this.resourceType, monthlyResourceAttributes.resourceType) + && Objects.equals(this.tags, monthlyResourceAttributes.tags) + && Objects.equals(this.timestamp, monthlyResourceAttributes.timestamp) + && Objects.equals(this.usageValue, monthlyResourceAttributes.usageValue) + && Objects.equals( + this.additionalProperties, monthlyResourceAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + dataDate, + orgName, + publicId, + resourceName, + resourceType, + tags, + timestamp, + usageValue, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonthlyResourceAttributes {\n"); + sb.append(" dataDate: ").append(toIndentedString(dataDate)).append("\n"); + sb.append(" orgName: ").append(toIndentedString(orgName)).append("\n"); + sb.append(" publicId: ").append(toIndentedString(publicId)).append("\n"); + sb.append(" resourceName: ").append(toIndentedString(resourceName)).append("\n"); + sb.append(" resourceType: ").append(toIndentedString(resourceType)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" usageValue: ").append(toIndentedString(usageValue)).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/MonthlyResourceType.java b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourceType.java new file mode 100644 index 00000000000..ede36048acd --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourceType.java @@ -0,0 +1,56 @@ +/* + * 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 a monthly resource usage record. */ +@JsonSerialize(using = MonthlyResourceType.MonthlyResourceTypeSerializer.class) +public class MonthlyResourceType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("monthly_resource")); + + public static final MonthlyResourceType MONTHLY_RESOURCE = + new MonthlyResourceType("monthly_resource"); + + MonthlyResourceType(String value) { + super(value, allowedValues); + } + + public static class MonthlyResourceTypeSerializer extends StdSerializer { + public MonthlyResourceTypeSerializer(Class t) { + super(t); + } + + public MonthlyResourceTypeSerializer() { + this(null); + } + + @Override + public void serialize( + MonthlyResourceType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static MonthlyResourceType fromValue(String value) { + return new MonthlyResourceType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesMetadata.java b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesMetadata.java new file mode 100644 index 00000000000..7f57a4bd5b7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesMetadata.java @@ -0,0 +1,139 @@ +/* + * 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; + +/** Metadata for monthly resource usage. */ +@JsonPropertyOrder({MonthlyResourcesMetadata.JSON_PROPERTY_PAGINATION}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonthlyResourcesMetadata { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PAGINATION = "pagination"; + private MonthlyResourcesPagination pagination; + + public MonthlyResourcesMetadata pagination(MonthlyResourcesPagination pagination) { + this.pagination = pagination; + this.unparsed |= pagination.unparsed; + return this; + } + + /** + * Pagination information for monthly resource usage. + * + * @return pagination + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGINATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MonthlyResourcesPagination getPagination() { + return pagination; + } + + public void setPagination(MonthlyResourcesPagination pagination) { + this.pagination = pagination; + if (pagination != null) { + this.unparsed |= pagination.unparsed; + } + } + + /** + * 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 MonthlyResourcesMetadata + */ + @JsonAnySetter + public MonthlyResourcesMetadata 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 MonthlyResourcesMetadata object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonthlyResourcesMetadata monthlyResourcesMetadata = (MonthlyResourcesMetadata) o; + return Objects.equals(this.pagination, monthlyResourcesMetadata.pagination) + && Objects.equals(this.additionalProperties, monthlyResourcesMetadata.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(pagination, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonthlyResourcesMetadata {\n"); + sb.append(" pagination: ").append(toIndentedString(pagination)).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/MonthlyResourcesPagination.java b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesPagination.java new file mode 100644 index 00000000000..382ec65cb63 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesPagination.java @@ -0,0 +1,178 @@ +/* + * 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; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Pagination information for monthly resource usage. */ +@JsonPropertyOrder({ + MonthlyResourcesPagination.JSON_PROPERTY_NEXT_RECORD_ID, + MonthlyResourcesPagination.JSON_PROPERTY_SORT_DIRECTION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonthlyResourcesPagination { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NEXT_RECORD_ID = "next_record_id"; + private JsonNullable nextRecordId = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_SORT_DIRECTION = "sort_direction"; + private String sortDirection; + + public MonthlyResourcesPagination nextRecordId(String nextRecordId) { + this.nextRecordId = JsonNullable.of(nextRecordId); + return this; + } + + /** + * Cursor for the next request. Pass as page[next_record_id] with the same filters. + * Null when there are no more results. + * + * @return nextRecordId + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getNextRecordId() { + return nextRecordId.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NEXT_RECORD_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getNextRecordId_JsonNullable() { + return nextRecordId; + } + + @JsonProperty(JSON_PROPERTY_NEXT_RECORD_ID) + public void setNextRecordId_JsonNullable(JsonNullable nextRecordId) { + this.nextRecordId = nextRecordId; + } + + public void setNextRecordId(String nextRecordId) { + this.nextRecordId = JsonNullable.of(nextRecordId); + } + + public MonthlyResourcesPagination sortDirection(String sortDirection) { + this.sortDirection = sortDirection; + return this; + } + + /** + * Direction used to order the results, either ASC or DESC. Ordering + * depends on the billing dimension. + * + * @return sortDirection + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SORT_DIRECTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSortDirection() { + return sortDirection; + } + + public void setSortDirection(String sortDirection) { + this.sortDirection = sortDirection; + } + + /** + * 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 MonthlyResourcesPagination + */ + @JsonAnySetter + public MonthlyResourcesPagination 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 MonthlyResourcesPagination object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonthlyResourcesPagination monthlyResourcesPagination = (MonthlyResourcesPagination) o; + return Objects.equals(this.nextRecordId, monthlyResourcesPagination.nextRecordId) + && Objects.equals(this.sortDirection, monthlyResourcesPagination.sortDirection) + && Objects.equals( + this.additionalProperties, monthlyResourcesPagination.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(nextRecordId, sortDirection, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonthlyResourcesPagination {\n"); + sb.append(" nextRecordId: ").append(toIndentedString(nextRecordId)).append("\n"); + sb.append(" sortDirection: ").append(toIndentedString(sortDirection)).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/MonthlyResourcesResponse.java b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesResponse.java new file mode 100644 index 00000000000..8ee3ee207c7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonthlyResourcesResponse.java @@ -0,0 +1,189 @@ +/* + * 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; + +/** Monthly usage for host and non-host resources. */ +@JsonPropertyOrder({ + MonthlyResourcesResponse.JSON_PROPERTY_DATA, + MonthlyResourcesResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonthlyResourcesResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public static final String JSON_PROPERTY_META = "meta"; + private MonthlyResourcesMetadata meta; + + public MonthlyResourcesResponse data(List data) { + this.data = data; + if (data != null) { + for (MonthlyResource item : data) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public MonthlyResourcesResponse addDataItem(MonthlyResource dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Resource usage records. Empty when no matching resources are available. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + if (data != null) { + for (MonthlyResource item : data) { + this.unparsed |= item.unparsed; + } + } + } + + public MonthlyResourcesResponse meta(MonthlyResourcesMetadata meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Metadata for monthly resource usage. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MonthlyResourcesMetadata getMeta() { + return meta; + } + + public void setMeta(MonthlyResourcesMetadata meta) { + this.meta = meta; + if (meta != null) { + this.unparsed |= meta.unparsed; + } + } + + /** + * 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 MonthlyResourcesResponse + */ + @JsonAnySetter + public MonthlyResourcesResponse 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 MonthlyResourcesResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonthlyResourcesResponse monthlyResourcesResponse = (MonthlyResourcesResponse) o; + return Objects.equals(this.data, monthlyResourcesResponse.data) + && Objects.equals(this.meta, monthlyResourcesResponse.meta) + && Objects.equals(this.additionalProperties, monthlyResourcesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonthlyResourcesResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).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/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 993492a315c..b5793a2f4b4 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 @@ -11672,6 +11672,12 @@ "type": "safe" } }, + "GetUsageMonthlyResources": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetUsageObservabilityPipelines": { "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 67ba7beacef..783eab95a1d 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 @@ -451,6 +451,42 @@ Feature: Usage Metering And the response "data[0].type" is equal to "usage_timeseries" And the response "data[0].attributes.product_family" is equal to "observability-pipelines" + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource returns "Bad Request" response + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "infra_host" + And request contains "filter[month]" parameter with value "not-a-month" + And request contains "filter[view]" parameter with value "all" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors[0].status" is equal to "400" + And the response "errors[0].title" is equal to "Bad Request" + And the response "errors[0]" has field "detail" + + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource returns "OK" response + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "infra_host" + And request contains "filter[month]" parameter with value "2026-04" + And request contains "filter[view]" parameter with value "all" + And request contains "page[limit]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "meta" has field "pagination" + And the response "meta.pagination" has field "next_record_id" + + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource supports non-host resources + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "indexed_points" + And request contains "filter[month]" parameter with value "2026-04" + And request contains "filter[view]" parameter with value "all" + And request contains "page[limit]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "meta" has field "pagination" + And the response "meta.pagination" has field "next_record_id" + @generated @skip @team:ddoghq/billing-hub Scenario: Get projected cost across your account returns "Bad Request" response Given new "GetProjectedCost" request