From 17a8bcbced29fa4a1b04dc3a542231772ce51a61 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 19 Aug 2026 20:35:23 +0000 Subject: [PATCH] Regenerate client from commit 0f1084c of spec repo --- .generator/schemas/v2/openapi.yaml | 554 ++++++++++ .../usage-metering/CreateOrUpdateQuotas.java | 44 + examples/v2/usage-metering/DeleteQuota.java | 23 + examples/v2/usage-metering/ListQuotas.java | 25 + .../usage-metering/ListQuotas_918754421.java | 27 + examples/v2/usage-metering/UpdateQuota.java | 43 + .../com/datadog/api/client/ApiClient.java | 4 + .../api/client/v2/api/UsageMeteringApi.java | 994 ++++++++++++++++++ .../v2/model/UsageQuotaCreateAttributes.java | 244 +++++ .../client/v2/model/UsageQuotaCreateData.java | 184 ++++ .../client/v2/model/UsageQuotaResponse.java | 148 +++ .../model/UsageQuotaResponseAttributes.java | 241 +++++ .../v2/model/UsageQuotaResponseData.java | 213 ++++ .../api/client/v2/model/UsageQuotaType.java | 53 + .../v2/model/UsageQuotaUpdateAttributes.java | 229 ++++ .../client/v2/model/UsageQuotaUpdateData.java | 212 ++++ .../v2/model/UsageQuotaUpdateRequest.java | 148 +++ .../v2/model/UsageQuotasCreateRequest.java | 165 +++ .../v2/model/UsageQuotasListResponse.java | 203 ++++ .../client/v2/model/UsageQuotasResponse.java | 163 +++ .../v2/model/UsageQuotasResponseMeta.java | 150 +++ .../com/datadog/api/client/v2/api/undo.json | 24 + .../api/client/v2/api/usage_metering.feature | 90 ++ 23 files changed, 4181 insertions(+) create mode 100644 examples/v2/usage-metering/CreateOrUpdateQuotas.java create mode 100644 examples/v2/usage-metering/DeleteQuota.java create mode 100644 examples/v2/usage-metering/ListQuotas.java create mode 100644 examples/v2/usage-metering/ListQuotas_918754421.java create mode 100644 examples/v2/usage-metering/UpdateQuota.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponseAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponseData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotasCreateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotasListResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotasResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UsageQuotasResponseMeta.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 982af418809..726d01d4a5b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -117055,6 +117055,210 @@ components: $ref: "#/components/schemas/UsageDataObject" type: array type: object + UsageQuotaCreateAttributes: + description: Attributes for creating or updating a usage quota by scope. + properties: + enforced: + description: Whether to actively block usage above the limit instead of only tracking or alerting on it. + example: true + type: boolean + org_public_id: + description: The public ID of the caller's organization or one of its descendants that should own the quota. This field is allowed only when `include_descendants` is true and defaults to the caller's organization when omitted. + example: abcdef12345 + type: string + scope: + $ref: "#/components/schemas/UsageQuotaRequestScope" + usage_limit: + description: The quota limit to set in the usage units defined by the quota namespace. The limit cannot be lower than the usage already recorded in the current period. + example: 100000 + format: int64 + type: integer + required: + - usage_limit + - enforced + type: object + UsageQuotaCreateData: + description: A usage quota resource to create or update by scope. + properties: + attributes: + $ref: "#/components/schemas/UsageQuotaCreateAttributes" + type: + $ref: "#/components/schemas/UsageQuotaType" + required: + - type + - attributes + type: object + UsageQuotaCreateDataList: + description: A bulk list of usage quota resources to create or update by scope. + items: + $ref: "#/components/schemas/UsageQuotaCreateData" + minItems: 1 + type: array + UsageQuotaRequestScope: + additionalProperties: + example: jane@example.com + type: string + description: A namespace-specific key and value identifying what the quota applies to within an organization. The object must contain exactly one entry. Use `"*"` as the value for the default quota applied to entities without a specific quota, or omit the scope for an organization-wide quota. When `include_descendants` is false, a specific value must identify an existing user handle in the caller's organization. When `include_descendants` is true, a specific value is validated only as an email address. + example: + user_handle: jane@example.com + maxProperties: 1 + minProperties: 1 + type: object + UsageQuotaResponse: + description: Response containing a usage quota. + properties: + data: + $ref: "#/components/schemas/UsageQuotaResponseData" + required: + - data + type: object + UsageQuotaResponseAttributes: + description: Attributes of a usage quota. + properties: + enforced: + description: Whether usage above the limit is actively blocked instead of only tracked or alerted on. + example: true + type: boolean + org_public_id: + description: The public ID of the organization that owns the quota. + example: abcdef12345 + type: string + scope: + $ref: "#/components/schemas/UsageQuotaResponseScope" + usage_limit: + description: The quota limit in the usage units defined by the quota namespace. + example: 100000 + format: int64 + type: integer + required: + - scope + - org_public_id + - usage_limit + - enforced + type: object + UsageQuotaResponseData: + description: A usage quota resource. + properties: + attributes: + $ref: "#/components/schemas/UsageQuotaResponseAttributes" + id: + description: An opaque usage quota identifier. Clients must pass this value back verbatim in update and delete requests and must not infer any structure from it. + example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: string + type: + $ref: "#/components/schemas/UsageQuotaType" + required: + - id + - type + - attributes + type: object + UsageQuotaResponseDataList: + description: A list of usage quota resources. + items: + $ref: "#/components/schemas/UsageQuotaResponseData" + type: array + UsageQuotaResponseScope: + additionalProperties: + example: jane@example.com + type: string + description: A namespace-specific key and value identifying what the quota applies to within an organization. The object contains exactly one entry. A value of `"*"` identifies the default quota applied to entities without a specific quota. This field is omitted or null for an organization-wide quota. + example: + user_handle: jane@example.com + maxProperties: 1 + minProperties: 1 + nullable: true + type: object + UsageQuotaType: + description: The JSON:API resource type for a usage quota. + enum: + - quota + example: quota + type: string + x-enum-varnames: + - QUOTA + UsageQuotaUpdateAttributes: + description: Attributes to update on a usage quota. Omitting a property leaves its current value unchanged. + properties: + enforced: + description: Whether to actively block usage above the limit. Omit this field to leave the current enforcement setting unchanged. + example: false + nullable: true + type: boolean + org_public_id: + description: The public ID of the organization that already owns the quota. This is a consistency check and cannot move the quota to another organization. + example: abcdef12345 + nullable: true + type: string + usage_limit: + description: The new quota limit in the usage units defined by the quota namespace. The limit cannot be lower than the usage already recorded in the current period. Omit this field to leave the current limit unchanged. + example: 120000 + format: int64 + nullable: true + type: integer + type: object + UsageQuotaUpdateData: + description: A usage quota resource to update. + properties: + attributes: + $ref: "#/components/schemas/UsageQuotaUpdateAttributes" + id: + description: The opaque usage quota identifier, which must match the identifier in the request path. + example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: string + type: + $ref: "#/components/schemas/UsageQuotaType" + required: + - id + - type + - attributes + type: object + UsageQuotaUpdateRequest: + description: Request containing the usage quota resource to update. + properties: + data: + $ref: "#/components/schemas/UsageQuotaUpdateData" + required: + - data + type: object + UsageQuotasCreateRequest: + description: A JSON:API bulk request containing an array of usage quota resources rather than a single resource. + properties: + data: + $ref: "#/components/schemas/UsageQuotaCreateDataList" + required: + - data + type: object + UsageQuotasListResponse: + description: Response containing a paginated list of usage quotas. + properties: + data: + $ref: "#/components/schemas/UsageQuotaResponseDataList" + meta: + $ref: "#/components/schemas/UsageQuotasResponseMeta" + required: + - data + - meta + type: object + UsageQuotasResponse: + description: Response containing a list of usage quotas. + properties: + data: + $ref: "#/components/schemas/UsageQuotaResponseDataList" + required: + - data + type: object + UsageQuotasResponseMeta: + description: Pagination metadata for a usage quota list response. This field may be omitted when no pagination metadata is available. + nullable: true + properties: + next_cursor: + description: An opaque cursor for retrieving the next page. This field may be omitted or null when there are no more results. + example: eyJvZmZzZXQiOjEwMH0= + nullable: true + type: string + required: + - next_cursor + type: object UsageSummaryAvailableFieldsAttributes: description: |- The lists of field names returned by `GET /api/v1/usage/summary` at each @@ -211442,6 +211646,356 @@ paths: permissions: - usage_read - billing_read + /api/v2/usage/quotas/{quota_namespace}: + get: + description: |- + Lists usage quotas configured for the caller's organization within a quota namespace. Descendant organizations can optionally be included, but only descendants in the same datacenter as the caller are supported. Requires the `user_access_manage`, `billing_edit`, and `org_management` permissions. + operationId: ListQuotas + parameters: + - description: The product-specific namespace whose usage quotas are being managed. + in: path + name: quota_namespace + required: true + schema: + example: ai_credits + type: string + - description: Whether to include quotas configured on descendant organizations in the caller's organization hierarchy. Only descendants in the same datacenter are supported. + in: query + name: include_descendants + required: false + schema: + default: false + type: boolean + - description: An opaque cursor from a previous response's `meta.next_cursor` used to retrieve the next page. + in: query + name: pagination[cursor] + required: false + schema: + type: string + - description: The number of usage quotas to return per page. + in: query + name: pagination[page_size] + required: false + schema: + default: 100 + format: int64 + maximum: 1000 + minimum: 1 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + enforced: true + org_public_id: abcdef12345 + scope: + user_handle: jane@example.com + usage_limit: 100000 + id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: quota + meta: + next_cursor: eyJvZmZzZXQiOjEwMH0= + schema: + $ref: "#/components/schemas/UsageQuotasListResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_access_manage + - billing_edit + - org_management + summary: List usage quotas + tags: + - Usage Metering + x-pagination: + cursorParam: pagination[cursor] + cursorPath: meta.next_cursor + limitParam: pagination[page_size] + resultsPath: data + "x-permission": + operator: AND + permissions: + - user_access_manage + - billing_edit + - org_management + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: |- + Creates or updates one or more usage quotas by scope. Existing quotas for a supplied scope are updated and missing quotas are created. Requires the `user_access_manage`, `billing_edit`, and `org_management` permissions. + operationId: CreateOrUpdateQuotas + parameters: + - description: The product-specific namespace whose usage quotas are being managed. + in: path + name: quota_namespace + required: true + schema: + example: ai_credits + type: string + - description: Whether request items may target the caller's organization or one of its descendants through `org_public_id`. When false, every item targets the caller's organization and `org_public_id` must be omitted. + in: query + name: include_descendants + required: false + schema: + default: false + type: boolean + requestBody: + content: + application/json: + examples: + default: + summary: Create or update quotas for the caller's organization. + value: + data: + - attributes: + enforced: true + scope: + user_handle: jane@example.com + usage_limit: 100000 + type: quota + - attributes: + enforced: false + scope: + user_handle: "*" + usage_limit: 250000 + type: quota + descendant: + summary: Create or update a quota for a descendant organization with `include_descendants` set to true. + value: + data: + - attributes: + enforced: true + org_public_id: abcdef12345 + scope: + user_handle: jane@example.com + usage_limit: 100000 + type: quota + schema: + $ref: "#/components/schemas/UsageQuotasCreateRequest" + description: The usage quotas to create or update. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + enforced: true + org_public_id: abcdef12345 + scope: + user_handle: jane@example.com + usage_limit: 100000 + id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: quota + schema: + $ref: "#/components/schemas/UsageQuotasResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_access_manage + - billing_edit + - org_management + summary: Create or update usage quotas + tags: + - Usage Metering + "x-permission": + operator: AND + permissions: + - user_access_manage + - billing_edit + - org_management + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/usage/quotas/{quota_namespace}/{id}: + delete: + description: |- + Deletes a usage quota by its opaque identifier. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the `user_access_manage`, `billing_edit`, and `org_management` permissions. + operationId: DeleteQuota + parameters: + - description: The product-specific namespace whose usage quotas are being managed. + in: path + name: quota_namespace + required: true + schema: + example: ai_credits + type: string + - description: The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim. + in: path + name: id + required: true + schema: + example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: string + responses: + "204": + description: No Content + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_access_manage + - billing_edit + - org_management + summary: Delete a usage quota + tags: + - Usage Metering + "x-permission": + operator: AND + permissions: + - user_access_manage + - billing_edit + - org_management + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + patch: + description: |- + Updates the supplied fields on a usage quota and leaves omitted fields unchanged. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the `user_access_manage`, `billing_edit`, and `org_management` permissions. + operationId: UpdateQuota + parameters: + - description: The product-specific namespace whose usage quotas are being managed. + in: path + name: quota_namespace + required: true + schema: + example: ai_credits + type: string + - description: The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim. + in: path + name: id + required: true + schema: + example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + enforced: false + usage_limit: 120000 + id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: quota + schema: + $ref: "#/components/schemas/UsageQuotaUpdateRequest" + description: The usage quota fields to update. Omitting an attribute leaves its current value unchanged. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + enforced: false + org_public_id: abcdef12345 + scope: + user_handle: jane@example.com + usage_limit: 120000 + id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + type: quota + schema: + $ref: "#/components/schemas/UsageQuotaResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_access_manage + - billing_edit + - org_management + summary: Update a usage quota + tags: + - Usage Metering + "x-permission": + operator: AND + permissions: + - user_access_manage + - billing_edit + - org_management + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/usage/summary/available_fields: get: description: |- diff --git a/examples/v2/usage-metering/CreateOrUpdateQuotas.java b/examples/v2/usage-metering/CreateOrUpdateQuotas.java new file mode 100644 index 00000000000..43f4c0a1165 --- /dev/null +++ b/examples/v2/usage-metering/CreateOrUpdateQuotas.java @@ -0,0 +1,44 @@ +// Create or update usage quotas 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.UsageQuotaCreateAttributes; +import com.datadog.api.client.v2.model.UsageQuotaCreateData; +import com.datadog.api.client.v2.model.UsageQuotaType; +import com.datadog.api.client.v2.model.UsageQuotasCreateRequest; +import com.datadog.api.client.v2.model.UsageQuotasResponse; +import java.util.Collections; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.createOrUpdateQuotas", true); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + UsageQuotasCreateRequest body = + new UsageQuotasCreateRequest() + .data( + Collections.singletonList( + new UsageQuotaCreateData() + .attributes( + new UsageQuotaCreateAttributes() + .enforced(true) + .orgPublicId("abcdef12345") + .scope(Map.ofEntries(Map.entry("user_handle", "jane@example.com"))) + .usageLimit(100000L)) + .type(UsageQuotaType.QUOTA))); + + try { + UsageQuotasResponse result = apiInstance.createOrUpdateQuotas("ai_credits", body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#createOrUpdateQuotas"); + 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/DeleteQuota.java b/examples/v2/usage-metering/DeleteQuota.java new file mode 100644 index 00000000000..5cb55ae7f86 --- /dev/null +++ b/examples/v2/usage-metering/DeleteQuota.java @@ -0,0 +1,23 @@ +// Delete a usage quota returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.UsageMeteringApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.deleteQuota", true); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + apiInstance.deleteQuota("ai_credits", "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f"); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#deleteQuota"); + 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/ListQuotas.java b/examples/v2/usage-metering/ListQuotas.java new file mode 100644 index 00000000000..d36cfd16e9e --- /dev/null +++ b/examples/v2/usage-metering/ListQuotas.java @@ -0,0 +1,25 @@ +// List usage quotas 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.UsageQuotasListResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listQuotas", true); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + UsageQuotasListResponse result = apiInstance.listQuotas("ai_credits"); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#listQuotas"); + 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/ListQuotas_918754421.java b/examples/v2/usage-metering/ListQuotas_918754421.java new file mode 100644 index 00000000000..44802bb377e --- /dev/null +++ b/examples/v2/usage-metering/ListQuotas_918754421.java @@ -0,0 +1,27 @@ +// List usage quotas returns "OK" response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.UsageMeteringApi; +import com.datadog.api.client.v2.model.UsageQuotaResponseData; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listQuotas", true); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + try { + PaginationIterable iterable = + apiInstance.listQuotasWithPagination("ai_credits"); + + for (UsageQuotaResponseData item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println("Exception when calling UsageMeteringApi#listQuotasWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/usage-metering/UpdateQuota.java b/examples/v2/usage-metering/UpdateQuota.java new file mode 100644 index 00000000000..3170e811459 --- /dev/null +++ b/examples/v2/usage-metering/UpdateQuota.java @@ -0,0 +1,43 @@ +// Update a usage quota 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.UsageQuotaResponse; +import com.datadog.api.client.v2.model.UsageQuotaType; +import com.datadog.api.client.v2.model.UsageQuotaUpdateAttributes; +import com.datadog.api.client.v2.model.UsageQuotaUpdateData; +import com.datadog.api.client.v2.model.UsageQuotaUpdateRequest; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.updateQuota", true); + UsageMeteringApi apiInstance = new UsageMeteringApi(defaultClient); + + UsageQuotaUpdateRequest body = + new UsageQuotaUpdateRequest() + .data( + new UsageQuotaUpdateData() + .attributes( + new UsageQuotaUpdateAttributes() + .enforced(false) + .orgPublicId("abcdef12345") + .usageLimit(120000L)) + .id("MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f") + .type(UsageQuotaType.QUOTA)); + + try { + UsageQuotaResponse result = + apiInstance.updateQuota( + "ai_credits", "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UsageMeteringApi#updateQuota"); + 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/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 5d4cf42b198..d457b62fdc2 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1045,6 +1045,10 @@ public class ApiClient { put("v2.listCostTagMetadataMonths", false); put("v2.listCostTagMetadataOrchestrators", false); put("v2.searchCostRecommendations", false); + put("v2.createOrUpdateQuotas", false); + put("v2.deleteQuota", false); + put("v2.listQuotas", false); + put("v2.updateQuota", false); put("v2.createOwnershipFeedback", false); put("v2.getOwnershipEvidence", false); put("v2.getOwnershipInference", false); 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 3610facb72a..4f687bec6b2 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 @@ -3,6 +3,7 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.ApiResponse; +import com.datadog.api.client.PaginationIterable; import com.datadog.api.client.Pair; import com.datadog.api.client.v2.model.ActiveBillingDimensionsResponse; import com.datadog.api.client.v2.model.BillingDimensionsMappingResponse; @@ -16,12 +17,19 @@ 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.UsageQuotaResponse; +import com.datadog.api.client.v2.model.UsageQuotaResponseData; +import com.datadog.api.client.v2.model.UsageQuotaUpdateRequest; +import com.datadog.api.client.v2.model.UsageQuotasCreateRequest; +import com.datadog.api.client.v2.model.UsageQuotasListResponse; +import com.datadog.api.client.v2.model.UsageQuotasResponse; import com.datadog.api.client.v2.model.UsageSummaryAvailableFieldsResponse; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -57,6 +65,456 @@ public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } + /** Manage optional parameters to createOrUpdateQuotas. */ + public static class CreateOrUpdateQuotasOptionalParameters { + private Boolean includeDescendants; + + /** + * Set includeDescendants. + * + * @param includeDescendants Whether request items may target the caller's organization or one + * of its descendants through org_public_id. When false, every item targets the + * caller's organization and org_public_id must be omitted. (optional, default + * to false) + * @return CreateOrUpdateQuotasOptionalParameters + */ + public CreateOrUpdateQuotasOptionalParameters includeDescendants(Boolean includeDescendants) { + this.includeDescendants = includeDescendants; + return this; + } + } + + /** + * Create or update usage quotas. + * + *

