Skip to content

import_document

import_document(
    instance_id: InstanceId,
    card_id: UUID,
    app_id: UUID,
    file_contents_base64: str,
    file_name: Filename,
    scope: DocumentScope,
    *,
    config_overrides: Optional[QAppsClientConfig] = None,
    session_id: Optional[UUID] = None,
) -> ImportDocumentOutput

Uploads a file that can then be used either as a default in a FileUploadCard from Q App definition or as a file that is used inside a single Q App run. The purpose of the document is determined by a scope parameter that indicates whether it is at the app definition level or at the app session level.

Parameters:

  • instance_id (InstanceId) –

    The unique identifier of the Amazon Q Business application environment instance.

  • card_id (UUID) –

    The unique identifier of the card the file is associated with.

  • app_id (UUID) –

    The unique identifier of the Q App the file is associated with.

  • file_contents_base64 (str) –

    The base64-encoded contents of the file to upload.

  • file_name (Filename) –

    The name of the file being uploaded.

  • scope (DocumentScope) –

    Whether the file is associated with a Q App definition or a specific Q App session.

  • session_id (Optional[UUID], default: None ) –

    The unique identifier of the Q App session the file is associated with, if applicable.

Raises:

Examples:

Upload a file to a specific session

>>> client.import_document(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_base64='data:text/plain;base64,SomeFileEncodedInBase64', file_name='myFile.txt', card_id='82f69028-22a9-4bea-8727-0eabf58e9fed', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', scope='SESSION', session_id='4f0e5b87-9d38-41cd-9eb4-ebce2f2917cc')
Upload a file into a application
>>> client.import_document(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_base64='data:text/plain;base64,SomeFileEncodedInBase64', file_name='anApplicationFile.txt', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', card_id='7a11f34b-42d4-4bc8-b668-ae4a788dae1e', scope='APPLICATION')
Source code in docs_src/capo_qapps/_services/q_apps.py
def import_document(
    self,
    instance_id: "capo_qapps.types.instance_id.InstanceId",
    card_id: "capo_qapps.types.uuid.UUID",
    app_id: "capo_qapps.types.uuid.UUID",
    file_contents_base64: str,
    file_name: "capo_qapps.types.filename.Filename",
    scope: "capo_qapps.types.document_scope.DocumentScope",
    *,
    config_overrides: Optional[QAppsClientConfig] = None,
    session_id: Optional["capo_qapps.types.uuid.UUID"] = None,
) -> "capo_qapps.types.import_document_output.ImportDocumentOutput":
    """<p>Uploads a file that can then be used either as a default in a <code>FileUploadCard</code> from Q App definition or as a file that is used inside a single Q App run. The purpose of the document is determined by a scope parameter that indicates whether it is at the app definition level or at the app session level.</p>

    Args:
        instance_id: <p>The unique identifier of the Amazon Q Business application environment instance.</p>
        card_id: <p>The unique identifier of the card the file is associated with.</p>
        app_id: <p>The unique identifier of the Q App the file is associated with.</p>
        file_contents_base64: <p>The base64-encoded contents of the file to upload.</p>
        file_name: <p>The name of the file being uploaded.</p>
        scope: <p>Whether the file is associated with a Q App definition or a specific Q App session.</p>
        session_id: <p>The unique identifier of the Q App session the file is associated with, if applicable.</p>

    Raises:
        capo_qapps.errors.access_denied_exception.AccessDeniedException: <p>The client is not authorized to perform the requested operation.</p>
        capo_qapps.errors.content_too_large_exception.ContentTooLargeException: <p>The requested operation could not be completed because the content exceeds the maximum allowed size.</p>
        capo_qapps.errors.internal_server_exception.InternalServerException: <p>An internal service error occurred while processing the request.</p>
        capo_qapps.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource could not be found.</p>
        capo_qapps.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The requested operation could not be completed because it would exceed the service's quota or limit.</p>
        capo_qapps.errors.throttling_exception.ThrottlingException: <p>The requested operation could not be completed because too many requests were sent at once. Wait a bit and try again later.</p>
        capo_qapps.errors.unauthorized_exception.UnauthorizedException: <p>The client is not authenticated or authorized to perform the requested operation.</p>
        capo_qapps.errors.validation_exception.ValidationException: <p>The input failed to satisfy the constraints specified by the service.</p>
        capo_qapps.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Upload a file to a specific session

        >>> client.import_document(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_base64='data:text/plain;base64,SomeFileEncodedInBase64', file_name='myFile.txt', card_id='82f69028-22a9-4bea-8727-0eabf58e9fed', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', scope='SESSION', session_id='4f0e5b87-9d38-41cd-9eb4-ebce2f2917cc')
        Upload a file into a application

        >>> client.import_document(instance_id='0b95c9c4-89cc-4aa8-9aae-aa91cbec699f', file_contents_base64='data:text/plain;base64,SomeFileEncodedInBase64', file_name='anApplicationFile.txt', app_id='4263767c-d889-4cb2-a8f6-8b649bc66af0', card_id='7a11f34b-42d4-4bc8-b668-ae4a788dae1e', scope='APPLICATION')
    """

    def _handler(
        req: "OperationRequest[capo_qapps.types.import_document_input.ImportDocumentInput]",
    ) -> OperationResponse[
        "capo_qapps.types.import_document_output.ImportDocumentOutput"
    ]:
        import capo_qapps._operations.q_apps_service.import_document

        output, http_response = (
            capo_qapps._operations.q_apps_service.import_document.import_document(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ImportDocument")
    )
    input_: capo_qapps.types.import_document_input.ImportDocumentInput = {
        "instance_id": instance_id,
        "card_id": card_id,
        "app_id": app_id,
        "file_contents_base64": file_contents_base64,
        "file_name": file_name,
        "scope": scope,
    }
    if session_id is not None:
        input_["session_id"] = session_id

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output