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 /gitlab/mixins.py | |
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 'gitlab/mixins.py')
-rw-r--r-- | gitlab/mixins.py | 29 |
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") |