Skip to content

Commit 44a7ef6

Browse files
author
Gauvain Pocentek
committed
Add support for user activities
1 parent 7fadf46 commit 44a7ef6

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

docs/gl_objects/users.rst

+36
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ Revoke (delete) an impersonation token for a user:
145145
Current User
146146
============
147147

148+
References
149+
----------
150+
148151
* v4 API:
149152

150153
+ :class:`gitlab.v4.objects.CurrentUser`
@@ -169,6 +172,9 @@ Get the current user:
169172
GPG keys
170173
========
171174

175+
References
176+
----------
177+
172178
You can manipulate GPG keys for the current user and for the other users if you
173179
are admin.
174180

@@ -211,6 +217,9 @@ Delete an GPG gpgkey for a user:
211217
SSH keys
212218
========
213219

220+
References
221+
----------
222+
214223
You can manipulate SSH keys for the current user and for the other users if you
215224
are admin.
216225

@@ -264,6 +273,9 @@ Delete an SSH key for a user:
264273
Emails
265274
======
266275

276+
References
277+
----------
278+
267279
You can manipulate emails for the current user and for the other users if you
268280
are admin.
269281

@@ -313,3 +325,27 @@ Delete an email for a user:
313325
.. literalinclude:: users.py
314326
:start-after: # email delete
315327
:end-before: # end email delete
328+
329+
Users activities
330+
================
331+
332+
References
333+
----------
334+
335+
* v4 only
336+
* admin only
337+
338+
* v4 API:
339+
340+
+ :class:`gitlab.v4.objects.UserActivities`
341+
+ :class:`gitlab.v4.objects.UserActivitiesManager`
342+
+ :attr:`gitlab.Gitlab.user_activities`
343+
344+
Examples
345+
--------
346+
347+
Get the users activities:
348+
349+
.. code-block:: python
350+
351+
activities = gl.user_activities.list(all=True, as_list=False)

gitlab/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def __init__(self, url, private_token=None, oauth_token=None, email=None,
125125
self.teams = objects.TeamManager(self)
126126
else:
127127
self.dockerfiles = objects.DockerfileManager(self)
128+
self.user_activities = objects.UserActivitiesManager(self)
128129

129130
if self._api_version == '3':
130131
# build the "submanagers"

gitlab/v4/objects.py

+9
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ def compound_metrics(self, **kwargs):
112112
return self.gitlab.http_get('/sidekiq/compound_metrics', **kwargs)
113113

114114

115+
class UserActivities(RESTObject):
116+
_id_attr = 'username'
117+
118+
119+
class UserActivitiesManager(ListMixin, RESTManager):
120+
_path = '/user/activities'
121+
_obj_cls = UserActivities
122+
123+
115124
class UserCustomAttribute(ObjectDeleteMixin, RESTObject):
116125
_id_attr = 'key'
117126

tools/python_test_v4.py

+3
Original file line numberDiff line numberDiff line change
@@ -580,3 +580,6 @@
580580
content = snippet.content()
581581
assert(content == 'import gitlab')
582582
snippet.delete()
583+
584+
# user activities
585+
gl.user_activities.list()

0 commit comments

Comments
 (0)