Skip to content

Commit

Permalink
Add support for user activities
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Nov 11, 2017
1 parent 7fadf46 commit 44a7ef6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/gl_objects/users.rst
Expand Up @@ -145,6 +145,9 @@ Revoke (delete) an impersonation token for a user:
Current User
============

References
----------

* v4 API:

+ :class:`gitlab.v4.objects.CurrentUser`
Expand All @@ -169,6 +172,9 @@ Get the current user:
GPG keys
========

References
----------

You can manipulate GPG keys for the current user and for the other users if you
are admin.

Expand Down Expand Up @@ -211,6 +217,9 @@ Delete an GPG gpgkey for a user:
SSH keys
========

References
----------

You can manipulate SSH keys for the current user and for the other users if you
are admin.

Expand Down Expand Up @@ -264,6 +273,9 @@ Delete an SSH key for a user:
Emails
======

References
----------

You can manipulate emails for the current user and for the other users if you
are admin.

Expand Down Expand Up @@ -313,3 +325,27 @@ Delete an email for a user:
.. literalinclude:: users.py
:start-after: # email delete
:end-before: # end email delete

Users activities
================

References
----------

* v4 only
* admin only

* v4 API:

+ :class:`gitlab.v4.objects.UserActivities`
+ :class:`gitlab.v4.objects.UserActivitiesManager`
+ :attr:`gitlab.Gitlab.user_activities`

Examples
--------

Get the users activities:

.. code-block:: python
activities = gl.user_activities.list(all=True, as_list=False)
1 change: 1 addition & 0 deletions gitlab/__init__.py
Expand Up @@ -125,6 +125,7 @@ def __init__(self, url, private_token=None, oauth_token=None, email=None,
self.teams = objects.TeamManager(self)
else:
self.dockerfiles = objects.DockerfileManager(self)
self.user_activities = objects.UserActivitiesManager(self)

if self._api_version == '3':
# build the "submanagers"
Expand Down
9 changes: 9 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -112,6 +112,15 @@ def compound_metrics(self, **kwargs):
return self.gitlab.http_get('/sidekiq/compound_metrics', **kwargs)


class UserActivities(RESTObject):
_id_attr = 'username'


class UserActivitiesManager(ListMixin, RESTManager):
_path = '/user/activities'
_obj_cls = UserActivities


class UserCustomAttribute(ObjectDeleteMixin, RESTObject):
_id_attr = 'key'

Expand Down
3 changes: 3 additions & 0 deletions tools/python_test_v4.py
Expand Up @@ -580,3 +580,6 @@
content = snippet.content()
assert(content == 'import gitlab')
snippet.delete()

# user activities
gl.user_activities.list()

0 comments on commit 44a7ef6

Please sign in to comment.