summaryrefslogtreecommitdiff
path: root/docs/gl_objects/projects.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/gl_objects/projects.rst')
-rw-r--r--docs/gl_objects/projects.rst57
1 files changed, 57 insertions, 0 deletions
diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst
index fdea7aa..6d69295 100644
--- a/docs/gl_objects/projects.rst
+++ b/docs/gl_objects/projects.rst
@@ -180,6 +180,63 @@ Get a list of users for the repository::
# search for users
users = p.users.list(search='pattern')
+Import / Export
+===============
+
+You can export projects from gitlab, and re-import them to create new projects
+or overwrite existing ones.
+
+Reference
+---------
+
+* v4 API:
+
+ + :class:`gitlab.v4.objects.ProjectExport`
+ + :class:`gitlab.v4.objects.ProjectExportManager`
+ + :attr:`gitlab.v4.objects.Project.exports`
+ + :class:`gitlab.v4.objects.ProjectImport`
+ + :class:`gitlab.v4.objects.ProjectImportManager`
+ + :attr:`gitlab.v4.objects.Project.imports`
+ + :attr:`gitlab.v4.objects.ProjectManager.import_project`
+
+* GitLab API: https://docs.gitlab.com/ce/api/project_import_export.html
+
+Examples
+--------
+
+A project export is an asynchronous operation. To retrieve the archive
+generated by GitLab you need to:
+
+#. Create an export using the API
+#. Wait for the export to be done
+#. Download the result
+
+::
+
+ # Create the export
+ p = gl.projects.get(my_project)
+ export = p.exports.create({})
+
+ # Wait for the 'finished' status
+ export.refresh()
+ while export.export_status != 'finished':
+ time.sleep(1)
+ export.refresh()
+
+ # Download the result
+ with open('/tmp/export.tgz', 'wb') as f:
+ export.download(streamed=True, action=f.write)
+
+Import the project::
+
+ gl.projects.import_project(open('/tmp/export.tgz', 'rb'), 'my_new_project')
+ # Get a ProjectImport object to track the import status
+ project_import = gl.projects.get(output['id'], lazy=True).imports.get()
+ while project_import.import_status != 'finished':
+ time.sleep(1)
+ project_import.refresh()
+
+
Project custom attributes
=========================