From a1b097ce1811d320322a225d22183c36125b4a3c Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 11 Nov 2017 15:40:13 +0100 Subject: Add a SetMixin Use it for UserCustomAttribute, will be useful for {Project,Group}CustomAttribute (#367) --- gitlab/v4/objects.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'gitlab/v4/objects.py') diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 722f8ab..77a6a72 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -125,31 +125,12 @@ class UserCustomAttribute(ObjectDeleteMixin, RESTObject): _id_attr = 'key' -class UserCustomAttributeManager(RetrieveMixin, DeleteMixin, RESTManager): +class UserCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, + RESTManager): _path = '/users/%(user_id)s/custom_attributes' _obj_cls = UserCustomAttribute _from_parent_attrs = {'user_id': 'id'} - def set(self, key, value, **kwargs): - """Create or update a user attribute. - - Args: - key (str): The attribute to update - value (str): The value to set - **kwargs: Extra options to send to the server (e.g. sudo) - - Raises: - GitlabAuthenticationError: If authentication is not correct - GitlabSetError: If an error occured - - Returns: - UserCustomAttribute: The created/updated user attribute - """ - path = '%s/%s' % (self.path, key.replace('/', '%2F')) - data = {'value': value} - server_data = self.gitlab.http_put(path, post_data=data, **kwargs) - return self._obj_cls(self, server_data) - class UserEmail(ObjectDeleteMixin, RESTObject): _short_print_attr = 'email' -- cgit v1.2.1