summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-03-05 09:39:12 +0100
committerGitHub <noreply@github.com>2018-03-05 09:39:12 +0100
commitee4591d44fa3c998694eded7f57aada2f6ea90c2 (patch)
tree978ad66f1e18027d6e86ceeffa83e6a4ed08c474 /gitlab/mixins.py
parent6bcc92a39a9a9dd97fa7387f754474c1cc5d78dc (diff)
parent3424333bc98fcfc4733f2c5f1bf9a93b9a02135b (diff)
downloadgitlab-ee4591d44fa3c998694eded7f57aada2f6ea90c2.tar.gz
Merge pull request #426 from tardyp/readmixin
introduce RefreshMixin
Diffstat (limited to 'gitlab/mixins.py')
-rw-r--r--gitlab/mixins.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index cb35efc..ea21e10 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -68,6 +68,25 @@ class GetWithoutIdMixin(object):
return self._obj_cls(self, server_data)
+class RefreshMixin(object):
+ @exc.on_http_error(exc.GitlabGetError)
+ def refresh(self, **kwargs):
+ """Refresh a single object from server.
+
+ Args:
+ **kwargs: Extra options to send to the Gitlab server (e.g. sudo)
+
+ Returns None (updates the object)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabGetError: If the server cannot perform the request
+ """
+ path = '%s/%s' % (self.manager.path, self.id)
+ server_data = self.manager.gitlab.http_get(path, **kwargs)
+ self._update_attrs(server_data)
+
+
class ListMixin(object):
@exc.on_http_error(exc.GitlabListError)
def list(self, **kwargs):