Closed
Description
Perhaps I'm using it wrong, but gitlab.v4.objects.ProjectFileManager.update
always gives me an error about missing attributes:
File "/Users/mrg/git/gitlabcp/env/lib/python2.7/site-packages/gitlab/mixins.py", line 216, in update
self._check_missing_update_attrs(new_data)
File "/Users/mrg/git/gitlabcp/env/lib/python2.7/site-packages/gitlab/mixins.py", line 183, in _check_missing_update_attrs
raise AttributeError("Missing attributes: %s" % ", ".join(missing))
AttributeError: Missing attributes: file_path, branch, content, commit_message
I'm invoking it with the same parameters I used for create
:
response = p.files.update({
'file_path': escaped_path,
'branch': args.branch,
'content': file_content,
'encoding': 'base64',
'commit_message': args.commit_message
})
I see that create
and get
are explicitly defined on ProjectFileManager, whereas update
falls back to the mixin.
If I use the following method instead (hacked version of create
with put
instead of post
), it seems to work:
def update(self, data, **kwargs):
"""Updates an existing object
Args:
data (dict): parameters to send to the server to create the
resource
**kwargs: Extra options to send to the Gitlab server (e.g. sudo)
Returns:
RESTObject: a new instance of the managed object class built with
the data sent by the server
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
self._check_missing_create_attrs(data)
file_path = data.pop('file_path')
path = '%s/%s' % (self.path, file_path)
server_data = self.gitlab.http_put(path, post_data=data, **kwargs)
return self._obj_cls(self, server_data)