Skip to content

Commit 1d4f31e

Browse files
committed
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
1 parent 35c8c82 commit 1d4f31e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

gitlab/v4/objects.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3589,6 +3589,25 @@ def mirror_pull(self, **kwargs):
35893589
path = '/projects/%d/mirror/pull' % self.get_id()
35903590
self.manager.gitlab.http_post(path, **kwargs)
35913591

3592+
@cli.register_custom_action('Project', ('to_namespace', ))
3593+
@exc.on_http_error(exc.GitlabTransferProjectError)
3594+
def transfer_project(self, to_namespace, **kwargs):
3595+
"""Transfer a project to the given namespace ID
3596+
3597+
Args:
3598+
to_namespace (str): ID or path of the namespace to transfer the
3599+
project to
3600+
**kwargs: Extra options to send to the server (e.g. sudo)
3601+
3602+
Raises:
3603+
GitlabAuthenticationError: If authentication is not correct
3604+
GitlabTransferProjectError: If the project could not be transfered
3605+
"""
3606+
path = '/projects/%d/transfer' % (self.id,)
3607+
self.manager.gitlab.http_put(path,
3608+
post_data={"namespace": to_namespace},
3609+
**kwargs)
3610+
35923611

35933612
class ProjectManager(CRUDMixin, RESTManager):
35943613
_path = '/projects'

0 commit comments

Comments
 (0)