# 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, UniversalBaseModel


class DeployStreamEvent_Complete(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["complete"] = "complete"
    status: 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 DeployStreamEvent_Connected(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["connected"] = "connected"
    version_id: 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 DeployStreamEvent_Error(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["error"] = "error"
    message: 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 DeployStreamEvent_Failed(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["failed"] = "failed"
    failure_reason: typing.Optional[str] = None
    message: typing.Optional[str] = None
    timestamp: str
    version_id: 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 DeployStreamEvent_HelmStarted(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["helm_started"] = "helm_started"
    message: typing.Optional[str] = None
    timestamp: str
    version_id: 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 DeployStreamEvent_HelmWaiting(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["helm_waiting"] = "helm_waiting"
    message: typing.Optional[str] = None
    timestamp: str
    version_id: 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 DeployStreamEvent_Queued(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["queued"] = "queued"
    message: typing.Optional[str] = None
    timestamp: str
    version_id: 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 DeployStreamEvent_Ready(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["ready"] = "ready"
    message: typing.Optional[str] = None
    timestamp: str
    version_id: 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 DeployStreamEvent_RollingBack(UniversalBaseModel):
    """
    Union of all possible deploy stream SSE events.

    Use the 'type' field to discriminate between event types:
    - "connected": Stream connection established
    - "queued": Deployment queued
    - "helm_started": Helm deployment started
    - "helm_waiting": Waiting for pods to be ready
    - "ready": Deployment successful
    - "failed": Deployment failed
    - "rolling_back": Rolling back deployment
    - "complete": Stream complete, terminal state reached
    - "error": An error occurred in the stream
    """

    type: typing.Literal["rolling_back"] = "rolling_back"
    message: typing.Optional[str] = None
    timestamp: str
    version_id: 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


DeployStreamEvent = typing_extensions.Annotated[
    typing.Union[
        DeployStreamEvent_Complete,
        DeployStreamEvent_Connected,
        DeployStreamEvent_Error,
        DeployStreamEvent_Failed,
        DeployStreamEvent_HelmStarted,
        DeployStreamEvent_HelmWaiting,
        DeployStreamEvent_Queued,
        DeployStreamEvent_Ready,
        DeployStreamEvent_RollingBack,
    ],
    pydantic.Field(discriminator="type"),
]
