Skip to content

Commit 0149020

Browse files
author
Gauvain Pocentek
committed
Allow to pass additional args to list constructors
This is needed mostly for pagination support.
1 parent 571ab0e commit 0149020

File tree

1 file changed

+48
-35
lines changed

1 file changed

+48
-35
lines changed

gitlab.py

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def _getListOrObject(self, cls, id, **kwargs):
241241
else:
242242
return cls(self, id, **kwargs)
243243

244-
def Project(self, id=None):
244+
def Project(self, id=None, **kwargs):
245245
"""Creates/gets/lists project(s) known by the GitLab server.
246246
247247
If id is None, returns a list of projects.
@@ -253,9 +253,9 @@ def Project(self, id=None):
253253
object is NOT saved on the server. Use the save() method on the object
254254
to write it on the server.
255255
"""
256-
return self._getListOrObject(Project, id)
256+
return self._getListOrObject(Project, id, **kwargs)
257257

258-
def Group(self, id=None):
258+
def Group(self, id=None, **kwargs):
259259
"""Creates/gets/lists groups(s) known by the GitLab server.
260260
261261
If id is None, returns a list of projects.
@@ -267,13 +267,13 @@ def Group(self, id=None):
267267
object is NOT saved on the server. Use the save() method on the object
268268
to write it on the server.
269269
"""
270-
return self._getListOrObject(Group, id)
270+
return self._getListOrObject(Group, id, **kwargs)
271271

272272
def Issue(self):
273273
"""Lists issues(s) known by the GitLab server."""
274-
return self._getListOrObject(Issue, None)
274+
return self._getListOrObject(Issue, None, **kwargs)
275275

276-
def User(self, id=None):
276+
def User(self, id=None, **kwargs):
277277
"""Creates/gets/lists users(s) known by the GitLab server.
278278
279279
If id is None, returns a list of projects.
@@ -285,7 +285,7 @@ def User(self, id=None):
285285
object is NOT saved on the server. Use the save() method on the object
286286
to write it on the server.
287287
"""
288-
return self._getListOrObject(User, id)
288+
return self._getListOrObject(User, id, **kwargs)
289289

290290

291291
class GitlabObject(object):
@@ -398,9 +398,9 @@ class CurrentUser(GitlabObject):
398398
canUpdate = False
399399
canDelete = False
400400

401-
def Key(self, id=None):
401+
def Key(self, id=None, **kwargs):
402402
if id is None:
403-
return CurrentUserKey.list(self.gitlab)
403+
return CurrentUserKey.list(self.gitlab, **kwargs)
404404
else:
405405
return CurrentUserKey(self.gitlab, id)
406406

@@ -452,10 +452,11 @@ class ProjectIssue(GitlabObject):
452452
'milestone': 'ProjectMilestone'}
453453
canDelete = False
454454

455-
def Note(self, id=None):
455+
def Note(self, id=None, **kwargs):
456456
return self._getListOrObject(ProjectIssueNote, id,
457457
project_id=self.project_id,
458-
issue_id=self.id)
458+
issue_id=self.id,
459+
**kwargs)
459460

460461

461462
class ProjectMember(GitlabObject):
@@ -492,10 +493,11 @@ class ProjectMergeRequest(GitlabObject):
492493
_constructorTypes = {'author': 'User', 'assignee': 'User'}
493494
canDelete = False
494495

495-
def Note(self, id=None):
496+
def Note(self, id=None, **kwargs):
496497
return self._getListOrObject(ProjectMergeRequestNote, id,
497498
project_id=self.id,
498-
merge_request_id=self.id)
499+
merge_request_id=self.id,
500+
**kwargs)
499501

500502

501503
class ProjectMilestone(GitlabObject):
@@ -514,10 +516,11 @@ class ProjectSnippet(GitlabObject):
514516
_url = '/projects/%(project_id)d/snippets'
515517
_constructorTypes = {'author': 'User'}
516518

517-
def Note(self, id=None):
519+
def Note(self, id=None, **kwargs):
518520
return self._getListOrObject(ProjectSnippetNote, id,
519521
project_id=self.project_id,
520-
snippet_id=self.id)
522+
snippet_id=self.id,
523+
**kwargs)
521524

522525

523526
class Project(GitlabObject):
@@ -526,45 +529,55 @@ class Project(GitlabObject):
526529
canUpdate = False
527530
canDelete = False
528531

529-
def Branch(self, id=None):
532+
def Branch(self, id=None, **kwargs):
530533
return self._getListOrObject(ProjectBranch, id,
531-
project_id=self.id)
534+
project_id=self.id,
535+
**kwargs)
532536

533-
def Commit(self, id=None):
537+
def Commit(self, id=None, **kwargs):
534538
return self._getListOrObject(ProjectCommit, id,
535-
project_id=self.id)
539+
project_id=self.id,
540+
**kwargs)
536541

537-
def Hook(self, id=None):
542+
def Hook(self, id=None, **kwargs):
538543
return self._getListOrObject(ProjectHook, id,
539-
project_id=self.id)
544+
project_id=self.id,
545+
**kwargs)
540546

541-
def Issue(self, id=None):
547+
def Issue(self, id=None, **kwargs):
542548
return self._getListOrObject(ProjectIssue, id,
543-
project_id=self.id)
549+
project_id=self.id,
550+
**kwargs)
544551

545-
def Member(self, id=None):
552+
def Member(self, id=None, **kwargs):
546553
return self._getListOrObject(ProjectMember, id,
547-
project_id=self.id)
554+
project_id=self.id,
555+
**kwargs)
548556

549-
def MergeRequest(self, id=None):
557+
def MergeRequest(self, id=None, **kwargs):
550558
return self._getListOrObject(ProjectMergeRequest, id,
551-
project_id=self.id)
559+
project_id=self.id,
560+
**kwargs)
552561

553-
def Milestone(self, id=None):
562+
def Milestone(self, id=None, **kwargs):
554563
return self._getListOrObject(ProjectMilestone, id,
555-
project_id=self.id)
564+
project_id=self.id,
565+
**kwargs)
556566

557-
def Note(self, id=None):
567+
def Note(self, id=None, **kwargs):
558568
return self._getListOrObject(ProjectNote, id,
559-
project_id=self.id)
569+
project_id=self.id,
570+
**kwargs)
560571

561-
def Snippet(self, id=None):
572+
def Snippet(self, id=None, **kwargs):
562573
return self._getListOrObject(ProjectSnippet, id,
563-
project_id=self.id)
574+
project_id=self.id,
575+
**kwargs)
564576

565-
def Tag(self, id=None):
577+
def Tag(self, id=None, **kwargs):
566578
return self._getListOrObject(ProjectTag, id,
567-
project_id=self.id)
579+
project_id=self.id,
580+
**kwargs)
568581

569582

570583
if __name__ == '__main__':

0 commit comments

Comments
 (0)