createGatewayRateLimit method
Creates a rate limit for a gateway. Rate limits define throttling rules for each dimension that control request rates, token consumption rates, and concurrent connections through the gateway.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter dimensionKeys :
Ordered list of dimension names defining the scope of this limit. Unique
per gateway — no two limits can share the same dimensionKeys.
Parameter entries :
Rule entries mapping dimension values to rate configurations.
Parameter gatewayIdentifier :
The unique identifier of the gateway to create the rate limit for.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the API request
completes no more than one time. If you don't specify this field, a value
is randomly generated for you. If this token matches a previous request,
the service ignores the request, but doesn't return an error. For more
information, see Ensuring
idempotency.
Parameter description :
Optional human-readable description for this limit.
Parameter rateLimitId :
Optional customer-defined limit ID. If not provided, system generates one.
Implementation
Future<CreateGatewayRateLimitResponse> createGatewayRateLimit({
required List<String> dimensionKeys,
required List<LimitEntry> entries,
required String gatewayIdentifier,
String? clientToken,
String? description,
String? rateLimitId,
}) async {
final $payload = <String, dynamic>{
'dimensionKeys': dimensionKeys,
'entries': entries,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (description != null) 'description': description,
if (rateLimitId != null) 'rateLimitId': rateLimitId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/gateways/${Uri.encodeComponent(gatewayIdentifier)}/rate-limits',
exceptionFnMap: _exceptionFns,
);
return CreateGatewayRateLimitResponse.fromJson(response);
}