| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c281d95 commit f5850d9
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ API examples | |||
| 15 | 15 | gl_objects/deploy_keys | |
| 16 | 16 | gl_objects/deployments | |
| 17 | 17 | gl_objects/environments | |
| 18 | + gl_objects/features | ||
| 18 | 19 | gl_objects/groups | |
| 19 | 20 | gl_objects/issues | |
| 20 | 21 | gl_objects/labels | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + ############## | ||
| 2 | + Features flags | ||
| 3 | + ############## | ||
| 4 | + | ||
| 5 | + Reference | ||
| 6 | + --------- | ||
| 7 | + | ||
| 8 | + * v4 API: | ||
| 9 | + | ||
| 10 | + + :class:`gitlab.v4.objects.Feature` | ||
| 11 | + + :class:`gitlab.v4.objects.FeatureManager` | ||
| 12 | + + :attr:`gitlab.Gitlab.features` | ||
| 13 | + | ||
| 14 | + * GitLab API: https://docs.gitlab.com/ce/api/features.html | ||
| 15 | + | ||
| 16 | + Examples | ||
| 17 | + -------- | ||
| 18 | + | ||
| 19 | + List features:: | ||
| 20 | + | ||
| 21 | + features = gl.features.list() | ||
| 22 | + | ||
| 23 | + Create or set a feature:: | ||
| 24 | + | ||
| 25 | + feature = gl.features.set(feature_name, True) | ||
| 26 | + feature = gl.features.set(feature_name, 30) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -125,6 +125,7 @@ def __init__(self, url, private_token=None, oauth_token=None, email=None, | |||
| 125 | 125 | self.teams = objects.TeamManager(self) | |
| 126 | 126 | else: | |
| 127 | 127 | self.dockerfiles = objects.DockerfileManager(self) | |
| 128 | + self.features = objects.FeatureManager(self) | ||
| 128 | 129 | self.pagesdomains = objects.PagesDomainManager(self) | |
| 129 | 130 | self.user_activities = objects.UserActivitiesManager(self) | |
| 130 | 131 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -242,7 +242,7 @@ def set(self, key, value, **kwargs): | |||
| 242 | 242 | GitlabSetError: If an error occured | |
| 243 | 243 | ||
| 244 | 244 | Returns: | |
| 245 | - UserCustomAttribute: The created/updated user attribute | ||
| 245 | + obj: The created/updated attribute | ||
| 246 | 246 | """ | |
| 247 | 247 | path = '%s/%s' % (self.path, key.replace('/', '%2F')) | |
| 248 | 248 | data = {'value': value} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -400,6 +400,38 @@ class DockerfileManager(RetrieveMixin, RESTManager): | |||
| 400 | 400 | _obj_cls = Dockerfile | |
| 401 | 401 | ||
| 402 | 402 | ||
| 403 | + class Feature(RESTObject): | ||
| 404 | + _id_attr = 'name' | ||
| 405 | + | ||
| 406 | + | ||
| 407 | + class FeatureManager(ListMixin, RESTManager): | ||
| 408 | + _path = '/features/' | ||
| 409 | + _obj_cls = Feature | ||
| 410 | + | ||
| 411 | + @exc.on_http_error(exc.GitlabSetError) | ||
| 412 | + def set(self, name, value, feature_group=None, user=None, **kwargs): | ||
| 413 | + """Create or update the object. | ||
| 414 | + | ||
| 415 | + Args: | ||
| 416 | + name (str): The value to set for the object | ||
| 417 | + value (bool/int): The value to set for the object | ||
| 418 | + feature_group (str): A feature group name | ||
| 419 | + user (str): A GitLab username | ||
| 420 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 421 | + | ||
| 422 | + Raises: | ||
| 423 | + GitlabAuthenticationError: If authentication is not correct | ||
| 424 | + GitlabSetError: If an error occured | ||
| 425 | + | ||
| 426 | + Returns: | ||
| 427 | + obj: The created/updated attribute | ||
| 428 | + """ | ||
| 429 | + path = '%s/%s' % (self.path, name.replace('/', '%2F')) | ||
| 430 | + data = {'value': value, 'feature_group': feature_group, 'user': user} | ||
| 431 | + server_data = self.gitlab.http_post(path, post_data=data, **kwargs) | ||
| 432 | + return self._obj_cls(self, server_data) | ||
| 433 | + | ||
| 434 | + | ||
| 403 | 435 | class Gitignore(RESTObject): | |
| 404 | 436 | _id_attr = 'name' | |
| 405 | 437 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -551,6 +551,11 @@ | |||
| 551 | 551 | ns = gl.namespaces.list(search='root', all=True)[0] | |
| 552 | 552 | assert(ns.kind == 'user') | |
| 553 | 553 | ||
| 554 | + # features | ||
| 555 | + feat = gl.features.set('foo', 30) | ||
| 556 | + assert(feat.name == 'foo') | ||
| 557 | + assert(len(gl.features.list()) == 1) | ||
| 558 | + | ||
| 554 | 559 | # broadcast messages | |
| 555 | 560 | msg = gl.broadcastmessages.create({'message': 'this is the message'}) | |
| 556 | 561 | msg.color = '#444444' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments