createGatewayRule method
Creates a rule for a gateway. Rules define conditions and actions that control how requests are routed and processed through the gateway, including principal-based access control and path-based routing.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter actions :
The actions to take when the rule conditions are met. Actions can route to
a specific target or apply a configuration bundle override.
Parameter gatewayIdentifier :
The identifier of the gateway to create a rule for.
Parameter priority :
The priority of the rule. Rules are evaluated in order of priority, with
lower numbers evaluated first. Must be between 1 and 1,000,000.
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 conditions :
The conditions that must be met for the rule to apply. Conditions can
match on principals (IAM ARNs) or request paths.
Parameter description :
The description of the gateway rule.
Implementation
Future<CreateGatewayRuleResponse> createGatewayRule({
required List<Action> actions,
required String gatewayIdentifier,
required int priority,
String? clientToken,
List<Condition>? conditions,
String? description,
}) async {
_s.validateNumRange(
'priority',
priority,
1,
1000000,
isRequired: true,
);
final $payload = <String, dynamic>{
'actions': actions,
'priority': priority,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (conditions != null) 'conditions': conditions,
if (description != null) 'description': description,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/gateways/${Uri.encodeComponent(gatewayIdentifier)}/rules',
exceptionFnMap: _exceptionFns,
);
return CreateGatewayRuleResponse.fromJson(response);
}