# 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
from .created_at import CreatedAt
from .extract_config import ExtractConfig


class ExtractorVersion(UncheckedBaseModel):
    object: typing.Literal["extractor_version"] = pydantic.Field(default="extractor_version")
    """
    The type of object. Will always be `"extractor_version"`.
    """

    id: str = pydantic.Field()
    """
    The unique identifier for this version of the extractor.
    
    Example: `"exv_xK9mLPqRtN3vS8wF5hB2cQ"`
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    A description of this version of the extractor.
    
    Example: `"Updated extraction fields for new invoice format"`
    """

    version: str = pydantic.Field()
    """
    The version number or identifier for this specific version of the extractor. The draft version will have version="draft".
    
    Examples: `"1.0"`, `"2.1"`, `"draft"`
    """

    config: ExtractConfig = pydantic.Field()
    """
    The configuration settings for this version of the extractor. This is a union of two possible shapes:
    
    - **[JSON Schema config](https://docs.extend.ai/2026-02-09/product/extraction/schema):** The current config format. All extractors created through this API version use this shape.
    - **[Legacy config](https://docs.extend.ai/2025-04-21/product/legacy/legacy-schema):** A fields-array config from a previous API version. This shape is only returned for extractors that were originally configured with the legacy format. This API version does not support creating extractors with legacy configs.
    """

    extractor_id: typing_extensions.Annotated[str, FieldMetadata(alias="extractorId")] = pydantic.Field(
        alias="extractorId"
    )
    """
    The ID of the extractor that this version belongs to.
    
    Example: `"ex_Xj8mK2pL9nR4vT7qY5wZ"`
    """

    created_at: typing_extensions.Annotated[CreatedAt, FieldMetadata(alias="createdAt")] = pydantic.Field(
        alias="createdAt"
    )

    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(ExtractorVersion)
