Skip to content

Commit 1b6c595

Browse files
author
Diego Giovane Pasqualin
committed
Add support for extra parameters when listing all projects (Refs #12)
Signed-off-by: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
1 parent 04574f3 commit 1b6c595

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

gitlab.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ def setCredentials(self, email, password):
131131
self.email = email
132132
self.password = password
133133

134-
def rawGet(self, path):
134+
def rawGet(self, path, **kwargs):
135135
url = '%s%s' % (self._url, path)
136+
if kwargs:
137+
url += "?%s" % ("&".join(
138+
["%s=%s" % (k, v) for k, v in kwargs.items()]))
139+
136140
try:
137141
return requests.get(url,
138142
headers=self.headers,
@@ -355,8 +359,8 @@ def UserProject(self, id=None, **kwargs):
355359
"""
356360
return self._getListOrObject(UserProject, id, **kwargs)
357361

358-
def _list_projects(self, url):
359-
r = self.rawGet(url)
362+
def _list_projects(self, url, **kwargs):
363+
r = self.rawGet(url, **kwargs)
360364
if r.status_code != 200:
361365
raise GitlabListError
362366

@@ -373,13 +377,13 @@ def search_projects(self, query):
373377
"""
374378
return self._list_projects("/projects/search/" + query)
375379

376-
def all_projects(self):
380+
def all_projects(self, **kwargs):
377381
"""Lists all the projects (need admin rights)."""
378-
return self._list_projects("/projects/all")
382+
return self._list_projects("/projects/all", **kwargs)
379383

380-
def owned_projects(self):
384+
def owned_projects(self, **kwargs):
381385
"""Lists owned projects."""
382-
return self._list_projects("/projects/owned")
386+
return self._list_projects("/projects/owned", **kwargs)
383387

384388
def Group(self, id=None, **kwargs):
385389
"""Creates/gets/lists group(s) known by the GitLab server.

0 commit comments

Comments
 (0)