From 1d4f31e343d59a5185d91ffe6b5b3cebd0caedfa Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Mon, 23 Jul 2018 16:55:34 +1000 Subject: [PATCH] Add support for project transfers from the projects interface. See https://docs.gitlab.com/ee/api/projects.html#transfer-a-project-to-a-new-namespace --- gitlab/v4/objects.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 508ca7c4d..1cbf4b058 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -3589,6 +3589,25 @@ def mirror_pull(self, **kwargs): path = '/projects/%d/mirror/pull' % self.get_id() self.manager.gitlab.http_post(path, **kwargs) + @cli.register_custom_action('Project', ('to_namespace', )) + @exc.on_http_error(exc.GitlabTransferProjectError) + def transfer_project(self, to_namespace, **kwargs): + """Transfer a project to the given namespace ID + + Args: + to_namespace (str): ID or path of the namespace to transfer the + project to + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabTransferProjectError: If the project could not be transfered + """ + path = '/projects/%d/transfer' % (self.id,) + self.manager.gitlab.http_put(path, + post_data={"namespace": to_namespace}, + **kwargs) + class ProjectManager(CRUDMixin, RESTManager): _path = '/projects'