Skip to content

list_targets_by_rule

list_targets_by_rule(
    rule: RuleName,
    *,
    config_overrides: Optional[EventBridgeClientConfig] = None,
    event_bus_name: Optional[EventBusNameOrArn] = None,
    next_token: Optional[NextToken] = None,
    limit: Optional[LimitMax100] = None,
) -> ListTargetsByRuleResponse

Lists the targets assigned to the specified rule.

The maximum number of results per page for requests is 100.

Parameters:

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

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

    The token returned by a previous call, which you can use to retrieve the next set of results.

    The value of nextToken is a unique pagination token for each page. To retrieve the next page of results, make the call again using the returned token. Keep all other arguments unchanged.

    Using an expired pagination token results in an HTTP 400 InvalidToken error.

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

    The maximum number of results to return.

Raises:

Source code in docs_src/capo_eventbridge/_services/event_bridge.py
def list_targets_by_rule(
    self,
    rule: "capo_eventbridge.types.rule_name.RuleName",
    *,
    config_overrides: Optional[EventBridgeClientConfig] = None,
    event_bus_name: Optional[
        "capo_eventbridge.types.event_bus_name_or_arn.EventBusNameOrArn"
    ] = None,
    next_token: Optional["capo_eventbridge.types.next_token.NextToken"] = None,
    limit: Optional["capo_eventbridge.types.limit_max100.LimitMax100"] = None,
) -> (
    "capo_eventbridge.types.list_targets_by_rule_response.ListTargetsByRuleResponse"
):
    """<p>Lists the targets assigned to the specified rule.</p> <p>The maximum number of results per page for requests is 100.</p>

    Args:
        rule: <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>
        next_token: <p>The token returned by a previous call, which you can use to retrieve the next set of results.</p> <p>The value of <code>nextToken</code> is a unique pagination token for each page. To retrieve the next page of results, make the call again using the returned token. Keep all other arguments unchanged.</p> <p> Using an expired pagination token results in an <code>HTTP 400 InvalidToken</code> error.</p>
        limit: <p>The maximum number of results to return.</p>

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

    def _handler(
        req: "OperationRequest[capo_eventbridge.types.list_targets_by_rule_request.ListTargetsByRuleRequest]",
    ) -> OperationResponse[
        "capo_eventbridge.types.list_targets_by_rule_response.ListTargetsByRuleResponse"
    ]:
        import capo_eventbridge._operations.aws_events.list_targets_by_rule

        output, http_response = (
            capo_eventbridge._operations.aws_events.list_targets_by_rule.list_targets_by_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_eventbridge.types.list_targets_by_rule_response.ListTargetsByRuleResponse",
    ) -> dict[str, Any]:
        import capo_eventbridge.types.list_targets_by_rule_response

        return (
            capo_eventbridge.types.list_targets_by_rule_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListTargetsByRule", redact_output=_redact_output),
    )
    input_: capo_eventbridge.types.list_targets_by_rule_request.ListTargetsByRuleRequest = {
        "rule": rule
    }
    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 = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output