|
|
|
@ -3,16 +3,18 @@ from core.plugin.manager.base import BasePluginManager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PluginEndpointManager(BasePluginManager):
|
|
|
|
class PluginEndpointManager(BasePluginManager):
|
|
|
|
def create_endpoint(self, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict):
|
|
|
|
def create_endpoint(
|
|
|
|
|
|
|
|
self, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict
|
|
|
|
|
|
|
|
) -> bool:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Create an endpoint for the given plugin.
|
|
|
|
Create an endpoint for the given plugin.
|
|
|
|
|
|
|
|
|
|
|
|
Errors will be raised if any error occurs.
|
|
|
|
Errors will be raised if any error occurs.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._request_with_plugin_daemon_response(
|
|
|
|
return self._request_with_plugin_daemon_response(
|
|
|
|
"POST",
|
|
|
|
"POST",
|
|
|
|
f"plugin/{tenant_id}/endpoint/setup",
|
|
|
|
f"plugin/{tenant_id}/endpoint/setup",
|
|
|
|
dict,
|
|
|
|
bool,
|
|
|
|
headers={
|
|
|
|
headers={
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -24,7 +26,7 @@ class PluginEndpointManager(BasePluginManager):
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def list_endpoints(self, tenant_id: str, user_id: str):
|
|
|
|
def list_endpoints(self, tenant_id: str, user_id: str, page: int, page_size: int):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
List all endpoints for the given tenant and user.
|
|
|
|
List all endpoints for the given tenant and user.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
@ -32,7 +34,7 @@ class PluginEndpointManager(BasePluginManager):
|
|
|
|
"GET",
|
|
|
|
"GET",
|
|
|
|
f"plugin/{tenant_id}/endpoint/list",
|
|
|
|
f"plugin/{tenant_id}/endpoint/list",
|
|
|
|
list[EndpointEntity],
|
|
|
|
list[EndpointEntity],
|
|
|
|
params={"page": 1, "page_size": 256},
|
|
|
|
params={"page": page, "page_size": page_size},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def list_plugin_endpoints(self, tenant_id: str, user_id: str, plugin_unique_identifier: str):
|
|
|
|
def list_plugin_endpoints(self, tenant_id: str, user_id: str, plugin_unique_identifier: str):
|
|
|
|
@ -55,53 +57,65 @@ class PluginEndpointManager(BasePluginManager):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Update the settings of the given endpoint.
|
|
|
|
Update the settings of the given endpoint.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._request_with_plugin_daemon_response(
|
|
|
|
return self._request_with_plugin_daemon_response(
|
|
|
|
"POST",
|
|
|
|
"POST",
|
|
|
|
f"plugin/{tenant_id}/endpoint/update",
|
|
|
|
f"plugin/{tenant_id}/endpoint/update",
|
|
|
|
dict,
|
|
|
|
bool,
|
|
|
|
data={
|
|
|
|
data={
|
|
|
|
"user_id": user_id,
|
|
|
|
"user_id": user_id,
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
"name": name,
|
|
|
|
"name": name,
|
|
|
|
"settings": settings,
|
|
|
|
"settings": settings,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
headers={
|
|
|
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def delete_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str):
|
|
|
|
def delete_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Delete the given endpoint.
|
|
|
|
Delete the given endpoint.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._request_with_plugin_daemon_response(
|
|
|
|
return self._request_with_plugin_daemon_response(
|
|
|
|
"DELETE",
|
|
|
|
"POST",
|
|
|
|
f"plugin/{tenant_id}/endpoint/remove",
|
|
|
|
f"plugin/{tenant_id}/endpoint/remove",
|
|
|
|
dict,
|
|
|
|
bool,
|
|
|
|
data={
|
|
|
|
data={
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
headers={
|
|
|
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def enable_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str):
|
|
|
|
def enable_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Enable the given endpoint.
|
|
|
|
Enable the given endpoint.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._request_with_plugin_daemon_response(
|
|
|
|
return self._request_with_plugin_daemon_response(
|
|
|
|
"POST",
|
|
|
|
"POST",
|
|
|
|
f"plugin/{tenant_id}/endpoint/enable",
|
|
|
|
f"plugin/{tenant_id}/endpoint/enable",
|
|
|
|
dict,
|
|
|
|
bool,
|
|
|
|
data={
|
|
|
|
data={
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
headers={
|
|
|
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def disable_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str):
|
|
|
|
def disable_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Disable the given endpoint.
|
|
|
|
Disable the given endpoint.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self._request_with_plugin_daemon_response(
|
|
|
|
return self._request_with_plugin_daemon_response(
|
|
|
|
"POST",
|
|
|
|
"POST",
|
|
|
|
f"plugin/{tenant_id}/endpoint/disable",
|
|
|
|
f"plugin/{tenant_id}/endpoint/disable",
|
|
|
|
dict,
|
|
|
|
bool,
|
|
|
|
data={
|
|
|
|
data={
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
"endpoint_id": endpoint_id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
headers={
|
|
|
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|