Skip to content

list_channel_messages async

list_channel_messages(
    channel_arn: ChimeArn,
    chime_bearer: ChimeArn,
    *,
    config_overrides: Optional[AsyncChimeSDKMessagingClientConfig] = None,
    sort_order: Optional[SortOrder] = None,
    not_before: Optional[Timestamp] = None,
    not_after: Optional[Timestamp] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[NextToken] = None,
    sub_channel_id: Optional[SubChannelId] = None,
) -> ListChannelMessagesResponse

List all the messages in a channel. Returns a paginated list of ChannelMessages. By default, sorted by creation timestamp in descending order.

Redacted messages appear in the results as empty, since they are only redacted, not deleted. Deleted messages do not appear in the results. This action always returns the latest version of an edited message.

Also, the x-amz-chime-bearer request header is mandatory. Use the ARN of the AppInstanceUser or AppInstanceBot that makes the API call as the value in the header.

Parameters:

  • channel_arn (ChimeArn) –

    The ARN of the channel.

  • sort_order (Optional[SortOrder], default: None ) –

    The order in which you want messages sorted. Default is Descending, based on time created.

  • not_before (Optional[Timestamp], default: None ) –

    The initial or starting time stamp for your requested messages.

  • not_after (Optional[Timestamp], default: None ) –

    The final or ending time stamp for your requested messages.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of messages that you want returned.

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

    The token passed by previous API calls until all requested messages are returned.

  • chime_bearer (ChimeArn) –

    The ARN of the AppInstanceUser or AppInstanceBot that makes the API call.

  • sub_channel_id (Optional[SubChannelId], default: None ) –

    The ID of the SubChannel in the request.

    Only required when listing the messages in a SubChannel that the user belongs to.

Raises:

Source code in docs_src/capo_chime_sdk_messaging/_services/async_chime_sdk_messaging.py
async def list_channel_messages(
    self,
    channel_arn: "capo_chime_sdk_messaging.types.chime_arn.ChimeArn",
    chime_bearer: "capo_chime_sdk_messaging.types.chime_arn.ChimeArn",
    *,
    config_overrides: Optional[AsyncChimeSDKMessagingClientConfig] = None,
    sort_order: Optional[
        "capo_chime_sdk_messaging.types.sort_order.SortOrder"
    ] = None,
    not_before: Optional[
        "capo_chime_sdk_messaging.types.timestamp.Timestamp"
    ] = None,
    not_after: Optional[
        "capo_chime_sdk_messaging.types.timestamp.Timestamp"
    ] = None,
    max_results: Optional[
        "capo_chime_sdk_messaging.types.max_results.MaxResults"
    ] = None,
    next_token: Optional[
        "capo_chime_sdk_messaging.types.next_token.NextToken"
    ] = None,
    sub_channel_id: Optional[
        "capo_chime_sdk_messaging.types.sub_channel_id.SubChannelId"
    ] = None,
) -> "capo_chime_sdk_messaging.types.list_channel_messages_response.ListChannelMessagesResponse":
    """<p>List all the messages in a channel. Returns a paginated list of <code>ChannelMessages</code>. By default, sorted by creation timestamp in descending order.</p> <note> <p>Redacted messages appear in the results as empty, since they are only redacted, not deleted. Deleted messages do not appear in the results. This action always returns the latest version of an edited message.</p> <p>Also, the <code>x-amz-chime-bearer</code> request header is mandatory. Use the ARN of the <code>AppInstanceUser</code> or <code>AppInstanceBot</code> that makes the API call as the value in the header.</p> </note>

    Args:
        channel_arn: <p>The ARN of the channel.</p>
        sort_order: <p>The order in which you want messages sorted. Default is Descending, based on time created.</p>
        not_before: <p>The initial or starting time stamp for your requested messages.</p>
        not_after: <p>The final or ending time stamp for your requested messages.</p>
        max_results: <p>The maximum number of messages that you want returned.</p>
        next_token: <p>The token passed by previous API calls until all requested messages are returned.</p>
        chime_bearer: <p>The ARN of the <code>AppInstanceUser</code> or <code>AppInstanceBot</code> that makes the API call.</p>
        sub_channel_id: <p>The ID of the SubChannel in the request.</p> <note> <p>Only required when listing the messages in a SubChannel that the user belongs to.</p> </note>

    Raises:
        capo_chime_sdk_messaging.errors.bad_request_exception.BadRequestException: <p>The input parameters don't match the service's restrictions.</p>
        capo_chime_sdk_messaging.errors.forbidden_exception.ForbiddenException: <p>The client is permanently forbidden from making the request.</p>
        capo_chime_sdk_messaging.errors.service_failure_exception.ServiceFailureException: <p>The service encountered an unexpected error.</p>
        capo_chime_sdk_messaging.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is currently unavailable.</p>
        capo_chime_sdk_messaging.errors.throttled_client_exception.ThrottledClientException: <p>The client exceeded its request rate limit.</p>
        capo_chime_sdk_messaging.errors.unauthorized_client_exception.UnauthorizedClientException: <p>The client is not currently authorized to make the request.</p>
        capo_chime_sdk_messaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_chime_sdk_messaging.types.list_channel_messages_request.ListChannelMessagesRequest]",
    ) -> AsyncOperationResponse[
        "capo_chime_sdk_messaging.types.list_channel_messages_response.ListChannelMessagesResponse"
    ]:
        import capo_chime_sdk_messaging._operations.chime_messaging_service.list_channel_messages

        (
            output,
            http_response,
        ) = await capo_chime_sdk_messaging._operations.chime_messaging_service.list_channel_messages.async_list_channel_messages(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_chime_sdk_messaging.types.list_channel_messages_request.ListChannelMessagesRequest",
    ) -> dict[str, Any]:
        import capo_chime_sdk_messaging.types.list_channel_messages_request

        return capo_chime_sdk_messaging.types.list_channel_messages_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_chime_sdk_messaging.types.list_channel_messages_response.ListChannelMessagesResponse",
    ) -> dict[str, Any]:
        import capo_chime_sdk_messaging.types.list_channel_messages_response

        return capo_chime_sdk_messaging.types.list_channel_messages_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ListChannelMessages",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_chime_sdk_messaging.types.list_channel_messages_request.ListChannelMessagesRequest = {
        "channel_arn": channel_arn,
        "chime_bearer": chime_bearer,
    }
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if not_before is not None:
        input_["not_before"] = not_before
    if not_after is not None:
        input_["not_after"] = not_after
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if sub_channel_id is not None:
        input_["sub_channel_id"] = sub_channel_id

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