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

from __future__ import annotations
from ..core.pydantic_utilities import UniversalBaseModel
import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.pydantic_utilities import update_forward_refs


class StructuredDocumentSection(UniversalBaseModel):
    """
    A logical section within a structured document.
    """

    id: typing.Optional[int] = pydantic.Field(default=None)
    """
    The section ID. This gets converted to a metadata field automatically.
    """

    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    The section title.
    """

    text: str = pydantic.Field()
    """
    The text of the section.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Arbitrary object that becomes document part level metadata on any document part created
    by this section. Properties of this object can be used by document part level
    filters if defined as a corpus filter attribute.
    """

    sections: typing.Optional[typing.List["StructuredDocumentSection"]] = pydantic.Field(default=None)
    """
    The sections that this section contains.
    """

    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)
