@@ -155,18 +155,6 @@ def delete(self, id, **kwargs):
155
155
raise NotImplementedError
156
156
self .gitlab .delete (self .obj_cls , id , ** args )
157
157
158
- def _custom_list (self , url , cls , ** kwargs ):
159
- r = self .gitlab ._raw_get (url , ** kwargs )
160
- raise_error_from_response (r , GitlabListError )
161
-
162
- l = []
163
- for j in r .json ():
164
- o = cls (self .gitlab , j )
165
- o ._from_api = True
166
- l .append (o )
167
-
168
- return l
169
-
170
158
171
159
class GitlabObject (object ):
172
160
"""Base class for all classes that interface with GitLab."""
@@ -569,6 +557,7 @@ def search(self, query, **kwargs):
569
557
570
558
Args:
571
559
query (str): The query string to send to GitLab for the search.
560
+ all (bool): If True, return all the items, without pagination
572
561
**kwargs: Additional arguments to send to GitLab.
573
562
574
563
Returns:
@@ -579,7 +568,7 @@ def search(self, query, **kwargs):
579
568
GitlabListError: If the server fails to perform the request.
580
569
"""
581
570
url = self .obj_cls ._url + '?search=' + query
582
- return self ._custom_list (url , self .obj_cls , ** kwargs )
571
+ return self .gitlab . _raw_list (url , self .obj_cls , ** kwargs )
583
572
584
573
def get_by_username (self , username , ** kwargs ):
585
574
"""Get a user by its username.
@@ -596,7 +585,7 @@ def get_by_username(self, username, **kwargs):
596
585
GitlabGetError: If the server fails to perform the request.
597
586
"""
598
587
url = self .obj_cls ._url + '?username=' + username
599
- results = self ._custom_list (url , self .obj_cls , ** kwargs )
588
+ results = self .gitlab . _raw_list (url , self .obj_cls , ** kwargs )
600
589
assert len (results ) in (0 , 1 )
601
590
try :
602
591
return results [0 ]
@@ -712,10 +701,15 @@ class GroupManager(BaseManager):
712
701
def search (self , query , ** kwargs ):
713
702
"""Searches groups by name.
714
703
715
- Returns a list of matching groups.
704
+ Args:
705
+ query (str): The search string
706
+ all (bool): If True, return all the items, without pagination
707
+
708
+ Returns:
709
+ list(Group): a list of matching groups.
716
710
"""
717
711
url = '/groups?search=' + query
718
- return self ._custom_list (url , Group , ** kwargs )
712
+ return self .gitlab . _raw_list (url , self . obj_cls , ** kwargs )
719
713
720
714
721
715
class Hook (GitlabObject ):
@@ -1524,35 +1518,38 @@ def search(self, query, **kwargs):
1524
1518
1525
1519
Args:
1526
1520
query (str): The query string to send to GitLab for the search.
1521
+ all (bool): If True, return all the items, without pagination
1527
1522
**kwargs: Additional arguments to send to GitLab.
1528
1523
1529
1524
Returns:
1530
1525
list(Project): A list of matching projects.
1531
1526
"""
1532
- return self ._custom_list ("/projects/search/" + query , Project ,
1533
- ** kwargs )
1527
+ return self .gitlab . _raw_list ("/projects/search/" + query , Project ,
1528
+ ** kwargs )
1534
1529
1535
1530
def all (self , ** kwargs ):
1536
1531
"""List all the projects (need admin rights).
1537
1532
1538
1533
Args:
1534
+ all (bool): If True, return all the items, without pagination
1539
1535
**kwargs: Additional arguments to send to GitLab.
1540
1536
1541
1537
Returns:
1542
1538
list(Project): The list of projects.
1543
1539
"""
1544
- return self ._custom_list ("/projects/all" , Project , ** kwargs )
1540
+ return self .gitlab . _raw_list ("/projects/all" , Project , ** kwargs )
1545
1541
1546
1542
def owned (self , ** kwargs ):
1547
1543
"""List owned projects.
1548
1544
1549
1545
Args:
1546
+ all (bool): If True, return all the items, without pagination
1550
1547
**kwargs: Additional arguments to send to GitLab.
1551
1548
1552
1549
Returns:
1553
1550
list(Project): The list of owned projects.
1554
1551
"""
1555
- return self ._custom_list ("/projects/owned" , Project , ** kwargs )
1552
+ return self .gitlab . _raw_list ("/projects/owned" , Project , ** kwargs )
1556
1553
1557
1554
1558
1555
class UserProjectManager (BaseManager ):
0 commit comments