from __future__ import annotations

from fastapi import APIRouter, Depends

from backend.app.api.schemas import MoveRequest, TaskCreateResponse
from backend.app.dependencies import get_move_task_service
from backend.app.services.move_task_service import MoveTaskService

router = APIRouter(prefix="/files")


@router.post("/move", response_model=TaskCreateResponse, status_code=202)
async def move_file(
    request: MoveRequest,
    service: MoveTaskService = Depends(get_move_task_service),
) -> TaskCreateResponse:
    if request.sources is not None:
        return service.create_batch_move_task(
            sources=request.sources,
            destination_base=request.destination_base,
        )
    return service.create_move_task(source=request.source, destination=request.destination)
