From c9f80b46a12ba8f46e9b7236bf9b162be98d8fac Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Mon, 30 Sep 2024 16:57:09 +0800 Subject: [PATCH] fix: add endpoint name --- api/controllers/console/workspace/endpoint.py | 6 ++++++ api/core/plugin/entities/endpoint.py | 1 + api/core/plugin/manager/endpoint.py | 6 ++++-- api/services/plugin/endpoint_service.py | 6 ++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api/controllers/console/workspace/endpoint.py b/api/controllers/console/workspace/endpoint.py index 44e35f32bd..5fe9eeea68 100644 --- a/api/controllers/console/workspace/endpoint.py +++ b/api/controllers/console/workspace/endpoint.py @@ -21,15 +21,18 @@ class EndpointCreateApi(Resource): parser = reqparse.RequestParser() parser.add_argument("plugin_unique_identifier", type=str, required=True) parser.add_argument("settings", type=dict, required=True) + parser.add_argument("name", type=str, required=True) args = parser.parse_args() plugin_unique_identifier = args["plugin_unique_identifier"] settings = args["settings"] + name = args["name"] return EndpointService.create_endpoint( tenant_id=user.current_tenant_id, user_id=user.id, plugin_unique_identifier=plugin_unique_identifier, + name=name, settings=settings, ) @@ -75,15 +78,18 @@ class EndpointUpdateApi(Resource): parser = reqparse.RequestParser() parser.add_argument("endpoint_id", type=str, required=True) parser.add_argument("settings", type=dict, required=True) + parser.add_argument("name", type=str, required=True) args = parser.parse_args() endpoint_id = args["endpoint_id"] settings = args["settings"] + name = args["name"] return EndpointService.update_endpoint( tenant_id=user.current_tenant_id, user_id=user.id, endpoint_id=endpoint_id, + name=name, settings=settings, ) diff --git a/api/core/plugin/entities/endpoint.py b/api/core/plugin/entities/endpoint.py index 2faa0e8f58..db7819f354 100644 --- a/api/core/plugin/entities/endpoint.py +++ b/api/core/plugin/entities/endpoint.py @@ -21,6 +21,7 @@ class EndpointEntity(BasePluginEntity): """ settings: dict + name: str hook_id: str tenant_id: str plugin_id: str diff --git a/api/core/plugin/manager/endpoint.py b/api/core/plugin/manager/endpoint.py index c4718b72dd..6112edb788 100644 --- a/api/core/plugin/manager/endpoint.py +++ b/api/core/plugin/manager/endpoint.py @@ -3,7 +3,7 @@ from core.plugin.manager.base import BasePluginManager class PluginEndpointManager(BasePluginManager): - def create_endpoint(self, tenant_id: str, user_id: str, plugin_unique_identifier: str, settings: dict): + def create_endpoint(self, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict): """ Create an endpoint for the given plugin. @@ -20,6 +20,7 @@ class PluginEndpointManager(BasePluginManager): "user_id": user_id, "plugin_unique_identifier": plugin_unique_identifier, "settings": settings, + "name": name, }, ) @@ -50,7 +51,7 @@ class PluginEndpointManager(BasePluginManager): }, ) - def update_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str, settings: dict): + def update_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str, name: str, settings: dict): """ Update the settings of the given endpoint. """ @@ -61,6 +62,7 @@ class PluginEndpointManager(BasePluginManager): data={ "user_id": user_id, "endpoint_id": endpoint_id, + "name": name, "settings": settings, }, ) diff --git a/api/services/plugin/endpoint_service.py b/api/services/plugin/endpoint_service.py index 4b3258ef6e..9203b322aa 100644 --- a/api/services/plugin/endpoint_service.py +++ b/api/services/plugin/endpoint_service.py @@ -3,11 +3,12 @@ from core.plugin.manager.endpoint import PluginEndpointManager class EndpointService: @classmethod - def create_endpoint(cls, tenant_id: str, user_id: str, plugin_unique_identifier: str, settings: dict): + def create_endpoint(cls, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict): return PluginEndpointManager().create_endpoint( tenant_id=tenant_id, user_id=user_id, plugin_unique_identifier=plugin_unique_identifier, + name=name, settings=settings, ) @@ -19,11 +20,12 @@ class EndpointService: ) @classmethod - def update_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str, settings: dict): + def update_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str, name: str, settings: dict): return PluginEndpointManager().update_endpoint( tenant_id=tenant_id, user_id=user_id, endpoint_id=endpoint_id, + name=name, settings=settings, )