48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
|
|
from datetime import date, time
|
||
|
|
|
||
|
|
from pydantic import BaseModel, field_validator
|
||
|
|
|
||
|
|
|
||
|
|
class TimeSlot(BaseModel):
|
||
|
|
"""A single time slot (start and end time)."""
|
||
|
|
|
||
|
|
start_time: time
|
||
|
|
end_time: time
|
||
|
|
|
||
|
|
@field_validator("start_time", "end_time")
|
||
|
|
@classmethod
|
||
|
|
def validate_15min_boundary(cls, v: time) -> time:
|
||
|
|
"""Ensure times are on 15-minute boundaries."""
|
||
|
|
if v.minute not in (0, 15, 30, 45):
|
||
|
|
raise ValueError("Time must be on 15-minute boundary (:00, :15, :30, :45)")
|
||
|
|
if v.second != 0 or v.microsecond != 0:
|
||
|
|
raise ValueError("Time must not have seconds or microseconds")
|
||
|
|
return v
|
||
|
|
|
||
|
|
|
||
|
|
class AvailabilityDay(BaseModel):
|
||
|
|
"""Availability for a single day."""
|
||
|
|
|
||
|
|
date: date
|
||
|
|
slots: list[TimeSlot]
|
||
|
|
|
||
|
|
|
||
|
|
class AvailabilityResponse(BaseModel):
|
||
|
|
"""Response model for availability query."""
|
||
|
|
|
||
|
|
days: list[AvailabilityDay]
|
||
|
|
|
||
|
|
|
||
|
|
class SetAvailabilityRequest(BaseModel):
|
||
|
|
"""Request to set availability for a specific date."""
|
||
|
|
|
||
|
|
date: date
|
||
|
|
slots: list[TimeSlot]
|
||
|
|
|
||
|
|
|
||
|
|
class CopyAvailabilityRequest(BaseModel):
|
||
|
|
"""Request to copy availability from one day to others."""
|
||
|
|
|
||
|
|
source_date: date
|
||
|
|
target_dates: list[date]
|