Skip to content

list_targets_by_rule

list_targets_by_rule(
    rule: RuleName,
    *,
    config_overrides: Optional[CloudWatchEventsClientConfig] = 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.

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 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/cloud_watch_events.py
def list_targets_by_rule(
    self,
    rule: "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,
    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_targets_by_rule_response.ListTargetsByRuleResponse":
    """<p>Lists the targets assigned to the specified rule.</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 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.
    """

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

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListTargetsByRule")
    )
    input_: capo_cloudwatch_events.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