summaryrefslogtreecommitdiff
path: root/gitlab/__init__.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2015-12-31 06:37:44 +0100
committerGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2015-12-31 06:37:44 +0100
commita636d5ab25d2b248d89363ac86ecad7a0b90f100 (patch)
tree94fad92df0571ddeadbd1dda7dfa166861c7e54b /gitlab/__init__.py
parent7e61a28d74a8589bffcfb70e0f3622113f6442ae (diff)
downloadgitlab-a636d5ab25d2b248d89363ac86ecad7a0b90f100.tar.gz
Provide a create method for GitlabObject's
Instead of using the constructor to do everything (get, list and create), we now provide a class method for each action. This should make code easier to read.
Diffstat (limited to 'gitlab/__init__.py')
-rw-r--r--gitlab/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 638c5eb..ab4fc87 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -761,6 +761,16 @@ class GitlabObject(object):
return self.gitlab.delete(self, **kwargs)
+ @classmethod
+ def create(cls, gl, data, **kwargs):
+ if not cls.canCreate:
+ raise NotImplementedError
+
+ obj = cls(gl, data, **kwargs)
+ obj.save()
+
+ return obj
+
def __init__(self, gl, data=None, **kwargs):
self._created = False
self.gitlab = gl