# 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, UniversalBaseModel
from .sync_operation_action import SyncOperationAction


class SyncOperation(UniversalBaseModel):
    """
    Single operation in a sync batch.
    """

    action: SyncOperationAction = pydantic.Field()
    """
    Operation type
    """

    namespace: str = pydantic.Field()
    """
    Data namespace (e.g., clickup_spaces)
    """

    id: str = pydantic.Field()
    """
    Unique record ID
    """

    data: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Record data (required for upsert, omit for delete)
    """

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

    updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Update timestamp (for upsert)
    """

    deleted_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    Deletion timestamp (for delete)
    """

    source_connector: typing.Optional[str] = pydantic.Field(default=None)
    """
    Source connector name (e.g., notion, clickup, jira)
    """

    stream_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Stream name (e.g., pages, databases)
    """

    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
