From 742328703f4d69d9df33449db56fb8e27e14522c Mon Sep 17 00:00:00 2001 From: Youngjin Jo Date: Sat, 28 Sep 2024 02:44:36 +0900 Subject: [PATCH] fix: convert type when call the add_user_name_and_state_to_users method Signed-off-by: Youngjin Jo --- .../identity/service/user_profile_service.py | 32 +++++++++---------- .../service/workspace_group_service.py | 6 ++-- .../service/workspace_group_user_service.py | 8 +++-- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/spaceone/identity/service/user_profile_service.py b/src/spaceone/identity/service/user_profile_service.py index e5773664..adc4d93d 100644 --- a/src/spaceone/identity/service/user_profile_service.py +++ b/src/spaceone/identity/service/user_profile_service.py @@ -16,23 +16,21 @@ from spaceone.identity.manager.mfa_manager.base import MFAManager from spaceone.identity.manager.role_binding_manager import RoleBindingManager from spaceone.identity.manager.role_manager import RoleManager -from spaceone.identity.manager.token_manager.local_token_manager import ( - LocalTokenManager, -) +from spaceone.identity.manager.token_manager.local_token_manager import \ + LocalTokenManager from spaceone.identity.manager.user_manager import UserManager -from spaceone.identity.manager.workspace_group_manager import WorkspaceGroupManager +from spaceone.identity.manager.workspace_group_manager import \ + WorkspaceGroupManager from spaceone.identity.manager.workspace_manager import WorkspaceManager from spaceone.identity.model.user.database import User from spaceone.identity.model.user.response import * from spaceone.identity.model.user_profile.request import * -from spaceone.identity.model.user_profile.request import ( - UserProfileGetWorkspaceGroupsRequest, -) +from spaceone.identity.model.user_profile.request import \ + UserProfileGetWorkspaceGroupsRequest from spaceone.identity.model.user_profile.response import ( - MyWorkspaceGroupsResponse, - MyWorkspacesResponse, -) -from spaceone.identity.service.workspace_group_service import WorkspaceGroupService + MyWorkspaceGroupsResponse, MyWorkspacesResponse) +from spaceone.identity.service.workspace_group_service import \ + WorkspaceGroupService _LOGGER = logging.getLogger(__name__) @@ -423,7 +421,6 @@ def get_workspace_groups( Returns: MyWorkspaceResponse: """ - rb_mgr = RoleBindingManager() allow_all = False @@ -466,16 +463,19 @@ def get_workspace_groups( workspace_group_user_ids = [] for workspace_group_info in workspace_group_infos: - if workspace_group_info["users"]: - for user in workspace_group_info["users"]: - workspace_group_user_ids.append(user.user_id) + if users := workspace_group_info.get("users"): + for user in users: + if isinstance(user, dict): + workspace_group_user_ids.append(user.get("user_id")) + elif hasattr(user, "user_id"): + workspace_group_user_ids.append(user.user_id) workspace_groups_info = [] for workspace_group_info in workspace_group_infos: workspace_group_dict = ( self.workspace_group_svc.add_user_name_and_state_to_users( workspace_group_user_ids, - workspace_group_info.to_dict(), + workspace_group_info, params.domain_id, ) ) diff --git a/src/spaceone/identity/service/workspace_group_service.py b/src/spaceone/identity/service/workspace_group_service.py index 17849f0c..4ad526b3 100644 --- a/src/spaceone/identity/service/workspace_group_service.py +++ b/src/spaceone/identity/service/workspace_group_service.py @@ -208,7 +208,7 @@ def add_users( ) workspace_group_info = self.add_user_name_and_state_to_users( - workspace_group_user_ids, workspace_group_vo, domain_id + workspace_group_user_ids, workspace_group_vo.to_dict(), domain_id ) return WorkspaceGroupResponse(**workspace_group_info) @@ -351,7 +351,7 @@ def get( workspace_group_user_ids: List[str] = old_users + new_users workspace_group_dict = self.add_user_name_and_state_to_users( - workspace_group_user_ids, workspace_group_vo, domain_id + workspace_group_user_ids, workspace_group_vo.to_dict(), domain_id ) return WorkspaceGroupResponse(**workspace_group_dict) @@ -399,7 +399,7 @@ def list( workspace_group_user_ids: List[str] = old_users + new_users workspace_group_dict = self.add_user_name_and_state_to_users( - workspace_group_user_ids, workspace_group_vo, params.domain_id + workspace_group_user_ids, workspace_group_vo.to_dict(), params.domain_id ) workspace_groups_info.append(workspace_group_dict) diff --git a/src/spaceone/identity/service/workspace_group_user_service.py b/src/spaceone/identity/service/workspace_group_user_service.py index 76431338..6916e03b 100644 --- a/src/spaceone/identity/service/workspace_group_user_service.py +++ b/src/spaceone/identity/service/workspace_group_user_service.py @@ -137,7 +137,7 @@ def add( workspace_group_user_dict = ( self.workspace_group_svc.add_user_name_and_state_to_users( - workspace_group_user_ids, workspace_group_vo, domain_id + workspace_group_user_ids, workspace_group_vo.to_dict(), domain_id ) ) @@ -349,7 +349,7 @@ def get( workspace_group_dict = ( self.workspace_group_svc.add_user_name_and_state_to_users( - workspace_group_user_ids, workspace_group_vo, domain_id + workspace_group_user_ids, workspace_group_vo.to_dict(), domain_id ) ) return WorkspaceGroupResponse(**workspace_group_dict) @@ -399,7 +399,9 @@ def list( workspace_group_dict = ( self.workspace_group_svc.add_user_name_and_state_to_users( - workspace_group_user_ids, workspace_group_vo, params.domain_id + workspace_group_user_ids, + workspace_group_vo.to_dict(), + params.domain_id, ) ) workspace_groups_info.append(workspace_group_dict)