11from gitlab import cli , types
22from gitlab import exceptions as exc
33from gitlab .base import RequiredOptional , RESTManager , RESTObject
4- from gitlab .mixins import CRUDMixin , ObjectDeleteMixin , SaveMixin
5-
4+ from gitlab .mixins import (
5+ CRUDMixin ,
6+ ObjectDeleteMixin ,
7+ SaveMixin ,
8+ RetrieveMixin ,
9+ MemberAllMixin ,
10+ )
611
712__all__ = [
813 "GroupMember" ,
@@ -16,7 +21,7 @@ class GroupMember(SaveMixin, ObjectDeleteMixin, RESTObject):
1621 _short_print_attr = "username"
1722
1823
19- class GroupMemberManager (CRUDMixin , RESTManager ):
24+ class GroupMemberManager (MemberAllMixin , CRUDMixin , RESTManager ):
2025 _path = "/groups/%(group_id)s/members"
2126 _obj_cls = GroupMember
2227 _from_parent_attrs = {"group_id" : "id" }
@@ -28,37 +33,18 @@ class GroupMemberManager(CRUDMixin, RESTManager):
2833 )
2934 _types = {"user_ids" : types .ListAttribute }
3035
31- @cli .register_custom_action ("GroupMemberManager" )
32- @exc .on_http_error (exc .GitlabListError )
33- def all (self , ** kwargs ):
34- """List all the members, included inherited ones.
35-
36- Args:
37- all (bool): If True, return all the items, without pagination
38- per_page (int): Number of items to retrieve per request
39- page (int): ID of the page to return (starts with page 1)
40- as_list (bool): If set to False and no pagination option is
41- defined, return a generator instead of a list
42- **kwargs: Extra options to send to the server (e.g. sudo)
43-
44- Raises:
45- GitlabAuthenticationError: If authentication is not correct
46- GitlabListError: If the list could not be retrieved
4736
48- Returns:
49- RESTObjectList: The list of members
50- """
51-
52- path = "%s/all" % self .path
53- obj = self .gitlab .http_list (path , ** kwargs )
54- return [self ._obj_cls (self , item ) for item in obj ]
37+ class GroupMemberAllManager (RetrieveMixin , RESTManager ):
38+ _path = "/groups/%(group_id)s/members/all"
39+ _obj_cls = GroupMember
40+ _from_parent_attrs = {"group_id" : "id" }
5541
5642
5743class ProjectMember (SaveMixin , ObjectDeleteMixin , RESTObject ):
5844 _short_print_attr = "username"
5945
6046
61- class ProjectMemberManager (CRUDMixin , RESTManager ):
47+ class ProjectMemberManager (MemberAllMixin , CRUDMixin , RESTManager ):
6248 _path = "/projects/%(project_id)s/members"
6349 _obj_cls = ProjectMember
6450 _from_parent_attrs = {"project_id" : "id" }
@@ -70,27 +56,8 @@ class ProjectMemberManager(CRUDMixin, RESTManager):
7056 )
7157 _types = {"user_ids" : types .ListAttribute }
7258
73- @cli .register_custom_action ("ProjectMemberManager" )
74- @exc .on_http_error (exc .GitlabListError )
75- def all (self , ** kwargs ):
76- """List all the members, included inherited ones.
7759
78- Args:
79- all (bool): If True, return all the items, without pagination
80- per_page (int): Number of items to retrieve per request
81- page (int): ID of the page to return (starts with page 1)
82- as_list (bool): If set to False and no pagination option is
83- defined, return a generator instead of a list
84- **kwargs: Extra options to send to the server (e.g. sudo)
85-
86- Raises:
87- GitlabAuthenticationError: If authentication is not correct
88- GitlabListError: If the list could not be retrieved
89-
90- Returns:
91- RESTObjectList: The list of members
92- """
93-
94- path = "%s/all" % self .path
95- obj = self .gitlab .http_list (path , ** kwargs )
96- return [self ._obj_cls (self , item ) for item in obj ]
60+ class ProjectMemberAllManager (RetrieveMixin , RESTManager ):
61+ _path = "/projects/%(project_id)s/members/all"
62+ _obj_cls = ProjectMember
63+ _from_parent_attrs = {"project_id" : "id" }
0 commit comments