|
| 1 | +from typing import Optional |
| 2 | + |
| 3 | +from fastapi import Body, HTTPException, Path, Query |
| 4 | +from fastapi.routing import APIRouter |
| 5 | + |
| 6 | +from invokeai.app.services.shared.pagination import OffsetPaginatedResults |
| 7 | +from invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirection |
| 8 | +from invokeai.app.services.videos_common import ( |
| 9 | + DeleteVideosResult, |
| 10 | + StarredVideosResult, |
| 11 | + UnstarredVideosResult, |
| 12 | + VideoDTO, |
| 13 | + VideoIdsResult, |
| 14 | + VideoRecordChanges, |
| 15 | +) |
| 16 | + |
| 17 | +videos_router = APIRouter(prefix="/v1/videos", tags=["videos"]) |
| 18 | + |
| 19 | + |
| 20 | +@videos_router.patch( |
| 21 | + "/i/{video_id}", |
| 22 | + operation_id="update_video", |
| 23 | + response_model=VideoDTO, |
| 24 | +) |
| 25 | +async def update_video( |
| 26 | + video_id: str = Path(description="The id of the video to update"), |
| 27 | + video_changes: VideoRecordChanges = Body(description="The changes to apply to the video"), |
| 28 | +) -> VideoDTO: |
| 29 | + """Updates a video""" |
| 30 | + |
| 31 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 32 | + |
| 33 | + |
| 34 | +@videos_router.get( |
| 35 | + "/i/{video_id}", |
| 36 | + operation_id="get_video_dto", |
| 37 | + response_model=VideoDTO, |
| 38 | +) |
| 39 | +async def get_video_dto( |
| 40 | + video_id: str = Path(description="The id of the video to get"), |
| 41 | +) -> VideoDTO: |
| 42 | + """Gets a video's DTO""" |
| 43 | + |
| 44 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 45 | + |
| 46 | + |
| 47 | +@videos_router.post("/delete", operation_id="delete_videos_from_list", response_model=DeleteVideosResult) |
| 48 | +async def delete_videos_from_list( |
| 49 | + video_ids: list[str] = Body(description="The list of ids of videos to delete", embed=True), |
| 50 | +) -> DeleteVideosResult: |
| 51 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 52 | + |
| 53 | + |
| 54 | +@videos_router.post("/star", operation_id="star_videos_in_list", response_model=StarredVideosResult) |
| 55 | +async def star_videos_in_list( |
| 56 | + video_ids: list[str] = Body(description="The list of ids of videos to star", embed=True), |
| 57 | +) -> StarredVideosResult: |
| 58 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 59 | + |
| 60 | + |
| 61 | +@videos_router.post("/unstar", operation_id="unstar_videos_in_list", response_model=UnstarredVideosResult) |
| 62 | +async def unstar_videos_in_list( |
| 63 | + video_ids: list[str] = Body(description="The list of ids of videos to unstar", embed=True), |
| 64 | +) -> UnstarredVideosResult: |
| 65 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 66 | + |
| 67 | + |
| 68 | +@videos_router.delete("/uncategorized", operation_id="delete_uncategorized_videos", response_model=DeleteVideosResult) |
| 69 | +async def delete_uncategorized_videos() -> DeleteVideosResult: |
| 70 | + """Deletes all videos that are uncategorized""" |
| 71 | + |
| 72 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 73 | + |
| 74 | + |
| 75 | +@videos_router.get("/", operation_id="list_video_dtos", response_model=OffsetPaginatedResults[VideoDTO]) |
| 76 | +async def list_video_dtos( |
| 77 | + is_intermediate: Optional[bool] = Query(default=None, description="Whether to list intermediate videos."), |
| 78 | + board_id: Optional[str] = Query( |
| 79 | + default=None, |
| 80 | + description="The board id to filter by. Use 'none' to find videos without a board.", |
| 81 | + ), |
| 82 | + offset: int = Query(default=0, description="The page offset"), |
| 83 | + limit: int = Query(default=10, description="The number of videos per page"), |
| 84 | + order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending, description="The order of sort"), |
| 85 | + starred_first: bool = Query(default=True, description="Whether to sort by starred videos first"), |
| 86 | + search_term: Optional[str] = Query(default=None, description="The term to search for"), |
| 87 | +) -> OffsetPaginatedResults[VideoDTO]: |
| 88 | + """Lists video DTOs""" |
| 89 | + |
| 90 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 91 | + |
| 92 | + |
| 93 | +@videos_router.get("/ids", operation_id="get_video_ids") |
| 94 | +async def get_video_ids( |
| 95 | + is_intermediate: Optional[bool] = Query(default=None, description="Whether to list intermediate videos."), |
| 96 | + board_id: Optional[str] = Query( |
| 97 | + default=None, |
| 98 | + description="The board id to filter by. Use 'none' to find videos without a board.", |
| 99 | + ), |
| 100 | + order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending, description="The order of sort"), |
| 101 | + starred_first: bool = Query(default=True, description="Whether to sort by starred videos first"), |
| 102 | + search_term: Optional[str] = Query(default=None, description="The term to search for"), |
| 103 | +) -> VideoIdsResult: |
| 104 | + """Gets ordered list of video ids with metadata for optimistic updates""" |
| 105 | + |
| 106 | + raise HTTPException(status_code=501, detail="Not implemented") |
| 107 | + |
| 108 | + |
| 109 | +@videos_router.post( |
| 110 | + "/videos_by_ids", |
| 111 | + operation_id="get_videos_by_ids", |
| 112 | + responses={200: {"model": list[VideoDTO]}}, |
| 113 | +) |
| 114 | +async def get_videos_by_ids( |
| 115 | + video_ids: list[str] = Body(embed=True, description="Object containing list of video ids to fetch DTOs for"), |
| 116 | +) -> list[VideoDTO]: |
| 117 | + """Gets video DTOs for the specified video ids. Maintains order of input ids.""" |
| 118 | + |
| 119 | + raise HTTPException(status_code=501, detail="Not implemented") |
0 commit comments