Skip to content

create_event_rule

create_event_rule(
    notification_configuration_arn: NotificationConfigurationArn,
    source: Source,
    event_type: EventType,
    regions: Regions,
    *,
    config_overrides: Optional[NotificationsClientConfig] = None,
    event_pattern: Optional[EventRuleEventPattern] = None,
) -> CreateEventRuleResponse

Creates an EventRule that is associated with a specified NotificationConfiguration.

Parameters:

  • notification_configuration_arn (NotificationConfigurationArn) –

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

  • source (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.

  • event_type (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.

  • event_pattern (Optional[EventRuleEventPattern], default: None ) –

    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.

  • regions (Regions) –

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

Raises:

Source code in docs_src/capo_notifications/_services/notifications.py
def create_event_rule(
    self,
    notification_configuration_arn: "capo_notifications.types.notification_configuration_arn.NotificationConfigurationArn",
    source: "capo_notifications.types.source.Source",
    event_type: "capo_notifications.types.event_type.EventType",
    regions: "capo_notifications.types.regions.Regions",
    *,
    config_overrides: Optional[NotificationsClientConfig] = None,
    event_pattern: Optional[
        "capo_notifications.types.event_rule_event_pattern.EventRuleEventPattern"
    ] = None,
) -> "capo_notifications.types.create_event_rule_response.CreateEventRuleResponse":
    """<p>Creates an <a href="https://docs.aws.amazon.com/notifications/latest/userguide/glossary.html"> <code>EventRule</code> </a> that is associated with a specified <code>NotificationConfiguration</code>.</p>

    Args:
        notification_configuration_arn: <p>The Amazon Resource Name (ARN) of the <code>NotificationConfiguration</code> associated with this <code>EventRule</code>.</p>
        source: <p>The matched event source.</p> <p>Must match one of the valid EventBridge sources. Only Amazon Web Services service sourced events are supported. For example, <code>aws.ec2</code> and <code>aws.cloudwatch</code>. For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html#eb-service-event-delivery-level">Event delivery from Amazon Web Services services</a> in the <i>Amazon EventBridge User Guide</i>.</p>
        event_type: <p>The event type to match.</p> <p>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 <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html#eb-service-event-delivery-level">Event delivery from Amazon Web Services services</a> in the <i>Amazon EventBridge User Guide</i>.</p>
        event_pattern: <p>An additional event pattern used to further filter the events this <code>EventRule</code> receives.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html">Amazon EventBridge event patterns</a> in the <i>Amazon EventBridge User Guide.</i> </p>
        regions: <p>A list of Amazon Web Services Regions that send events to this <code>EventRule</code>.</p>

    Raises:
        capo_notifications.errors.access_denied_exception.AccessDeniedException: <p>User does not have sufficient access to perform this action.</p>
        capo_notifications.errors.conflict_exception.ConflictException: <p>Updating or deleting a resource can cause an inconsistent state.</p>
        capo_notifications.errors.internal_server_exception.InternalServerException: <p>Unexpected error during processing of request.</p>
        capo_notifications.errors.resource_not_found_exception.ResourceNotFoundException: <p>Request references a resource which does not exist. </p>
        capo_notifications.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Request would cause a service quota to be exceeded.</p>
        capo_notifications.errors.throttling_exception.ThrottlingException: <p>Request was denied due to request throttling. </p>
        capo_notifications.errors.validation_exception.ValidationException: <p>This exception is thrown when the notification event fails validation.</p>
        capo_notifications.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_notifications.types.create_event_rule_request.CreateEventRuleRequest]",
    ) -> OperationResponse[
        "capo_notifications.types.create_event_rule_response.CreateEventRuleResponse"
    ]:
        import capo_notifications._operations.notifications.create_event_rule

        output, http_response = (
            capo_notifications._operations.notifications.create_event_rule.create_event_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEventRule")
    )
    input_: capo_notifications.types.create_event_rule_request.CreateEventRuleRequest = {
        "notification_configuration_arn": notification_configuration_arn,
        "source": source,
        "event_type": event_type,
        "regions": regions,
    }
    if event_pattern is not None:
        input_["event_pattern"] = event_pattern

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output