diff options
| author | Max Wittig <max.wittig@siemens.com> | 2020-04-06 09:40:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-06 09:40:35 +0200 |
| commit | c161852b5a976d11f682c5af00ff3f4e8daa26ef (patch) | |
| tree | cb2b89648e7f3678e0e6bfb47f60f77979296f99 /docs/gl_objects | |
| parent | fa34f5e20ecbd3f5d868df2fa9e399ac6559c5d5 (diff) | |
| parent | 847da6063b4c63c8133e5e5b5b45e5b4f004bdc4 (diff) | |
| download | gitlab-c161852b5a976d11f682c5af00ff3f4e8daa26ef.tar.gz | |
Merge pull request #1063 from python-gitlab/feat/group-import-export
Feat: support for group import/export API
Diffstat (limited to 'docs/gl_objects')
| -rw-r--r-- | docs/gl_objects/groups.rst | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/docs/gl_objects/groups.rst b/docs/gl_objects/groups.rst index 0bc00d9..d3e4d92 100644 --- a/docs/gl_objects/groups.rst +++ b/docs/gl_objects/groups.rst @@ -67,6 +67,62 @@ Remove a group:: # or group.delete() +Import / Export +=============== + +You can export groups from gitlab, and re-import them to create new groups. + +Reference +--------- + +* v4 API: + + + :class:`gitlab.v4.objects.GroupExport` + + :class:`gitlab.v4.objects.GroupExportManager` + + :attr:`gitlab.v4.objects.Group.exports` + + :class:`gitlab.v4.objects.GroupImport` + + :class:`gitlab.v4.objects.GroupImportManager` + + :attr:`gitlab.v4.objects.Group.imports` + + :attr:`gitlab.v4.objects.GroupManager.import_group` + +* GitLab API: https://docs.gitlab.com/ce/api/group_import_export.html + +Examples +-------- + +A group 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 + +.. warning:: + + Unlike the Project Export API, GitLab does not provide an export_status + for Group Exports. It is up to the user to ensure the export is finished. + + However, Group Exports only contain metadata, so they are much faster + than Project Exports. + +:: + + # Create the export + group = gl.groups.get(my_group) + export = group.exports.create() + + # Wait for the export to finish + time.sleep(3) + + # Download the result + with open('/tmp/export.tgz', 'wb') as f: + export.download(streamed=True, action=f.write) + +Import the group:: + + with open('/tmp/export.tgz', 'rb') as f: + gl.groups.import_group(f, path='imported-group', name="Imported Group") + Subgroups ========= |
