summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
diff options
context:
space:
mode:
authorPierre Tardy <tardyp@gmail.com>2018-02-05 15:55:11 +0100
committerPierre Tardy <tardyp@gmail.com>2018-03-04 10:49:00 +0100
commit3424333bc98fcfc4733f2c5f1bf9a93b9a02135b (patch)
tree978ad66f1e18027d6e86ceeffa83e6a4ed08c474 /gitlab/mixins.py
parent6bcc92a39a9a9dd97fa7387f754474c1cc5d78dc (diff)
downloadgitlab-3424333bc98fcfc4733f2c5f1bf9a93b9a02135b.tar.gz
introduce RefreshMixin
RefreshMixin allows to update a REST object so that you can poll on it. This is mostly useful for pipelines and jobs, but could be set on most of other objects, with unknown usecases.
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):