summaryrefslogtreecommitdiff
path: root/gitlab/objects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2016-01-08 22:35:30 +0100
committerGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2016-01-08 22:35:30 +0100
commit689ecae70585e79c281224162a0ba2ab3921242a (patch)
tree61c99944622d40947b9542d59f7d1afdd04aa559 /gitlab/objects.py
parente48e14948f886a7bb71b22f82d71c2572a09341e (diff)
downloadgitlab-689ecae70585e79c281224162a0ba2ab3921242a.tar.gz
Implement ProjectManager search/list methods
The existing Gitlab methods are deprecated. Unit tests have been added.
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r--gitlab/objects.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 3637fe8..aaaadbb 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1016,6 +1016,33 @@ class UserProject(GitlabObject):
class ProjectManager(BaseManager):
obj_cls = Project
+ def _custom_list(self, url, **kwargs):
+ r = self.gitlab._raw_get(url, **kwargs)
+ raise_error_from_response(r, GitlabListError)
+
+ l = []
+ for o in r.json():
+ p = Project(self, o)
+ p._from_api = True
+ l.append(p)
+
+ return l
+
+ def search(self, query, **kwargs):
+ """Searches projects by name.
+
+ Returns a list of matching projects.
+ """
+ return self._custom_list("/projects/search/" + query, **kwargs)
+
+ def all(self, **kwargs):
+ """Lists all the projects (need admin rights)."""
+ return self._custom_list("/projects/all", **kwargs)
+
+ def owned(self, **kwargs):
+ """Lists owned projects."""
+ return self._custom_list("/projects/owned", **kwargs)
+
class UserProjectManager(BaseManager):
obj_cls = UserProject