From 473dc6f50d27b2e5349bb2e7c8bc07b48e9834d1 Mon Sep 17 00:00:00 2001 From: Eric Sabouraud Date: Fri, 8 Jun 2018 19:11:11 +0200 Subject: Add support for project-level MR approval configuration --- gitlab/mixins.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'gitlab/mixins.py') diff --git a/gitlab/mixins.py b/gitlab/mixins.py index 966a647..59fcf1b 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -223,6 +223,18 @@ class UpdateMixin(object): """ return getattr(self, '_update_attrs', (tuple(), tuple())) + def _get_update_method(self): + """Return the HTTP method to use. + + Returns: + object: http_put (default) or http_post + """ + if getattr(self, '_update_uses_post', False): + http_method = self.gitlab.http_post + else: + http_method = self.gitlab.http_put + return http_method + @exc.on_http_error(exc.GitlabUpdateError) def update(self, id=None, new_data={}, **kwargs): """Update an object on the server. @@ -265,8 +277,8 @@ class UpdateMixin(object): else: new_data[attr_name] = type_obj.get_for_api() - return self.gitlab.http_put(path, post_data=new_data, files=files, - **kwargs) + http_method = self._get_update_method() + return http_method(path, post_data=new_data, files=files, **kwargs) class SetMixin(object): -- cgit v1.2.1