Skip to content

create_message_template_attachment async

create_message_template_attachment(
    knowledge_base_id: UuidOrArn,
    message_template_id: UuidOrArnOrEitherWithQualifier,
    content_disposition: ContentDisposition,
    name: AttachmentFileName,
    body: NonEmptyUnlimitedString,
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateMessageTemplateAttachmentResponse

Uploads an attachment file to the specified Amazon Q in Connect message template. The name of the message template attachment has to be unique for each message template referenced by the $LATEST qualifier. The body of the attachment file should be encoded using base64 encoding. After the file is uploaded, you can use the pre-signed Amazon S3 URL returned in response to download the uploaded file.

Parameters:

  • knowledge_base_id (UuidOrArn) –

    The identifier of the knowledge base. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • message_template_id (UuidOrArnOrEitherWithQualifier) –

    The identifier of the message template. Can be either the ID or the ARN. It cannot contain any qualifier.

  • content_disposition (ContentDisposition) –

    The presentation information for the attachment file.

  • name (AttachmentFileName) –

    The name of the attachment file being uploaded. The name should include the file extension.

  • body (NonEmptyUnlimitedString) –

    The body of the attachment file being uploaded. It should be encoded using base64 encoding.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • ServiceQuotaExceededException –

    You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.

  • ThrottlingException –

    The throttling limit has been exceeded.

  • UnauthorizedException –

    You do not have permission to perform this action.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qconnect/_services/async_q_connect.py
async def create_message_template_attachment(
    self,
    knowledge_base_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    message_template_id: "capo_qconnect.types.uuid_or_arn_or_either_with_qualifier.UuidOrArnOrEitherWithQualifier",
    content_disposition: "capo_qconnect.types.content_disposition.ContentDisposition",
    name: "capo_qconnect.types.attachment_file_name.AttachmentFileName",
    body: "capo_qconnect.types.non_empty_unlimited_string.NonEmptyUnlimitedString",
    *,
    config_overrides: Optional[AsyncQConnectClientConfig] = None,
    client_token: Optional["capo_qconnect.types.client_token.ClientToken"] = None,
) -> "capo_qconnect.types.create_message_template_attachment_response.CreateMessageTemplateAttachmentResponse":
    """<p>Uploads an attachment file to the specified Amazon Q in Connect message template. The name of the message template attachment has to be unique for each message template referenced by the <code>$LATEST</code> qualifier. The body of the attachment file should be encoded using base64 encoding. After the file is uploaded, you can use the pre-signed Amazon S3 URL returned in response to download the uploaded file.</p>

    Args:
        knowledge_base_id: <p>The identifier of the knowledge base. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        message_template_id: <p>The identifier of the message template. Can be either the ID or the ARN. It cannot contain any qualifier.</p>
        content_disposition: <p>The presentation information for the attachment file.</p>
        name: <p>The name of the attachment file being uploaded. The name should include the file extension.</p>
        body: <p>The body of the attachment file being uploaded. It should be encoded using base64 encoding.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see <a href="http://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>

    Raises:
        capo_qconnect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_qconnect.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource. For example, if you're using a <code>Create</code> API (such as <code>CreateAssistant</code>) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.</p>
        capo_qconnect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_qconnect.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.</p>
        capo_qconnect.errors.throttling_exception.ThrottlingException: <p>The throttling limit has been exceeded.</p>
        capo_qconnect.errors.unauthorized_exception.UnauthorizedException: <p>You do not have permission to perform this action.</p>
        capo_qconnect.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_qconnect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qconnect.types.create_message_template_attachment_request.CreateMessageTemplateAttachmentRequest]",
    ) -> AsyncOperationResponse[
        "capo_qconnect.types.create_message_template_attachment_response.CreateMessageTemplateAttachmentResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.create_message_template_attachment

        (
            output,
            http_response,
        ) = await capo_qconnect._operations.wisdom_service.create_message_template_attachment.async_create_message_template_attachment(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_qconnect.types.create_message_template_attachment_request.CreateMessageTemplateAttachmentRequest",
    ) -> dict[str, Any]:
        import capo_qconnect.types.create_message_template_attachment_request

        return capo_qconnect.types.create_message_template_attachment_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_qconnect.types.create_message_template_attachment_response.CreateMessageTemplateAttachmentResponse",
    ) -> dict[str, Any]:
        import capo_qconnect.types.create_message_template_attachment_response

        return capo_qconnect.types.create_message_template_attachment_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateMessageTemplateAttachment",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_qconnect.types.create_message_template_attachment_request.CreateMessageTemplateAttachmentRequest = {
        "knowledge_base_id": knowledge_base_id,
        "message_template_id": message_template_id,
        "content_disposition": content_disposition,
        "name": name,
        "body": body,
    }
    if client_token is not None:
        input_["client_token"] = client_token

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