Repository: python-gitlab/python-gitlab

Issue:
Surprising interaction between "as_list" and "all"
From [reading here](https://python-gitlab.readthedocs.io/en/stable/api-usage.html) I understood that I have to use `all=True` if I want to get all results, and then do `as_list=False` to get a generator to iterate over. But in fact this does not work well together. By specifying `all=True` it first starts fetching all results and generator does not call anything with results as pages are coming in.

I think `all=True` should just work with `as_list=False`. If I understand correctly, `all=True` is a noop in that case because `as_list=False` already implies it?


Discussion:
Yes. Basically, if you supply as_list you won't need all=True. 
Yes, but I think that if you supply `as_list` `all` should just be ignored.
Good point

Resolving patch:
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -630,7 +630,7 @@ def http_list(self, path, query_data=None, as_list=None, **kwargs):
         get_all = kwargs.pop("all", False)
         url = self._build_url(path)
 
-        if get_all is True:
+        if get_all is True and as_list is True:
             return list(GitlabList(self, url, query_data, **kwargs))
 
         if "page" in kwargs or as_list is True:
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -762,8 +762,8 @@ class GroupClusterManager(CRUDMixin, RESTManager):
     _obj_cls = GroupCluster
     _from_parent_attrs = {"group_id": "id"}
     _create_attrs = (
-        ("name", "platform_kubernetes_attributes",),
-        ("domain", "enabled", "managed", "environment_scope",),
+        ("name", "platform_kubernetes_attributes"),
+        ("domain", "enabled", "managed", "environment_scope"),
     )
     _update_attrs = (
         tuple(),
@@ -1664,8 +1664,8 @@ class ProjectClusterManager(CRUDMixin, RESTManager):
     _obj_cls = ProjectCluster
     _from_parent_attrs = {"project_id": "id"}
     _create_attrs = (
-        ("name", "platform_kubernetes_attributes",),
-        ("domain", "enabled", "managed", "environment_scope",),
+        ("name", "platform_kubernetes_attributes"),
+        ("domain", "enabled", "managed", "environment_scope"),
     )
     _update_attrs = (
         tuple(),


Test patch:
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -119,6 +119,24 @@ def resp_2(url, request):
                 self.assertEqual(l[0]["a"], "b")
                 self.assertEqual(l[1]["c"], "d")
 
+    def test_all_omitted_when_as_list(self):
+        @urlmatch(scheme="http", netloc="localhost", path="/api/v4/tests", method="get")
+        def resp(url, request):
+            headers = {
+                "content-type": "application/json",
+                "X-Page": 2,
+                "X-Next-Page": 2,
+                "X-Per-Page": 1,
+                "X-Total-Pages": 2,
+                "X-Total": 2,
+            }
+            content = '[{"c": "d"}]'
+            return response(200, content, headers, None, 5, request)
+
+        with HTTMock(resp):
+            result = self.gl.http_list("/tests", as_list=False, all=True)
+            self.assertIsInstance(result, GitlabList)
+
 
 class TestGitlabHttpMethods(unittest.TestCase):
     def setUp(self):