diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-05-15 18:20:01 +0200 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-05-15 18:21:19 +0200 |
commit | dcf71a0290a3af14ae2f0eee70a2776eb29d9dc2 (patch) | |
tree | 16029ed5197ed207e458f66af7192a01790a7dd3 /gitlab | |
parent | f35c73e50918e4d55b70323669f394e52e75cde9 (diff) | |
download | gitlab-fix/all-pages-consumes-all-param.tar.gz |
fix(api): add all_pages param to allow passing `all` to APIfix/all-pages-consumes-all-param
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/client.py | 13 | ||||
-rw-r--r-- | gitlab/v4/cli.py | 13 |
2 files changed, 21 insertions, 5 deletions
diff --git a/gitlab/client.py b/gitlab/client.py index 1fcda1e..e42350e 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -652,9 +652,9 @@ class Gitlab(object): Returns: list: A list of the objects returned by the server. If `as_list` is False and no pagination-related arguments (`page`, `per_page`, - `all`) are defined then a GitlabList object (generator) is returned - instead. This object will make API calls when needed to fetch the - next items from the server. + `all`/`all_pages`) are defined then a GitlabList object (generator) is + returned instead. This object will make API calls when needed to fetch + the next items from the server. Raises: GitlabHttpError: When the return code is not 2xx @@ -665,7 +665,12 @@ class Gitlab(object): # In case we want to change the default behavior at some point as_list = True if as_list is None else as_list - get_all = kwargs.pop("all", False) + # Provide an "all_pages" param for endpoints that also take "all" as param. + get_all = kwargs.pop("all_pages", None) + + if get_all is None: + get_all = kwargs.pop("all", False) + url = self._build_url(path) page = kwargs.get("page") diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 42b94aa..b8f40db 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -152,7 +152,18 @@ def _populate_sub_parser_by_class(cls, sub_parser): sub_parser_action.add_argument("--page", required=False) sub_parser_action.add_argument("--per-page", required=False) - sub_parser_action.add_argument("--all", required=False, action="store_true") + sub_parser_action.add_argument( + "--all", + required=False, + action="store_true", + help="Return all items from the server, without pagination.", + ) + sub_parser_action.add_argument( + "--all-pages", + required=False, + action="store_true", + help="Same as --all. Use when you need to pass `all` to the GitLab API.", + ) if action_name == "delete": if cls._id_attr is not None: |