From ba3659a7929fdda3a4bb621691588d8bcec1ccfa Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Mon, 25 Nov 2024 17:11:41 +0800 Subject: [PATCH] feat: support delete all install tasks --- api/controllers/console/workspace/plugin.py | 15 +++++++++++++++ api/core/plugin/manager/plugin.py | 10 ++++++++++ api/services/plugin/plugin_service.py | 10 ++++++++++ 3 files changed, 35 insertions(+) diff --git a/api/controllers/console/workspace/plugin.py b/api/controllers/console/workspace/plugin.py index ca63316919..7e85914532 100644 --- a/api/controllers/console/workspace/plugin.py +++ b/api/controllers/console/workspace/plugin.py @@ -305,6 +305,20 @@ class PluginDeleteInstallTaskApi(Resource): 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): @setup_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(PluginFetchInstallTaskApi, "/workspaces/current/plugin/tasks/") api.add_resource(PluginDeleteInstallTaskApi, "/workspaces/current/plugin/tasks//delete") +api.add_resource(PluginDeleteAllInstallTaskItemsApi, "/workspaces/current/plugin/tasks/delete_all") api.add_resource(PluginDeleteInstallTaskItemApi, "/workspaces/current/plugin/tasks//delete/") api.add_resource(PluginUninstallApi, "/workspaces/current/plugin/uninstall") diff --git a/api/core/plugin/manager/plugin.py b/api/core/plugin/manager/plugin.py index 2ae3004281..82073e34b3 100644 --- a/api/core/plugin/manager/plugin.py +++ b/api/core/plugin/manager/plugin.py @@ -126,6 +126,16 @@ class PluginInstallationManager(BasePluginManager): 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: """ Delete a plugin installation task item. diff --git a/api/services/plugin/plugin_service.py b/api/services/plugin/plugin_service.py index 81d6fd8aa1..5fb136e634 100644 --- a/api/services/plugin/plugin_service.py +++ b/api/services/plugin/plugin_service.py @@ -105,6 +105,16 @@ class PluginService: manager = PluginInstallationManager() 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 def delete_install_task_item(tenant_id: str, task_id: str, identifier: str) -> bool: """