@@ -67,6 +67,62 @@ Remove a group::
6767 # or
6868 group.delete()
6969
70+ Import / Export
71+ ===============
72+
73+ You can export groups from gitlab, and re-import them to create new groups.
74+
75+ Reference
76+ ---------
77+
78+ * v4 API:
79+
80+ + :class: `gitlab.v4.objects.GroupExport `
81+ + :class: `gitlab.v4.objects.GroupExportManager `
82+ + :attr: `gitlab.v4.objects.Group.exports `
83+ + :class: `gitlab.v4.objects.GroupImport `
84+ + :class: `gitlab.v4.objects.GroupImportManager `
85+ + :attr: `gitlab.v4.objects.Group.imports `
86+ + :attr: `gitlab.v4.objects.GroupManager.import_group `
87+
88+ * GitLab API: https://docs.gitlab.com/ce/api/group_import_export.html
89+
90+ Examples
91+ --------
92+
93+ A group export is an asynchronous operation. To retrieve the archive
94+ generated by GitLab you need to:
95+
96+ #. Create an export using the API
97+ #. Wait for the export to be done
98+ #. Download the result
99+
100+ .. warning ::
101+
102+ Unlike the Project Export API, GitLab does not provide an export_status
103+ for Group Exports. It is up to the user to ensure the export is finished.
104+
105+ However, Group Exports only contain metadata, so they are much faster
106+ than Project Exports.
107+
108+ ::
109+
110+ # Create the export
111+ group = gl.groups.get(my_group)
112+ export = group.exports.create()
113+
114+ # Wait for the export to finish
115+ time.sleep(3)
116+
117+ # Download the result
118+ with open('/tmp/export.tgz', 'wb') as f:
119+ export.download(streamed=True, action=f.write)
120+
121+ Import the group::
122+
123+ with open('/tmp/export.tgz', 'rb') as f:
124+ gl.groups.import_group(f, path='imported-group', name="Imported Group")
125+
70126Subgroups
71127=========
72128
0 commit comments