dify/api/services/plugin/endpoint_service.py

67 lines
2.2 KiB
Python
Raw Normal View History

2024-09-26 12:49:00 +08:00
from core.plugin.manager.endpoint import PluginEndpointManager
2024-09-26 10:26:45 +08:00
class EndpointService:
2024-09-26 12:49:00 +08:00
@classmethod
2024-09-30 16:57:09 +08:00
def create_endpoint(cls, tenant_id: str, user_id: str, plugin_unique_identifier: str, name: str, settings: dict):
2024-09-26 12:49:00 +08:00
return PluginEndpointManager().create_endpoint(
tenant_id=tenant_id,
user_id=user_id,
plugin_unique_identifier=plugin_unique_identifier,
2024-09-30 16:57:09 +08:00
name=name,
2024-09-26 12:49:00 +08:00
settings=settings,
)
@classmethod
2024-10-08 23:48:38 +08:00
def list_endpoints(cls, tenant_id: str, user_id: str, page: int, page_size: int):
2024-09-26 12:49:00 +08:00
return PluginEndpointManager().list_endpoints(
tenant_id=tenant_id,
user_id=user_id,
2024-10-08 23:48:38 +08:00
page=page,
page_size=page_size,
2024-09-26 12:49:00 +08:00
)
@classmethod
def list_endpoints_for_single_plugin(cls, tenant_id: str, user_id: str, plugin_id: str, page: int, page_size: int):
return PluginEndpointManager().list_endpoints_for_single_plugin(
tenant_id=tenant_id,
user_id=user_id,
plugin_id=plugin_id,
page=page,
page_size=page_size,
)
2024-09-26 12:49:00 +08:00
@classmethod
2024-09-30 16:57:09 +08:00
def update_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str, name: str, settings: dict):
2024-09-26 12:49:00 +08:00
return PluginEndpointManager().update_endpoint(
tenant_id=tenant_id,
user_id=user_id,
endpoint_id=endpoint_id,
2024-09-30 16:57:09 +08:00
name=name,
2024-09-26 12:49:00 +08:00
settings=settings,
)
@classmethod
def delete_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
return PluginEndpointManager().delete_endpoint(
tenant_id=tenant_id,
user_id=user_id,
endpoint_id=endpoint_id,
)
@classmethod
def enable_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
return PluginEndpointManager().enable_endpoint(
tenant_id=tenant_id,
user_id=user_id,
endpoint_id=endpoint_id,
)
@classmethod
def disable_endpoint(cls, tenant_id: str, user_id: str, endpoint_id: str):
return PluginEndpointManager().disable_endpoint(
tenant_id=tenant_id,
user_id=user_id,
endpoint_id=endpoint_id,
)