diff options
| author | Gauvain Pocentek <gauvain@pocentek.net> | 2017-10-21 09:21:11 +0200 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-10-21 09:21:11 +0200 |
| commit | fe5805f3b60fc97c107e1c9b0a4ff299459ca800 (patch) | |
| tree | 1986cb728f6b033840de5a1c9acbc51e068ccc6d | |
| parent | 1b5d4809d8a6a5a6b130265d5ab8fb97fc725ee8 (diff) | |
| download | gitlab-fe5805f3b60fc97c107e1c9b0a4ff299459ca800.tar.gz | |
ProjectFileManager: custom update() method
Closes #340
| -rw-r--r-- | gitlab/v4/objects.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 0fe2ea5..80c4286 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -1420,6 +1420,30 @@ class ProjectFileManager(GetMixin, CreateMixin, UpdateMixin, DeleteMixin, server_data = self.gitlab.http_post(path, post_data=data, **kwargs) return self._obj_cls(self, server_data) + @exc.on_http_error(exc.GitlabUpdateError) + def update(self, file_path, 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() + file_path = file_path.replace('/', '%2F') + data['file_path'] = file_path + path = '%s/%s' % (self.path, file_path) + self._check_missing_update_attrs(data) + return self.gitlab.http_put(path, post_data=data, **kwargs) + @cli.register_custom_action('ProjectFileManager', ('file_path', 'branch', 'commit_message')) @exc.on_http_error(exc.GitlabDeleteError) |
