from typing import Any, List

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session

import app.crud as crud
import app.models as models
import app.schemas as schemas 
from app.api import deps

router = APIRouter()

@router.get("/", response_model=List[schemas.Video])
def get_video_list(
    db: Session = Depends(deps.get_db),
    skip: int = 0,
    limit: int = 100,
    current_user: models.User = Depends(deps.get_current_active_user),
) -> Any:
    """
    Retrieve items.
    """
    if crud.user.is_superuser(current_user):
        videos = crud.video.get_multi(db, skip=skip, limit=limit)
    else:
        videos = crud.video.get_multi_by_owner(
            db=db, owner_id=current_user.id, skip=skip, limit=limit
        )
    return videos

@router.post("/", response_model=schemas.Item)
def upload_plot(
    *,
    db: Session = Depends(deps.get_db),
    video_upload: schemas.VideoUpload,
    current_user: models.User = Depends(deps.get_current_active_user),
) -> Any:
    """
    Create new video.
    """
    video_create = schemas.VideoCreate
    video_create.title = video_upload.title
    video_create.progress = models.Progress.WAITING
    video = crud.item.create_with_owner(db=db, obj_in=video_create, owner_id=current_user.id)
    return video

@router.get("/{id}")
def download_video(

) -> Any:
    pass

@router.get("/worker/{id}")
def download_plot(

) -> Any:
    pass

@router.get("/worker")
def upload_complete_video(

) -> Any:
    pass