Repository: python-gitlab/python-gitlab

Issue:
Add user status feature
https://docs.gitlab.com/ce/api/users.html#set-user-status


Discussion:
+1 to this one.  I am using this excellent library to [clean the spam users](https://gitlab.isc.org/ondrej/gitlab-victor) and they have recently adopted new technique of adding spammy content to the status message which I can't get or set right now.

Resolving patch:
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -128,6 +128,17 @@ class UserActivities(RESTObject):
     _id_attr = "username"
 
 
+class UserStatus(RESTObject):
+    _id_attr = None
+    _short_print_attr = "message"
+
+
+class UserStatusManager(GetWithoutIdMixin, RESTManager):
+    _path = "/users/%(user_id)s/status"
+    _obj_cls = UserStatus
+    _from_parent_attrs = {"user_id": "id"}
+
+
 class UserActivitiesManager(ListMixin, RESTManager):
     _path = "/user/activities"
     _obj_cls = UserActivities
@@ -186,6 +197,16 @@ class UserKeyManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
     _create_attrs = (("title", "key"), tuple())
 
 
+class UserStatus(RESTObject):
+    pass
+
+
+class UserStatusManager(GetWithoutIdMixin, RESTManager):
+    _path = "/users/%(user_id)s/status"
+    _obj_cls = UserStatus
+    _from_parent_attrs = {"user_id": "id"}
+
+
 class UserImpersonationToken(ObjectDeleteMixin, RESTObject):
     pass
 
@@ -272,6 +293,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject):
         ("impersonationtokens", "UserImpersonationTokenManager"),
         ("keys", "UserKeyManager"),
         ("projects", "UserProjectManager"),
+        ("status", "UserStatusManager"),
     )
 
     @cli.register_custom_action("User")
@@ -330,6 +352,7 @@ class UserManager(CRUDMixin, RESTManager):
         "external",
         "search",
         "custom_attributes",
+        "status",
     )
     _create_attrs = (
         tuple(),
@@ -410,10 +433,22 @@ class CurrentUserKeyManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager
     _create_attrs = (("title", "key"), tuple())
 
 
+class CurrentUserStatus(SaveMixin, RESTObject):
+    _id_attr = None
+    _short_print_attr = "message"
+
+
+class CurrentUserStatusManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
+    _path = "/user/status"
+    _obj_cls = CurrentUserStatus
+    _update_attrs = (tuple(), ("emoji", "message"))
+
+
 class CurrentUser(RESTObject):
     _id_attr = None
     _short_print_attr = "username"
     _managers = (
+        ("status", "CurrentUserStatusManager"),
         ("emails", "CurrentUserEmailManager"),
         ("gpgkeys", "CurrentUserGPGKeyManager"),
         ("keys", "CurrentUserKeyManager"),


Test patch:
diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py
--- a/tools/python_test_v4.py
+++ b/tools/python_test_v4.py
@@ -911,3 +911,14 @@
 release_test_project.releases.delete(release_tag_name)
 assert len(release_test_project.releases.list()) == 0
 release_test_project.delete()
+
+# status
+message = "Test"
+emoji = "thumbsup"
+status = gl.user.status.get()
+status.message = message
+status.emoji = emoji
+status.save()
+new_status = gl.user.status.get()
+assert new_status.message == message
+assert new_status.emoji == emoji