diff options
author | Will Rouesnel <w.rouesnel@gmail.com> | 2018-08-03 04:46:30 +1000 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2018-08-02 20:46:30 +0200 |
commit | a1c79d2b7d719204c829235a9b0ebb08b45b4efb (patch) | |
tree | 9d1637a938866cb04bf11bede838a5db85838f48 /gitlab/v4/objects.py | |
parent | b325bd73400e3806e6ede59cc10011fbf138b877 (diff) | |
download | gitlab-a1c79d2b7d719204c829235a9b0ebb08b45b4efb.tar.gz |
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
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r-- | gitlab/v4/objects.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 7438655..bd7635f 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -3611,6 +3611,25 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject): 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' |