From dd1ef0c75837ac578c624e9013ef385fa214303d Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 16 Oct 2026 15:22:27 +0000 Subject: [PATCH] Regenerate client from commit 7a2dee1 of spec repo --- .generator/schemas/v2/openapi.yaml | 162 +++++++++++++++--- examples/v2/usage-metering/CreateQuotas.rb | 6 +- .../v2/usage-metering/DeletePendingQuota.rb | 9 + examples/v2/usage-metering/DeleteQuota.rb | 2 +- examples/v2/usage-metering/UpdateQuota.rb | 5 +- features/scenarios_model_mapping.rb | 4 + features/v2/undo.json | 6 + features/v2/usage_metering.feature | 45 ++++- lib/datadog_api_client/configuration.rb | 1 + .../v2/api/usage_metering_api.rb | 84 ++++++++- .../usage_quota_bulk_result_attributes.rb | 44 ++++- .../v2/models/usage_quota_bulk_result_data.rb | 2 +- .../models/usage_quota_create_attributes.rb | 40 +++-- .../v2/models/usage_quota_create_data.rb | 2 +- .../models/usage_quota_response_attributes.rb | 37 +++- .../models/usage_quota_update_attributes.rb | 26 ++- .../v2/models/usage_quota_update_data.rb | 2 +- 17 files changed, 410 insertions(+), 67 deletions(-) create mode 100644 examples/v2/usage-metering/DeletePendingQuota.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 8e540e2cff55..6b96392bdd5c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -137258,7 +137258,7 @@ components: type: array type: object UsageQuotaBulkResultAttributes: - description: Attributes of a usage quota bulk write result. On success, all fields except `error` are present. On failure, only `error` is present and the other fields are omitted. + description: Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only `error` is present and the other fields are omitted. properties: enforced: description: Whether usage above the limit is actively blocked instead of only tracked or alerted on. Omitted if this item failed to write. @@ -137272,6 +137272,16 @@ components: description: The public ID of the organization that owns the quota. Omitted if this item failed to write. example: abcdef12345 type: string + pending_effective_from: + description: The future UTC month when the scheduled limit takes effect, formatted as `YYYY-MM`, starting at 00:00 UTC on its first day. Present only together with `pending_usage_limit` and omitted when no change is scheduled or this item failed to write. + example: "2026-11" + pattern: '^\d{4}-\d{2}$' + type: string + pending_usage_limit: + description: The usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. A value of `0` is valid. At the start of the effective month, this value becomes `usage_limit` and both pending fields are omitted. Omitted when no change is scheduled or this item failed to write. + example: 50000 + format: double + type: number scope: $ref: "#/components/schemas/UsageQuotaResponseScope" usage_limit: @@ -137287,7 +137297,7 @@ components: $ref: "#/components/schemas/UsageQuotaBulkResultAttributes" 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" + example: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: string type: $ref: "#/components/schemas/UsageQuotaType" @@ -137302,23 +137312,30 @@ components: $ref: "#/components/schemas/UsageQuotaBulkResultData" type: array UsageQuotaCreateAttributes: - description: Attributes for creating or updating a usage quota by scope. + description: Attributes for creating or updating a usage quota by scope. Each item must provide `usage_limit`, `pending_usage_limit`, or both. Providing only `pending_usage_limit` updates an existing organization-wide quota, never creates one, requires `enforced` to be omitted, and fails if the quota does not exist. + example: + enforced: true + pending_usage_limit: 100000 + usage_limit: 600000 properties: enforced: - description: Whether to actively block usage above the limit instead of only tracking or alerting on it. + description: Whether to actively block usage above `usage_limit` instead of only tracking or alerting on it. Required when `usage_limit` is provided and must be omitted when only `pending_usage_limit` is provided. example: true type: boolean + pending_usage_limit: + description: The non-negative, whole-number limit to schedule for the organization-wide quota in the usage units defined by the quota namespace. It is not checked against current usage. Each write schedules the value for 00:00 UTC on the first day of the next calendar month and replaces any previously scheduled change; the server computes `pending_effective_from`. Omit this field to leave any scheduled change unchanged, including when raising `usage_limit`. Cancel a scheduled change only by deleting the quota's `/pending` sub-resource. + example: 50000 + format: int64 + minimum: 0 + type: integer scope: $ref: "#/components/schemas/UsageQuotaRequestScope" usage_limit: - description: The quota limit to set in the usage units defined by the quota namespace. For an organization-wide quota (scope omitted), the limit must be greater than the usage already recorded in the current period. + description: The non-negative, whole-number quota limit to set in the usage units defined by the quota namespace. For an organization-wide quota (scope omitted), the limit must be greater than usage already recorded in the current period. When this field is provided, `enforced` is required. example: 100000 format: int64 minimum: 0 type: integer - required: - - usage_limit - - enforced type: object UsageQuotaCreateData: description: A usage quota resource to create or update by scope. @@ -137366,6 +137383,19 @@ components: description: The public ID of the organization that owns the quota. example: abcdef12345 type: string + pending_effective_from: + description: The future UTC month when the scheduled limit takes effect, formatted as `YYYY-MM`, starting at 00:00 UTC on its first day. Present only together with `pending_usage_limit` and omitted when no change is scheduled. + example: "2026-11" + pattern: '^\d{4}-\d{2}$' + type: string + pending_usage_limit: + description: |- + The usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. + A value of `0` is valid. At the start of the effective month, this value becomes `usage_limit` and both pending + fields are omitted. Omitted when no change is scheduled. + example: 50000 + format: double + type: number scope: $ref: "#/components/schemas/UsageQuotaResponseScope" usage_limit: @@ -137385,7 +137415,7 @@ components: $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" + example: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: string type: $ref: "#/components/schemas/UsageQuotaType" @@ -137418,13 +137448,20 @@ components: x-enum-varnames: - QUOTAS UsageQuotaUpdateAttributes: - description: Attributes to update on a usage quota. Omitting a property leaves its current value unchanged. + description: Attributes to update on a usage quota. At least one of `usage_limit`, `enforced`, or `pending_usage_limit` must be provided. 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 + pending_usage_limit: + description: The non-negative, whole-number limit to schedule for the organization-wide quota in the usage units defined by the quota namespace. It is not checked against current usage. Each write schedules the value for 00:00 UTC on the first day of the next calendar month and replaces any previously scheduled change; the server computes `pending_effective_from`. Omit this field to leave any scheduled change unchanged, including when raising `usage_limit`; use `DELETE /api/v2/usage/quotas/{quota_namespace}/{id}/pending` to cancel one. + example: 50000 + format: int64 + minimum: 0 + nullable: true + type: integer usage_limit: description: The new quota limit in the usage units defined by the quota namespace. For an organization-wide quota (empty scope), the limit must be greater than the usage already recorded in the current period. Omit this field to leave the current limit unchanged. example: 120000 @@ -137440,7 +137477,7 @@ components: $ref: "#/components/schemas/UsageQuotaUpdateAttributes" id: description: The opaque usage quota identifier, which must match the identifier in the request path. - example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + example: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: string type: $ref: "#/components/schemas/UsageQuotaType" @@ -245841,7 +245878,15 @@ paths: scope: user_handle: jane@example.com usage_limit: 100000 - id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOmphbmVAZXhhbXBsZS5jb20" + type: quotas + - attributes: + enforced: true + org_public_id: abcdef12345 + pending_effective_from: "2026-11" + pending_usage_limit: 100000 + usage_limit: 600000 + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: quotas meta: page: @@ -245888,7 +245933,11 @@ paths: 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. If a quota already exists for a supplied scope, it is updated; otherwise, a new quota is created. Requires the `billing_edit` permission. + Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated. + Otherwise, a quota is created only when `usage_limit` and `enforced` are provided. + For the organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period and can + accompany an immediate limit or update an existing quota by itself. + Scheduled changes follow `include_descendants` like the other fields. Requires the `billing_edit` permission. operationId: CreateQuotas parameters: - description: The product-specific namespace whose usage quotas are being managed. @@ -245925,6 +245974,15 @@ paths: user_handle: "*" usage_limit: 250000 type: quotas + schedule_reduction: + summary: Set a limit and schedule a reduction + value: + data: + - attributes: + enforced: true + pending_usage_limit: 100000 + usage_limit: 600000 + type: quotas schema: $ref: "#/components/schemas/UsageQuotasCreateRequest" description: The usage quotas to create or update. @@ -245943,11 +246001,11 @@ paths: scope: user_handle: jane@example.com usage_limit: 100000 - id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOmphbmVAZXhhbXBsZS5jb20" type: quotas - attributes: error: usage_limit is out of range - id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTp1c2VyQGV4YW1wbGUuY29t" + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOnVzZXJAZXhhbXBsZS5jb20" type: quotas schema: $ref: "#/components/schemas/UsageQuotasBulkResponse" @@ -245957,7 +246015,7 @@ paths: application/json: schema: $ref: "#/components/schemas/JSONAPIErrorResponse" - description: Bad Request + description: Bad Request. Returned if the request is malformed, including when an item sets `pending_usage_limit` on a scoped quota, provides `enforced` without `usage_limit`, or provides neither limit. A pending-only item for a quota that does not exist is reported in that item's `error`; when only the caller's organization is targeted, this failure returns `400`. "403": content: application/json: @@ -246005,7 +246063,7 @@ paths: name: id required: true schema: - example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + example: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: string responses: "204": @@ -246041,7 +246099,7 @@ paths: 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 `billing_edit` permission. + Updates the supplied fields on a usage quota and leaves omitted fields unchanged. For an organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period. 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 `billing_edit` permission. operationId: UpdateQuota parameters: - description: The product-specific namespace whose usage quotas are being managed. @@ -246056,7 +246114,7 @@ paths: name: id required: true schema: - example: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + example: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: string requestBody: content: @@ -246068,7 +246126,7 @@ paths: attributes: enforced: false usage_limit: 120000 - id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: quotas schema: $ref: "#/components/schemas/UsageQuotaUpdateRequest" @@ -246085,10 +246143,8 @@ paths: attributes: enforced: false org_public_id: abcdef12345 - scope: - user_handle: jane@example.com usage_limit: 120000 - id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f" + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" type: quotas schema: $ref: "#/components/schemas/UsageQuotaResponse" @@ -246098,7 +246154,7 @@ paths: application/json: schema: $ref: "#/components/schemas/JSONAPIErrorResponse" - description: Bad Request. Returned if the request is malformed, or if the `id` in the request body does not match the `id` in the request path. + description: Bad Request. Returned if the request is malformed, if the `id` in the request body does not match the `id` in the request path, if none of `usage_limit`, `enforced`, or `pending_usage_limit` is provided, or if `pending_usage_limit` is set on a scoped quota. "403": content: application/json: @@ -246128,6 +246184,64 @@ paths: 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}/pending: + delete: + description: |- + Cancels the limit change scheduled to take effect at the start of the next usage period, leaving the usage quota and its current limit unchanged. Returns `404` when the quota does not exist, has no scheduled change, or its scheduled change has already taken effect; in every case the quota is left 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 `billing_edit` permission. + operationId: DeletePendingQuota + 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: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18" + type: string + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request. Returned if the `id` is malformed or does not belong to the requested quota namespace. + "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: + - billing_edit + summary: Cancel a scheduled usage quota limit + tags: + - Usage Metering + "x-permission": + operator: OR + permissions: + - billing_edit + 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/CreateQuotas.rb b/examples/v2/usage-metering/CreateQuotas.rb index 66fe57225963..9b62b2e8289c 100644 --- a/examples/v2/usage-metering/CreateQuotas.rb +++ b/examples/v2/usage-metering/CreateQuotas.rb @@ -13,10 +13,8 @@ DatadogAPIClient::V2::UsageQuotaCreateData.new({ attributes: DatadogAPIClient::V2::UsageQuotaCreateAttributes.new({ enforced: true, - scope: { - user_handle: "jane@example.com", - }, - usage_limit: 100000, + pending_usage_limit: 100000, + usage_limit: 600000, }), type: DatadogAPIClient::V2::UsageQuotaType::QUOTAS, }), diff --git a/examples/v2/usage-metering/DeletePendingQuota.rb b/examples/v2/usage-metering/DeletePendingQuota.rb new file mode 100644 index 000000000000..0e0cde1c98e2 --- /dev/null +++ b/examples/v2/usage-metering/DeletePendingQuota.rb @@ -0,0 +1,9 @@ +# Cancel a scheduled usage quota limit returns "No Content" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.delete_pending_quota".to_sym] = true +end +api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new +api_instance.delete_pending_quota("ai_credits", "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18") diff --git a/examples/v2/usage-metering/DeleteQuota.rb b/examples/v2/usage-metering/DeleteQuota.rb index 1b329f4415d9..96452d83ec86 100644 --- a/examples/v2/usage-metering/DeleteQuota.rb +++ b/examples/v2/usage-metering/DeleteQuota.rb @@ -6,4 +6,4 @@ config.unstable_operations["v2.delete_quota".to_sym] = true end api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new -api_instance.delete_quota("ai_credits", "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f") +api_instance.delete_quota("ai_credits", "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18") diff --git a/examples/v2/usage-metering/UpdateQuota.rb b/examples/v2/usage-metering/UpdateQuota.rb index ca678e226a3e..78364315ec4d 100644 --- a/examples/v2/usage-metering/UpdateQuota.rb +++ b/examples/v2/usage-metering/UpdateQuota.rb @@ -11,10 +11,11 @@ data: DatadogAPIClient::V2::UsageQuotaUpdateData.new({ attributes: DatadogAPIClient::V2::UsageQuotaUpdateAttributes.new({ enforced: false, + pending_usage_limit: 50000, usage_limit: 120000, }), - id: "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", + id: "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", type: DatadogAPIClient::V2::UsageQuotaType::QUOTAS, }), }) -p api_instance.update_quota("ai_credits", "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", body) +p api_instance.update_quota("ai_credits", "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 1377d926590b..3b60878868a3 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3220,6 +3220,10 @@ "id" => "String", "body" => "UsageQuotaUpdateRequest", }, + "v2.DeletePendingQuota" => { + "quota_namespace" => "String", + "id" => "String", + }, "v2.ListAllCSMAgents" => { "page" => "Integer", "size" => "Integer", diff --git a/features/v2/undo.json b/features/v2/undo.json index 8b44c9415758..47f57825d51c 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -11046,6 +11046,12 @@ "type": "idempotent" } }, + "DeletePendingQuota": { + "tag": "Usage Metering", + "undo": { + "type": "idempotent" + } + }, "GetUsageSummaryAvailableFields": { "tag": "Usage Metering", "undo": { diff --git a/features/v2/usage_metering.feature b/features/v2/usage_metering.feature index cdab1476abf5..9fd783ecd662 100644 --- a/features/v2/usage_metering.feature +++ b/features/v2/usage_metering.feature @@ -15,20 +15,47 @@ Feature: Usage Metering And an instance of "UsageMetering" API @generated @skip @team:ddoghq/billing-hub - Scenario: Create or update usage quotas returns "Bad Request" response + Scenario: Cancel a scheduled usage quota limit returns "Bad Request. Returned if the `id` is malformed or does not belong to the requested quota namespace." response + Given operation "DeletePendingQuota" enabled + And new "DeletePendingQuota" 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 400 Bad Request. Returned if the `id` is malformed or does not belong to the requested quota namespace. + + @generated @skip @team:ddoghq/billing-hub + Scenario: Cancel a scheduled usage quota limit returns "No Content" response + Given operation "DeletePendingQuota" enabled + And new "DeletePendingQuota" 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:ddoghq/billing-hub + Scenario: Cancel a scheduled usage quota limit returns "Not Found" response + Given operation "DeletePendingQuota" enabled + And new "DeletePendingQuota" 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 + + @generated @skip @team:ddoghq/billing-hub + Scenario: Create or update usage quotas returns "Bad Request. Returned if the request is malformed, including when an item sets `pending_usage_limit` on a scoped quota, provides `enforced` without `usage_limit`, or provides neither limit. A pending-only item for a quota that does not exist is reported in that item's `error`; when only the caller's organization is targeted, this failure returns `400`." response Given operation "CreateQuotas" enabled And new "CreateQuotas" request And request contains "quota_namespace" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"enforced": true, "scope": {"user_handle": "jane@example.com"}, "usage_limit": 100000}, "type": "quotas"}]} + And body with value {"data": [{"attributes": {"enforced": true, "pending_usage_limit": 100000, "usage_limit": 600000}, "type": "quotas"}]} When the request is sent - Then the response status is 400 Bad Request + Then the response status is 400 Bad Request. Returned if the request is malformed, including when an item sets `pending_usage_limit` on a scoped quota, provides `enforced` without `usage_limit`, or provides neither limit. A pending-only item for a quota that does not exist is reported in that item's `error`; when only the caller's organization is targeted, this failure returns `400`. @generated @skip @team:ddoghq/billing-hub Scenario: Create or update usage quotas returns "OK. The response includes each item's result; see each item's `error` attribute for any that failed to write." response Given operation "CreateQuotas" enabled And new "CreateQuotas" request And request contains "quota_namespace" parameter from "REPLACE.ME" - And body with value {"data": [{"attributes": {"enforced": true, "scope": {"user_handle": "jane@example.com"}, "usage_limit": 100000}, "type": "quotas"}]} + And body with value {"data": [{"attributes": {"enforced": true, "pending_usage_limit": 100000, "usage_limit": 600000}, "type": "quotas"}]} When the request is sent Then the response status is 200 OK. The response includes each item's result; see each item's `error` attribute for any that failed to write. @@ -304,14 +331,14 @@ Feature: Usage Metering Then the response status is 200 OK @generated @skip @team:ddoghq/billing-hub - Scenario: Update a usage quota returns "Bad Request. Returned if the request is malformed, or if the `id` in the request body does not match the `id` in the request path." response + Scenario: Update a usage quota returns "Bad Request. Returned if the request is malformed, if the `id` in the request body does not match the `id` in the request path, if none of `usage_limit`, `enforced`, or `pending_usage_limit` is provided, or if `pending_usage_limit` is set on a scoped quota." 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, "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quotas"}} + And body with value {"data": {"attributes": {"enforced": false, "pending_usage_limit": 50000, "usage_limit": 120000}, "id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", "type": "quotas"}} When the request is sent - Then the response status is 400 Bad Request. Returned if the request is malformed, or if the `id` in the request body does not match the `id` in the request path. + Then the response status is 400 Bad Request. Returned if the request is malformed, if the `id` in the request body does not match the `id` in the request path, if none of `usage_limit`, `enforced`, or `pending_usage_limit` is provided, or if `pending_usage_limit` is set on a scoped quota. @generated @skip @team:ddoghq/billing-hub Scenario: Update a usage quota returns "Not Found" response @@ -319,7 +346,7 @@ Feature: Usage Metering 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, "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quotas"}} + And body with value {"data": {"attributes": {"enforced": false, "pending_usage_limit": 50000, "usage_limit": 120000}, "id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", "type": "quotas"}} When the request is sent Then the response status is 404 Not Found @@ -329,6 +356,6 @@ Feature: Usage Metering 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, "usage_limit": 120000}, "id": "MjAfYWlfY3JlZGl0c1911c2VyX2hhbmRsZTpfX0FMTF9f", "type": "quotas"}} + And body with value {"data": {"attributes": {"enforced": false, "pending_usage_limit": 50000, "usage_limit": 120000}, "id": "MTIzNB9haV9jcmVkaXRzH3VzZXJfaGFuZGxlOl9fQUxMX18", "type": "quotas"}} When the request is sent Then the response status is 200 OK diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 941ac5ce9f0f..0ace45fbcc7d 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -435,6 +435,7 @@ def initialize "v2.search_cost_recommendations": false, "v2.update_unit_cost": false, "v2.create_quotas": false, + "v2.delete_pending_quota": false, "v2.delete_quota": false, "v2.list_quotas": false, "v2.update_quota": false, diff --git a/lib/datadog_api_client/v2/api/usage_metering_api.rb b/lib/datadog_api_client/v2/api/usage_metering_api.rb index e5a8299cd2fa..dee74b7f0b66 100644 --- a/lib/datadog_api_client/v2/api/usage_metering_api.rb +++ b/lib/datadog_api_client/v2/api/usage_metering_api.rb @@ -33,7 +33,11 @@ def create_quotas(quota_namespace, body, opts = {}) # Create or update usage quotas. # - # Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated; otherwise, a new quota is created. Requires the `billing_edit` permission. + # Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated. + # Otherwise, a quota is created only when `usage_limit` and `enforced` are provided. + # For the organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period and can + # accompany an immediate limit or update an existing quota by itself. + # Scheduled changes follow `include_descendants` like the other fields. Requires the `billing_edit` permission. # # @param quota_namespace [String] The product-specific namespace whose usage quotas are being managed. # @param body [UsageQuotasCreateRequest] The usage quotas to create or update. @@ -103,6 +107,82 @@ def create_quotas_with_http_info(quota_namespace, body, opts = {}) return data, status_code, headers end + # Cancel a scheduled usage quota limit. + # + # @see #delete_pending_quota_with_http_info + def delete_pending_quota(quota_namespace, id, opts = {}) + delete_pending_quota_with_http_info(quota_namespace, id, opts) + nil + end + + # Cancel a scheduled usage quota limit. + # + # Cancels the limit change scheduled to take effect at the start of the next usage period, leaving the usage quota and its current limit unchanged. Returns `404` when the quota does not exist, has no scheduled change, or its scheduled change has already taken effect; in every case the quota is left 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 `billing_edit` permission. + # + # @param quota_namespace [String] The product-specific namespace whose usage quotas are being managed. + # @param id [String] The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_pending_quota_with_http_info(quota_namespace, id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.delete_pending_quota".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_pending_quota") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_pending_quota")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.delete_pending_quota ...' + end + # verify the required parameter 'quota_namespace' is set + if @api_client.config.client_side_validation && quota_namespace.nil? + fail ArgumentError, "Missing the required parameter 'quota_namespace' when calling UsageMeteringAPI.delete_pending_quota" + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling UsageMeteringAPI.delete_pending_quota" + end + # resource path + local_var_path = '/api/v2/usage/quotas/{quota_namespace}/{id}/pending'.sub('{quota_namespace}', CGI.escape(quota_namespace.to_s).gsub('%2F', '/')).sub('{id}', CGI.escape(id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :delete_pending_quota, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UsageMeteringAPI#delete_pending_quota\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete a usage quota. # # @see #delete_quota_with_http_info @@ -1292,7 +1372,7 @@ def update_quota(quota_namespace, id, body, opts = {}) # Update a usage quota. # - # 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 `billing_edit` permission. + # Updates the supplied fields on a usage quota and leaves omitted fields unchanged. For an organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period. 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 `billing_edit` permission. # # @param quota_namespace [String] The product-specific namespace whose usage quotas are being managed. # @param id [String] The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim. diff --git a/lib/datadog_api_client/v2/models/usage_quota_bulk_result_attributes.rb b/lib/datadog_api_client/v2/models/usage_quota_bulk_result_attributes.rb index 9c3412d1c186..9cd9e7825810 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_bulk_result_attributes.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_bulk_result_attributes.rb @@ -17,7 +17,7 @@ require 'time' module DatadogAPIClient::V2 - # Attributes of a usage quota bulk write result. On success, all fields except `error` are present. On failure, only `error` is present and the other fields are omitted. + # Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only `error` is present and the other fields are omitted. class UsageQuotaBulkResultAttributes include BaseGenericModel @@ -30,6 +30,12 @@ class UsageQuotaBulkResultAttributes # The public ID of the organization that owns the quota. Omitted if this item failed to write. attr_accessor :org_public_id + # The future UTC month when the scheduled limit takes effect, formatted as `YYYY-MM`, starting at 00:00 UTC on its first day. Present only together with `pending_usage_limit` and omitted when no change is scheduled or this item failed to write. + attr_reader :pending_effective_from + + # The usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. A value of `0` is valid. At the start of the effective month, this value becomes `usage_limit` and both pending fields are omitted. Omitted when no change is scheduled or this item failed to write. + attr_accessor :pending_usage_limit + # 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 for an organization-wide quota. attr_accessor :scope @@ -45,6 +51,8 @@ def self.attribute_map :'enforced' => :'enforced', :'error' => :'error', :'org_public_id' => :'org_public_id', + :'pending_effective_from' => :'pending_effective_from', + :'pending_usage_limit' => :'pending_usage_limit', :'scope' => :'scope', :'usage_limit' => :'usage_limit' } @@ -57,6 +65,8 @@ def self.openapi_types :'enforced' => :'Boolean', :'error' => :'String', :'org_public_id' => :'String', + :'pending_effective_from' => :'String', + :'pending_usage_limit' => :'Float', :'scope' => :'Hash', :'usage_limit' => :'Float' } @@ -92,6 +102,14 @@ def initialize(attributes = {}) self.org_public_id = attributes[:'org_public_id'] end + if attributes.key?(:'pending_effective_from') + self.pending_effective_from = attributes[:'pending_effective_from'] + end + + if attributes.key?(:'pending_usage_limit') + self.pending_usage_limit = attributes[:'pending_usage_limit'] + end + if attributes.key?(:'scope') self.scope = attributes[:'scope'] end @@ -101,6 +119,26 @@ def initialize(attributes = {}) end end + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + pattern = Regexp.new(/^\d{4}-\d{2}$/) + return false if !@pending_effective_from.nil? && @pending_effective_from !~ pattern + true + end + + # Custom attribute writer method with validation + # @param pending_effective_from [Object] Object to be assigned + # @!visibility private + def pending_effective_from=(pending_effective_from) + pattern = Regexp.new(/^\d{4}-\d{2}$/) + if !pending_effective_from.nil? && pending_effective_from !~ pattern + fail ArgumentError, "invalid value for \"pending_effective_from\", must conform to the pattern #{pattern}." + end + @pending_effective_from = pending_effective_from + end + # Returns the object in the form of hash, with additionalProperties support. # @return [Hash] Returns the object in the form of hash # @!visibility private @@ -130,6 +168,8 @@ def ==(o) enforced == o.enforced && error == o.error && org_public_id == o.org_public_id && + pending_effective_from == o.pending_effective_from && + pending_usage_limit == o.pending_usage_limit && scope == o.scope && usage_limit == o.usage_limit && additional_properties == o.additional_properties @@ -139,7 +179,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enforced, error, org_public_id, scope, usage_limit, additional_properties].hash + [enforced, error, org_public_id, pending_effective_from, pending_usage_limit, scope, usage_limit, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/usage_quota_bulk_result_data.rb b/lib/datadog_api_client/v2/models/usage_quota_bulk_result_data.rb index 75e4a4ee46b9..33542901ea5b 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_bulk_result_data.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_bulk_result_data.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class UsageQuotaBulkResultData include BaseGenericModel - # Attributes of a usage quota bulk write result. On success, all fields except `error` are present. On failure, only `error` is present and the other fields are omitted. + # Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only `error` is present and the other fields are omitted. attr_reader :attributes # 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. diff --git a/lib/datadog_api_client/v2/models/usage_quota_create_attributes.rb b/lib/datadog_api_client/v2/models/usage_quota_create_attributes.rb index 788631fa2b6d..89629e721ab6 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_create_attributes.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_create_attributes.rb @@ -17,17 +17,20 @@ require 'time' module DatadogAPIClient::V2 - # Attributes for creating or updating a usage quota by scope. + # Attributes for creating or updating a usage quota by scope. Each item must provide `usage_limit`, `pending_usage_limit`, or both. Providing only `pending_usage_limit` updates an existing organization-wide quota, never creates one, requires `enforced` to be omitted, and fails if the quota does not exist. class UsageQuotaCreateAttributes include BaseGenericModel - # Whether to actively block usage above the limit instead of only tracking or alerting on it. - attr_reader :enforced + # Whether to actively block usage above `usage_limit` instead of only tracking or alerting on it. Required when `usage_limit` is provided and must be omitted when only `pending_usage_limit` is provided. + attr_accessor :enforced + + # The non-negative, whole-number limit to schedule for the organization-wide quota in the usage units defined by the quota namespace. It is not checked against current usage. Each write schedules the value for 00:00 UTC on the first day of the next calendar month and replaces any previously scheduled change; the server computes `pending_effective_from`. Omit this field to leave any scheduled change unchanged, including when raising `usage_limit`. Cancel a scheduled change only by deleting the quota's `/pending` sub-resource. + attr_reader :pending_usage_limit # 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. A specific value must identify an existing user handle in the caller's organization when `include_descendants` is false. When `include_descendants` is true, the handle must exist in the caller's organization or in at least one targeted descendant organization; the quota is then applied only to the organizations where that handle exists, and the request fails only if the handle exists in none of them. attr_accessor :scope - # The quota limit to set in the usage units defined by the quota namespace. For an organization-wide quota (scope omitted), the limit must be greater than the usage already recorded in the current period. + # The non-negative, whole-number quota limit to set in the usage units defined by the quota namespace. For an organization-wide quota (scope omitted), the limit must be greater than usage already recorded in the current period. When this field is provided, `enforced` is required. attr_reader :usage_limit attr_accessor :additional_properties @@ -37,6 +40,7 @@ class UsageQuotaCreateAttributes def self.attribute_map { :'enforced' => :'enforced', + :'pending_usage_limit' => :'pending_usage_limit', :'scope' => :'scope', :'usage_limit' => :'usage_limit' } @@ -47,6 +51,7 @@ def self.attribute_map def self.openapi_types { :'enforced' => :'Boolean', + :'pending_usage_limit' => :'Integer', :'scope' => :'Hash', :'usage_limit' => :'Integer' } @@ -74,6 +79,10 @@ def initialize(attributes = {}) self.enforced = attributes[:'enforced'] end + if attributes.key?(:'pending_usage_limit') + self.pending_usage_limit = attributes[:'pending_usage_limit'] + end + if attributes.key?(:'scope') self.scope = attributes[:'scope'] end @@ -87,30 +96,26 @@ def initialize(attributes = {}) # @return true if the model is valid # @!visibility private def valid? - return false if @enforced.nil? - return false if @usage_limit.nil? - return false if @usage_limit < 0 + return false if !@pending_usage_limit.nil? && @pending_usage_limit < 0 + return false if !@usage_limit.nil? && @usage_limit < 0 true end # Custom attribute writer method with validation - # @param enforced [Object] Object to be assigned + # @param pending_usage_limit [Object] Object to be assigned # @!visibility private - def enforced=(enforced) - if enforced.nil? - fail ArgumentError, 'invalid value for "enforced", enforced cannot be nil.' + def pending_usage_limit=(pending_usage_limit) + if !pending_usage_limit.nil? && pending_usage_limit < 0 + fail ArgumentError, 'invalid value for "pending_usage_limit", must be greater than or equal to 0.' end - @enforced = enforced + @pending_usage_limit = pending_usage_limit end # Custom attribute writer method with validation # @param usage_limit [Object] Object to be assigned # @!visibility private def usage_limit=(usage_limit) - if usage_limit.nil? - fail ArgumentError, 'invalid value for "usage_limit", usage_limit cannot be nil.' - end - if usage_limit < 0 + if !usage_limit.nil? && usage_limit < 0 fail ArgumentError, 'invalid value for "usage_limit", must be greater than or equal to 0.' end @usage_limit = usage_limit @@ -143,6 +148,7 @@ def ==(o) return true if self.equal?(o) self.class == o.class && enforced == o.enforced && + pending_usage_limit == o.pending_usage_limit && scope == o.scope && usage_limit == o.usage_limit && additional_properties == o.additional_properties @@ -152,7 +158,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enforced, scope, usage_limit, additional_properties].hash + [enforced, pending_usage_limit, scope, usage_limit, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/usage_quota_create_data.rb b/lib/datadog_api_client/v2/models/usage_quota_create_data.rb index d4e0b1a48c33..3cc913bf4c1c 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_create_data.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_create_data.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class UsageQuotaCreateData include BaseGenericModel - # Attributes for creating or updating a usage quota by scope. + # Attributes for creating or updating a usage quota by scope. Each item must provide `usage_limit`, `pending_usage_limit`, or both. Providing only `pending_usage_limit` updates an existing organization-wide quota, never creates one, requires `enforced` to be omitted, and fails if the quota does not exist. attr_reader :attributes # The JSON:API resource type for a usage quota. diff --git a/lib/datadog_api_client/v2/models/usage_quota_response_attributes.rb b/lib/datadog_api_client/v2/models/usage_quota_response_attributes.rb index 7002751b5937..f06f564a75ef 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_response_attributes.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_response_attributes.rb @@ -27,6 +27,14 @@ class UsageQuotaResponseAttributes # The public ID of the organization that owns the quota. attr_reader :org_public_id + # The future UTC month when the scheduled limit takes effect, formatted as `YYYY-MM`, starting at 00:00 UTC on its first day. Present only together with `pending_usage_limit` and omitted when no change is scheduled. + attr_reader :pending_effective_from + + # The usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. + # A value of `0` is valid. At the start of the effective month, this value becomes `usage_limit` and both pending + # fields are omitted. Omitted when no change is scheduled. + attr_accessor :pending_usage_limit + # 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 for an organization-wide quota. attr_accessor :scope @@ -41,6 +49,8 @@ def self.attribute_map { :'enforced' => :'enforced', :'org_public_id' => :'org_public_id', + :'pending_effective_from' => :'pending_effective_from', + :'pending_usage_limit' => :'pending_usage_limit', :'scope' => :'scope', :'usage_limit' => :'usage_limit' } @@ -52,6 +62,8 @@ def self.openapi_types { :'enforced' => :'Boolean', :'org_public_id' => :'String', + :'pending_effective_from' => :'String', + :'pending_usage_limit' => :'Float', :'scope' => :'Hash', :'usage_limit' => :'Float' } @@ -83,6 +95,14 @@ def initialize(attributes = {}) self.org_public_id = attributes[:'org_public_id'] end + if attributes.key?(:'pending_effective_from') + self.pending_effective_from = attributes[:'pending_effective_from'] + end + + if attributes.key?(:'pending_usage_limit') + self.pending_usage_limit = attributes[:'pending_usage_limit'] + end + if attributes.key?(:'scope') self.scope = attributes[:'scope'] end @@ -98,6 +118,8 @@ def initialize(attributes = {}) def valid? return false if @enforced.nil? return false if @org_public_id.nil? + pattern = Regexp.new(/^\d{4}-\d{2}$/) + return false if !@pending_effective_from.nil? && @pending_effective_from !~ pattern return false if @usage_limit.nil? true end @@ -122,6 +144,17 @@ def org_public_id=(org_public_id) @org_public_id = org_public_id end + # Custom attribute writer method with validation + # @param pending_effective_from [Object] Object to be assigned + # @!visibility private + def pending_effective_from=(pending_effective_from) + pattern = Regexp.new(/^\d{4}-\d{2}$/) + if !pending_effective_from.nil? && pending_effective_from !~ pattern + fail ArgumentError, "invalid value for \"pending_effective_from\", must conform to the pattern #{pattern}." + end + @pending_effective_from = pending_effective_from + end + # Custom attribute writer method with validation # @param usage_limit [Object] Object to be assigned # @!visibility private @@ -160,6 +193,8 @@ def ==(o) self.class == o.class && enforced == o.enforced && org_public_id == o.org_public_id && + pending_effective_from == o.pending_effective_from && + pending_usage_limit == o.pending_usage_limit && scope == o.scope && usage_limit == o.usage_limit && additional_properties == o.additional_properties @@ -169,7 +204,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enforced, org_public_id, scope, usage_limit, additional_properties].hash + [enforced, org_public_id, pending_effective_from, pending_usage_limit, scope, usage_limit, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/usage_quota_update_attributes.rb b/lib/datadog_api_client/v2/models/usage_quota_update_attributes.rb index 78ccd0d5ac49..72af19048b69 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_update_attributes.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_update_attributes.rb @@ -17,13 +17,16 @@ require 'time' module DatadogAPIClient::V2 - # Attributes to update on a usage quota. Omitting a property leaves its current value unchanged. + # Attributes to update on a usage quota. At least one of `usage_limit`, `enforced`, or `pending_usage_limit` must be provided. Omitting a property leaves its current value unchanged. class UsageQuotaUpdateAttributes include BaseGenericModel # Whether to actively block usage above the limit. Omit this field to leave the current enforcement setting unchanged. attr_accessor :enforced + # The non-negative, whole-number limit to schedule for the organization-wide quota in the usage units defined by the quota namespace. It is not checked against current usage. Each write schedules the value for 00:00 UTC on the first day of the next calendar month and replaces any previously scheduled change; the server computes `pending_effective_from`. Omit this field to leave any scheduled change unchanged, including when raising `usage_limit`; use `DELETE /api/v2/usage/quotas/{quota_namespace}/{id}/pending` to cancel one. + attr_reader :pending_usage_limit + # The new quota limit in the usage units defined by the quota namespace. For an organization-wide quota (empty scope), the limit must be greater than the usage already recorded in the current period. Omit this field to leave the current limit unchanged. attr_reader :usage_limit @@ -34,6 +37,7 @@ class UsageQuotaUpdateAttributes def self.attribute_map { :'enforced' => :'enforced', + :'pending_usage_limit' => :'pending_usage_limit', :'usage_limit' => :'usage_limit' } end @@ -43,6 +47,7 @@ def self.attribute_map def self.openapi_types { :'enforced' => :'Boolean', + :'pending_usage_limit' => :'Integer', :'usage_limit' => :'Integer' } end @@ -52,6 +57,7 @@ def self.openapi_types def self.openapi_nullable Set.new([ :'enforced', + :'pending_usage_limit', :'usage_limit', ]) end @@ -78,6 +84,10 @@ def initialize(attributes = {}) self.enforced = attributes[:'enforced'] end + if attributes.key?(:'pending_usage_limit') + self.pending_usage_limit = attributes[:'pending_usage_limit'] + end + if attributes.key?(:'usage_limit') self.usage_limit = attributes[:'usage_limit'] end @@ -87,10 +97,21 @@ def initialize(attributes = {}) # @return true if the model is valid # @!visibility private def valid? + return false if !@pending_usage_limit.nil? && @pending_usage_limit < 0 return false if !@usage_limit.nil? && @usage_limit < 0 true end + # Custom attribute writer method with validation + # @param pending_usage_limit [Object] Object to be assigned + # @!visibility private + def pending_usage_limit=(pending_usage_limit) + if !pending_usage_limit.nil? && pending_usage_limit < 0 + fail ArgumentError, 'invalid value for "pending_usage_limit", must be greater than or equal to 0.' + end + @pending_usage_limit = pending_usage_limit + end + # Custom attribute writer method with validation # @param usage_limit [Object] Object to be assigned # @!visibility private @@ -128,6 +149,7 @@ def ==(o) return true if self.equal?(o) self.class == o.class && enforced == o.enforced && + pending_usage_limit == o.pending_usage_limit && usage_limit == o.usage_limit && additional_properties == o.additional_properties end @@ -136,7 +158,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enforced, usage_limit, additional_properties].hash + [enforced, pending_usage_limit, usage_limit, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/usage_quota_update_data.rb b/lib/datadog_api_client/v2/models/usage_quota_update_data.rb index ed59e7f32712..6ff681ee9c45 100644 --- a/lib/datadog_api_client/v2/models/usage_quota_update_data.rb +++ b/lib/datadog_api_client/v2/models/usage_quota_update_data.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class UsageQuotaUpdateData include BaseGenericModel - # Attributes to update on a usage quota. Omitting a property leaves its current value unchanged. + # Attributes to update on a usage quota. At least one of `usage_limit`, `enforced`, or `pending_usage_limit` must be provided. Omitting a property leaves its current value unchanged. attr_reader :attributes # The opaque usage quota identifier, which must match the identifier in the request path.