8000 Add support for listing project users · python-gitlab/python-gitlab@d6fa94e · GitHub
[go: up one dir, main page]

Skip to content

Commit d6fa94e

Browse files
author
Gauvain Pocentek
committed
Add support for listing project users
https://docs.gitlab.com/ce/api/projects.html#get-project-users Closes #328
1 parent 5945537 commit d6fa94e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

docs/gl_objects/projects.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,10 @@
393393
"body": "See the [attached file]({})".format(uploaded_file["url"])
394394
})
395395
# end project file upload markdown custom
396+
397+
# users list
398+
users = p.users.list()
399+
400+
# search for users
401+
users = p.users.list(search='pattern')
402+
# end users list

docs/gl_objects/projects.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ Get a list of contributors for the repository:
160160
:start-after: # repository contributors
161161
:end-before: # end repository contributors
162162

163+
Get a list of users for the repository:
164+
165+
.. literalinclude:: projects.py
166+
:start-after: # users list
167+
:end-before: # end users list
168+
163169
Project files
164170
=============
165171

gitlab/v4/objects.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,17 @@ class ProjectTriggerManager(CRUDMixin, RESTManager):
16161616
_update_attrs = (('description', ), tuple())
16171617

16181618

1619+
class ProjectUser(User):
1620+
pass
1621+
1622+
1623+
class ProjectUserManager(ListMixin, RESTManager):
1624+
_path = '/projects/%(project_id)s/users'
1625+
_obj_cls = ProjectUser
1626+
_from_parent_attrs = {'project_id': 'id'}
1627+
_list_filters = ('search',)
1628+
1629+
16191630
class ProjectVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
16201631
_id_attr = 'key'
16211632

@@ -1795,6 +1806,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
17951806
('services', 'ProjectServiceManager'),
17961807
('snippets', 'ProjectSnippetManager'),
17971808
('tags', 'ProjectTagManager'),
1809+
('users', 'ProjectUserManager'),
17981810
('triggers', 'ProjectTriggerManager'),
17991811
('variables', 'ProjectVariableManager'),
18001812
)

0 commit comments

Comments
 (0)
0