Skip to content

list_rules async

list_rules(
    *,
    config_overrides: Optional[AsyncCloudWatchEventsClientConfig] = None,
    name_prefix: Optional[RuleName] = None,
    event_bus_name: Optional[EventBusNameOrArn] = None,
    next_token: Optional[NextToken] = None,
    limit: Optional[LimitMax100] = None,
) -> ListRulesResponse

Lists your Amazon EventBridge rules. You can either list all the rules or you can provide a prefix to match to the rule names.

ListRules does not list the targets of a rule. To see the targets associated with a rule, use ListTargetsByRule.

Parameters:

  • name_prefix (Optional[RuleName], default: None ) –

    The prefix matching the rule name.

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

    The name or ARN of the event bus to list the rules for. If you omit this, the default event bus is used.

  • next_token (Optional[NextToken], default: None ) –

    The token returned by a previous call to retrieve the next set of results.

  • limit (Optional[LimitMax100], default: None ) –

    The maximum number of results to return.

Raises:

Source code in docs_src/capo_cloudwatch_events/_services/async_cloud_watch_events.py
async def list_rules(
    self,
    *,
    config_overrides: Optional[AsyncCloudWatchEventsClientConfig] = None,
    name_prefix: Optional["capo_cloudwatch_events.types.rule_name.RuleName"] = None,
    event_bus_name: Optional[
        "capo_cloudwatch_events.types.event_bus_name_or_arn.EventBusNameOrArn"
    ] = None,
    next_token: Optional[
        "capo_cloudwatch_events.types.next_token.NextToken"
    ] = None,
    limit: Optional["capo_cloudwatch_events.types.limit_max100.LimitMax100"] = None,
) -> "capo_cloudwatch_events.types.list_rules_response.ListRulesResponse":
    """<p>Lists your Amazon EventBridge rules. You can either list all the rules or you can provide a prefix to match to the rule names.</p> <p>ListRules does not list the targets of a rule. To see the targets associated with a rule, use <a href="https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListTargetsByRule.html">ListTargetsByRule</a>.</p>

    Args:
        name_prefix: <p>The prefix matching the rule name.</p>
        event_bus_name: <p>The name or ARN of the event bus to list the rules for. If you omit this, the default event bus is used.</p>
        next_token: <p>The token returned by a previous call to retrieve the next set of results.</p>
        limit: <p>The maximum number of results to return.</p>

    Raises:
        capo_cloudwatch_events.errors.internal_exception.InternalException: <p>This exception occurs due to unexpected causes.</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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatch_events.types.list_rules_request.ListRulesRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatch_events.types.list_rules_response.ListRulesResponse"
    ]:
        import capo_cloudwatch_events._operations.aws_events.list_rules

        (
            output,
            http_response,
        ) = await capo_cloudwatch_events._operations.aws_events.list_rules.async_list_rules(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListRules")
    )
    input_: capo_cloudwatch_events.types.list_rules_request.ListRulesRequest = {}
    if name_prefix is not None:
        input_["name_prefix"] = name_prefix
    if event_bus_name is not None:
        input_["event_bus_name"] = event_bus_name
    if next_token is not None:
        input_["next_token"] = next_token
    if limit is not None:
        input_["limit"] = limit

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output