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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .document_part import DocumentPart
from .document_storage_usage import DocumentStorageUsage
from .extraction_usage import ExtractionUsage
from .image_metadata import ImageMetadata
from .table import Table


class Document(UniversalBaseModel):
    """
    A document stored in a corpus, containing metadata and indexed content.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The document ID.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The document metadata.
    """

    tables: typing.Optional[typing.List[Table]] = pydantic.Field(default=None)
    """
    The tables that this document contains. Tables are not available when table extraction is not enabled.
    """

    images: typing.Optional[typing.List[ImageMetadata]] = pydantic.Field(default=None)
    """
    The images that this document contains.
    """

    parts: typing.Optional[typing.List[DocumentPart]] = pydantic.Field(default=None)
    """
    Parts of the document that make up the document. However, parts are not available when retrieving a list of documents or when creating a document. This property is only available when retrieving a document by ID.
    """

    storage_usage: typing.Optional[DocumentStorageUsage] = None
    extraction_usage: typing.Optional[ExtractionUsage] = None

    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
