Skip to content

Commit 68d15fd

Browse files
author
Gauvain Pocentek
committed
Make GroupProject more "python-gitlabish"
1 parent 69e64a3 commit 68d15fd

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

gitlab/objects.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,29 @@ class GroupMemberManager(BaseManager):
666666
obj_cls = GroupMember
667667

668668

669+
class GroupProject(GitlabObject):
670+
_url = '/groups/%(group_id)s/projects'
671+
canGet = 'from_list'
672+
canCreate = False
673+
canDelete = False
674+
canUpdate = False
675+
optionalListAttrs = ['archived', 'visibility', 'order_by', 'sort',
676+
'search', 'ci_enabled_first']
677+
678+
679+
class GroupProjectManager(BaseManager):
680+
obj_cls = GroupProject
681+
682+
669683
class Group(GitlabObject):
670684
_url = '/groups'
671685
canUpdate = False
672686
_constructorTypes = {'projects': 'Project'}
673687
requiredCreateAttrs = ['name', 'path']
674688
optionalCreateAttrs = ['description', 'visibility_level']
675689
shortPrintAttr = 'name'
676-
managers = [('members', GroupMemberManager, [('group_id', 'id')])]
690+
managers = [('members', GroupMemberManager, [('group_id', 'id')]),
691+
('projects', GroupProjectManager, [('group_id', 'id')])]
677692

678693
GUEST_ACCESS = 10
679694
REPORTER_ACCESS = 20
@@ -725,24 +740,6 @@ def search(self, query, **kwargs):
725740
return self.gitlab._raw_list(url, self.obj_cls, **kwargs)
726741

727742

728-
class GroupProject(GitlabObject):
729-
def list_projects(self, gid, **kwargs):
730-
"""List projects in a group
731-
732-
Attrs:
733-
gid (int): ID of the group
734-
735-
Returns:
736-
list(Group): a list of projects in the group
737-
"""
738-
url = '/groups/%d/projects' % gid
739-
return self.gitlab._raw_list(url, self.obj_cls, **kwargs)
740-
741-
742-
class GroupProjectManager(BaseManager):
743-
obj_cls = GroupProject
744-
745-
746743
class Hook(GitlabObject):
747744
_url = '/hooks'
748745
canUpdate = False

0 commit comments

Comments
 (0)