Skip to content

enable_rule

enable_rule(
    name: RuleName,
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    event_bus_name: Optional[EventBusNameOrArn] = None,
) -> None

Enables the specified rule. If the rule does not exist, the operation fails.

When you enable a rule, incoming events might not immediately start matching to a newly enabled rule. Allow a short period of time for changes to take effect.

Parameters:

  • name (RuleName) –

    The name of the rule.

  • event_bus_name (Optional[EventBusNameOrArn], default: None ) –

    The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.

Raises:

  • ConcurrentModificationException –

    There is concurrent modification on a rule, target, archive, or replay.

  • InternalException –

    This exception occurs due to unexpected causes.

  • ManagedRuleException –

    This rule was created by an Amazon Web Services service on behalf of your account. It is managed by that service. If you see this error in response to DeleteRule or RemoveTargets, you can use the Force parameter in those calls to delete the rule or remove targets from the rule. You cannot modify these managed rules by using DisableRule, EnableRule, PutTargets, PutRule, TagResource, or UntagResource.

  • ResourceNotFoundException –

    An entity that you specified does not exist.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_cloudwatch_events/_services/cloud_watch_events.py
def enable_rule(
    self,
    name: "capo_cloudwatch_events.types.rule_name.RuleName",
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = None,
    event_bus_name: Optional[
        "capo_cloudwatch_events.types.event_bus_name_or_arn.EventBusNameOrArn"
    ] = None,
) -> None:
    """<p>Enables the specified rule. If the rule does not exist, the operation fails.</p> <p>When you enable a rule, incoming events might not immediately start matching to a newly enabled rule. Allow a short period of time for changes to take effect.</p>

    Args:
        name: <p>The name of the rule.</p>
        event_bus_name: <p>The name or ARN of the event bus associated with the rule. If you omit this, the default event bus is used.</p>

    Raises:
        capo_cloudwatch_events.errors.concurrent_modification_exception.ConcurrentModificationException: <p>There is concurrent modification on a rule, target, archive, or replay.</p>
        capo_cloudwatch_events.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
        capo_cloudwatch_events.errors.managed_rule_exception.ManagedRuleException: <p>This rule was created by an Amazon Web Services service on behalf of your account. It is managed by that service. If you see this error in response to <code>DeleteRule</code> or <code>RemoveTargets</code>, you can use the <code>Force</code> parameter in those calls to delete the rule or remove targets from the rule. You cannot modify these managed rules by using <code>DisableRule</code>, <code>EnableRule</code>, <code>PutTargets</code>, <code>PutRule</code>, <code>TagResource</code>, or <code>UntagResource</code>. </p>
        capo_cloudwatch_events.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
        capo_cloudwatch_events.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch_events.types.enable_rule_request.EnableRuleRequest]",
    ) -> OperationResponse[None]:
        import capo_cloudwatch_events._operations.aws_events.enable_rule

        output, http_response = (
            capo_cloudwatch_events._operations.aws_events.enable_rule.enable_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("EnableRule")
    )
    input_: capo_cloudwatch_events.types.enable_rule_request.EnableRuleRequest = {
        "name": name
    }
    if event_bus_name is not None:
        input_["event_bus_name"] = event_bus_name

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