See {@link #createOrUpdateQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param body The usage quotas to create or update. (required) + * @return UsageQuotasResponse + * @throws ApiException if fails to make API call + */ + public UsageQuotasResponse createOrUpdateQuotas( + String quotaNamespace, UsageQuotasCreateRequest body) throws ApiException { + return createOrUpdateQuotasWithHttpInfo( + quotaNamespace, body, new CreateOrUpdateQuotasOptionalParameters()) + .getData(); + } + + /** + * Create or update usage quotas. + * + *

See {@link #createOrUpdateQuotasWithHttpInfoAsync}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param body The usage quotas to create or update. (required) + * @return CompletableFuture<UsageQuotasResponse> + */ + public CompletableFuture createOrUpdateQuotasAsync( + String quotaNamespace, UsageQuotasCreateRequest body) { + return createOrUpdateQuotasWithHttpInfoAsync( + quotaNamespace, body, new CreateOrUpdateQuotasOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create or update usage quotas. + * + *

See {@link #createOrUpdateQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param body The usage quotas to create or update. (required) + * @param parameters Optional parameters for the request. + * @return UsageQuotasResponse + * @throws ApiException if fails to make API call + */ + public UsageQuotasResponse createOrUpdateQuotas( + String quotaNamespace, + UsageQuotasCreateRequest body, + CreateOrUpdateQuotasOptionalParameters parameters) + throws ApiException { + return createOrUpdateQuotasWithHttpInfo(quotaNamespace, body, parameters).getData(); + } + + /** + * Create or update usage quotas. + * + *

See {@link #createOrUpdateQuotasWithHttpInfoAsync}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param body The usage quotas to create or update. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<UsageQuotasResponse> + */ + public CompletableFuture createOrUpdateQuotasAsync( + String quotaNamespace, + UsageQuotasCreateRequest body, + CreateOrUpdateQuotasOptionalParameters parameters) { + return createOrUpdateQuotasWithHttpInfoAsync(quotaNamespace, body, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Creates or updates one or more usage quotas by scope. Existing quotas for a supplied scope are + * updated and missing quotas are created. Requires the user_access_manage, + * billing_edit, and org_management permissions. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param body The usage quotas to create or update. (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<UsageQuotasResponse> + * @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 -
429 Too many requests -
+ */ + public ApiResponse createOrUpdateQuotasWithHttpInfo( + String quotaNamespace, + UsageQuotasCreateRequest body, + CreateOrUpdateQuotasOptionalParameters parameters) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "createOrUpdateQuotas"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + throw new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling createOrUpdateQuotas"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createOrUpdateQuotas"); + } + Boolean includeDescendants = parameters.includeDescendants; + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "include_descendants", includeDescendants)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.createOrUpdateQuotas", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create or update usage quotas. + * + *

See {@link #createOrUpdateQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param body The usage quotas to create or update. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<UsageQuotasResponse>> + */ + public CompletableFuture> createOrUpdateQuotasWithHttpInfoAsync( + String quotaNamespace, + UsageQuotasCreateRequest body, + CreateOrUpdateQuotasOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "createOrUpdateQuotas"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'quotaNamespace' when calling createOrUpdateQuotas")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling createOrUpdateQuotas")); + return result; + } + Boolean includeDescendants = parameters.includeDescendants; + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "include_descendants", includeDescendants)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.createOrUpdateQuotas", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Delete a usage quota. + * + *

See {@link #deleteQuotaWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @throws ApiException if fails to make API call + */ + public void deleteQuota(String quotaNamespace, String id) throws ApiException { + deleteQuotaWithHttpInfo(quotaNamespace, id); + } + + /** + * Delete a usage quota. + * + *

See {@link #deleteQuotaWithHttpInfoAsync}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @return CompletableFuture + */ + public CompletableFuture deleteQuotaAsync(String quotaNamespace, String id) { + return deleteQuotaWithHttpInfoAsync(quotaNamespace, id) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Deletes a usage quota by its opaque identifier. The quota must belong to the caller's + * organization or one of its descendants, and its opaque identifier must belong to the requested + * quota namespace. Requires the user_access_manage, billing_edit, and + * org_management permissions. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse deleteQuotaWithHttpInfo(String quotaNamespace, String id) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "deleteQuota"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + throw new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling deleteQuota"); + } + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException(400, "Missing the required parameter 'id' when calling deleteQuota"); + } + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}/{id}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())) + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.deleteQuota", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete a usage quota. + * + *

See {@link #deleteQuotaWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteQuotaWithHttpInfoAsync( + String quotaNamespace, String id) { + // Check if unstable operation is enabled + String operationId = "deleteQuota"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling deleteQuota")); + return result; + } + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(400, "Missing the required parameter 'id' when calling deleteQuota")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}/{id}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())) + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.deleteQuota", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** * Get active billing dimensions for cost attribution. * @@ -3161,4 +3619,540 @@ public UsageSummaryAvailableFieldsResponse getUsageSummaryAvailableFields() thro false, new GenericType() {}); } + + /** Manage optional parameters to listQuotas. */ + public static class ListQuotasOptionalParameters { + private Boolean includeDescendants; + private String paginationCursor; + private Long paginationPageSize; + + /** + * Set includeDescendants. + * + * @param includeDescendants Whether to include quotas configured on descendant organizations in + * the caller's organization hierarchy. Only descendants in the same datacenter are + * supported. (optional, default to false) + * @return ListQuotasOptionalParameters + */ + public ListQuotasOptionalParameters includeDescendants(Boolean includeDescendants) { + this.includeDescendants = includeDescendants; + return this; + } + + /** + * Set paginationCursor. + * + * @param paginationCursor An opaque cursor from a previous response's meta.next_cursor + * used to retrieve the next page. (optional) + * @return ListQuotasOptionalParameters + */ + public ListQuotasOptionalParameters paginationCursor(String paginationCursor) { + this.paginationCursor = paginationCursor; + return this; + } + + /** + * Set paginationPageSize. + * + * @param paginationPageSize The number of usage quotas to return per page. (optional, default + * to 100) + * @return ListQuotasOptionalParameters + */ + public ListQuotasOptionalParameters paginationPageSize(Long paginationPageSize) { + this.paginationPageSize = paginationPageSize; + return this; + } + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @return UsageQuotasListResponse + * @throws ApiException if fails to make API call + */ + public UsageQuotasListResponse listQuotas(String quotaNamespace) throws ApiException { + return listQuotasWithHttpInfo(quotaNamespace, new ListQuotasOptionalParameters()).getData(); + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfoAsync}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @return CompletableFuture<UsageQuotasListResponse> + */ + public CompletableFuture listQuotasAsync(String quotaNamespace) { + return listQuotasWithHttpInfoAsync(quotaNamespace, new ListQuotasOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param parameters Optional parameters for the request. + * @return UsageQuotasListResponse + * @throws ApiException if fails to make API call + */ + public UsageQuotasListResponse listQuotas( + String quotaNamespace, ListQuotasOptionalParameters parameters) throws ApiException { + return listQuotasWithHttpInfo(quotaNamespace, parameters).getData(); + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfoAsync}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<UsageQuotasListResponse> + */ + public CompletableFuture listQuotasAsync( + String quotaNamespace, ListQuotasOptionalParameters parameters) { + return listQuotasWithHttpInfoAsync(quotaNamespace, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @return PaginationIterable<UsageQuotaResponseData> + */ + public PaginationIterable listQuotasWithPagination( + String quotaNamespace) { + ListQuotasOptionalParameters parameters = new ListQuotasOptionalParameters(); + return listQuotasWithPagination(quotaNamespace, parameters); + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @return UsageQuotasListResponse + */ + public PaginationIterable listQuotasWithPagination( + String quotaNamespace, ListQuotasOptionalParameters parameters) { + String resultsPath = "getData"; + String valueGetterPath = "getMeta.getNextCursor"; + String valueSetterPath = "paginationCursor"; + Boolean valueSetterParamOptional = true; + Long limit; + + if (parameters.paginationPageSize == null) { + limit = 100l; + parameters.paginationPageSize(limit); + } else { + limit = parameters.paginationPageSize; + } + + LinkedHashMap args = new LinkedHashMap(); + args.put("quotaNamespace", quotaNamespace); + args.put("optionalParams", parameters); + + PaginationIterable iterator = + new PaginationIterable( + this, + "listQuotas", + resultsPath, + valueGetterPath, + valueSetterPath, + valueSetterParamOptional, + true, + true, + limit, + args, + 0); + + return iterator; + } + + /** + * Lists usage quotas configured for the caller's organization within a quota namespace. + * Descendant organizations can optionally be included, but only descendants in the same + * datacenter as the caller are supported. Requires the user_access_manage, + * billing_edit, and org_management permissions. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<UsageQuotasListResponse> + * @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 -
429 Too many requests -
+ */ + public ApiResponse listQuotasWithHttpInfo( + String quotaNamespace, ListQuotasOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "listQuotas"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + throw new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling listQuotas"); + } + Boolean includeDescendants = parameters.includeDescendants; + String paginationCursor = parameters.paginationCursor; + Long paginationPageSize = parameters.paginationPageSize; + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "include_descendants", includeDescendants)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "pagination[cursor]", paginationCursor)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "pagination[page_size]", paginationPageSize)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.listQuotas", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * List usage quotas. + * + *

See {@link #listQuotasWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<UsageQuotasListResponse>> + */ + public CompletableFuture> listQuotasWithHttpInfoAsync( + String quotaNamespace, ListQuotasOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "listQuotas"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling listQuotas")); + return result; + } + Boolean includeDescendants = parameters.includeDescendants; + String paginationCursor = parameters.paginationCursor; + Long paginationPageSize = parameters.paginationPageSize; + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "include_descendants", includeDescendants)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "pagination[cursor]", paginationCursor)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("", "pagination[page_size]", paginationPageSize)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.listQuotas", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + 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() {}); + } + + /** + * Update a usage quota. + * + *

See {@link #updateQuotaWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @param body The usage quota fields to update. Omitting an attribute leaves its current value + * unchanged. (required) + * @return UsageQuotaResponse + * @throws ApiException if fails to make API call + */ + public UsageQuotaResponse updateQuota( + String quotaNamespace, String id, UsageQuotaUpdateRequest body) throws ApiException { + return updateQuotaWithHttpInfo(quotaNamespace, id, body).getData(); + } + + /** + * Update a usage quota. + * + *

See {@link #updateQuotaWithHttpInfoAsync}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @param body The usage quota fields to update. Omitting an attribute leaves its current value + * unchanged. (required) + * @return CompletableFuture<UsageQuotaResponse> + */ + public CompletableFuture updateQuotaAsync( + String quotaNamespace, String id, UsageQuotaUpdateRequest body) { + return updateQuotaWithHttpInfoAsync(quotaNamespace, id, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Updates the supplied fields on a usage quota and leaves omitted fields unchanged. The quota + * must belong to the caller's organization or one of its descendants, and its opaque identifier + * must belong to the requested quota namespace. Requires the user_access_manage, + * billing_edit, and org_management permissions. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @param body The usage quota fields to update. Omitting an attribute leaves its current value + * unchanged. (required) + * @return ApiResponse<UsageQuotaResponse> + * @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 -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse updateQuotaWithHttpInfo( + String quotaNamespace, String id, UsageQuotaUpdateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "updateQuota"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + throw new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling updateQuota"); + } + + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException(400, "Missing the required parameter 'id' when calling updateQuota"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updateQuota"); + } + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}/{id}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())) + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.updateQuota", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update a usage quota. + * + *

See {@link #updateQuotaWithHttpInfo}. + * + * @param quotaNamespace The product-specific namespace whose usage quotas are being managed. + * (required) + * @param id The opaque quota identifier returned by a previous list or create request. Clients + * must pass this value verbatim. (required) + * @param body The usage quota fields to update. Omitting an attribute leaves its current value + * unchanged. (required) + * @return CompletableFuture<ApiResponse<UsageQuotaResponse>> + */ + public CompletableFuture> updateQuotaWithHttpInfoAsync( + String quotaNamespace, String id, UsageQuotaUpdateRequest body) { + // Check if unstable operation is enabled + String operationId = "updateQuota"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'quotaNamespace' is set + if (quotaNamespace == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'quotaNamespace' when calling updateQuota")); + return result; + } + + // verify the required parameter 'id' is set + if (id == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(400, "Missing the required parameter 'id' when calling updateQuota")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(400, "Missing the required parameter 'body' when calling updateQuota")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/usage/quotas/{quota_namespace}/{id}" + .replaceAll( + "\\{" + "quota_namespace" + "\\}", + apiClient.escapeString(quotaNamespace.toString())) + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.UsageMeteringApi.updateQuota", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateAttributes.java new file mode 100644 index 00000000000..12ae6000a36 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateAttributes.java @@ -0,0 +1,244 @@ +/* + * 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.JsonCreator; +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; + +/** Attributes for creating or updating a usage quota by scope. */ +@JsonPropertyOrder({ + UsageQuotaCreateAttributes.JSON_PROPERTY_ENFORCED, + UsageQuotaCreateAttributes.JSON_PROPERTY_ORG_PUBLIC_ID, + UsageQuotaCreateAttributes.JSON_PROPERTY_SCOPE, + UsageQuotaCreateAttributes.JSON_PROPERTY_USAGE_LIMIT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaCreateAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENFORCED = "enforced"; + private Boolean enforced; + + public static final String JSON_PROPERTY_ORG_PUBLIC_ID = "org_public_id"; + private String orgPublicId; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private Map scope = null; + + public static final String JSON_PROPERTY_USAGE_LIMIT = "usage_limit"; + private Long usageLimit; + + public UsageQuotaCreateAttributes() {} + + @JsonCreator + public UsageQuotaCreateAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_ENFORCED) Boolean enforced, + @JsonProperty(required = true, value = JSON_PROPERTY_USAGE_LIMIT) Long usageLimit) { + this.enforced = enforced; + this.usageLimit = usageLimit; + } + + public UsageQuotaCreateAttributes enforced(Boolean enforced) { + this.enforced = enforced; + return this; + } + + /** + * Whether to actively block usage above the limit instead of only tracking or alerting on it. + * + * @return enforced + */ + @JsonProperty(JSON_PROPERTY_ENFORCED) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getEnforced() { + return enforced; + } + + public void setEnforced(Boolean enforced) { + this.enforced = enforced; + } + + public UsageQuotaCreateAttributes orgPublicId(String orgPublicId) { + this.orgPublicId = orgPublicId; + return this; + } + + /** + * The public ID of the caller's organization or one of its descendants that should own the quota. + * This field is allowed only when include_descendants is true and defaults to the + * caller's organization when omitted. + * + * @return orgPublicId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ORG_PUBLIC_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOrgPublicId() { + return orgPublicId; + } + + public void setOrgPublicId(String orgPublicId) { + this.orgPublicId = orgPublicId; + } + + public UsageQuotaCreateAttributes scope(Map scope) { + this.scope = scope; + return this; + } + + public UsageQuotaCreateAttributes putScopeItem(String key, String scopeItem) { + if (this.scope == null) { + this.scope = new HashMap<>(); + } + this.scope.put(key, scopeItem); + return this; + } + + /** + * A namespace-specific key and value identifying what the quota applies to within an + * organization. The object must contain exactly one entry. Use "*" as the value for + * the default quota applied to entities without a specific quota, or omit the scope for an + * organization-wide quota. When include_descendants is false, a specific value must + * identify an existing user handle in the caller's organization. When include_descendants + * is true, a specific value is validated only as an email address. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getScope() { + return scope; + } + + public void setScope(Map scope) { + this.scope = scope; + } + + public UsageQuotaCreateAttributes usageLimit(Long usageLimit) { + this.usageLimit = usageLimit; + return this; + } + + /** + * The quota limit to set in the usage units defined by the quota namespace. The limit cannot be + * lower than the usage already recorded in the current period. + * + * @return usageLimit + */ + @JsonProperty(JSON_PROPERTY_USAGE_LIMIT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getUsageLimit() { + return usageLimit; + } + + public void setUsageLimit(Long usageLimit) { + this.usageLimit = usageLimit; + } + + /** + * 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 UsageQuotaCreateAttributes + */ + @JsonAnySetter + public UsageQuotaCreateAttributes 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 UsageQuotaCreateAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaCreateAttributes usageQuotaCreateAttributes = (UsageQuotaCreateAttributes) o; + return Objects.equals(this.enforced, usageQuotaCreateAttributes.enforced) + && Objects.equals(this.orgPublicId, usageQuotaCreateAttributes.orgPublicId) + && Objects.equals(this.scope, usageQuotaCreateAttributes.scope) + && Objects.equals(this.usageLimit, usageQuotaCreateAttributes.usageLimit) + && Objects.equals( + this.additionalProperties, usageQuotaCreateAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enforced, orgPublicId, scope, usageLimit, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaCreateAttributes {\n"); + sb.append(" enforced: ").append(toIndentedString(enforced)).append("\n"); + sb.append(" orgPublicId: ").append(toIndentedString(orgPublicId)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" usageLimit: ").append(toIndentedString(usageLimit)).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/UsageQuotaCreateData.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateData.java new file mode 100644 index 00000000000..e0f8334ef5a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaCreateData.java @@ -0,0 +1,184 @@ +/* + * 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.JsonCreator; +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 usage quota resource to create or update by scope. */ +@JsonPropertyOrder({ + UsageQuotaCreateData.JSON_PROPERTY_ATTRIBUTES, + UsageQuotaCreateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaCreateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private UsageQuotaCreateAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private UsageQuotaType type; + + public UsageQuotaCreateData() {} + + @JsonCreator + public UsageQuotaCreateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + UsageQuotaCreateAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) UsageQuotaType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public UsageQuotaCreateData attributes(UsageQuotaCreateAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for creating or updating a usage quota by scope. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaCreateAttributes getAttributes() { + return attributes; + } + + public void setAttributes(UsageQuotaCreateAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public UsageQuotaCreateData type(UsageQuotaType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The JSON:API resource type for a usage quota. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaType getType() { + return type; + } + + public void setType(UsageQuotaType 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 UsageQuotaCreateData + */ + @JsonAnySetter + public UsageQuotaCreateData 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 UsageQuotaCreateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaCreateData usageQuotaCreateData = (UsageQuotaCreateData) o; + return Objects.equals(this.attributes, usageQuotaCreateData.attributes) + && Objects.equals(this.type, usageQuotaCreateData.type) + && Objects.equals(this.additionalProperties, usageQuotaCreateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaCreateData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).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/UsageQuotaResponse.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponse.java new file mode 100644 index 00000000000..8d96cea6266 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponse.java @@ -0,0 +1,148 @@ +/* + * 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.JsonCreator; +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 containing a usage quota. */ +@JsonPropertyOrder({UsageQuotaResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private UsageQuotaResponseData data; + + public UsageQuotaResponse() {} + + @JsonCreator + public UsageQuotaResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) UsageQuotaResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public UsageQuotaResponse data(UsageQuotaResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * A usage quota resource. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaResponseData getData() { + return data; + } + + public void setData(UsageQuotaResponseData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.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 UsageQuotaResponse + */ + @JsonAnySetter + public UsageQuotaResponse 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 UsageQuotaResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaResponse usageQuotaResponse = (UsageQuotaResponse) o; + return Objects.equals(this.data, usageQuotaResponse.data) + && Objects.equals(this.additionalProperties, usageQuotaResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaResponse {\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/UsageQuotaResponseAttributes.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponseAttributes.java new file mode 100644 index 00000000000..214f1361ddf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponseAttributes.java @@ -0,0 +1,241 @@ +/* + * 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.JsonCreator; +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; + +/** Attributes of a usage quota. */ +@JsonPropertyOrder({ + UsageQuotaResponseAttributes.JSON_PROPERTY_ENFORCED, + UsageQuotaResponseAttributes.JSON_PROPERTY_ORG_PUBLIC_ID, + UsageQuotaResponseAttributes.JSON_PROPERTY_SCOPE, + UsageQuotaResponseAttributes.JSON_PROPERTY_USAGE_LIMIT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaResponseAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENFORCED = "enforced"; + private Boolean enforced; + + public static final String JSON_PROPERTY_ORG_PUBLIC_ID = "org_public_id"; + private String orgPublicId; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private Map scope = new HashMap(); + + public static final String JSON_PROPERTY_USAGE_LIMIT = "usage_limit"; + private Long usageLimit; + + public UsageQuotaResponseAttributes() {} + + @JsonCreator + public UsageQuotaResponseAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_ENFORCED) Boolean enforced, + @JsonProperty(required = true, value = JSON_PROPERTY_ORG_PUBLIC_ID) String orgPublicId, + @JsonProperty(required = true, value = JSON_PROPERTY_SCOPE) Map scope, + @JsonProperty(required = true, value = JSON_PROPERTY_USAGE_LIMIT) Long usageLimit) { + this.enforced = enforced; + this.orgPublicId = orgPublicId; + this.scope = scope; + if (scope != null) {} + this.usageLimit = usageLimit; + } + + public UsageQuotaResponseAttributes enforced(Boolean enforced) { + this.enforced = enforced; + return this; + } + + /** + * Whether usage above the limit is actively blocked instead of only tracked or alerted on. + * + * @return enforced + */ + @JsonProperty(JSON_PROPERTY_ENFORCED) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getEnforced() { + return enforced; + } + + public void setEnforced(Boolean enforced) { + this.enforced = enforced; + } + + public UsageQuotaResponseAttributes orgPublicId(String orgPublicId) { + this.orgPublicId = orgPublicId; + return this; + } + + /** + * The public ID of the organization that owns the quota. + * + * @return orgPublicId + */ + @JsonProperty(JSON_PROPERTY_ORG_PUBLIC_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getOrgPublicId() { + return orgPublicId; + } + + public void setOrgPublicId(String orgPublicId) { + this.orgPublicId = orgPublicId; + } + + public UsageQuotaResponseAttributes scope(Map scope) { + this.scope = scope; + if (scope != null) {} + return this; + } + + public UsageQuotaResponseAttributes putScopeItem(String key, String scopeItem) { + this.scope.put(key, scopeItem); + return this; + } + + /** + * A namespace-specific key and value identifying what the quota applies to within an + * organization. The object contains exactly one entry. A value of "*" identifies the + * default quota applied to entities without a specific quota. This field is omitted or null for + * an organization-wide quota. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Map getScope() { + return scope; + } + + public void setScope(Map scope) { + this.scope = scope; + } + + public UsageQuotaResponseAttributes usageLimit(Long usageLimit) { + this.usageLimit = usageLimit; + return this; + } + + /** + * The quota limit in the usage units defined by the quota namespace. + * + * @return usageLimit + */ + @JsonProperty(JSON_PROPERTY_USAGE_LIMIT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getUsageLimit() { + return usageLimit; + } + + public void setUsageLimit(Long usageLimit) { + this.usageLimit = usageLimit; + } + + /** + * 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 UsageQuotaResponseAttributes + */ + @JsonAnySetter + public UsageQuotaResponseAttributes 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 UsageQuotaResponseAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaResponseAttributes usageQuotaResponseAttributes = (UsageQuotaResponseAttributes) o; + return Objects.equals(this.enforced, usageQuotaResponseAttributes.enforced) + && Objects.equals(this.orgPublicId, usageQuotaResponseAttributes.orgPublicId) + && Objects.equals(this.scope, usageQuotaResponseAttributes.scope) + && Objects.equals(this.usageLimit, usageQuotaResponseAttributes.usageLimit) + && Objects.equals( + this.additionalProperties, usageQuotaResponseAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enforced, orgPublicId, scope, usageLimit, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaResponseAttributes {\n"); + sb.append(" enforced: ").append(toIndentedString(enforced)).append("\n"); + sb.append(" orgPublicId: ").append(toIndentedString(orgPublicId)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" usageLimit: ").append(toIndentedString(usageLimit)).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/UsageQuotaResponseData.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponseData.java new file mode 100644 index 00000000000..4f36b7a1824 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaResponseData.java @@ -0,0 +1,213 @@ +/* + * 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.JsonCreator; +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 usage quota resource. */ +@JsonPropertyOrder({ + UsageQuotaResponseData.JSON_PROPERTY_ATTRIBUTES, + UsageQuotaResponseData.JSON_PROPERTY_ID, + UsageQuotaResponseData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaResponseData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private UsageQuotaResponseAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private UsageQuotaType type; + + public UsageQuotaResponseData() {} + + @JsonCreator + public UsageQuotaResponseData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + UsageQuotaResponseAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) UsageQuotaType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public UsageQuotaResponseData attributes(UsageQuotaResponseAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a usage quota. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaResponseAttributes getAttributes() { + return attributes; + } + + public void setAttributes(UsageQuotaResponseAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public UsageQuotaResponseData id(String id) { + this.id = id; + return this; + } + + /** + * An opaque usage quota identifier. Clients must pass this value back verbatim in update and + * delete requests and must not infer any structure from it. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public UsageQuotaResponseData type(UsageQuotaType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The JSON:API resource type for a usage quota. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaType getType() { + return type; + } + + public void setType(UsageQuotaType 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 UsageQuotaResponseData + */ + @JsonAnySetter + public UsageQuotaResponseData 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 UsageQuotaResponseData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaResponseData usageQuotaResponseData = (UsageQuotaResponseData) o; + return Objects.equals(this.attributes, usageQuotaResponseData.attributes) + && Objects.equals(this.id, usageQuotaResponseData.id) + && Objects.equals(this.type, usageQuotaResponseData.type) + && Objects.equals(this.additionalProperties, usageQuotaResponseData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaResponseData {\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/UsageQuotaType.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaType.java new file mode 100644 index 00000000000..1084f3e6cd9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaType.java @@ -0,0 +1,53 @@ +/* + * 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; + +/** The JSON:API resource type for a usage quota. */ +@JsonSerialize(using = UsageQuotaType.UsageQuotaTypeSerializer.class) +public class UsageQuotaType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("quota")); + + public static final UsageQuotaType QUOTA = new UsageQuotaType("quota"); + + UsageQuotaType(String value) { + super(value, allowedValues); + } + + public static class UsageQuotaTypeSerializer extends StdSerializer { + public UsageQuotaTypeSerializer(Class t) { + super(t); + } + + public UsageQuotaTypeSerializer() { + this(null); + } + + @Override + public void serialize(UsageQuotaType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static UsageQuotaType fromValue(String value) { + return new UsageQuotaType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateAttributes.java new file mode 100644 index 00000000000..8176a6cf5d6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateAttributes.java @@ -0,0 +1,229 @@ +/* + * 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; + +/** + * Attributes to update on a usage quota. Omitting a property leaves its current value unchanged. + */ +@JsonPropertyOrder({ + UsageQuotaUpdateAttributes.JSON_PROPERTY_ENFORCED, + UsageQuotaUpdateAttributes.JSON_PROPERTY_ORG_PUBLIC_ID, + UsageQuotaUpdateAttributes.JSON_PROPERTY_USAGE_LIMIT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaUpdateAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENFORCED = "enforced"; + private JsonNullable enforced = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_ORG_PUBLIC_ID = "org_public_id"; + private JsonNullable orgPublicId = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_USAGE_LIMIT = "usage_limit"; + private JsonNullable usageLimit = JsonNullable.undefined(); + + public UsageQuotaUpdateAttributes enforced(Boolean enforced) { + this.enforced = JsonNullable.of(enforced); + return this; + } + + /** + * Whether to actively block usage above the limit. Omit this field to leave the current + * enforcement setting unchanged. + * + * @return enforced + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Boolean getEnforced() { + return enforced.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_ENFORCED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getEnforced_JsonNullable() { + return enforced; + } + + @JsonProperty(JSON_PROPERTY_ENFORCED) + public void setEnforced_JsonNullable(JsonNullable enforced) { + this.enforced = enforced; + } + + public void setEnforced(Boolean enforced) { + this.enforced = JsonNullable.of(enforced); + } + + public UsageQuotaUpdateAttributes orgPublicId(String orgPublicId) { + this.orgPublicId = JsonNullable.of(orgPublicId); + return this; + } + + /** + * The public ID of the organization that already owns the quota. This is a consistency check and + * cannot move the quota to another organization. + * + * @return orgPublicId + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getOrgPublicId() { + return orgPublicId.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_ORG_PUBLIC_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getOrgPublicId_JsonNullable() { + return orgPublicId; + } + + @JsonProperty(JSON_PROPERTY_ORG_PUBLIC_ID) + public void setOrgPublicId_JsonNullable(JsonNullable orgPublicId) { + this.orgPublicId = orgPublicId; + } + + public void setOrgPublicId(String orgPublicId) { + this.orgPublicId = JsonNullable.of(orgPublicId); + } + + public UsageQuotaUpdateAttributes usageLimit(Long usageLimit) { + this.usageLimit = JsonNullable.of(usageLimit); + return this; + } + + /** + * The new quota limit in the usage units defined by the quota namespace. The limit cannot be + * lower than the usage already recorded in the current period. Omit this field to leave the + * current limit unchanged. + * + * @return usageLimit + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getUsageLimit() { + return usageLimit.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_USAGE_LIMIT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getUsageLimit_JsonNullable() { + return usageLimit; + } + + @JsonProperty(JSON_PROPERTY_USAGE_LIMIT) + public void setUsageLimit_JsonNullable(JsonNullable usageLimit) { + this.usageLimit = usageLimit; + } + + public void setUsageLimit(Long usageLimit) { + this.usageLimit = JsonNullable.of(usageLimit); + } + + /** + * 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 UsageQuotaUpdateAttributes + */ + @JsonAnySetter + public UsageQuotaUpdateAttributes 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 UsageQuotaUpdateAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaUpdateAttributes usageQuotaUpdateAttributes = (UsageQuotaUpdateAttributes) o; + return Objects.equals(this.enforced, usageQuotaUpdateAttributes.enforced) + && Objects.equals(this.orgPublicId, usageQuotaUpdateAttributes.orgPublicId) + && Objects.equals(this.usageLimit, usageQuotaUpdateAttributes.usageLimit) + && Objects.equals( + this.additionalProperties, usageQuotaUpdateAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enforced, orgPublicId, usageLimit, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaUpdateAttributes {\n"); + sb.append(" enforced: ").append(toIndentedString(enforced)).append("\n"); + sb.append(" orgPublicId: ").append(toIndentedString(orgPublicId)).append("\n"); + sb.append(" usageLimit: ").append(toIndentedString(usageLimit)).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/UsageQuotaUpdateData.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateData.java new file mode 100644 index 00000000000..2faa9e49607 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateData.java @@ -0,0 +1,212 @@ +/* + * 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.JsonCreator; +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 usage quota resource to update. */ +@JsonPropertyOrder({ + UsageQuotaUpdateData.JSON_PROPERTY_ATTRIBUTES, + UsageQuotaUpdateData.JSON_PROPERTY_ID, + UsageQuotaUpdateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaUpdateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private UsageQuotaUpdateAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private UsageQuotaType type; + + public UsageQuotaUpdateData() {} + + @JsonCreator + public UsageQuotaUpdateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + UsageQuotaUpdateAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) UsageQuotaType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public UsageQuotaUpdateData attributes(UsageQuotaUpdateAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes to update on a usage quota. Omitting a property leaves its current value unchanged. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaUpdateAttributes getAttributes() { + return attributes; + } + + public void setAttributes(UsageQuotaUpdateAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public UsageQuotaUpdateData id(String id) { + this.id = id; + return this; + } + + /** + * The opaque usage quota identifier, which must match the identifier in the request path. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public UsageQuotaUpdateData type(UsageQuotaType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The JSON:API resource type for a usage quota. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaType getType() { + return type; + } + + public void setType(UsageQuotaType 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 UsageQuotaUpdateData + */ + @JsonAnySetter + public UsageQuotaUpdateData 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 UsageQuotaUpdateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaUpdateData usageQuotaUpdateData = (UsageQuotaUpdateData) o; + return Objects.equals(this.attributes, usageQuotaUpdateData.attributes) + && Objects.equals(this.id, usageQuotaUpdateData.id) + && Objects.equals(this.type, usageQuotaUpdateData.type) + && Objects.equals(this.additionalProperties, usageQuotaUpdateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaUpdateData {\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/UsageQuotaUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateRequest.java new file mode 100644 index 00000000000..0f2e94a63a9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotaUpdateRequest.java @@ -0,0 +1,148 @@ +/* + * 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.JsonCreator; +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; + +/** Request containing the usage quota resource to update. */ +@JsonPropertyOrder({UsageQuotaUpdateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotaUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private UsageQuotaUpdateData data; + + public UsageQuotaUpdateRequest() {} + + @JsonCreator + public UsageQuotaUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) UsageQuotaUpdateData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public UsageQuotaUpdateRequest data(UsageQuotaUpdateData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * A usage quota resource to update. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotaUpdateData getData() { + return data; + } + + public void setData(UsageQuotaUpdateData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.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 UsageQuotaUpdateRequest + */ + @JsonAnySetter + public UsageQuotaUpdateRequest 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 UsageQuotaUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotaUpdateRequest usageQuotaUpdateRequest = (UsageQuotaUpdateRequest) o; + return Objects.equals(this.data, usageQuotaUpdateRequest.data) + && Objects.equals(this.additionalProperties, usageQuotaUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotaUpdateRequest {\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/UsageQuotasCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasCreateRequest.java new file mode 100644 index 00000000000..0be36ecad3a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasCreateRequest.java @@ -0,0 +1,165 @@ +/* + * 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.JsonCreator; +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; + +/** + * A JSON:API bulk request containing an array of usage quota resources rather than a single + * resource. + */ +@JsonPropertyOrder({UsageQuotasCreateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotasCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public UsageQuotasCreateRequest() {} + + @JsonCreator + public UsageQuotasCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) List data) { + this.data = data; + for (UsageQuotaCreateData item : data) { + this.unparsed |= item.unparsed; + } + } + + public UsageQuotasCreateRequest data(List data) { + this.data = data; + for (UsageQuotaCreateData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public UsageQuotasCreateRequest addDataItem(UsageQuotaCreateData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * A bulk list of usage quota resources to create or update by scope. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + if (data != null) { + for (UsageQuotaCreateData item : data) { + this.unparsed |= item.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 UsageQuotasCreateRequest + */ + @JsonAnySetter + public UsageQuotasCreateRequest 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 UsageQuotasCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotasCreateRequest usageQuotasCreateRequest = (UsageQuotasCreateRequest) o; + return Objects.equals(this.data, usageQuotasCreateRequest.data) + && Objects.equals(this.additionalProperties, usageQuotasCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotasCreateRequest {\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/UsageQuotasListResponse.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasListResponse.java new file mode 100644 index 00000000000..2694339ffe9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasListResponse.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.JsonCreator; +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; + +/** Response containing a paginated list of usage quotas. */ +@JsonPropertyOrder({ + UsageQuotasListResponse.JSON_PROPERTY_DATA, + UsageQuotasListResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotasListResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public static final String JSON_PROPERTY_META = "meta"; + private UsageQuotasResponseMeta meta; + + public UsageQuotasListResponse() {} + + @JsonCreator + public UsageQuotasListResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) List data, + @JsonProperty(required = true, value = JSON_PROPERTY_META) UsageQuotasResponseMeta meta) { + this.data = data; + for (UsageQuotaResponseData item : data) { + this.unparsed |= item.unparsed; + } + this.meta = meta; + if (meta != null) { + this.unparsed |= meta.unparsed; + } + } + + public UsageQuotasListResponse data(List data) { + this.data = data; + for (UsageQuotaResponseData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public UsageQuotasListResponse addDataItem(UsageQuotaResponseData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * A list of usage quota resources. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + if (data != null) { + for (UsageQuotaResponseData item : data) { + this.unparsed |= item.unparsed; + } + } + } + + public UsageQuotasListResponse meta(UsageQuotasResponseMeta meta) { + this.meta = meta; + if (meta != null) { + this.unparsed |= meta.unparsed; + } + return this; + } + + /** + * Pagination metadata for a usage quota list response. This field may be omitted when no + * pagination metadata is available. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UsageQuotasResponseMeta getMeta() { + return meta; + } + + public void setMeta(UsageQuotasResponseMeta 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 UsageQuotasListResponse + */ + @JsonAnySetter + public UsageQuotasListResponse 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 UsageQuotasListResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotasListResponse usageQuotasListResponse = (UsageQuotasListResponse) o; + return Objects.equals(this.data, usageQuotasListResponse.data) + && Objects.equals(this.meta, usageQuotasListResponse.meta) + && Objects.equals(this.additionalProperties, usageQuotasListResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotasListResponse {\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/main/java/com/datadog/api/client/v2/model/UsageQuotasResponse.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasResponse.java new file mode 100644 index 00000000000..f77c5cc2c4b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasResponse.java @@ -0,0 +1,163 @@ +/* + * 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.JsonCreator; +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; + +/** Response containing a list of usage quotas. */ +@JsonPropertyOrder({UsageQuotasResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotasResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public UsageQuotasResponse() {} + + @JsonCreator + public UsageQuotasResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + List data) { + this.data = data; + for (UsageQuotaResponseData item : data) { + this.unparsed |= item.unparsed; + } + } + + public UsageQuotasResponse data(List data) { + this.data = data; + for (UsageQuotaResponseData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public UsageQuotasResponse addDataItem(UsageQuotaResponseData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * A list of usage quota resources. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + if (data != null) { + for (UsageQuotaResponseData item : data) { + this.unparsed |= item.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 UsageQuotasResponse + */ + @JsonAnySetter + public UsageQuotasResponse 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 UsageQuotasResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotasResponse usageQuotasResponse = (UsageQuotasResponse) o; + return Objects.equals(this.data, usageQuotasResponse.data) + && Objects.equals(this.additionalProperties, usageQuotasResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotasResponse {\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/UsageQuotasResponseMeta.java b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasResponseMeta.java new file mode 100644 index 00000000000..8bbf0d061ad --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UsageQuotasResponseMeta.java @@ -0,0 +1,150 @@ +/* + * 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.JsonCreator; +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; + +/** + * Pagination metadata for a usage quota list response. This field may be omitted when no pagination + * metadata is available. + */ +@JsonPropertyOrder({UsageQuotasResponseMeta.JSON_PROPERTY_NEXT_CURSOR}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UsageQuotasResponseMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NEXT_CURSOR = "next_cursor"; + private String nextCursor; + + public UsageQuotasResponseMeta() {} + + @JsonCreator + public UsageQuotasResponseMeta( + @JsonProperty(required = true, value = JSON_PROPERTY_NEXT_CURSOR) String nextCursor) { + this.nextCursor = nextCursor; + if (nextCursor != null) {} + } + + public UsageQuotasResponseMeta nextCursor(String nextCursor) { + this.nextCursor = nextCursor; + if (nextCursor != null) {} + return this; + } + + /** + * An opaque cursor for retrieving the next page. This field may be omitted or null when there are + * no more results. + * + * @return nextCursor + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NEXT_CURSOR) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getNextCursor() { + return nextCursor; + } + + public void setNextCursor(String nextCursor) { + this.nextCursor = nextCursor; + } + + /** + * 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 UsageQuotasResponseMeta + */ + @JsonAnySetter + public UsageQuotasResponseMeta 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 UsageQuotasResponseMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsageQuotasResponseMeta usageQuotasResponseMeta = (UsageQuotasResponseMeta) o; + return Objects.equals(this.nextCursor, usageQuotasResponseMeta.nextCursor) + && Objects.equals(this.additionalProperties, usageQuotasResponseMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(nextCursor, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UsageQuotasResponseMeta {\n"); + sb.append(" nextCursor: ").append(toIndentedString(nextCursor)).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 870f4e34a50..f78a571d68d 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 @@ -9883,6 +9883,30 @@ "type": "safe" } }, + "ListQuotas": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, + "CreateOrUpdateQuotas": { + "tag": "Usage Metering", + "undo": { + "type": "idempotent" + } + }, + "DeleteQuota": { + "tag": "Usage Metering", + "undo": { + "type": "idempotent" + } + }, + "UpdateQuota": { + "tag": "Usage Metering", + "undo": { + "type": "idempotent" + } + }, "GetUsageSummaryAvailableFields": { "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 ca4cfbd6706..cfca4bbac94 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 @@ -14,6 +14,42 @@ Feature: Usage Metering And a valid "appKeyAuth" key in the system And an instance of "UsageMetering" API + @generated @skip @team:DataDog/billing-hub + Scenario: Create or update usage quotas returns "Bad Request" response + Given operation "CreateOrUpdateQuotas" enabled + And new "CreateOrUpdateQuotas" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"enforced": true, "org_public_id": "abcdef12345", "scope": {"user_handle": "jane@example.com"}, "usage_limit": 100000}, "type": "quota"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/billing-hub + Scenario: Create or update usage quotas returns "OK" response + Given operation "CreateOrUpdateQuotas" enabled + And new "CreateOrUpdateQuotas" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"enforced": true, "org_public_id": "abcdef12345", "scope": {"user_handle": "jane@example.com"}, "usage_limit": 100000}, "type": "quota"}]} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/billing-hub + Scenario: Delete a usage quota returns "No Content" response + Given operation "DeleteQuota" enabled + And new "DeleteQuota" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/billing-hub + Scenario: Delete a usage quota returns "Not Found" response + Given operation "DeleteQuota" enabled + And new "DeleteQuota" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @replay-only @team:DataDog/billing-hub Scenario: Get Monthly Cost Attribution returns "Bad Request" response Given new "GetMonthlyCostAttribution" request @@ -242,3 +278,57 @@ Feature: Usage Metering And request contains "start_month" parameter with value "{{ timeISO('now') }}" When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/billing-hub + Scenario: List usage quotas returns "Bad Request" response + Given operation "ListQuotas" enabled + And new "ListQuotas" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/billing-hub + Scenario: List usage quotas returns "OK" response + Given operation "ListQuotas" enabled + And new "ListQuotas" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/billing-hub @with-pagination + Scenario: List usage quotas returns "OK" response with pagination + Given operation "ListQuotas" enabled + And new "ListQuotas" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + When the request with pagination is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/billing-hub + Scenario: Update a usage quota returns "Bad Request" response + Given operation "UpdateQuota" enabled + And new "UpdateQuota" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enforced": false, "org_public_id": "abcdef12345", "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quota"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/billing-hub + Scenario: Update a usage quota returns "Not Found" response + Given operation "UpdateQuota" enabled + And new "UpdateQuota" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enforced": false, "org_public_id": "abcdef12345", "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quota"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/billing-hub + Scenario: Update a usage quota returns "OK" response + Given operation "UpdateQuota" enabled + And new "UpdateQuota" request + And request contains "quota_namespace" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enforced": false, "org_public_id": "abcdef12345", "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quota"}} + When the request is sent + Then the response status is 200 OK