From 27293c917f77363de04c7c7a47ade711bfa7aca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Kr=C3=BCger=20Svensson?= Date: Mon, 21 Mar 2022 16:49:49 +0100 Subject: [PATCH] Fix response key for API consistency --- .gitignore | 1 + app/api/api_v2/endpoints/delete.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index eb9ecf2..cad4d0f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ notes .coverage htmlcov/ coverage.xml +.DS_Store diff --git a/app/api/api_v2/endpoints/delete.py b/app/api/api_v2/endpoints/delete.py index 665ca2d..126c47b 100644 --- a/app/api/api_v2/endpoints/delete.py +++ b/app/api/api_v2/endpoints/delete.py @@ -14,12 +14,12 @@ class DeletedFileResponse(BaseModel): - file_path: str = Field(...) + path: str = Field(...) @router.delete('/files', response_model=DeletedFileResponse) async def delete_file( - file_path: str, + path: str, boto_session: AioBaseClient = Depends(get_boto), user: User = Depends(cognito_signed_in), db_session: AsyncSession = Depends(yield_db_session), @@ -27,7 +27,7 @@ async def delete_file( """ Delete file with filename """ - video_statement = select(Video).where(and_(Video.path == file_path, Video.user_id == user.id)) + video_statement = select(Video).where(and_(Video.path == path, Video.user_id == user.id)) db_result = await db_session.exec(video_statement) # type: ignore video = db_result.first() if not video: @@ -35,7 +35,7 @@ async def delete_file( status_code=status.HTTP_404_NOT_FOUND, detail='File not found. Ensure you own the file, and that the file already exist.', ) - await boto_session.delete_object(Bucket=settings.S3_BUCKET_URL, Key=file_path) + await boto_session.delete_object(Bucket=settings.S3_BUCKET_URL, Key=path) await db_session.delete(video) await db_session.commit() - return {'file_path': file_path} + return {'path': path}