Skip to content

Commit

Permalink
[v4] User: drop the manager filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed May 24, 2017
1 parent 8e4b65f commit dcbb501
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions gitlab/v4/objects.py
Expand Up @@ -124,6 +124,8 @@ class UserProjectManager(BaseManager):
class User(GitlabObject):
_url = '/users'
shortPrintAttr = 'username'
optionalListAttrs = ['active', 'blocked', 'username', 'extern_uid',
'provider', 'external']
requiredCreateAttrs = ['email', 'username', 'name']
optionalCreateAttrs = ['password', 'reset_password', 'skype', 'linkedin',
'twitter', 'projects_limit', 'extern_uid',
Expand Down Expand Up @@ -175,46 +177,6 @@ def __eq__(self, other):
class UserManager(BaseManager):
obj_cls = User

def search(self, query, **kwargs):
"""Search users.
Args:
query (str): The query string to send to GitLab for the search.
all (bool): If True, return all the items, without pagination
**kwargs: Additional arguments to send to GitLab.
Returns:
list(User): A list of matching users.
Raises:
GitlabConnectionError: If the server cannot be reached.
GitlabListError: If the server fails to perform the request.
"""
url = self.obj_cls._url + '?search=' + query
return self.gitlab._raw_list(url, self.obj_cls, **kwargs)

def get_by_username(self, username, **kwargs):
"""Get a user by its username.
Args:
username (str): The name of the user.
**kwargs: Additional arguments to send to GitLab.
Returns:
User: The matching user.
Raises:
GitlabConnectionError: If the server cannot be reached.
GitlabGetError: If the server fails to perform the request.
"""
url = self.obj_cls._url + '?username=' + username
results = self.gitlab._raw_list(url, self.obj_cls, **kwargs)
assert len(results) in (0, 1)
try:
return results[0]
except IndexError:
raise GitlabGetError('no such user: ' + username)


class CurrentUserEmail(GitlabObject):
_url = '/user/emails'
Expand Down

0 comments on commit dcbb501

Please sign in to comment.