Skip to content

Commit

Permalink
Add support for unsharing projects to v4 API
Browse files Browse the repository at this point in the history
  • Loading branch information
esabouraud committed Feb 28, 2018
1 parent 9a30266 commit 5fdd06e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/gl_objects/projects.py
Expand Up @@ -101,6 +101,10 @@
project.share(group.id, gitlab.DEVELOPER_ACCESS)
# end share

# unshare
project.unshare(group.id)
# end unshare

# hook list
hooks = project.hooks.list()
# end hook list
Expand Down
16 changes: 16 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -2672,6 +2672,22 @@ def share(self, group_id, group_access, expires_at=None, **kwargs):
'expires_at': expires_at}
self.manager.gitlab.http_post(path, post_data=data, **kwargs)

@cli.register_custom_action('Project', ('group_id', ))
@exc.on_http_error(exc.GitlabDeleteError)
def unshare(self, group_id, **kwargs):
"""Delete a shared project link within a group.
Args:
group_id (int): ID of the group.
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server failed to perform the request
"""
path = '/projects/%s/share/%s' % (self.get_id(), group_id)
self.manager.gitlab.http_delete(path, **kwargs)

# variables not supported in CLI
@cli.register_custom_action('Project', ('ref', 'token'))
@exc.on_http_error(exc.GitlabCreateError)
Expand Down

0 comments on commit 5fdd06e

Please sign in to comment.