diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2020-04-05 23:39:19 +0200 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2020-04-05 23:39:19 +0200 |
commit | 8c3d744ec6393ad536b565c94f120b3e26b6f3e8 (patch) | |
tree | ff0a77295ff883ce4275bb8c31031a5c7df8eab7 /docs/gl_objects | |
parent | e7b2d6c873f0bfd502d06c9bd239cedc465e51c5 (diff) | |
download | gitlab-8c3d744ec6393ad536b565c94f120b3e26b6f3e8.tar.gz |
docs: add docs 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 ========= |