Deletes the specified rule.
Before you can delete the rule, you must remove all targets, using RemoveTargets.
When you delete a rule, incoming events might continue to match to the deleted rule. Allow a short period of time for changes to take effect.
If you call delete rule multiple times for the same rule, all calls will succeed. When you call delete rule for a non-existent custom eventbus, ResourceNotFoundException is returned.
Managed rules are rules created and managed by another Amazon Web Services service on your behalf. These rules are created by those other Amazon Web Services services to support functionality in those services. You can delete these rules using the Force option, but you should do so only if you are sure the other service is not still using that rule.
Parameters:
-
name
(RuleName)
–
-
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.
-
force
(Optional[Boolean], default:
None
)
–
If this is a managed rule, created by an Amazon Web Services service on your behalf, you must specify Force as True to delete the rule. This parameter is ignored for rules that are not managed rules. You can check whether a rule is a managed rule by using DescribeRule or ListRules and checking the ManagedBy field of the response.
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_eventbridge/_services/async_event_bridge.py
| async def delete_rule(
self,
name: "capo_eventbridge.types.rule_name.RuleName",
*,
config_overrides: Optional[AsyncEventBridgeClientConfig] = None,
event_bus_name: Optional[
"capo_eventbridge.types.event_bus_name_or_arn.EventBusNameOrArn"
] = None,
force: Optional["capo_eventbridge.types.boolean.Boolean"] = None,
) -> None:
"""<p>Deletes the specified rule.</p> <p>Before you can delete the rule, you must remove all targets, using <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_RemoveTargets.html">RemoveTargets</a>.</p> <p>When you delete a rule, incoming events might continue to match to the deleted rule. Allow a short period of time for changes to take effect.</p> <p>If you call delete rule multiple times for the same rule, all calls will succeed. When you call delete rule for a non-existent custom eventbus, <code>ResourceNotFoundException</code> is returned.</p> <p>Managed rules are rules created and managed by another Amazon Web Services service on your behalf. These rules are created by those other Amazon Web Services services to support functionality in those services. You can delete these rules using the <code>Force</code> option, but you should do so only if you are sure the other service is not still using that rule.</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>
force: <p>If this is a managed rule, created by an Amazon Web Services service on your behalf, you must specify <code>Force</code> as <code>True</code> to delete the rule. This parameter is ignored for rules that are not managed rules. You can check whether a rule is a managed rule by using <code>DescribeRule</code> or <code>ListRules</code> and checking the <code>ManagedBy</code> field of the response.</p>
Raises:
capo_eventbridge.errors.concurrent_modification_exception.ConcurrentModificationException: <p>There is concurrent modification on a rule, target, archive, or replay.</p>
capo_eventbridge.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</p>
capo_eventbridge.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_eventbridge.errors.resource_not_found_exception.ResourceNotFoundException: <p>An entity that you specified does not exist.</p>
capo_eventbridge.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_eventbridge.types.delete_rule_request.DeleteRuleRequest]",
) -> AsyncOperationResponse[None]:
import capo_eventbridge._operations.aws_events.delete_rule
(
output,
http_response,
) = await capo_eventbridge._operations.aws_events.delete_rule.async_delete_rule(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DeleteRule")
)
input_: capo_eventbridge.types.delete_rule_request.DeleteRuleRequest = {
"name": name
}
if event_bus_name is not None:
input_["event_bus_name"] = event_bus_name
if force is not None:
input_["force"] = force
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|