GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update iterator to take a method and **kwargs · Issue #1554 · googleapis/google-cloud-python

Update iterator to take a method and **kwargs #1554

New issue
Copy link
New issue
Copy link
Closed
Closed
Update iterator to take a method and **kwargs#1554
Copy link
Assignees
tseaver
Labels
api: bigqueryIssues related to the BigQuery API.api: cloudresourcemanagerIssues related to the Resource Manager API.api: coreapi: dnsIssues related to the Cloud DNS API.api: pubsubIssues related to the Pub/Sub API.api: storageIssues related to the Cloud Storage API.

Description

@tseaver
tseaver
opened on Mar 1, 2016
Issue body actions

gcloud.iterator.Iterator is a base class, relying on a path for the API method. I think it would be clearer if it wrapped around a method of a client (or other domain object), where that method takes page_token, page_size, etc., along with other named arguments in **kw. We could then ditch all the derived classes, and just use the one, common implementation. E.g.:

from gcloud.iterator import Iterator
from gcloud.pubsub import Client

client = Client()
topics = list(Iterator(client.list_topics))
subs = list(Iterator(client.list_subscriptions, topic_name='my-topic'))

Activity

  1. tseaver
    added
    api: storageIssues related to the Cloud Storage API.
    api: bigqueryIssues related to the BigQuery API.
    api: dnsIssues related to the Cloud DNS API.
    api: pubsubIssues related to the Pub/Sub API.
    api: core
    api: cloudresourcemanagerIssues related to the Resource Manager API.
    search
    on Mar 1, 2016
  2. dhermes commented on Mar 2, 2016

    @dhermes
    dhermes
    on Mar 2, 2016
    Contributor
    More actions

    SGTM in spirit. Iterator was something we inherited, so it never really had an encompassing design discussion.

    Also 👍 to making it no longer public.

  3. tseaver commented on Mar 3, 2016

    @tseaver
    tseaver
    on Mar 3, 2016
    ContributorAuthor
    More actions

    It needs to be public: we expect client code to instantiate the Iterator class directly. We would likely be removing the various subclasses, however.

  4. dhermes commented on Mar 3, 2016

    @dhermes
    dhermes
    on Mar 3, 2016
    Contributor
    More actions

    Ahh I didn't realize we'd use the class directly. Works for me.

  5. rimey commented on Apr 9, 2016

    @rimey
    rimey
    on Apr 9, 2016
    Contributor
    More actions

    There are really two points here:

    1. Client code could request "infiniscrolling" by wrapping a paging-aware list_* bound method in a MethodIterator. This proposal and others are being discussed in Allow easy paging for list operations #895.
    2. Having to subclass Iterator is burdensome and unnecessary.

    The second point is worthy of attention independently of the first. For example, the current list_projects method could be implemented more concisely in terms of MethodIterator.

    For infiniscrolling, a simple generator would do the job as well as a class:

    def chain_pages(function, **kwargs):
        token = None
        while True:
            items, token = function(page_token=token, **kwargs)
            for item in items:
                yield item
            if token is None:
                break
    
  6. dhermes commented on Apr 11, 2016

    @dhermes
    dhermes
    on Apr 11, 2016
    Contributor
    More actions

    FWIW: We've got a pending issue (#1467) which points out that a bit more logic is needed when max_results is used.

  7. tseaver commented on Feb 6, 2017

    @tseaver
    tseaver
    on Feb 6, 2017
    ContributorAuthor
    More actions

    Obsoleted by #2531 and subsequent PRs.

  8. tseaver
    closed this as completedon Feb 6, 2017
  9. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  10. parthea
    added 2 commits that reference this issue on Nov 24, 2025

    chore(main): release 1.8.0 (#1554)

    128734b

    chore(python): use python 3.10 for docs build (#1554)

    735cbd9
  11. parthea
    added 3 commits that reference this issue on Mar 2, 2026

    chore(librarian): remove release please configuration files (#1554)

    15a49e0

    fix: type annotations include Optional when None is accepted (#1554)

    c63f6eb

    feat(zb-experimental): Add support for closing MRD (#1554)

    30d3490
  12. parthea
    added a commit that references this issue on Apr 1, 2026

    feat: support bigquery connection in managed function (#1554)

    e0e7b15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: bigqueryIssues related to the BigQuery API.api: cloudresourcemanagerIssues related to the Resource Manager API.api: coreapi: dnsIssues related to the Cloud DNS API.api: pubsubIssues related to the Pub/Sub API.api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.