createLinkRoutingRule method

Future<CreateLinkRoutingRuleResponse> createLinkRoutingRule({
  1. required RuleCondition conditions,
  2. required String gatewayId,
  3. required String linkId,
  4. required int priority,
  5. String? clientToken,
  6. Map<String, String>? tags,
})

Creates a routing rule for a link.

Routing rules use priority-based evaluation where lower priority numbers are evaluated first. Each rule specifies conditions that must all match for the rule to apply.

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

Parameter conditions : The conditions for the routing rule. All specified fields must match for the rule to apply. At least one condition field must be set.

Parameter gatewayId : The unique identifier of the gateway.

Parameter linkId : The unique identifier of the link.

Parameter priority : The priority of the routing rule. Lower numbers are evaluated first. Valid values are 1 to 1000. Priority must be unique among non-deleted rules within a link.

Parameter clientToken : Specifies a unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value.

If you don't provide this value, then Amazon Web Services generates a random one for you.

If you retry the operation with the same ClientToken, but with different parameters, the retry fails with an IdempotentParameterMismatch error.

Parameter tags : A map of the key-value pairs of the tag or tags to assign to the resource.

Implementation

Future<CreateLinkRoutingRuleResponse> createLinkRoutingRule({
  required RuleCondition conditions,
  required String gatewayId,
  required String linkId,
  required int priority,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  _s.validateNumRange(
    'priority',
    priority,
    1,
    1000,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'conditions': conditions,
    'priority': priority,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/responder-gateway/${Uri.encodeComponent(gatewayId)}/link/${Uri.encodeComponent(linkId)}/routing-rule',
    exceptionFnMap: _exceptionFns,
  );
  return CreateLinkRoutingRuleResponse.fromJson(response);
}