# 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
from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata
from .classification_next_entry import ClassificationNextEntry
from .classify_step_definition_config import ClassifyStepDefinitionConfig
from .conditional_extract_step_definition_config import ConditionalExtractStepDefinitionConfig
from .conditional_next_entry import ConditionalNextEntry
from .conditional_step_definition_config import ConditionalStepDefinitionConfig
from .external_data_validation_step_definition_config import ExternalDataValidationStepDefinitionConfig
from .extract_step_definition_config import ExtractStepDefinitionConfig
from .file_conversion_step_definition_config import FileConversionStepDefinitionConfig
from .merge_extract_step_definition_config import MergeExtractStepDefinitionConfig
from .parse_step_definition_config import ParseStepDefinitionConfig
from .rule_validation_next_entry import RuleValidationNextEntry
from .rule_validation_step_definition_config import RuleValidationStepDefinitionConfig
from .simple_next_entry import SimpleNextEntry
from .split_step_definition_config import SplitStepDefinitionConfig


class WorkflowStepDefinition_Trigger(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["TRIGGER"] = "TRIGGER"
    name: str
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_Parse(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["PARSE"] = "PARSE"
    name: str
    config: typing.Optional[ParseStepDefinitionConfig] = None
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_Extract(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["EXTRACT"] = "EXTRACT"
    name: str
    config: typing.Optional[ExtractStepDefinitionConfig] = None
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_Classify(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["CLASSIFY"] = "CLASSIFY"
    name: str
    config: typing.Optional[ClassifyStepDefinitionConfig] = None
    next: typing.Optional[typing.List[ClassificationNextEntry]] = 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 WorkflowStepDefinition_Split(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["SPLIT"] = "SPLIT"
    name: str
    config: typing.Optional[SplitStepDefinitionConfig] = None
    next: typing.Optional[typing.List[ClassificationNextEntry]] = 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 WorkflowStepDefinition_MergeExtract(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["MERGE_EXTRACT"] = "MERGE_EXTRACT"
    name: str
    config: typing.Optional[MergeExtractStepDefinitionConfig] = None
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_Conditional(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["CONDITIONAL"] = "CONDITIONAL"
    name: str
    config: ConditionalStepDefinitionConfig
    next: typing.Optional[typing.List[ConditionalNextEntry]] = 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 WorkflowStepDefinition_ConditionalExtract(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["CONDITIONAL_EXTRACT"] = "CONDITIONAL_EXTRACT"
    name: str
    config: typing.Optional[ConditionalExtractStepDefinitionConfig] = None
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_ExternalDataValidation(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["EXTERNAL_DATA_VALIDATION"] = "EXTERNAL_DATA_VALIDATION"
    name: str
    config: typing.Optional[ExternalDataValidationStepDefinitionConfig] = None
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_WebhookResponse(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["WEBHOOK_RESPONSE"] = "WEBHOOK_RESPONSE"
    name: str

    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 WorkflowStepDefinition_RuleValidation(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["RULE_VALIDATION"] = "RULE_VALIDATION"
    name: str
    config: typing.Optional[RuleValidationStepDefinitionConfig] = None
    next: typing.Optional[typing.List[RuleValidationNextEntry]] = 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 WorkflowStepDefinition_HumanReview(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["HUMAN_REVIEW"] = "HUMAN_REVIEW"
    name: str
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_Collect(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["COLLECT"] = "COLLECT"
    name: str
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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 WorkflowStepDefinition_FileConversion(UncheckedBaseModel):
    """
    A workflow step definition used when creating, updating, deploying, and retrieving workflow versions.

    See the [Configuring Workflows via API guide](https://docs.extend.ai/2026-02-09/product/workflows/configuring-workflows-via-api) for routing patterns and examples.
    """

    type: typing.Literal["FILE_CONVERSION"] = "FILE_CONVERSION"
    name: str
    config: typing.Optional[FileConversionStepDefinitionConfig] = None
    next: typing.Optional[typing.List[SimpleNextEntry]] = 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


WorkflowStepDefinition = typing_extensions.Annotated[
    typing.Union[
        WorkflowStepDefinition_Trigger,
        WorkflowStepDefinition_Parse,
        WorkflowStepDefinition_Extract,
        WorkflowStepDefinition_Classify,
        WorkflowStepDefinition_Split,
        WorkflowStepDefinition_MergeExtract,
        WorkflowStepDefinition_Conditional,
        WorkflowStepDefinition_ConditionalExtract,
        WorkflowStepDefinition_ExternalDataValidation,
        WorkflowStepDefinition_WebhookResponse,
        WorkflowStepDefinition_RuleValidation,
        WorkflowStepDefinition_HumanReview,
        WorkflowStepDefinition_Collect,
        WorkflowStepDefinition_FileConversion,
    ],
    UnionMetadata(discriminant="type"),
]
