Skip to content

Commit

Permalink
feat: add update_role method and delete role_binding when remove work…
Browse files Browse the repository at this point in the history
…spaces&users

Signed-off-by: Youngjin Jo <[email protected]>
  • Loading branch information
yjinjo committed Aug 27, 2024
1 parent a7edea7 commit e2f12ee
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 152 deletions.
4 changes: 4 additions & 0 deletions src/spaceone/identity/error/error_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class ERROR_NOT_ALLOWED_ROLE_TYPE(ERROR_INVALID_ARGUMENT):
)


class ERROR_NOT_ALLOWED_USER_STATE(ERROR_INVALID_ARGUMENT):
_message = "User state is not allowed. (user_id = {user_id}, state = {state})"


class ERROR_DUPLICATED_ROLE_BINDING(ERROR_INVALID_ARGUMENT):
_message = (
"Role type is duplicated. (role_type = {role_type}), "
Expand Down
6 changes: 6 additions & 0 deletions src/spaceone/identity/interface/grpc/workspace_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def remove_users(self, request, context):
response: dict = workspace_group_svc.remove_users(params)
return self.dict_to_message(response)

def update_role(self, request, context):
params, metadata = self.parse_request(request, context)
workspace_group_svc = WorkspaceGroupService(metadata)
response: dict = workspace_group_svc.update_role(params)
return self.dict_to_message(response)

def get(self, request, context):
params, metadata = self.parse_request(request, context)
workspace_group_svc = WorkspaceGroupService(metadata)
Expand Down
15 changes: 7 additions & 8 deletions src/spaceone/identity/model/workspace_group/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"WorkspaceGroupRemoveWorkspacesRequest",
"WorkspaceGroupAddUsersRequest",
"WorkspaceGroupRemoveUsersRequest",
"WorkspaceGroupFindRequest",
"WorkspaceGroupUpdateRoleRequest",
"WorkspaceGroupGetRequest",
"WorkspaceGroupSearchQueryRequest",
"WorkspaceGroupStatQueryRequest",
Expand Down Expand Up @@ -55,25 +55,24 @@ class WorkspaceGroupRemoveWorkspacesRequest(BaseModel):
domain_id: str


class WorkspaceGroupFindRequest(BaseModel):
keyword: Union[str, None] = None
state: Union[State, None] = None
page: Union[dict, None] = None
class WorkspaceGroupAddUsersRequest(BaseModel):
workspace_group_id: str
users: List[Dict[str, str]]
workspace_id: Union[str, None] = None
domain_id: str


class WorkspaceGroupAddUsersRequest(BaseModel):
class WorkspaceGroupRemoveUsersRequest(BaseModel):
workspace_group_id: str
users: List[Dict[str, str]]
workspace_id: Union[str, None] = None
domain_id: str


class WorkspaceGroupRemoveUsersRequest(BaseModel):
class WorkspaceGroupUpdateRoleRequest(BaseModel):
workspace_group_id: str
users: List[Dict[str, str]]
user_id: str
role_id: str
workspace_id: Union[str, None] = None
domain_id: str

Expand Down
20 changes: 1 addition & 19 deletions src/spaceone/identity/model/workspace_group/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
from pydantic.main import BaseModel
from spaceone.core import utils

__all__ = [
"WorkspaceGroupResponse",
"WorkspaceGroupsResponse",
"WorkspaceGroupUserSummaryResponse",
"WorkspaceGroupUsersSummaryResponse",
]

from spaceone.identity.model.workspace_group.request import State
__all__ = ["WorkspaceGroupResponse", "WorkspaceGroupsResponse"]


class WorkspaceGroupResponse(BaseModel):
Expand All @@ -36,14 +29,3 @@ def dict(self, *args, **kwargs):
class WorkspaceGroupsResponse(BaseModel):
results: List[WorkspaceGroupResponse]
total_count: int


class WorkspaceGroupUserSummaryResponse(BaseModel):
user_id: str
name: str
state: State


class WorkspaceGroupUsersSummaryResponse(BaseModel):
results: List[WorkspaceGroupUserSummaryResponse]
total_count: int
6 changes: 3 additions & 3 deletions src/spaceone/identity/service/role_binding_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from spaceone.core.service import *
from spaceone.core.service.utils import *

from spaceone.identity.model.role_binding.request import *
from spaceone.identity.model.role_binding.response import *
from spaceone.identity.error.error_role import *
from spaceone.identity.manager.role_binding_manager import RoleBindingManager
from spaceone.identity.manager.role_manager import RoleManager
from spaceone.identity.manager.user_manager import UserManager
from spaceone.identity.manager.workspace_manager import WorkspaceManager
from spaceone.identity.error.error_role import *
from spaceone.identity.model.role_binding.request import *
from spaceone.identity.model.role_binding.response import *

_LOGGER = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit e2f12ee

Please sign in to comment.