diff options
author | Roger Meier <r.meier@siemens.com> | 2020-02-25 12:31:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 12:31:32 +0100 |
commit | 3aa9873c8e5f38c85f7ac4dd11a21728e553399b (patch) | |
tree | c65c601e30dfa08298e1aa9c236188df02eb278b | |
parent | 745bdf7caeffa907bb0594b602194f41d3a75e3e (diff) | |
parent | 16098244ad7c19867495cf4f0fda0c83fe54cd2b (diff) | |
download | gitlab-3aa9873c8e5f38c85f7ac4dd11a21728e553399b.tar.gz |
Merge pull request #1003 from python-gitlab/feat/all-keyset-pagination
feat: use keyset pagination by default for `all=True`
-rw-r--r-- | docs/api-usage.rst | 6 | ||||
-rw-r--r-- | gitlab/__init__.py | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/docs/api-usage.rst b/docs/api-usage.rst index dc88684..e23cd1d 100644 --- a/docs/api-usage.rst +++ b/docs/api-usage.rst @@ -204,6 +204,11 @@ listing methods support the ``page`` and ``per_page`` parameters: By default GitLab does not return the complete list of items. Use the ``all`` parameter to get all the items when using listing methods: +.. warning:: + + The all=True option uses keyset pagination by default if order_by is not supplied, + or if order_by="id". + .. code-block:: python all_groups = gl.groups.list(all=True) @@ -391,4 +396,3 @@ parameter to that API invocation: gl = gitlab.gitlab(url, token, api_version=4) gl.projects.import_github(ACCESS_TOKEN, 123456, "root", timeout=120.0) - diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 32aa265..96a3c13 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -640,6 +640,12 @@ class Gitlab(object): get_all = kwargs.pop("all", False) url = self._build_url(path) + # use keyset pagination automatically, if all=True + order_by = kwargs.get("order_by") + if get_all and (not order_by or order_by == "id"): + kwargs["pagination"] = "keyset" + kwargs["order_by"] = "id" + if get_all is True and as_list is True: return list(GitlabList(self, url, query_data, **kwargs)) |