Skip to content

Commit a1c79d2

Browse files
wrouesnelGauvain Pocentek
authored andcommitted
Add support for project transfers from the projects interface. (#561)
See https://docs.gitlab.com/ee/api/projects.html#transfer-a-project-to-a-new-namespace
1 parent b325bd7 commit a1c79d2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

gitlab/v4/objects.py

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

3614+
@cli.register_custom_action('Project', ('to_namespace', ))
3615+
@exc.on_http_error(exc.GitlabTransferProjectError)
3616+
def transfer_project(self, to_namespace, **kwargs):
3617+
"""Transfer a project to the given namespace ID
3618+
3619+
Args:
3620+
to_namespace (str): ID or path of the namespace to transfer the
3621+
project to
3622+
**kwargs: Extra options to send to the server (e.g. sudo)
3623+
3624+
Raises:
3625+
GitlabAuthenticationError: If authentication is not correct
3626+
GitlabTransferProjectError: If the project could not be transfered
3627+
"""
3628+
path = '/projects/%d/transfer' % (self.id,)
3629+
self.manager.gitlab.http_put(path,
3630+
post_data={"namespace": to_namespace},
3631+
**kwargs)
3632+
36143633

36153634
class ProjectManager(CRUDMixin, RESTManager):
36163635
_path = '/projects'

0 commit comments

Comments
 (0)