import datetime

from fastapi import FastAPI

from gallery.easel.core import AppRequest
from gallery.sketch.schedule.model import ChannelId, Schedule


def mount(app: FastAPI):
    @app.get("/api/schedule/channels", tags=["API"])
    async def get_api_schedule_channels(request: AppRequest) -> list[ChannelId]:
        schedule_api = request.app.state.api.schedule
        return await schedule_api.get_channels()

    @app.get("/api/schedule/{channel}/{date}", tags=["API"])
    async def get_api_schedule_channel_schedule(request: AppRequest, channel: str, date: datetime.date) -> Schedule:
        schedule_api = request.app.state.api.schedule
        return await schedule_api.get_channel_schedule(ChannelId(channel), date)
