summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/v3/cli.py8
-rw-r--r--gitlab/v3/objects.py14
2 files changed, 22 insertions, 0 deletions
diff --git a/gitlab/v3/cli.py b/gitlab/v3/cli.py
index a8e3a5f..94fa03c 100644
--- a/gitlab/v3/cli.py
+++ b/gitlab/v3/cli.py
@@ -69,6 +69,7 @@ EXTRA_ACTIONS = {
'archive': {'required': ['id']},
'unarchive': {'required': ['id']},
'share': {'required': ['id', 'group-id', 'group-access']},
+ 'unshare': {'required': ['id', 'group-id']},
'upload': {'required': ['id', 'filename', 'filepath']}},
gitlab.v3.objects.User: {
'block': {'required': ['id']},
@@ -213,6 +214,13 @@ class GitlabCLI(object):
except Exception as e:
cli.die("Impossible to share project", e)
+ def do_project_unshare(self, cls, gl, what, args):
+ try:
+ o = self.do_get(cls, gl, what, args)
+ o.unshare(args['group_id'])
+ except Exception as e:
+ cli.die("Impossible to unshare project", e)
+
def do_user_block(self, cls, gl, what, args):
try:
o = self.do_get(cls, gl, what, args)
diff --git a/gitlab/v3/objects.py b/gitlab/v3/objects.py
index 0db9dfd..dec2933 100644
--- a/gitlab/v3/objects.py
+++ b/gitlab/v3/objects.py
@@ -2056,6 +2056,20 @@ class Project(GitlabObject):
r = self.gitlab._raw_post(url, data=data, **kwargs)
raise_error_from_response(r, GitlabCreateError, 201)
+ def unshare(self, group_id, **kwargs):
+ """Delete a shared project link within a group.
+
+ Args:
+ group_id (int): ID of the group.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ GitlabDeleteError: If the server fails to perform the request.
+ """
+ url = "/projects/%s/share/%s" % (self.id, group_id)
+ r = self.gitlab._raw_delete(url, **kwargs)
+ raise_error_from_response(r, GitlabDeleteError, 204)
+
def trigger_build(self, ref, token, variables={}, **kwargs):
"""Trigger a CI build.