createRule method

Future<CreateRuleResponse> createRule({
  1. required List<RuleAction> actions,
  2. required String function,
  3. required String instanceId,
  4. required String name,
  5. required RulePublishStatus publishStatus,
  6. required RuleTriggerEventSource triggerEventSource,
  7. String? clientToken,
})

Creates a rule for the specified Connect Customer instance.

Use the Rules Function language to code conditions for the rule.

May throw AccessDeniedException. May throw InternalServiceException. May throw InvalidRequestException. May throw ResourceConflictException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException.

Parameter actions : A list of actions to be run when the rule is triggered.

Parameter function : The conditions of the rule.

Parameter instanceId : The identifier of the Connect Customer instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

Parameter name : A unique name for the rule.

Parameter publishStatus : The publish status of the rule.

Parameter triggerEventSource : The event source to trigger the rule.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Implementation

Future<CreateRuleResponse> createRule({
  required List<RuleAction> actions,
  required String function,
  required String instanceId,
  required String name,
  required RulePublishStatus publishStatus,
  required RuleTriggerEventSource triggerEventSource,
  String? clientToken,
}) async {
  final $payload = <String, dynamic>{
    'Actions': actions,
    'Function': function,
    'Name': name,
    'PublishStatus': publishStatus.value,
    'TriggerEventSource': triggerEventSource,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/rules/${Uri.encodeComponent(instanceId)}',
    exceptionFnMap: _exceptionFns,
  );
  return CreateRuleResponse.fromJson(response);
}