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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .version_event_trigger import VersionEventTrigger
from .version_status import VersionStatus


class VersionEventContent(UniversalBaseModel):
    """
    Typed content for version events stored as JSONB.
    """

    actor_email: typing.Optional[str] = pydantic.Field(default=None)
    """
    Email of the user who triggered this event
    """

    error_message: typing.Optional[str] = pydantic.Field(default=None)
    """
    Error message for failure events
    """

    failure_reason: typing.Optional[str] = pydantic.Field(default=None)
    """
    Classified failure reason (DeploymentFailureReason value) for VERSION_FAILED events
    """

    from_version_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Version ID tasks were migrated FROM (for TASKS_MIGRATED events)
    """

    git_hash: typing.Optional[str] = pydantic.Field(default=None)
    """
    Git hash for context
    """

    migrated_task_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of tasks migrated (for TASKS_MIGRATED events)
    """

    migrated_task_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Task IDs that were migrated (for TASKS_MIGRATED events)
    """

    new_status: typing.Optional[VersionStatus] = pydantic.Field(default=None)
    """
    Status after this event
    """

    previous_status: typing.Optional[VersionStatus] = pydantic.Field(default=None)
    """
    Status before this event
    """

    target_version_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Target version ID for rollback events
    """

    triggered_by: typing.Optional[VersionEventTrigger] = pydantic.Field(default=None)
    """
    What triggered this event
    """

    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
