diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-01-01 15:30:24 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2018-01-01 15:30:24 +0100 |
commit | f5850d950a77b1d985fdc3d1639e2627468d3548 (patch) | |
tree | 908316276b55d8897ff0dcb6c30315bc6efa731d /gitlab | |
parent | c281d95c2f978d8d2eb1d77352babf5217d32062 (diff) | |
download | gitlab-f5850d950a77b1d985fdc3d1639e2627468d3548.tar.gz |
Add support for features flags
Fixes #360
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/__init__.py | 1 | ||||
-rw-r--r-- | gitlab/mixins.py | 2 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 32 |
3 files changed, 34 insertions, 1 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 950db86..b5f32c9 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -125,6 +125,7 @@ class Gitlab(object): self.teams = objects.TeamManager(self) else: self.dockerfiles = objects.DockerfileManager(self) + self.features = objects.FeatureManager(self) self.pagesdomains = objects.PagesDomainManager(self) self.user_activities = objects.UserActivitiesManager(self) diff --git a/gitlab/mixins.py b/gitlab/mixins.py index 0c06f92..cb35efc 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -242,7 +242,7 @@ class SetMixin(object): GitlabSetError: If an error occured Returns: - UserCustomAttribute: The created/updated user attribute + obj: The created/updated attribute """ path = '%s/%s' % (self.path, key.replace('/', '%2F')) data = {'value': value} diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 397bfb5..0a0cebd 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -400,6 +400,38 @@ class DockerfileManager(RetrieveMixin, RESTManager): _obj_cls = Dockerfile +class Feature(RESTObject): + _id_attr = 'name' + + +class FeatureManager(ListMixin, RESTManager): + _path = '/features/' + _obj_cls = Feature + + @exc.on_http_error(exc.GitlabSetError) + def set(self, name, value, feature_group=None, user=None, **kwargs): + """Create or update the object. + + Args: + name (str): The value to set for the object + value (bool/int): The value to set for the object + feature_group (str): A feature group name + user (str): A GitLab username + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabSetError: If an error occured + + Returns: + obj: The created/updated attribute + """ + path = '%s/%s' % (self.path, name.replace('/', '%2F')) + data = {'value': value, 'feature_group': feature_group, 'user': user} + server_data = self.gitlab.http_post(path, post_data=data, **kwargs) + return self._obj_cls(self, server_data) + + class Gitignore(RESTObject): _id_attr = 'name' |