summaryrefslogtreecommitdiff
path: root/gitlab/mixins.py
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2020-04-06 09:40:35 +0200
committerGitHub <noreply@github.com>2020-04-06 09:40:35 +0200
commitc161852b5a976d11f682c5af00ff3f4e8daa26ef (patch)
treecb2b89648e7f3678e0e6bfb47f60f77979296f99 /gitlab/mixins.py
parentfa34f5e20ecbd3f5d868df2fa9e399ac6559c5d5 (diff)
parent847da6063b4c63c8133e5e5b5b45e5b4f004bdc4 (diff)
downloadgitlab-c161852b5a976d11f682c5af00ff3f4e8daa26ef.tar.gz
Merge pull request #1063 from python-gitlab/feat/group-import-export
Feat: support for group import/export API
Diffstat (limited to 'gitlab/mixins.py')
-rw-r--r--gitlab/mixins.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index dde11d0..9c00c32 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -443,6 +443,35 @@ class AccessRequestMixin(object):
self._update_attrs(server_data)
+class DownloadMixin(object):
+ @cli.register_custom_action(("GroupExport", "ProjectExport"))
+ @exc.on_http_error(exc.GitlabGetError)
+ def download(self, streamed=False, action=None, chunk_size=1024, **kwargs):
+ """Download the archive of a resource export.
+
+ Args:
+ streamed (bool): If True the data will be processed by chunks of
+ `chunk_size` and each chunk is passed to `action` for
+ reatment
+ action (callable): Callable responsible of dealing with chunk of
+ data
+ chunk_size (int): Size of each chunk
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabGetError: If the server failed to perform the request
+
+ Returns:
+ str: The blob content if streamed is False, None otherwise
+ """
+ path = "%s/download" % (self.manager.path)
+ result = self.manager.gitlab.http_get(
+ path, streamed=streamed, raw=True, **kwargs
+ )
+ return utils.response_content(result, streamed, action, chunk_size)
+
+
class SubscribableMixin(object):
@cli.register_custom_action(
("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel")