Skip to content

Commit

Permalink
Add support for subgroups listing
Browse files Browse the repository at this point in the history
Closes #390
  • Loading branch information
Gauvain Pocentek committed Dec 31, 2017
1 parent 81c9d1f commit 928865e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docs/gl_objects/groups.rst
Expand Up @@ -72,6 +72,25 @@ Remove a group:
:start-after: # delete
:end-before: # end delete

Subgroups
=========

Reference
---------

* v4 API:

+ :class:`gitlab.v4.objects.GroupSubgroup`
+ :class:`gitlab.v4.objects.GroupSubgroupManager`
+ :attr:`gitlab.v4.objects.Group.subgroups`

Examples
--------

List the subgroups for a group::

subgroups = group.subgroups.list()

Group members
=============

Expand Down
15 changes: 14 additions & 1 deletion gitlab/v4/objects.py
Expand Up @@ -554,6 +554,18 @@ class GroupProjectManager(GetFromListMixin, RESTManager):
'ci_enabled_first')


class GroupSubgroup(RESTObject):
pass


class GroupSubgroupManager(GetFromListMixin, RESTManager):
_path = '/groups/%(group_id)s/subgroups'
_obj_cls = GroupSubgroup
_from_parent_attrs = {'group_id': 'id'}
_list_filters = ('skip_groups', 'all_available', 'search', 'order_by',
'sort', 'statistics', 'owned')


class GroupVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
_id_attr = 'key'

Expand All @@ -570,11 +582,12 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
_short_print_attr = 'name'
_managers = (
('accessrequests', 'GroupAccessRequestManager'),
('issues', 'GroupIssueManager'),
('members', 'GroupMemberManager'),
('milestones', 'GroupMilestoneManager'),
('notificationsettings', 'GroupNotificationSettingsManager'),
('projects', 'GroupProjectManager'),
('issues', 'GroupIssueManager'),
('subgroups', 'GroupSubgroupManager'),
('variables', 'GroupVariableManager'),
)

Expand Down
1 change: 1 addition & 0 deletions tools/python_test_v4.py
Expand Up @@ -206,6 +206,7 @@
assert(len(gl.groups.list()) == 3)
assert(len(gl.groups.list(search='oup1')) == 1)
assert(group3.parent_id == p_id)
assert(group2.subgroups.list()[0].id == group3.id)

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

0 comments on commit 928865e

Please sign in to comment.