"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .createruntransfer import CreateRunTransfer, CreateRunTransferTypedDict
from datetime import datetime
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class OccurrenceTypedDict(TypedDict):
    r"""Occurrences to either create or modify."""

    canceled: NotRequired[bool]
    r"""If set to true, will cancel the occurrence. If set false will resume the occurrence. If unset leaves the value unchanged."""
    occurrence_id: NotRequired[str]
    r"""If set this defines what occurrence to modify, if invalid will fail the request.
    If null or \"\" it defines to add a new occurrence.
    """
    run_on: NotRequired[datetime]
    r"""Timestamp to run the transfer after. Value must be into the future."""
    run_transfer: NotRequired[CreateRunTransferTypedDict]
    r"""Defines the attributes of a transfer."""


class Occurrence(BaseModel):
    r"""Occurrences to either create or modify."""

    canceled: Optional[bool] = None
    r"""If set to true, will cancel the occurrence. If set false will resume the occurrence. If unset leaves the value unchanged."""

    occurrence_id: Annotated[Optional[str], pydantic.Field(alias="occurrenceID")] = None
    r"""If set this defines what occurrence to modify, if invalid will fail the request.
    If null or \"\" it defines to add a new occurrence.
    """

    run_on: Annotated[Optional[datetime], pydantic.Field(alias="runOn")] = None
    r"""Timestamp to run the transfer after. Value must be into the future."""

    run_transfer: Annotated[
        Optional[CreateRunTransfer], pydantic.Field(alias="runTransfer")
    ] = None
    r"""Defines the attributes of a transfer."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["canceled", "occurrenceID", "runOn", "runTransfer"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    Occurrence.model_rebuild()
except NameError:
    pass
