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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata
from .json_object import JsonObject
from .legacy_classification import LegacyClassification
from .legacy_classification_advanced_options import LegacyClassificationAdvancedOptions
from .legacy_classification_config_base_processor import LegacyClassificationConfigBaseProcessor
from .legacy_extraction_advanced_options import LegacyExtractionAdvancedOptions
from .legacy_extraction_config_base_processor import LegacyExtractionConfigBaseProcessor
from .legacy_splitter_advanced_options import LegacySplitterAdvancedOptions
from .legacy_splitter_config_base_processor import LegacySplitterConfigBaseProcessor
from .parse_config import ParseConfig


class LegacyProcessorVersionConfig_Classify(UncheckedBaseModel):
    """
    The configuration settings for this version of the document processor. The structure of this object will vary depending on the processor type.

    See the configuration section in the "Guides" tab, for yout specific processor type, for more details on the configuration settings.
    """

    type: typing.Literal["CLASSIFY"] = "CLASSIFY"
    base_processor: typing_extensions.Annotated[
        typing.Optional[LegacyClassificationConfigBaseProcessor], FieldMetadata(alias="baseProcessor")
    ] = pydantic.Field(alias="baseProcessor", default=None)
    base_version: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="baseVersion")] = (
        pydantic.Field(alias="baseVersion", default=None)
    )
    classifications: typing.List[LegacyClassification]
    classification_rules: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="classificationRules")
    ] = pydantic.Field(alias="classificationRules", default=None)
    advanced_options: typing_extensions.Annotated[
        typing.Optional[LegacyClassificationAdvancedOptions], FieldMetadata(alias="advancedOptions")
    ] = pydantic.Field(alias="advancedOptions", default=None)
    parser: typing.Optional[ParseConfig] = 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


class LegacyProcessorVersionConfig_Extract(UncheckedBaseModel):
    """
    The configuration settings for this version of the document processor. The structure of this object will vary depending on the processor type.

    See the configuration section in the "Guides" tab, for yout specific processor type, for more details on the configuration settings.
    """

    type: typing.Literal["EXTRACT"] = "EXTRACT"
    base_processor: typing_extensions.Annotated[
        typing.Optional[LegacyExtractionConfigBaseProcessor], FieldMetadata(alias="baseProcessor")
    ] = pydantic.Field(alias="baseProcessor", default=None)
    base_version: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="baseVersion")] = (
        pydantic.Field(alias="baseVersion", default=None)
    )
    extraction_rules: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="extractionRules")] = (
        pydantic.Field(alias="extractionRules", default=None)
    )
    schema_: typing_extensions.Annotated[typing.Optional[JsonObject], FieldMetadata(alias="schema")] = pydantic.Field(
        alias="schema", default=None
    )
    fields: typing.Optional[typing.List["LegacyExtractionField"]] = None
    advanced_options: typing_extensions.Annotated[
        typing.Optional[LegacyExtractionAdvancedOptions], FieldMetadata(alias="advancedOptions")
    ] = pydantic.Field(alias="advancedOptions", default=None)
    parser: typing.Optional[ParseConfig] = 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


class LegacyProcessorVersionConfig_Splitter(UncheckedBaseModel):
    """
    The configuration settings for this version of the document processor. The structure of this object will vary depending on the processor type.

    See the configuration section in the "Guides" tab, for yout specific processor type, for more details on the configuration settings.
    """

    type: typing.Literal["SPLITTER"] = "SPLITTER"
    base_processor: typing_extensions.Annotated[
        typing.Optional[LegacySplitterConfigBaseProcessor], FieldMetadata(alias="baseProcessor")
    ] = pydantic.Field(alias="baseProcessor", default=None)
    base_version: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="baseVersion")] = (
        pydantic.Field(alias="baseVersion", default=None)
    )
    split_classifications: typing_extensions.Annotated[
        typing.List[LegacyClassification], FieldMetadata(alias="splitClassifications")
    ] = pydantic.Field(alias="splitClassifications")
    split_rules: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="splitRules")] = pydantic.Field(
        alias="splitRules", default=None
    )
    advanced_options: typing_extensions.Annotated[
        typing.Optional[LegacySplitterAdvancedOptions], FieldMetadata(alias="advancedOptions")
    ] = pydantic.Field(alias="advancedOptions", default=None)
    parser: typing.Optional[ParseConfig] = 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


LegacyProcessorVersionConfig = typing_extensions.Annotated[
    typing.Union[
        LegacyProcessorVersionConfig_Classify,
        LegacyProcessorVersionConfig_Extract,
        LegacyProcessorVersionConfig_Splitter,
    ],
    UnionMetadata(discriminant="type"),
]
from .legacy_extraction_field import LegacyExtractionField  # noqa: E402, I001

update_forward_refs(LegacyProcessorVersionConfig_Extract, LegacyExtractionField=LegacyExtractionField)
