From 47d693147eab5dcbf81187453835ca4b7c58b810 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Tue, 5 Mar 2024 18:51:33 +0900 Subject: [PATCH] fix: fix response description format error --- .../search/manager/identity_manager.py | 3 +++ src/cloudforet/search/service/resource.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cloudforet/search/manager/identity_manager.py b/src/cloudforet/search/manager/identity_manager.py index 04d3c4b..8b44e49 100644 --- a/src/cloudforet/search/manager/identity_manager.py +++ b/src/cloudforet/search/manager/identity_manager.py @@ -22,3 +22,6 @@ def __init__(self, *args, **kwargs): ) def get_workspaces(self, domain_id: str, user_id: str) -> dict: return self.identity_conn.dispatch("UserProfile.get_workspaces") + + def list_workspace(self, query: dict) -> dict: + return self.identity_conn.dispatch("Workspace.list", {"query": query}) diff --git a/src/cloudforet/search/service/resource.py b/src/cloudforet/search/service/resource.py index ad646d6..5a09c91 100644 --- a/src/cloudforet/search/service/resource.py +++ b/src/cloudforet/search/service/resource.py @@ -175,11 +175,16 @@ def _get_accessible_workspaces( all_workspaces: Union[bool, None], ) -> list: if all_workspaces or not workspaces: - return [] - - # check is accessible workspace with params.workspaces - workspace_ids = self._get_all_workspace_ids(domain_id, user_id) - workspaces = list(set(workspaces) & set(workspace_ids)) + workspaces = [] + elif user_id is None: + identity_mgr: IdentityManager = self.locator.get_manager("IdentityManager") + identity_mgr.list_workspace( + {"filter": [{"k": "workspace_id", "v": workspaces, "o": "in"}]} + ) + else: + # check is accessible workspace with params.workspaces + workspace_ids = self._get_all_workspace_ids(domain_id, user_id) + workspaces = list(set(workspaces) & set(workspace_ids)) return workspaces @@ -236,9 +241,7 @@ def _make_filter_by_workspaces( @staticmethod def _make_response(results: list, next_token: str, response_conf: dict) -> dict: response_name_format = response_conf["name"] - response_description_format = response_conf.get( - "description", response_name_format - ) + response_description_format = response_conf.get("description") for result in results: result["name"] = response_name_format.format(**result) result["resource_id"] = result[response_conf["resource_id"]]