Skip to content

Commit

Permalink
Merge pull request #372 from yjinjo/master
Browse files Browse the repository at this point in the history
Convert type when calling the add_user_name_and_state_to_users method
  • Loading branch information
yjinjo authored Sep 27, 2024
2 parents 18057db + 7423287 commit 02b96cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
32 changes: 16 additions & 16 deletions src/spaceone/identity/service/user_profile_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -423,7 +421,6 @@ def get_workspace_groups(
Returns:
MyWorkspaceResponse:
"""

rb_mgr = RoleBindingManager()
allow_all = False

Expand Down Expand Up @@ -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,
)
)
Expand Down
6 changes: 3 additions & 3 deletions src/spaceone/identity/service/workspace_group_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

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

Expand Down
8 changes: 5 additions & 3 deletions src/spaceone/identity/service/workspace_group_user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)

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

0 comments on commit 02b96cd

Please sign in to comment.