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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel


class TaskEvent(UncheckedBaseModel):
    """
    Serializer for TaskEvent model to handle event creation from frontend.

    This serializer validates and processes task events sent from the labeling interface,
    ensuring proper data format and automatically setting required relationships.
    """

    actor: typing.Optional[int] = None
    annotation: typing.Optional[int] = pydantic.Field(default=None)
    """
    Annotation ID associated with this event
    """

    annotation_draft: typing.Optional[int] = pydantic.Field(default=None)
    """
    Draft annotation ID associated with this event
    """

    created_at: typing.Optional[dt.datetime] = None
    event_key: str = pydantic.Field()
    """
    Event type identifier (e.g., "annotation_loaded", "region_finished_drawing")
    """

    event_time: dt.datetime = pydantic.Field()
    """
    Timestamp when the event occurred (frontend time)
    """

    id: typing.Optional[int] = None
    meta: typing.Optional[typing.Any] = pydantic.Field(default=None)
    """
    Additional event metadata (region data, hotkey info, etc.)
    """

    organization: typing.Optional[int] = None
    project: typing.Optional[int] = None
    review: typing.Optional[int] = pydantic.Field(default=None)
    """
    Review ID associated with this event
    """

    task: typing.Optional[int] = pydantic.Field(default=None)
    """
    Task this event is associated with
    """

    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
