# 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
from .last_action_enum import LastActionEnum


class Annotation(UncheckedBaseModel):
    """
    Annotation Serializer with FSM state support.

    Note: The 'state' field will be populated from the queryset annotation
    if present, preventing N+1 queries. Use .with_state() on your queryset.
    """

    bulk_created: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Annotation was created in bulk mode
    """

    completed_by: typing.Optional[int] = None
    created_ago: typing.Optional[str] = pydantic.Field(default=None)
    """
    Time delta from creation time
    """

    created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Creation time
    """

    created_username: typing.Optional[str] = pydantic.Field(default=None)
    """
    Username string
    """

    draft_created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Draft creation time
    """

    ground_truth: typing.Optional[bool] = pydantic.Field(default=None)
    """
    This annotation is a Ground Truth (ground_truth)
    """

    id: typing.Optional[int] = None
    import_id: typing.Optional[int] = pydantic.Field(default=None)
    """
    Original annotation ID that was at the import step or NULL if this annotation wasn't imported
    """

    last_action: typing.Optional[LastActionEnum] = pydantic.Field(default=None)
    """
    Action which was performed in the last annotation history item
    
    * `prediction` - Created from prediction
    * `propagated_annotation` - Created from another annotation
    * `imported` - Imported
    * `submitted` - Submitted
    * `updated` - Updated
    * `skipped` - Skipped
    * `accepted` - Accepted
    * `rejected` - Rejected
    * `fixed_and_accepted` - Fixed and accepted
    * `deleted_review` - Deleted review
    """

    last_created_by: typing.Optional[int] = pydantic.Field(default=None)
    """
    User who created the last annotation history item
    """

    lead_time: typing.Optional[float] = pydantic.Field(default=None)
    """
    How much time it took to annotate the task
    """

    parent_annotation: typing.Optional[int] = pydantic.Field(default=None)
    """
    Points to the parent annotation from which this annotation was created
    """

    parent_prediction: typing.Optional[int] = pydantic.Field(default=None)
    """
    Points to the prediction from which this annotation was created
    """

    project: typing.Optional[int] = pydantic.Field(default=None)
    """
    Project ID for this annotation
    """

    result: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = pydantic.Field(default=None)
    """
    List of annotation results for the task
    """

    state: typing.Optional[str] = None
    task: typing.Optional[int] = pydantic.Field(default=None)
    """
    Corresponding task for this annotation
    """

    updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Last updated time
    """

    updated_by: typing.Optional[int] = pydantic.Field(default=None)
    """
    Last user who updated this annotation
    """

    was_cancelled: typing.Optional[bool] = pydantic.Field(default=None)
    """
    User skipped the task
    """

    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
