Skip to content

Commit

Permalink
Merge branch 'fix/chore-fix' into dev/plugin-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Nov 14, 2024
2 parents 94a8547 + 634cb62 commit 1812af6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
16 changes: 16 additions & 0 deletions api/controllers/console/workspace/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ def get(self):
return jsonable_encoder({"plugins": plugins})


class PluginListInstallationsFromIdsApi(Resource):
@setup_required
@login_required
@account_initialization_required
def post(self):
tenant_id = current_user.current_tenant_id

parser = reqparse.RequestParser()
parser.add_argument("plugin_ids", type=list, required=True, location="json")
args = parser.parse_args()

plugins = PluginService.list_installations_from_ids(tenant_id, args["plugin_ids"])
return jsonable_encoder({"plugins": plugins})


class PluginIconApi(Resource):
@setup_required
def get(self):
Expand Down Expand Up @@ -363,6 +378,7 @@ def get(self):

api.add_resource(PluginDebuggingKeyApi, "/workspaces/current/plugin/debugging-key")
api.add_resource(PluginListApi, "/workspaces/current/plugin/list")
api.add_resource(PluginListInstallationsFromIdsApi, "/workspaces/current/plugin/list/installations/ids")
api.add_resource(PluginIconApi, "/workspaces/current/plugin/icon")
api.add_resource(PluginUploadFromPkgApi, "/workspaces/current/plugin/upload/pkg")
api.add_resource(PluginUploadFromGithubApi, "/workspaces/current/plugin/upload/github")
Expand Down
4 changes: 3 additions & 1 deletion api/core/plugin/entities/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ class PluginInstallation(BasePluginEntity):
meta: Mapping[str, Any]
plugin_id: str
plugin_unique_identifier: str
version: str
checksum: str
declaration: PluginDeclaration


class PluginEntity(PluginInstallation):
name: str
declaration: PluginDeclaration
installation_id: str
version: str
latest_version: Optional[str] = None
Expand Down
4 changes: 3 additions & 1 deletion api/core/plugin/manager/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ class PluginDeclarationResponse(BaseModel):
params={"plugin_unique_identifier": plugin_unique_identifier},
).declaration

def fetch_plugin_installation_by_ids(self, tenant_id: str, plugin_ids: Sequence[str]) -> list[PluginInstallation]:
def fetch_plugin_installation_by_ids(
self, tenant_id: str, plugin_ids: Sequence[str]
) -> Sequence[PluginInstallation]:
"""
Fetch plugin installations by ids.
"""
Expand Down
10 changes: 9 additions & 1 deletion api/services/plugin/plugin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from core.helper.download import download_with_size_limit
from core.helper.marketplace import download_plugin_pkg
from core.plugin.entities.bundle import PluginBundleDependency
from core.plugin.entities.plugin import PluginDeclaration, PluginEntity, PluginInstallationSource
from core.plugin.entities.plugin import PluginDeclaration, PluginEntity, PluginInstallation, PluginInstallationSource
from core.plugin.entities.plugin_daemon import PluginInstallTask, PluginUploadResponse
from core.plugin.manager.asset import PluginAssetManager
from core.plugin.manager.debugging import PluginDebuggingManager
Expand Down Expand Up @@ -50,6 +50,14 @@ def list(tenant_id: str) -> list[PluginEntity]:

return plugins

@staticmethod
def list_installations_from_ids(tenant_id: str, ids: Sequence[str]) -> Sequence[PluginInstallation]:
"""
List plugin installations from ids
"""
manager = PluginInstallationManager()
return manager.fetch_plugin_installation_by_ids(tenant_id, ids)

@staticmethod
def get_asset(tenant_id: str, asset_file: str) -> tuple[bytes, str]:
"""
Expand Down

0 comments on commit 1812af6

Please sign in to comment.