diff options
author | Max Wittig <max.wittig95@gmail.com> | 2020-01-26 17:28:30 +0100 |
---|---|---|
committer | Max Wittig <max.wittig95@gmail.com> | 2020-01-26 17:35:18 +0100 |
commit | 0b71ba4d2965658389b705c1bb0d83d1ff2ee8f2 (patch) | |
tree | cf0f742bca253ec1f73032e56c4df5a9016a69ab /gitlab | |
parent | bded2de51951902444bc62aa016a3ad34aab799e (diff) | |
download | gitlab-0b71ba4d2965658389b705c1bb0d83d1ff2ee8f2.tar.gz |
feat: support keyset pagination globally
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/__init__.py | 4 | ||||
-rw-r--r-- | gitlab/config.py | 6 | ||||
-rw-r--r-- | gitlab/mixins.py | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 9cb027b..166e00f 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -69,6 +69,7 @@ class Gitlab(object): http_username (str): Username for HTTP authentication http_password (str): Password for HTTP authentication api_version (str): Gitlab API version to use (support for 4 only) + pagination (str): Can be set to 'keyset' to use keyset pagination """ def __init__( @@ -84,6 +85,7 @@ class Gitlab(object): api_version="4", session=None, per_page=None, + pagination=None, ): self._api_version = str(api_version) @@ -109,6 +111,7 @@ class Gitlab(object): self.session = session or requests.Session() self.per_page = per_page + self.pagination = pagination objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) self._objects = objects @@ -200,6 +203,7 @@ class Gitlab(object): http_password=config.http_password, api_version=config.api_version, per_page=config.per_page, + pagination=config.pagination, ) def auth(self): diff --git a/gitlab/config.py b/gitlab/config.py index b2c0dbf..95a1245 100644 --- a/gitlab/config.py +++ b/gitlab/config.py @@ -163,3 +163,9 @@ class GitlabConfigParser(object): pass if self.per_page is not None and not 0 <= self.per_page <= 100: raise GitlabDataError("Unsupported per_page number: %s" % self.per_page) + + self.pagination = None + try: + self.pagination = self._config.get(self.gitlab_id, "pagination") + except Exception: + pass diff --git a/gitlab/mixins.py b/gitlab/mixins.py index c812d66..2437a6f 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -120,6 +120,10 @@ class ListMixin(object): if self.gitlab.per_page: data.setdefault("per_page", self.gitlab.per_page) + # global keyset pagination + if self.gitlab.pagination: + data.setdefault("pagination", self.gitlab.pagination) + # We get the attributes that need some special transformation types = getattr(self, "_types", {}) if types: |