diff options
author | Max Wittig <max.wittig@siemens.com> | 2020-01-27 16:52:16 +0100 |
---|---|---|
committer | Max Wittig <max.wittig@siemens.com> | 2020-01-27 16:52:16 +0100 |
commit | 99b4484da924f9378518a1a1194e1a3e75b48073 (patch) | |
tree | d6fc66d3ef6a943061f3ca0af8b8e9c17fa91b2b | |
parent | 7843ace913589cf629f448a2541f290a4c7214cd (diff) | |
download | gitlab-99b4484da924f9378518a1a1194e1a3e75b48073.tar.gz |
feat: use keyset pagination by default for `all=True`
-rw-r--r-- | docs/api-usage.rst | 5 | ||||
-rw-r--r-- | gitlab/__init__.py | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/docs/api-usage.rst b/docs/api-usage.rst index dc88684..3e2355c 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="id" + or if order_by is not supplied. + .. code-block:: python all_groups = gl.groups.list(all=True) diff --git a/gitlab/__init__.py b/gitlab/__init__.py index c9716c2..b4adacf 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)) |