:param filter_q: filter of data to be applied
:return: The list, it can be empty if no one match the filter.
"""
- return self.auth.get_user_list()
+ if not filter_q:
+ filter_q = {}
+
+ return self.auth.get_user_list(filter_q)
def delete(self, session, _id, dry_run=False):
"""
"""
raise AuthconnNotImplementedException("Should have implemented this")
- def get_user_list(self):
+ def get_user_list(self, filter_q={}):
"""
Get user list.
+ :param filter_q: dictionary to filter user list.
:return: returns a list of users.
"""
self.logger.exception("Error during user deletion using keystone")
raise AuthconnOperationException("Error during user deletion using Keystone")
- def get_user_list(self):
+ def get_user_list(self, filter_q={}):
"""
Get user list.
+ :param filter_q: dictionary to filter user list.
:return: returns a list of users.
"""
try:
"_id": user.id
} for user in users if user.name != self.admin_username]
+ allowed_fields = ["_id", "username"]
+ for key in filter_q.keys():
+ if key not in allowed_fields:
+ continue
+
+ users = [user for user in users
+ if filter_q[key] == user[key]]
+
for user in users:
projects = self.keystone.projects.list(user=user["_id"])
projects = [{