summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Meier <r.meier@siemens.com>2020-02-25 12:31:32 +0100
committerGitHub <noreply@github.com>2020-02-25 12:31:32 +0100
commit3aa9873c8e5f38c85f7ac4dd11a21728e553399b (patch)
treec65c601e30dfa08298e1aa9c236188df02eb278b
parent745bdf7caeffa907bb0594b602194f41d3a75e3e (diff)
parent16098244ad7c19867495cf4f0fda0c83fe54cd2b (diff)
downloadgitlab-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.rst6
-rw-r--r--gitlab/__init__.py6
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))