summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-05-15 18:20:01 +0200
committerJohn Villalovos <john@sodarock.com>2022-07-21 15:03:11 -0700
commit7c71d5db1199164b3fa9958e3c3bc6ec96efc78d (patch)
tree1b17a6e3467e22187ef0530c9174534e816c3560 /gitlab
parent0549afa6631f21ab98e1f1457607daa03b398185 (diff)
downloadgitlab-7c71d5db1199164b3fa9958e3c3bc6ec96efc78d.tar.gz
fix: add `get_all` param (and `--get-all`) to allow passing `all` to API
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/client.py16
-rw-r--r--gitlab/v4/cli.py13
2 files changed, 23 insertions, 6 deletions
diff --git a/gitlab/client.py b/gitlab/client.py
index 6f41678..12f3d0b 100644
--- a/gitlab/client.py
+++ b/gitlab/client.py
@@ -857,7 +857,7 @@ class Gitlab:
Returns:
A list of the objects returned by the server. If `iterator` is
True and no pagination-related arguments (`page`, `per_page`,
- `all`) are defined then a GitlabList object (generator) is returned
+ `get_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.
@@ -884,7 +884,13 @@ class Gitlab:
category=DeprecationWarning,
)
- get_all = kwargs.pop("all", None)
+ # Provide a `get_all`` param to avoid clashes with `all` API attributes.
+ get_all = kwargs.pop("get_all", None)
+
+ if get_all is None:
+ # For now, keep `all` without deprecation.
+ get_all = kwargs.pop("all", None)
+
url = self._build_url(path)
page = kwargs.get("page")
@@ -902,7 +908,7 @@ class Gitlab:
def should_emit_warning() -> bool:
# No warning is emitted if any of the following conditions apply:
- # * `all=False` was set in the `list()` call.
+ # * `get_all=False` was set in the `list()` call.
# * `page` was set in the `list()` call.
# * GitLab did not return the `x-per-page` header.
# * Number of items received is less than per-page value.
@@ -927,12 +933,12 @@ class Gitlab:
total_items = "many" if gl_list.total is None else gl_list.total
utils.warn(
message=(
- f"Calling a `list()` method without specifying `all=True` or "
+ f"Calling a `list()` method without specifying `get_all=True` or "
f"`iterator=True` will return a maximum of {gl_list.per_page} items. "
f"Your query returned {len(items)} of {total_items} items. See "
f"{_PAGINATION_URL} for more details. If this was done intentionally, "
f"then this warning can be supressed by adding the argument "
- f"`all=False` to the `list()` call."
+ f"`get_all=False` to the `list()` call."
),
category=UserWarning,
)
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index b496669..90b6ba6 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -240,7 +240,18 @@ def _populate_sub_parser_by_class(
sub_parser_action.add_argument("--page", required=False, type=int)
sub_parser_action.add_argument("--per-page", required=False, type=int)
- sub_parser_action.add_argument("--all", required=False, action="store_true")
+ sub_parser_action.add_argument(
+ "--get-all",
+ required=False,
+ action="store_true",
+ help="Return all items from the server, without pagination.",
+ )
+ sub_parser_action.add_argument(
+ "--all",
+ required=False,
+ action="store_true",
+ help="Deprecated. Use --get-all instead.",
+ )
if action_name == "delete":
if cls._id_attr is not None: