From cc33f073f817c0d197d62fac07c1151e2ee3e56c Mon Sep 17 00:00:00 2001 From: Daniel Serodio Date: Fri, 13 Feb 2015 15:07:30 -0200 Subject: [PATCH 1/2] Add support for searching groups --- gitlab.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gitlab.py b/gitlab.py index 1ba23d639..f8e1cf9de 100644 --- a/gitlab.py +++ b/gitlab.py @@ -501,6 +501,24 @@ def owned_projects(self, **kwargs): """Lists owned projects.""" return self._list_projects("/projects/owned", **kwargs) + def _list_groups(self, url, **kwargs): + r = self.rawGet(url, **kwargs) + if r.status_code != 200: + _raiseErrorFromResponse(r, GitlabListError) + + l = [] + for o in r.json(): + l.append(Group(self, o)) + + return l + + def search_groups(self, query, **kwargs): + """Searches groups by name. + + Returns a list of matching groups. + """ + return self._list_groups("/groups?search=" + query, **kwargs) + def Group(self, id=None, **kwargs): """Creates/gets/lists group(s) known by the GitLab server From 5fce4bf21dfba3706a29fb9e6ecd4b312bd846d9 Mon Sep 17 00:00:00 2001 From: Daniel Serodio Date: Fri, 13 Feb 2015 15:18:27 -0200 Subject: [PATCH 2/2] Improve docstring for search_groups --- gitlab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab.py b/gitlab.py index f8e1cf9de..3c5d8fe47 100644 --- a/gitlab.py +++ b/gitlab.py @@ -513,7 +513,7 @@ def _list_groups(self, url, **kwargs): return l def search_groups(self, query, **kwargs): - """Searches groups by name. + """Get all groups that match your query string in their name or path. Returns a list of matching groups. """