Skip to content

Commit 928865e

Browse files
author
Gauvain Pocentek
committed
Add support for subgroups listing
Closes #390
1 parent 81c9d1f commit 928865e

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

docs/gl_objects/groups.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ Remove a group:
7272
:start-after: # delete
7373
:end-before: # end delete
7474

75+
Subgroups
76+
=========
77+
78+
Reference
79+
---------
80+
81+
* v4 API:
82+
83+
+ :class:`gitlab.v4.objects.GroupSubgroup`
84+
+ :class:`gitlab.v4.objects.GroupSubgroupManager`
85+
+ :attr:`gitlab.v4.objects.Group.subgroups`
86+
87+
Examples
88+
--------
89+
90+
List the subgroups for a group::
91+
92+
subgroups = group.subgroups.list()
93+
7594
Group members
7695
=============
7796

gitlab/v4/objects.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,18 @@ class GroupProjectManager(GetFromListMixin, RESTManager):
554554
'ci_enabled_first')
555555

556556

557+
class GroupSubgroup(RESTObject):
558+
pass
559+
560+
561+
class GroupSubgroupManager(GetFromListMixin, RESTManager):
562+
_path = '/groups/%(group_id)s/subgroups'
563+
_obj_cls = GroupSubgroup
564+
_from_parent_attrs = {'group_id': 'id'}
565+
_list_filters = ('skip_groups', 'all_available', 'search', 'order_by',
566+
'sort', 'statistics', 'owned')
567+
568+
557569
class GroupVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
558570
_id_attr = 'key'
559571

@@ -570,11 +582,12 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
570582
_short_print_attr = 'name'
571583
_managers = (
572584
('accessrequests', 'GroupAccessRequestManager'),
585+
('issues', 'GroupIssueManager'),
573586
('members', 'GroupMemberManager'),
574587
('milestones', 'GroupMilestoneManager'),
575588
('notificationsettings', 'GroupNotificationSettingsManager'),
576589
('projects', 'GroupProjectManager'),
577-
('issues', 'GroupIssueManager'),
590+
('subgroups', 'GroupSubgroupManager'),
578591
('variables', 'GroupVariableManager'),
579592
)
580593

tools/python_test_v4.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
assert(len(gl.groups.list()) == 3)
207207
assert(len(gl.groups.list(search='oup1')) == 1)
208208
assert(group3.parent_id == p_id)
209+
assert(group2.subgroups.list()[0].id == group3.id)
209210

210211
group1.members.create({'access_level': gitlab.Group.OWNER_ACCESS,
211212
'user_id': user1.id})

0 commit comments

Comments
 (0)