feat: adapt to plugin_daemon endpoint

This commit is contained in:
Stream 2025-08-27 16:12:40 +08:00
parent 7db77cf9f8
commit 11f4743624
No known key found for this signature in database
GPG Key ID: 9475891C9507B4F3
3 changed files with 27 additions and 7 deletions

View File

@ -656,7 +656,9 @@ class PluginReadmeApi(Resource):
return jsonable_encoder(
{
"readme": PluginService.fetch_plugin_readme(
tenant_id, args["plugin_unique_identifier"], args.get("language", "en-US")
tenant_id,
args["plugin_unique_identifier"],
args.get("language", "en-US")
)
}
)

View File

@ -196,3 +196,7 @@ class PluginListResponse(BaseModel):
class PluginDynamicSelectOptionsResponse(BaseModel):
options: Sequence[PluginParameterOption] = Field(description="The options of the dynamic select.")
class PluginReadmeResponse(BaseModel):
content: str = Field(description="The readme of the plugin.")
language: str = Field(description="The language of the readme.")

View File

@ -1,5 +1,7 @@
from collections.abc import Sequence
from requests import HTTPError
from core.plugin.entities.bundle import PluginBundleDependency
from core.plugin.entities.plugin import (
GenericProviderID,
@ -14,6 +16,7 @@ from core.plugin.entities.plugin_daemon import (
PluginInstallTask,
PluginInstallTaskStartResponse,
PluginListResponse,
PluginReadmeResponse,
)
from core.plugin.impl.base import BasePluginClient
@ -23,12 +26,23 @@ class PluginInstaller(BasePluginClient):
"""
Fetch plugin readme
"""
return self._request_with_plugin_daemon_response(
"GET",
f"plugin/{tenant_id}/management/fetch/readme",
str,
params={"plugin_unique_identifier": plugin_unique_identifier, "language": language},
)
try:
response = self._request_with_plugin_daemon_response(
"GET",
f"plugin/{tenant_id}/management/fetch/readme",
PluginReadmeResponse,
params={
"tenant_id":tenant_id,
"plugin_unique_identifier": plugin_unique_identifier,
"language": language
}
)
return response.content
except HTTPError as e:
message = e.args[0]
if "404" in message:
return ""
raise e
def fetch_plugin_by_identifier(
self,