Skip to content

Commit

Permalink
fix: fix response description format error
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed Mar 5, 2024
1 parent effc483 commit 47d6931
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/cloudforet/search/manager/identity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
19 changes: 11 additions & 8 deletions src/cloudforet/search/service/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]]
Expand Down

0 comments on commit 47d6931

Please sign in to comment.