# This file was auto-generated by Fern from our API Definition.

from ..core.pydantic_utilities import UniversalBaseModel
import typing
import pydantic
import datetime as dt
from .processing_state_enum import ProcessingStateEnum
from .document_status import DocumentStatus
from .document_document_to_document_index import DocumentDocumentToDocumentIndex
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class DocumentRead(UniversalBaseModel):
    id: str
    external_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The unique id of this document as it exists in the user's system.
    """

    last_uploaded_at: dt.datetime
    label: str = pydantic.Field()
    """
    A human-readable label for the document. Defaults to the originally uploaded file's file name.
    """

    processing_state: typing.Optional[ProcessingStateEnum] = pydantic.Field(default=None)
    """
    The current processing state of the document
    
    - `QUEUED` - Queued
    - `PROCESSING` - Processing
    - `PROCESSED` - Processed
    - `FAILED` - Failed
    """

    status: typing.Optional[DocumentStatus] = pydantic.Field(default=None)
    """
    The current status of the document
    
    - `ACTIVE` - Active
    """

    original_file_url: typing.Optional[str] = None
    processed_file_url: typing.Optional[str] = None
    document_to_document_indexes: typing.List[DocumentDocumentToDocumentIndex]
    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    A previously supplied JSON object containing metadata that can be filtered on when searching.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
