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

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata


class MessageSchedule(UniversalBaseModel):
    """
    Define when and how your message should be sent.
    """

    send_at: typing_extensions.Annotated[str, FieldMetadata(alias="sendAt")] = pydantic.Field()
    """
    The date and time you want your message to be sent. 
    - Use [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601), for example: `2024-12-17T14:30:00Z`. Format: `YYYY-MM-DDThh:mm` (e.g., `2024-12-25T14:30`). 
    - This time must be at least 5 minutes in the future.
    - The message will be scheduled based on the `timezone` you provide.
    - If you set a `recurrence` schedule, this is the start date and time for the recurring schedule.
    """

    recurrence: typing.Optional[str] = pydantic.Field(default=None)
    """
    AWS cron expression for recurring schedules (6 fields). <br>
    
    [Learn more about cron expressions](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html). <br>
    
    **Examples:**
    - `0 10 * * ? *` - Every day at 10:00 AM
    - `0/30 * * * ? *` - Every 30 minutes
    - `0 9 ? * MON-FRI *` - Every weekday at 9:00 AM
    - `0 12 1 * ? *` - First day of every month at noon
    """

    timezone: typing.Optional[str] = pydantic.Field(default=None)
    """
    IANA timezone identifier (e.g., `America/New_York`, `UTC`). <br>
    
    Defaults to `UTC` if not specified.
    """

    end_date: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="endDate")] = pydantic.Field(
        default=None
    )
    """
    Date and time when recurring messages should stop. <br>
    
    Format: `YYYY-MM-DDThh:mm`. Required if `recurrence` is set.
    """

    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
