"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 2d8256704c6b

from __future__ import annotations
from .scheduledefinition import ScheduleDefinition, ScheduleDefinitionTypedDict
from mistralai.client.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing_extensions import Annotated, NotRequired, TypedDict


class WorkflowScheduleRequestTypedDict(TypedDict):
    schedule: ScheduleDefinitionTypedDict
    r"""Specification of the times scheduled actions may occur.

    The times are the union of :py:attr:`calendars`, :py:attr:`intervals`, and
    :py:attr:`cron_expressions` excluding anything in :py:attr:`skip`.

    Used for input where schedule_id is optional (can be provided or auto-generated).
    """
    workflow_registration_id: NotRequired[Nullable[str]]
    r"""The ID of the workflow registration to schedule"""
    workflow_version_id: NotRequired[Nullable[str]]
    r"""Deprecated: use workflow_registration_id"""
    workflow_identifier: NotRequired[Nullable[str]]
    r"""The name or ID of the workflow to schedule"""
    workflow_task_queue: NotRequired[Nullable[str]]
    r"""Deprecated. Use deployment_name instead."""
    schedule_id: NotRequired[Nullable[str]]
    r"""Allows you to specify a custom schedule ID. If not provided, a random ID will be generated."""
    deployment_name: NotRequired[Nullable[str]]
    r"""Name of the deployment to route this schedule to"""


class WorkflowScheduleRequest(BaseModel):
    schedule: ScheduleDefinition
    r"""Specification of the times scheduled actions may occur.

    The times are the union of :py:attr:`calendars`, :py:attr:`intervals`, and
    :py:attr:`cron_expressions` excluding anything in :py:attr:`skip`.

    Used for input where schedule_id is optional (can be provided or auto-generated).
    """

    workflow_registration_id: OptionalNullable[str] = UNSET
    r"""The ID of the workflow registration to schedule"""

    workflow_version_id: OptionalNullable[str] = UNSET
    r"""Deprecated: use workflow_registration_id"""

    workflow_identifier: OptionalNullable[str] = UNSET
    r"""The name or ID of the workflow to schedule"""

    workflow_task_queue: Annotated[
        OptionalNullable[str],
        pydantic.Field(
            deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
        ),
    ] = UNSET
    r"""Deprecated. Use deployment_name instead."""

    schedule_id: OptionalNullable[str] = UNSET
    r"""Allows you to specify a custom schedule ID. If not provided, a random ID will be generated."""

    deployment_name: OptionalNullable[str] = UNSET
    r"""Name of the deployment to route this schedule to"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "workflow_registration_id",
                "workflow_version_id",
                "workflow_identifier",
                "workflow_task_queue",
                "schedule_id",
                "deployment_name",
            ]
        )
        nullable_fields = set(
            [
                "workflow_registration_id",
                "workflow_version_id",
                "workflow_identifier",
                "workflow_task_queue",
                "schedule_id",
                "deployment_name",
            ]
        )
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

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

        return m
