createEventRule method

Future<CreateEventRuleResponse> createEventRule({
  1. required String eventType,
  2. required String notificationConfigurationArn,
  3. required List<String> regions,
  4. required String source,
  5. String? eventPattern,
})

Creates an EventRule that is associated with a specified NotificationConfiguration.

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

Parameter eventType : The event type to match.

Must match one of the valid Amazon EventBridge event types. For example, EC2 Instance State-change Notification and Amazon CloudWatch Alarm State Change. For more information, see Event delivery from Amazon Web Services services in the Amazon EventBridge User Guide.

Parameter notificationConfigurationArn : The Amazon Resource Name (ARN) of the NotificationConfiguration associated with this EventRule.

Parameter regions : A list of Amazon Web Services Regions that send events to this EventRule.

Parameter source : The matched event source.

Must match one of the valid EventBridge sources. Only Amazon Web Services service sourced events are supported. For example, aws.ec2 and aws.cloudwatch. For more information, see Event delivery from Amazon Web Services services in the Amazon EventBridge User Guide.

Parameter eventPattern : An additional event pattern used to further filter the events this EventRule receives.

For more information, see Amazon EventBridge event patterns in the Amazon EventBridge User Guide.

Implementation

Future<CreateEventRuleResponse> createEventRule({
  required String eventType,
  required String notificationConfigurationArn,
  required List<String> regions,
  required String source,
  String? eventPattern,
}) async {
  final $payload = <String, dynamic>{
    'eventType': eventType,
    'notificationConfigurationArn': notificationConfigurationArn,
    'regions': regions,
    'source': source,
    if (eventPattern != null) 'eventPattern': eventPattern,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/event-rules',
    exceptionFnMap: _exceptionFns,
  );
  return CreateEventRuleResponse.fromJson(response);
}