From c9e4c4fc5458b25b28e04d0258db09abd6ff5e59 Mon Sep 17 00:00:00 2001 From: Sanghun Lee Date: Thu, 7 Mar 2024 14:04:13 +0900 Subject: [PATCH] update API names --- src/ai/backend/client/cli/vfolder.py | 10 +++++----- src/ai/backend/client/func/vfolder.py | 8 ++++---- src/ai/backend/manager/api/vfolder.py | 6 ++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ai/backend/client/cli/vfolder.py b/src/ai/backend/client/cli/vfolder.py index bf0e65d22f..e3fe29525b 100644 --- a/src/ai/backend/client/cli/vfolder.py +++ b/src/ai/backend/client/cli/vfolder.py @@ -150,8 +150,8 @@ def create(name, host, group, host_path, usage_mode, permission, cloneable): @vfolder.command() @click.argument("name", type=str) -def delete(name): - """Delete the given virtual folder. The virtual folder will be under `delete-pending` status, which means trash-bin. +def move_to_trash(name): + """Move the given virtual folder to trash-bin. The virtual folder will be under `delete-pending` status. This operation can be retracted by calling `restore()`. @@ -160,7 +160,7 @@ def delete(name): """ with Session() as session: try: - session.VFolder(name).delete() + session.VFolder(name).move_to_trash() print_done("Deleted.") except Exception as e: print_error(e) @@ -185,7 +185,7 @@ def purge(name): @vfolder.command() @click.argument("name", type=str) -def delete_trash(name): +def delete_forever(name): """Delete the given virtual folder's real data. The virtual folder should be under `delete-pending` status, which means trash-bin. This operation is irreversible! @@ -193,7 +193,7 @@ def delete_trash(name): """ with Session() as session: try: - session.VFolder(name).delete_trash() + session.VFolder(name).delete_forever() print_done("Delete completed.") except Exception as e: print_error(e) diff --git a/src/ai/backend/client/func/vfolder.py b/src/ai/backend/client/func/vfolder.py index 13e735b715..40c20ea26c 100644 --- a/src/ai/backend/client/func/vfolder.py +++ b/src/ai/backend/client/func/vfolder.py @@ -247,7 +247,7 @@ async def info(self): return await resp.json() @api_function - async def delete(self): + async def move_to_trash(self): rqst = Request("DELETE", "/folders/{0}".format(self.name)) async with rqst.fetch(): return {} @@ -268,7 +268,7 @@ async def _restore(self) -> Mapping[str, Any]: if self.id is None: vfolder_id = await self._get_id_by_name() self.id = vfolder_id - rqst = Request("POST", "/folders/restore-from-trash-bin") + rqst = Request("POST", "/folders/restore") rqst.set_json({ "id": self.id.hex, }) @@ -284,11 +284,11 @@ async def restore(self): return await self._restore() @api_function - async def delete_trash(self) -> Mapping[str, Any]: + async def delete_forever(self) -> Mapping[str, Any]: if self.id is None: vfolder_id = await self._get_id_by_name() self.id = vfolder_id - rqst = Request("POST", "/folders/delete-from-trash-bin") + rqst = Request("POST", "/folders/delete-forever") rqst.set_json({ "id": self.id.hex, }) diff --git a/src/ai/backend/manager/api/vfolder.py b/src/ai/backend/manager/api/vfolder.py index b364b9acb6..f89a4e86e5 100644 --- a/src/ai/backend/manager/api/vfolder.py +++ b/src/ai/backend/manager/api/vfolder.py @@ -2403,7 +2403,7 @@ class DeleteFromTrashRequestModel(BaseModel): @auth_required @pydantic_params_api_handler(DeleteFromTrashRequestModel) -async def delete_from_trash_bin( +async def delete_forever( request: web.Request, params: DeleteFromTrashRequestModel ) -> BackgroundTaskResponseModel: """ @@ -3493,7 +3493,9 @@ def create_app(default_cors_options): cors.add(add_route("POST", r"/{name}/clone", clone)) cors.add(add_route("POST", r"/purge", purge)) cors.add(add_route("POST", r"/restore-from-trash-bin", restore)) - cors.add(add_route("POST", r"/delete-from-trash-bin", delete_from_trash_bin)) + cors.add(add_route("POST", r"/restore", restore)) + cors.add(add_route("POST", r"/delete-from-trash-bin", delete_forever)) + cors.add(add_route("POST", r"/delete-forever", delete_forever)) cors.add(add_route("GET", r"/invitations/list-sent", list_sent_invitations)) cors.add(add_route("GET", r"/invitations/list_sent", list_sent_invitations)) # legacy underbar cors.add(add_route("POST", r"/invitations/update/{inv_id}", update_invitation))