diff options
author | Max Wittig <max.wittig@siemens.com> | 2020-08-21 09:25:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-21 09:25:20 +0200 |
commit | cfa80974a1e767928016e3935d2fd94d4ab705c1 (patch) | |
tree | 08bd01b5474352d149ae23d68a19d25b7dc723f0 /gitlab/v4/objects.py | |
parent | 5b92de8eba9224210ecff1a1d4dae6a561c894be (diff) | |
parent | 99777991e0b9d5a39976d08554dea8bb7e514019 (diff) | |
download | gitlab-cfa80974a1e767928016e3935d2fd94d4ab705c1.tar.gz |
Merge pull request #1139 from sathieu/share_group_with_group
feat: add share/unshare the group with a group
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r-- | gitlab/v4/objects.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 6b47e08..2f3e8a5 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -1467,6 +1467,44 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path = "/groups/%s/ldap_sync" % self.get_id() self.manager.gitlab.http_post(path, **kwargs) + @cli.register_custom_action("Group", ("group_id", "group_access"), ("expires_at",)) + @exc.on_http_error(exc.GitlabCreateError) + def share(self, group_id, group_access, expires_at=None, **kwargs): + """Share the group with a group. + + Args: + group_id (int): ID of the group. + group_access (int): Access level for the group. + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabCreateError: If the server failed to perform the request + """ + path = "/groups/%s/share" % self.get_id() + data = { + "group_id": group_id, + "group_access": group_access, + "expires_at": expires_at, + } + self.manager.gitlab.http_post(path, post_data=data, **kwargs) + + @cli.register_custom_action("Group", ("group_id",)) + @exc.on_http_error(exc.GitlabDeleteError) + def unshare(self, group_id, **kwargs): + """Delete a shared group 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 = "/groups/%s/share/%s" % (self.get_id(), group_id) + self.manager.gitlab.http_delete(path, **kwargs) + class GroupManager(CRUDMixin, RESTManager): _path = "/groups" |