summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2019-11-25 13:52:37 +0100
committerGitHub <noreply@github.com>2019-11-25 13:52:37 +0100
commitda557c931fa6c6d50c373fc022d88acf1431c24a (patch)
tree54ed3620c892c7b4479eb1633f5ab4e75ae330b4 /gitlab
parente0066b6b7c5ce037635f6a803ea26707d5684ef5 (diff)
parentebd053e7bb695124c8117a95eab0072db185ddf9 (diff)
downloadgitlab-da557c931fa6c6d50c373fc022d88acf1431c24a.tar.gz
Merge pull request #946 from lundbird/master
feat: add project and group clusters
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/v4/objects.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 2b1f955..62e8d4a 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -743,6 +743,51 @@ class GroupBoardManager(CRUDMixin, RESTManager):
_create_attrs = (("name",), tuple())
+class GroupCluster(SaveMixin, ObjectDeleteMixin, RESTObject):
+ pass
+
+
+class GroupClusterManager(CRUDMixin, RESTManager):
+ _path = "/groups/%(group_id)s/clusters"
+ _obj_cls = GroupCluster
+ _from_parent_attrs = {"group_id": "id"}
+ _create_attrs = (
+ ("name", "platform_kubernetes_attributes",),
+ ("domain", "enabled", "managed", "environment_scope",),
+ )
+ _update_attrs = (
+ tuple(),
+ (
+ "name",
+ "domain",
+ "management_project_id",
+ "platform_kubernetes_attributes",
+ "environment_scope",
+ ),
+ )
+
+ @exc.on_http_error(exc.GitlabStopError)
+ def create(self, data, **kwargs):
+ """Create a new object.
+
+ Args:
+ data (dict): Parameters to send to the server to create the
+ resource
+ **kwargs: Extra options to send to the server (e.g. sudo or
+ 'ref_name', 'stage', 'name', 'all')
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabCreateError: If the server cannot perform the request
+
+ Returns:
+ RESTObject: A new instance of the manage object class build with
+ the data sent by the server
+ """
+ path = "%s/user" % (self.path)
+ return CreateMixin.create(self, data, path=path, **kwargs)
+
+
class GroupCustomAttribute(ObjectDeleteMixin, RESTObject):
_id_attr = "key"
@@ -1150,6 +1195,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
("projects", "GroupProjectManager"),
("subgroups", "GroupSubgroupManager"),
("variables", "GroupVariableManager"),
+ ("clusters", "GroupClusterManager"),
)
@cli.register_custom_action("Group", ("to_project_id",))
@@ -1599,6 +1645,51 @@ class ProjectBranchManager(NoUpdateMixin, RESTManager):
_create_attrs = (("branch", "ref"), tuple())
+class ProjectCluster(SaveMixin, ObjectDeleteMixin, RESTObject):
+ pass
+
+
+class ProjectClusterManager(CRUDMixin, RESTManager):
+ _path = "/projects/%(project_id)s/clusters"
+ _obj_cls = ProjectCluster
+ _from_parent_attrs = {"project_id": "id"}
+ _create_attrs = (
+ ("name", "platform_kubernetes_attributes",),
+ ("domain", "enabled", "managed", "environment_scope",),
+ )
+ _update_attrs = (
+ tuple(),
+ (
+ "name",
+ "domain",
+ "management_project_id",
+ "platform_kubernetes_attributes",
+ "environment_scope",
+ ),
+ )
+
+ @exc.on_http_error(exc.GitlabStopError)
+ def create(self, data, **kwargs):
+ """Create a new object.
+
+ Args:
+ data (dict): Parameters to send to the server to create the
+ resource
+ **kwargs: Extra options to send to the server (e.g. sudo or
+ 'ref_name', 'stage', 'name', 'all')
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabCreateError: If the server cannot perform the request
+
+ Returns:
+ RESTObject: A new instance of the manage object class build with
+ the data sent by the server
+ """
+ path = "%s/user" % (self.path)
+ return CreateMixin.create(self, data, path=path, **kwargs)
+
+
class ProjectCustomAttribute(ObjectDeleteMixin, RESTObject):
_id_attr = "key"
@@ -3940,6 +4031,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
("triggers", "ProjectTriggerManager"),
("variables", "ProjectVariableManager"),
("wikis", "ProjectWikiManager"),
+ ("clusters", "ProjectClusterManager"),
)
@cli.register_custom_action("Project", ("submodule", "branch", "commit_sha"))