Skip to content

Commit

Permalink
Add support for listing project users
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Oct 8, 2017
1 parent 5945537 commit d6fa94e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/gl_objects/projects.py
Expand Up @@ -393,3 +393,10 @@
"body": "See the [attached file]({})".format(uploaded_file["url"])
})
# end project file upload markdown custom

# users list
users = p.users.list()

# search for users
users = p.users.list(search='pattern')
# end users list
6 changes: 6 additions & 0 deletions docs/gl_objects/projects.rst
Expand Up @@ -160,6 +160,12 @@ Get a list of contributors for the repository:
:start-after: # repository contributors
:end-before: # end repository contributors

Get a list of users for the repository:

.. literalinclude:: projects.py
:start-after: # users list
:end-before: # end users list

Project files
=============

Expand Down
12 changes: 12 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -1616,6 +1616,17 @@ class ProjectTriggerManager(CRUDMixin, RESTManager):
_update_attrs = (('description', ), tuple())


class ProjectUser(User):
pass


class ProjectUserManager(ListMixin, RESTManager):
_path = '/projects/%(project_id)s/users'
_obj_cls = ProjectUser
_from_parent_attrs = {'project_id': 'id'}
_list_filters = ('search',)


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

Expand Down Expand Up @@ -1795,6 +1806,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
('services', 'ProjectServiceManager'),
('snippets', 'ProjectSnippetManager'),
('tags', 'ProjectTagManager'),
('users', 'ProjectUserManager'),
('triggers', 'ProjectTriggerManager'),
('variables', 'ProjectVariableManager'),
)
Expand Down

0 comments on commit d6fa94e

Please sign in to comment.