Skip to content

Commit

Permalink
Improve the doc for UserManager
Browse files Browse the repository at this point in the history
Describe parameters, return values and exceptions for search() and
get_by_username().
  • Loading branch information
Gauvain Pocentek committed Feb 12, 2016
1 parent 073d8d5 commit b79af1d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions gitlab/objects.py
Expand Up @@ -568,16 +568,33 @@ class UserManager(BaseManager):
def search(self, query, **kwargs):
"""Search users.
Returns a list of matching users.
Args:
query (str): The query string to send to GitLab for the search.
**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._custom_list(url, self.obj_cls, **kwargs)

def get_by_username(self, username, **kwargs):
"""Get a user by its username.
Returns a User object or None if the named user does not
exist.
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._custom_list(url, self.obj_cls, **kwargs)
Expand Down

0 comments on commit b79af1d

Please sign in to comment.