diff options
-rw-r--r-- | gitlab/mixins.py | 18 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 24 |
2 files changed, 24 insertions, 18 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py index 28ad04d..88fea2d 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -200,10 +200,6 @@ class CreateMixin(object): """ self._check_missing_create_attrs(data) - # special handling of the object if needed - if hasattr(self, '_sanitize_data'): - data = self._sanitize_data(data, 'create') - # We get the attributes that need some special transformation types = getattr(self, '_types', {}) @@ -265,20 +261,14 @@ class UpdateMixin(object): self._check_missing_update_attrs(new_data) - # special handling of the object if needed - if hasattr(self, '_sanitize_data'): - data = self._sanitize_data(new_data, 'update') - else: - data = new_data - # We get the attributes that need some special transformation types = getattr(self, '_types', {}) for attr_name, type_cls in types.items(): - if attr_name in data.keys(): - type_obj = type_cls(data[attr_name]) - data[attr_name] = type_obj.get_for_api() + if attr_name in new_data.keys(): + type_obj = type_cls(new_data[attr_name]) + new_data[attr_name] = type_obj.get_for_api() - return self.gitlab.http_put(path, post_data=data, **kwargs) + return self.gitlab.http_put(path, post_data=new_data, **kwargs) class SetMixin(object): diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 348775e..956038b 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -388,11 +388,27 @@ class ApplicationSettingsManager(GetWithoutIdMixin, UpdateMixin, RESTManager): 'user_oauth_applications') ) - def _sanitize_data(self, data, action): - new_data = data.copy() + @exc.on_http_error(exc.GitlabUpdateError) + def update(self, id=None, new_data={}, **kwargs): + """Update an object on the server. + + Args: + id: ID of the object to update (can be None if not required) + new_data: the update data for the object + **kwargs: Extra options to send to the Gitlab server (e.g. sudo) + + Returns: + dict: The new object data (*not* a RESTObject) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabUpdateError: If the server cannot perform the request + """ + + data = new_data.copy() if 'domain_whitelist' in data and data['domain_whitelist'] is None: - new_data.pop('domain_whitelist') - return new_data + data.pop('domain_whitelist') + super(ApplicationSettingsManager, self).update(id, data, **kwargs) class BroadcastMessage(SaveMixin, ObjectDeleteMixin, RESTObject): |