Skip to content

get_document_content

get_document_content(
    application_id: ApplicationId,
    index_id: IndexId,
    document_id: DocumentId,
    *,
    config_overrides: Optional[QBusinessClientConfig] = None,
    data_source_id: Optional[DataSourceId] = None,
    output_format: Optional[OutputFormat] = None,
) -> GetDocumentContentResponse

Retrieves the content of a document that was ingested into Amazon Q Business. This API validates user authorization against document ACLs before returning a pre-signed URL for secure document access. You can download or view source documents referenced in chat responses through the URL.

Parameters:

  • application_id (ApplicationId) –

    The unique identifier of the Amazon Q Business application containing the document. This ensures the request is scoped to the correct application environment and its associated security policies.

  • index_id (IndexId) –

    The identifier of the index where documents are indexed.

  • data_source_id (Optional[DataSourceId], default: None ) –

    The identifier of the data source from which the document was ingested. This field is not present if the document is ingested by directly calling the BatchPutDocument API. If the document is from a file-upload data source, the datasource will be "uploaded-docs-file-stat-datasourceid".

  • document_id (DocumentId) –

    The unique identifier of the document that is indexed via BatchPutDocument API or file-upload or connector sync. It is also found in chat or chatSync response.

  • output_format (Optional[OutputFormat], default: None ) –

    Document outputFormat. Defaults to RAW if not selected.

Raises:

  • AccessDeniedException –

    You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.

  • InternalServerException –

    An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact Support for help.

  • ResourceNotFoundException –

    The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.

  • ThrottlingException –

    The request was denied due to throttling. Reduce the number of requests and try again.

  • ValidationException –

    The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.

  • UnknownServiceError –

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

Source code in docs_src/capo_qbusiness/_services/q_business.py
def get_document_content(
    self,
    application_id: "capo_qbusiness.types.application_id.ApplicationId",
    index_id: "capo_qbusiness.types.index_id.IndexId",
    document_id: "capo_qbusiness.types.document_id.DocumentId",
    *,
    config_overrides: Optional[QBusinessClientConfig] = None,
    data_source_id: Optional[
        "capo_qbusiness.types.data_source_id.DataSourceId"
    ] = None,
    output_format: Optional[
        "capo_qbusiness.types.output_format.OutputFormat"
    ] = None,
) -> (
    "capo_qbusiness.types.get_document_content_response.GetDocumentContentResponse"
):
    """<p>Retrieves the content of a document that was ingested into Amazon Q Business. This API validates user authorization against document ACLs before returning a pre-signed URL for secure document access. You can download or view source documents referenced in chat responses through the URL.</p>

    Args:
        application_id: <p>The unique identifier of the Amazon Q Business application containing the document. This ensures the request is scoped to the correct application environment and its associated security policies.</p>
        index_id: <p>The identifier of the index where documents are indexed.</p>
        data_source_id: <p>The identifier of the data source from which the document was ingested. This field is not present if the document is ingested by directly calling the BatchPutDocument API. If the document is from a file-upload data source, the datasource will be "uploaded-docs-file-stat-datasourceid".</p>
        document_id: <p>The unique identifier of the document that is indexed via BatchPutDocument API or file-upload or connector sync. It is also found in chat or chatSync response.</p>
        output_format: <p>Document outputFormat. Defaults to RAW if not selected.</p>

    Raises:
        capo_qbusiness.errors.access_denied_exception.AccessDeniedException: <p> You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.</p>
        capo_qbusiness.errors.internal_server_exception.InternalServerException: <p>An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> for help.</p>
        capo_qbusiness.errors.resource_not_found_exception.ResourceNotFoundException: <p>The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.</p>
        capo_qbusiness.errors.throttling_exception.ThrottlingException: <p>The request was denied due to throttling. Reduce the number of requests and try again.</p>
        capo_qbusiness.errors.validation_exception.ValidationException: <p>The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.</p>
        capo_qbusiness.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_qbusiness.types.get_document_content_request.GetDocumentContentRequest]",
    ) -> OperationResponse[
        "capo_qbusiness.types.get_document_content_response.GetDocumentContentResponse"
    ]:
        import capo_qbusiness._operations.expert_q.get_document_content

        output, http_response = (
            capo_qbusiness._operations.expert_q.get_document_content.get_document_content(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetDocumentContent")
    )
    input_: capo_qbusiness.types.get_document_content_request.GetDocumentContentRequest = {
        "application_id": application_id,
        "index_id": index_id,
        "document_id": document_id,
    }
    if data_source_id is not None:
        input_["data_source_id"] = data_source_id
    if output_format is not None:
        input_["output_format"] = output_format

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