fix: missing detailed paths of endpoints

This commit is contained in:
Yeuoly 2024-10-10 00:12:46 +08:00
parent 2622159763
commit a470e0e60e
No known key found for this signature in database
GPG Key ID: A66E7E320FB19F61
3 changed files with 23 additions and 25 deletions

View File

@ -1,4 +1,5 @@
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, model_validator
@ -12,7 +13,17 @@ class EndpointDeclaration(BaseModel):
declaration of an endpoint
"""
path: str
method: str
class EndpointProviderDeclaration(BaseModel):
"""
declaration of an endpoint group
"""
settings: list[ProviderConfig] = Field(default_factory=list)
endpoints: Optional[list[EndpointDeclaration]] = Field(default_factory=list)
class EndpointEntity(BasePluginEntity):
@ -21,14 +32,17 @@ class EndpointEntity(BasePluginEntity):
"""
settings: dict
tenant_id: str
plugin_id: str
expired_at: datetime
declaration: EndpointProviderDeclaration = Field(default_factory=EndpointProviderDeclaration)
class EndpointEntityWithInstance(EndpointEntity):
name: str
enabled: bool
url: str
hook_id: str
tenant_id: str
plugin_id: str
expired_at: datetime
declaration: EndpointDeclaration = Field(default_factory=EndpointDeclaration)
@model_validator(mode="before")
@classmethod

View File

@ -5,7 +5,7 @@ from pydantic import BaseModel, Field
from core.model_runtime.entities.provider_entities import ProviderEntity
from core.plugin.entities.base import BasePluginEntity
from core.plugin.entities.endpoint import EndpointEntity
from core.plugin.entities.endpoint import EndpointProviderDeclaration
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_entities import ToolProviderEntity
@ -61,7 +61,7 @@ class PluginDeclaration(BaseModel):
plugins: Plugins
tool: Optional[ToolProviderEntity] = None
model: Optional[ProviderEntity] = None
endpoint: Optional[EndpointEntity] = None
endpoint: Optional[EndpointProviderDeclaration] = None
class PluginEntity(BasePluginEntity):

View File

@ -1,4 +1,4 @@
from core.plugin.entities.endpoint import EndpointEntity
from core.plugin.entities.endpoint import EndpointEntityWithInstance
from core.plugin.manager.base import BasePluginManager
@ -33,7 +33,7 @@ class PluginEndpointManager(BasePluginManager):
return self._request_with_plugin_daemon_response(
"GET",
f"plugin/{tenant_id}/endpoint/list",
list[EndpointEntity],
list[EndpointEntityWithInstance],
params={"page": page, "page_size": page_size},
)
@ -44,26 +44,10 @@ class PluginEndpointManager(BasePluginManager):
return self._request_with_plugin_daemon_response(
"GET",
f"plugin/{tenant_id}/endpoint/list/plugin",
list[EndpointEntity],
list[EndpointEntityWithInstance],
params={"plugin_id": plugin_id, "page": page, "page_size": page_size},
)
def list_plugin_endpoints(self, tenant_id: str, user_id: str, plugin_unique_identifier: str):
"""
List all endpoints for the given tenant, user and plugin.
"""
return self._request_with_plugin_daemon_response(
"GET",
f"plugin/{tenant_id}/endpoint/list/plugin",
list[EndpointEntity],
headers={
"Content-Type": "application/json",
},
data={
"plugin_unique_identifier": plugin_unique_identifier,
},
)
def update_endpoint(self, tenant_id: str, user_id: str, endpoint_id: str, name: str, settings: dict):
"""
Update the settings of the given endpoint.