UpdateGatewayQuotaRule

Updated at:

Updates a quota throttling rule on a gateway.

Operation description

Updates a quota rule on a gateway. Note that this operation takes effect only on AI gateways of a version later than 2.1.21. The update retains the historical usage of the consumers associated with the rule.

Note

Recommended call logic:

    1. Perform a dry run to check for rule conflicts.

    • Set dryRun=true.

    • The response returns a conflict preview that contains a conflictHash.

    1. Formally submit the request after confirmation.

    • If no conflicts exist: Set dryRun=false and overwrite=false.

    • If conflicts exist and you confirm to overwrite: Set dryRun=false, overwrite=true, and conflictHash=.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

apig:UpdateGatewayQuotaRule

update

*Gateway

acs:apig:{#regionId}:{#accountId}:gateway/{#GatewayId}

None None

Request syntax

PUT /v1/gateways/{gatewayId}/quota-rules/{ruleId} HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

gatewayId

string

No

The unique identifier of the gateway.

gw-123456

ruleId

string

No

The ID of the rule.

qr-d8j7fpmm1hks65xxxx

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body.

{'key': 'value'}

addIds

array

No

The list of IDs of the subjects (consumers) to be bound.

cs-001,cs-002

string

No

The ID of the subject.

cs-001xxxxx

conflictHash

string

No

The hash of the conflict snapshot, which is used to prevent concurrent dirty overwrites when you confirm an overwrite. You can obtain this value by first performing a dry run with dryRun=true and extracting it from the response.

You do not need to specify this parameter in the following scenarios: no conflicts exist; you are only performing a dry run with dryRun=true; or overwrite=false, which means you do not confirm the overwrite.

If dryRun=false and overwrite=true, but this parameter is not specified or has expired and does not match, the backend returns accepted=false along with a new conflict preview. In this case, you must perform a dry run again to confirm the new conflicts.

f8f44dc6cf369a017d56b7197eb4fb5ac4bbb6b09a92b9b41999541f50xxxxxx

consumerGroupIds deprecated

array

No

[Deprecated] The list of consumer group IDs.

group1,group2

deprecated

string

No

[Deprecated] The ID of the consumer group.

consumer-group-001

dryRun

boolean

No

Specifies whether to perform a dry run only. A dry run does not persist data to the database or deliver actual configurations. It is used to check whether conflicting rules exist on the bound consumers. A single consumer cannot be configured with two natural period quotas of the same period. For example, if a consumer already has a natural daily quota, you cannot add another natural daily quota rule to it.

true

overwrite

boolean

No

Specifies whether to allow overwriting when conflicts exist. Note that if you allow overwriting, the conflicting subjects (consumers or consumer groups) are unbound from the old rule and bound to the new rule.

quotaLimit

integer

No

The updated total available quota.

1000

removeIds

array

No

The list of IDs of the subjects (consumers) to be unbound.

cs003,cs-004

string

No

The ID of the subject.

cs-003xxxxx

ruleName

string

No

The updated name of the rule.

team-rule

Response elements

Element

Type

Description

Example

object

Schema of Response

code

string

The status code or error code.

200, 404, 500

data

object

The response data.

{'key': 'value'}

accepted

boolean

Indicates whether the semantics of the current write request can be accepted by the system. A value of false typically occurs in retryable scenarios, such as when an overwrite for a conflict is not confirmed. When dryRun=true, a value of true indicates only that the dry run is accepted, not that the data is saved. If a formal write request returns false, it indicates that the data is not saved due to conflicts, and you should check conflictPreview.

true

conflictPreview

object

The conflict preview.

conflictHash

string

The hash of the conflict.

f8f44dc6cf369a017d56b7197eb4fb5ac4bbb6b09a92b9b41999541f50xxxxxx

items

array<object>

The list of conflicting subjects (consumers or consumer groups).

object

The details of the conflicting subject (consumer or consumer group).

conflictPeriodType deprecated

string

The period type of the existing conflicting rule on the consumer. This is a legacy field. Use periodType in the actual response. This field is not guaranteed to be returned. Valid values:

  • day: The period of the existing conflicting rule on the consumer is daily.

  • week: The period of the existing conflicting rule on the consumer is weekly.

  • month: The period of the existing conflicting rule on the consumer is monthly.

week

conflictType

string

The type of the existing conflicting rule on the consumer. Valid values:

  • calendar: The existing conflicting rule on the consumer uses a natural period.

  • epoch: The existing conflicting rule on the consumer uses a custom period.

calendar

consumerId

string

The ID of the consumer. You can use subjectId instead.

cs-d82n1g6m1hkm375xxxxx

consumerName

string

The name of the consumer. You can use subjectName instead.

consumer-a

periodType

string

The period type of the existing conflicting rule. Valid values:

  • day: Daily.

  • week: Weekly.

  • month: Monthly.

day

subjectId

string

The ID of the conflicting subject.

cs-xxx

subjectName

string

The name of the conflicting subject.

consumer-a

subjectType

string

The type of the conflicting subject. Valid values:

  • consumer

  • consumer_group

consumer

totalConflictCount

integer

The total number of conflicts.

2

dryRun

boolean

Indicates whether a dry run is performed.

true

ruleId

string

The ID of the rule.

qr-xxxxxx

message

string

The message.

Hello, world!

requestId

string

The unique identifier of the request.

1234567890

Examples

Success response

JSON format

{
  "code": "200, 404, 500",
  "data": {
    "accepted": true,
    "conflictPreview": {
      "conflictHash": "\t\nf8f44dc6cf369a017d56b7197eb4fb5ac4bbb6b09a92b9b41999541f50xxxxxx",
      "items": [
        {
          "conflictPeriodType": "week",
          "conflictType": "calendar",
          "consumerId": "cs-d82n1g6m1hkm375xxxxx",
          "consumerName": "consumer-a",
          "periodType": "day",
          "subjectId": "cs-xxx",
          "subjectName": "consumer-a",
          "subjectType": "consumer"
        }
      ],
      "totalConflictCount": 2
    },
    "dryRun": true,
    "ruleId": "qr-xxxxxx"
  },
  "message": "Hello, world!",
  "requestId": "1234567890"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.