diff --git a/store/app/crud/kclips.py b/store/app/crud/kclips.py index 8c7b6af9..45cf9515 100644 --- a/store/app/crud/kclips.py +++ b/store/app/crud/kclips.py @@ -23,7 +23,7 @@ async def create_kclip( user_id: str, robot_id: str, name: str, - description: str, + description: str | None = None, file_size: int | None = None, part_size: int | None = None, ) -> tuple[KClip, MultipartUploadDetails]: diff --git a/store/app/routers/kclips.py b/store/app/routers/kclips.py index 8158d0e3..9a6417dc 100644 --- a/store/app/routers/kclips.py +++ b/store/app/routers/kclips.py @@ -14,6 +14,14 @@ router = APIRouter() +class CreateKClipRequest(BaseModel): + name: str + robot_id: str + description: str | None = None + file_size: int | None = None + part_size: int | None = None + + class NewKClipResponse(BaseModel): kclip_id: str upload_details: MultipartUploadDetails @@ -22,29 +30,36 @@ class NewKClipResponse(BaseModel): @router.post("/create") async def create_kclip( user: Annotated[User, Depends(get_session_user_with_write_permission)], - robot_id: str, - name: str, - description: str, + kclip_data: CreateKClipRequest, crud: Annotated[Crud, Depends(Crud.get)], ) -> NewKClipResponse: kclip, upload_details = await crud.create_kclip( - user_id=user.id, robot_id=robot_id, name=name, description=description + user_id=user.id, + robot_id=kclip_data.robot_id, + name=kclip_data.name, + description=kclip_data.description, + file_size=kclip_data.file_size, + part_size=kclip_data.part_size, ) return NewKClipResponse(kclip_id=kclip.id, upload_details=upload_details) +class CompletedKClipUploadRequest(BaseModel): + kclip_id: str + upload_id: str + parts: list[KClipPartCompleted] + + class CompletedKClipUploadResponse(BaseModel): status: str @router.post("/{kclip_id}/complete") async def complete_upload( - kclip_id: str, - upload_id: str, - parts: list[KClipPartCompleted], + kclip_data: CompletedKClipUploadRequest, user: Annotated[User, Depends(get_session_user_with_write_permission)], crud: Annotated[Crud, Depends(Crud.get)], ) -> CompletedKClipUploadResponse: - await crud.complete_upload(kclip_id, upload_id, parts) + await crud.complete_upload(kclip_data.kclip_id, kclip_data.upload_id, kclip_data.parts) return CompletedKClipUploadResponse(status="completed")