diff --git a/src/spaceone/identity/model/user/request.py b/src/spaceone/identity/model/user/request.py index 64073171..a87eb868 100644 --- a/src/spaceone/identity/model/user/request.py +++ b/src/spaceone/identity/model/user/request.py @@ -122,7 +122,7 @@ class UserWorkspacesRequest(BaseModel): class UserFindRequest(BaseModel): - keyword: str + keyword: Union[str, None] = None state: Union[State, None] = None exclude_workspace_id: Union[str, None] = None page: Union[dict, None] = None diff --git a/src/spaceone/identity/service/user_service.py b/src/spaceone/identity/service/user_service.py index f1c51f82..85627639 100644 --- a/src/spaceone/identity/service/user_service.py +++ b/src/spaceone/identity/service/user_service.py @@ -603,14 +603,17 @@ def find(self, params: UserFindRequest) -> Union[UsersSummaryResponse, dict]: query = { "filter": [{"k": "domain_id", "v": params.domain_id, "o": "eq"}], - "filter_or": [ - {"k": "user_id", "v": params.keyword, "o": "contain"}, - {"k": "name", "v": params.keyword, "o": "contain"}, - ], + "sort": {"key": "user_id"}, "page": params.page, "only": ["user_id", "name", "state"], } + if params.keyword: + query["filter_or"] = [ + {"k": "user_id", "v": params.keyword, "o": "contain"}, + {"k": "name", "v": params.keyword, "o": "contain"}, + ] + if params.state: query["filter"].append({"k": "state", "v": params.state, "o": "eq"}) @@ -634,7 +637,6 @@ def find(self, params: UserFindRequest) -> Union[UsersSummaryResponse, dict]: "name", "state", "email", - "user_type", "auth_type", "domain_id", ]