feat: support remove single item from installation task

This commit is contained in:
Yeuoly 2024-10-25 13:22:37 +08:00
parent 99c8f364ae
commit ffdc6f5c60
No known key found for this signature in database
GPG Key ID: A66E7E320FB19F61
3 changed files with 30 additions and 0 deletions

View File

@ -266,6 +266,20 @@ class PluginDeleteInstallTaskApi(Resource):
return {"success": PluginService.delete_install_task(tenant_id, task_id)}
class PluginDeleteInstallTaskItemApi(Resource):
@setup_required
@login_required
@account_initialization_required
def post(self, task_id: str, identifier: str):
user = current_user
if not user.is_admin_or_owner:
raise Forbidden()
tenant_id = user.current_tenant_id
return {"success": PluginService.delete_install_task_item(tenant_id, task_id, identifier)}
class PluginUninstallApi(Resource):
@setup_required
@login_required
@ -296,4 +310,5 @@ 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/<task_id>")
api.add_resource(PluginDeleteInstallTaskApi, "/workspaces/current/plugin/tasks/<task_id>/delete")
api.add_resource(PluginDeleteInstallTaskItemApi, "/workspaces/current/plugin/tasks/<task_id>/delete/<identifier>")
api.add_resource(PluginUninstallApi, "/workspaces/current/plugin/uninstall")

View File

@ -103,6 +103,16 @@ class PluginInstallationManager(BasePluginManager):
bool,
)
def delete_plugin_installation_task_item(self, tenant_id: str, task_id: str, identifier: str) -> bool:
"""
Delete a plugin installation task item.
"""
return self._request_with_plugin_daemon_response(
"POST",
f"plugin/{tenant_id}/management/install/tasks/{task_id}/delete/{identifier}",
bool,
)
def fetch_plugin_manifest(self, tenant_id: str, plugin_unique_identifier: str) -> PluginDeclaration:
"""
Fetch a plugin manifest.

View File

@ -66,6 +66,11 @@ class PluginService:
manager = PluginInstallationManager()
return manager.delete_plugin_installation_task(tenant_id, task_id)
@staticmethod
def delete_install_task_item(tenant_id: str, task_id: str, identifier: str) -> bool:
manager = PluginInstallationManager()
return manager.delete_plugin_installation_task_item(tenant_id, task_id, identifier)
@staticmethod
def upload_pkg(tenant_id: str, pkg: bytes, verify_signature: bool = False) -> PluginUploadResponse:
"""