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

from __future__ import annotations
from ..core.pydantic_utilities import UniversalBaseModel
from .structured_document_section import StructuredDocumentSection
import pydantic
import typing
from .custom_dimensions import CustomDimensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.pydantic_utilities import update_forward_refs


class StructuredDocument(UniversalBaseModel):
    """
    A document with layout features.
    """

    id: str = pydantic.Field()
    """
    The Document ID, must be unique within the corpus.
    """

    type: typing.Literal["structured"] = "structured"
    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    The title of the document.
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    The description of the document.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The metadata for a document and is an arbitrary JSON object. Properties of this object
    can be used by document level filter attributes.
    """

    custom_dimensions: typing.Optional[CustomDimensions] = None
    sections: typing.List[StructuredDocumentSection] = pydantic.Field()
    """
    The subsection of the document.
    """

    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


update_forward_refs(StructuredDocumentSection, StructuredDocument=StructuredDocument)
