Skip to content

Commit

Permalink
update API names
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa committed Mar 7, 2024
1 parent 5dde934 commit c9e4c4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/ai/backend/client/cli/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand All @@ -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)
Expand All @@ -185,15 +185,15 @@ 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!
NAME: Name of a virtual folder.
"""
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)
Expand Down
8 changes: 4 additions & 4 deletions src/ai/backend/client/func/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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,
})
Expand All @@ -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,
})
Expand Down
6 changes: 4 additions & 2 deletions src/ai/backend/manager/api/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c9e4c4f

Please sign in to comment.