# 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 ...types.classification import Classification
from ...types.classification_advanced_options import ClassificationAdvancedOptions
from ...types.classification_config_base_processor import ClassificationConfigBaseProcessor
from ...types.extraction_advanced_options import ExtractionAdvancedOptions
from ...types.extraction_config_base_processor import ExtractionConfigBaseProcessor
from ...types.json_object import JsonObject
from ...types.parse_config import ParseConfig
from ...types.splitter_advanced_options import SplitterAdvancedOptions
from ...types.splitter_config_base_processor import SplitterConfigBaseProcessor


class ProcessorVersionCreateRequestConfig_Classify(UncheckedBaseModel):
    """
    The configuration for this version of the processor. The type of configuration must match the processor type.
    """

    type: typing.Literal["CLASSIFY"] = "CLASSIFY"
    base_processor: typing_extensions.Annotated[
        typing.Optional[ClassificationConfigBaseProcessor], 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[Classification]
    classification_rules: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="classificationRules")
    ] = pydantic.Field(alias="classificationRules", default=None)
    advanced_options: typing_extensions.Annotated[
        typing.Optional[ClassificationAdvancedOptions], 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 ProcessorVersionCreateRequestConfig_Extract(UncheckedBaseModel):
    """
    The configuration for this version of the processor. The type of configuration must match the processor type.
    """

    type: typing.Literal["EXTRACT"] = "EXTRACT"
    base_processor: typing_extensions.Annotated[
        typing.Optional[ExtractionConfigBaseProcessor], 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["ExtractionField"]] = None
    advanced_options: typing_extensions.Annotated[
        typing.Optional[ExtractionAdvancedOptions], 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 ProcessorVersionCreateRequestConfig_Splitter(UncheckedBaseModel):
    """
    The configuration for this version of the processor. The type of configuration must match the processor type.
    """

    type: typing.Literal["SPLITTER"] = "SPLITTER"
    base_processor: typing_extensions.Annotated[
        typing.Optional[SplitterConfigBaseProcessor], 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[Classification], 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[SplitterAdvancedOptions], 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


ProcessorVersionCreateRequestConfig = typing_extensions.Annotated[
    typing.Union[
        ProcessorVersionCreateRequestConfig_Classify,
        ProcessorVersionCreateRequestConfig_Extract,
        ProcessorVersionCreateRequestConfig_Splitter,
    ],
    UnionMetadata(discriminant="type"),
]
from ...types.extraction_field import ExtractionField  # noqa: E402, I001

update_forward_refs(ProcessorVersionCreateRequestConfig_Extract, ExtractionField=ExtractionField)
