Skip to content

Conversation

@dwsupplee
Copy link
Contributor

@dwsupplee dwsupplee commented Mar 15, 2017

Closes: #342

Example:

use Google\Cloud\Storage\StorageClient;

$storage = new StorageClient();
$bucketsIterator = $storage->buckets([
    'maxResults' => 5 // The number of results per page
    'resultLimit' => 10 // The number of results returned in total **new**
    'pageToken' => null // Set this to the value of a previously retrieved token to resume iterating from a specific point **new**
]);

// Iterate by each item (bucket) in the project
foreach ($bucketsIterator as $bucket) {
    var_dump($bucket->name());
}

// Or iterate by page
$bucketsPageIterator = $bucketsIterator->iterateByPage();

foreach ($bucketsPageIterator as $page) {
    foreach ($page as $bucket) {
        var_dump($bucket->name());
    }
}

// Get the next result token
$nextToken = $bucketsIterator->nextResultToken();

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 15, 2017
Copy link
Contributor

@jdpedrie jdpedrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I'm going to pull it down and play around with it a bit more before signing off, but I don't have any requested changes in the code at the moment.

* return the specified fields.
* }
* @return \Generator<Google\Cloud\Storage\StorageObject>
* @return ObjectsIterator<Google\Cloud\Storage\StorageObject>

This comment was marked as spam.

use Google\Cloud\Core\Iterator\ItemIteratorTrait;

/**
* Iterates over a set of {@see Google\Cloud\Storage\Object} items.

This comment was marked as spam.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Mar 15, 2017
@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Mar 16, 2017
Copy link
Contributor

@jdpedrie jdpedrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@jdpedrie
Copy link
Contributor

I'm letting travis run again against the doc changes I made in #400.

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

Labels

api: core cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants