Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ef1523a

Browse filesBrowse files
author
Gauvain Pocentek
committed
[feature] Add support for members all() method
Closes python-gitlab#589
1 parent 011274e commit ef1523a
Copy full SHA for ef1523a

File tree

Expand file treeCollapse file tree

4 files changed

+59
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+59
-0
lines changed
Open diff view settings
Collapse file

‎docs/gl_objects/groups.rst‎

Copy file name to clipboardExpand all lines: docs/gl_objects/groups.rst
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ List group members::
164164

165165
members = group.members.list()
166166

167+
List the group members recursively (including inherited members through
168+
ancestor groups)::
169+
170+
members = group.members.all(all=True)
171+
167172
Get a group member::
168173

169174
members = group.members.get(member_id)
Collapse file

‎docs/gl_objects/projects.rst‎

Copy file name to clipboardExpand all lines: docs/gl_objects/projects.rst
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ List the project members::
478478

479479
members = project.members.list()
480480

481+
List the project members recursively (including inherited members through
482+
ancestor groups)::
483+
484+
members = project.members.all(all=True)
485+
481486
Search project members matching a query string::
482487

483488
members = project.members.list(query='bar')
Collapse file

‎gitlab/v4/objects.py‎

Copy file name to clipboardExpand all lines: gitlab/v4/objects.py
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,30 @@ class GroupMemberManager(CRUDMixin, RESTManager):
705705
_create_attrs = (('access_level', 'user_id'), ('expires_at', ))
706706
_update_attrs = (('access_level', ), ('expires_at', ))
707707

708+
@cli.register_custom_action('GroupMemberManager')
709+
@exc.on_http_error(exc.GitlabListError)
710+
def all(self, **kwargs):
711+
"""List all the members, included inherited ones.
712+
713+
Args:
714+
all (bool): If True, return all the items, without pagination
715+
per_page (int): Number of items to retrieve per request
716+
page (int): ID of the page to return (starts with page 1)
717+
as_list (bool): If set to False and no pagination option is
718+
defined, return a generator instead of a list
719+
**kwargs: Extra options to send to the server (e.g. sudo)
720+
721+
Raises:
722+
GitlabAuthenticationError: If authentication is not correct
723+
GitlabListError: If the list could not be retrieved
724+
725+
Returns:
726+
RESTObjectList: The list of members
727+
"""
728+
729+
path = '%s/all' % self.path
730+
return self.gitlab.http_list(path, **kwargs)
731+
708732

709733
class GroupMergeRequest(RESTObject):
710734
pass
@@ -1884,6 +1908,30 @@ class ProjectMemberManager(CRUDMixin, RESTManager):
18841908
_create_attrs = (('access_level', 'user_id'), ('expires_at', ))
18851909
_update_attrs = (('access_level', ), ('expires_at', ))
18861910

1911+
@cli.register_custom_action('ProjectMemberManager')
1912+
@exc.on_http_error(exc.GitlabListError)
1913+
def all(self, **kwargs):
1914+
"""List all the members, included inherited ones.
1915+
1916+
Args:
1917+
all (bool): If True, return all the items, without pagination
1918+
per_page (int): Number of items to retrieve per request
1919+
page (int): ID of the page to return (starts with page 1)
1920+
as_list (bool): If set to False and no pagination option is
1921+
defined, return a generator instead of a list
1922+
**kwargs: Extra options to send to the server (e.g. sudo)
1923+
1924+
Raises:
1925+
GitlabAuthenticationError: If authentication is not correct
1926+
GitlabListError: If the list could not be retrieved
1927+
1928+
Returns:
1929+
RESTObjectList: The list of members
1930+
"""
1931+
1932+
path = '%s/all' % self.path
1933+
return self.gitlab.http_list(path, **kwargs)
1934+
18871935

18881936
class ProjectNote(RESTObject):
18891937
pass
Collapse file

‎tools/python_test_v4.py‎

Copy file name to clipboardExpand all lines: tools/python_test_v4.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244

245245
group1.members.delete(user1.id)
246246
assert(len(group1.members.list()) == 2)
247+
assert(len(group1.members.all()))
247248
member = group1.members.get(user2.id)
248249
member.access_level = gitlab.const.OWNER_ACCESS
249250
member.save()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.