summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/groups.py
diff options
context:
space:
mode:
authorChristian Sattler <sattler.christian@gmail.com>2022-01-05 18:00:45 +0100
committerJohn Villalovos <john@sodarock.com>2022-01-13 17:17:20 -0800
commit0007006c184c64128caa96b82dafa3db0ea1101f (patch)
tree021d517ebf6ec79d914b331eb3442d18b33f2be8 /gitlab/v4/objects/groups.py
parent2c62d91a67442b21ce3011a2ba5aec7360ca766f (diff)
downloadgitlab-0007006c184c64128caa96b82dafa3db0ea1101f.tar.gz
feat: add support for Groups API method `transfer()`
Diffstat (limited to 'gitlab/v4/objects/groups.py')
-rw-r--r--gitlab/v4/objects/groups.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py
index 662ea5d..adfca6e 100644
--- a/gitlab/v4/objects/groups.py
+++ b/gitlab/v4/objects/groups.py
@@ -95,12 +95,34 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
path = f"/groups/{self.encoded_id}/projects/{project_id}"
self.manager.gitlab.http_post(path, **kwargs)
+ @cli.register_custom_action("Group", tuple(), ("group_id",))
+ @exc.on_http_error(exc.GitlabGroupTransferError)
+ def transfer(self, group_id: Optional[int] = None, **kwargs: Any) -> None:
+ """Transfer the group to a new parent group or make it a top-level group.
+
+ Requires GitLab ≥14.6.
+
+ Args:
+ group_id: ID of the new parent group. When not specified,
+ the group to transfer is instead turned into a top-level group.
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabGroupTransferError: If the group could not be transferred
+ """
+ path = f"/groups/{self.id}/transfer"
+ post_data = {}
+ if group_id is not None:
+ post_data["group_id"] = group_id
+ self.manager.gitlab.http_post(path, post_data=post_data, **kwargs)
+
@cli.register_custom_action("Group", ("scope", "search"))
@exc.on_http_error(exc.GitlabSearchError)
def search(
self, scope: str, search: str, **kwargs: Any
) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]:
- """Search the group resources matching the provided string.'
+ """Search the group resources matching the provided string.
Args:
scope: Scope of the search