feat: support delete all install tasks

This commit is contained in:
Yeuoly 2024-11-25 17:11:41 +08:00
parent 965fabd578
commit ba3659a792
No known key found for this signature in database
GPG Key ID: A66E7E320FB19F61
3 changed files with 35 additions and 0 deletions

View File

@ -305,6 +305,20 @@ class PluginDeleteInstallTaskApi(Resource):
raise ValueError(e) raise ValueError(e)
class PluginDeleteAllInstallTaskItemsApi(Resource):
@setup_required
@login_required
@account_initialization_required
@plugin_permission_required(debug_required=True)
def post(self):
tenant_id = current_user.current_tenant_id
try:
return {"success": PluginService.delete_all_install_task_items(tenant_id)}
except PluginDaemonBadRequestError as e:
raise ValueError(e)
class PluginDeleteInstallTaskItemApi(Resource): class PluginDeleteInstallTaskItemApi(Resource):
@setup_required @setup_required
@login_required @login_required
@ -453,6 +467,7 @@ api.add_resource(PluginFetchManifestApi, "/workspaces/current/plugin/fetch-manif
api.add_resource(PluginFetchInstallTasksApi, "/workspaces/current/plugin/tasks") api.add_resource(PluginFetchInstallTasksApi, "/workspaces/current/plugin/tasks")
api.add_resource(PluginFetchInstallTaskApi, "/workspaces/current/plugin/tasks/<task_id>") api.add_resource(PluginFetchInstallTaskApi, "/workspaces/current/plugin/tasks/<task_id>")
api.add_resource(PluginDeleteInstallTaskApi, "/workspaces/current/plugin/tasks/<task_id>/delete") api.add_resource(PluginDeleteInstallTaskApi, "/workspaces/current/plugin/tasks/<task_id>/delete")
api.add_resource(PluginDeleteAllInstallTaskItemsApi, "/workspaces/current/plugin/tasks/delete_all")
api.add_resource(PluginDeleteInstallTaskItemApi, "/workspaces/current/plugin/tasks/<task_id>/delete/<path:identifier>") api.add_resource(PluginDeleteInstallTaskItemApi, "/workspaces/current/plugin/tasks/<task_id>/delete/<path:identifier>")
api.add_resource(PluginUninstallApi, "/workspaces/current/plugin/uninstall") api.add_resource(PluginUninstallApi, "/workspaces/current/plugin/uninstall")

View File

@ -126,6 +126,16 @@ class PluginInstallationManager(BasePluginManager):
bool, bool,
) )
def delete_all_plugin_installation_task_items(self, tenant_id: str) -> bool:
"""
Delete all plugin installation task items.
"""
return self._request_with_plugin_daemon_response(
"POST",
f"plugin/{tenant_id}/management/install/tasks/delete_all",
bool,
)
def delete_plugin_installation_task_item(self, tenant_id: str, task_id: str, identifier: str) -> bool: def delete_plugin_installation_task_item(self, tenant_id: str, task_id: str, identifier: str) -> bool:
""" """
Delete a plugin installation task item. Delete a plugin installation task item.

View File

@ -105,6 +105,16 @@ class PluginService:
manager = PluginInstallationManager() manager = PluginInstallationManager()
return manager.delete_plugin_installation_task(tenant_id, task_id) return manager.delete_plugin_installation_task(tenant_id, task_id)
@staticmethod
def delete_all_install_task_items(
tenant_id: str,
) -> bool:
"""
Delete all plugin installation task items
"""
manager = PluginInstallationManager()
return manager.delete_all_plugin_installation_task_items(tenant_id)
@staticmethod @staticmethod
def delete_install_task_item(tenant_id: str, task_id: str, identifier: str) -> bool: def delete_install_task_item(tenant_id: str, task_id: str, identifier: str) -> bool:
""" """