createRule method

Future<CreateRuleResponse> createRule({
  1. required RuleAction action,
  2. required String listenerIdentifier,
  3. required RuleMatch match,
  4. required String name,
  5. required int priority,
  6. required String serviceIdentifier,
  7. String? clientToken,
  8. Map<String, String>? tags,
})

Creates a listener rule. Each listener has a default rule for checking connection requests, but you can define additional rules. Each rule consists of a priority, one or more actions, and one or more conditions. For more information, see Listener rules in the Amazon VPC Lattice User Guide.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter action : The action for the default rule.

Parameter listenerIdentifier : The ID or ARN of the listener.

Parameter match : The rule match.

Parameter name : The name of the rule. The name must be unique within the listener. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.

Parameter priority : The priority assigned to the rule. Each rule for a specific listener must have a unique priority. The lower the priority number the higher the priority.

Parameter serviceIdentifier : The ID or ARN of the service.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.

Parameter tags : The tags for the rule.

Implementation

Future<CreateRuleResponse> createRule({
  required RuleAction action,
  required String listenerIdentifier,
  required RuleMatch match,
  required String name,
  required int priority,
  required String serviceIdentifier,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  _s.validateNumRange(
    'priority',
    priority,
    1,
    2000,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'action': action,
    'match': match,
    'name': name,
    'priority': priority,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/services/${Uri.encodeComponent(serviceIdentifier)}/listeners/${Uri.encodeComponent(listenerIdentifier)}/rules',
    exceptionFnMap: _exceptionFns,
  );
  return CreateRuleResponse.fromJson(response);
}