Skip to content

Commit 5fdd06e

Browse files
committed
Add support for unsharing projects to v4 API
1 parent 9a30266 commit 5fdd06e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/gl_objects/projects.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
project.share(group.id, gitlab.DEVELOPER_ACCESS)
102102
# end share
103103

104+
# unshare
105+
project.unshare(group.id)
106+
# end unshare
107+
104108
# hook list
105109
hooks = project.hooks.list()
106110
# end hook list

gitlab/v4/objects.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,6 +2672,22 @@ def share(self, group_id, group_access, expires_at=None, **kwargs):
26722672
'expires_at': expires_at}
26732673
self.manager.gitlab.http_post(path, post_data=data, **kwargs)
26742674

2675+
@cli.register_custom_action('Project', ('group_id', ))
2676+
@exc.on_http_error(exc.GitlabDeleteError)
2677+
def unshare(self, group_id, **kwargs):
2678+
"""Delete a shared project link within a group.
2679+
2680+
Args:
2681+
group_id (int): ID of the group.
2682+
**kwargs: Extra options to send to the server (e.g. sudo)
2683+
2684+
Raises:
2685+
GitlabAuthenticationError: If authentication is not correct
2686+
GitlabDeleteError: If the server failed to perform the request
2687+
"""
2688+
path = '/projects/%s/share/%s' % (self.get_id(), group_id)
2689+
self.manager.gitlab.http_delete(path, **kwargs)
2690+
26752691
# variables not supported in CLI
26762692
@cli.register_custom_action('Project', ('ref', 'token'))
26772693
@exc.on_http_error(exc.GitlabCreateError)

0 commit comments

Comments
 (0)