NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class AwsResourceIterator

Iterate over a client command

  Guzzle\Common\AbstractHasDispatcher implements Guzzle\Common\HasDispatcherInterface
  Guzzle\Service\Resource\ResourceIterator implements Guzzle\Service\Resource\ResourceIteratorInterface
  Aws\Common\Iterator\AwsResourceIterator

### Direct known subclasses

`Aws\Ec2\Iterator\DescribeInstancesIterator`, `Aws\S3\Iterator\ListBucketsIterator`, `Aws\S3\Iterator\ListMultipartUploadsIterator`, `Aws\S3\Iterator\ListObjectsIterator`, `Aws\S3\Iterator\ListObjectVersionsIterator`

Namespace: Aws\Common\Iterator
Located at Aws/Common/Iterator/AwsResourceIterator.php

## Methods summary

- `public` `getLastResult ( )`

  Provides access to the most recent result obtained by the iterator. This makes it easier to extract any additional information from the result which you do not have access to from the values emitted by the iterator

- `protected` `sendRequest ( )`

  Send a request to retrieve the next page of results. Hook for subclasses to implement. This AWS specific version of the resource iterator provides a default implementation of the typical AWS iterator process. It relies on configuration and extension to implement the operation-specific logic of handling results and nextTokens. This method will loop until resources are acquired or there are no more iterations available.

- `protected` `prepareRequest ( )`
- `protected` `handleResults ( Guzzle\Service\Resource\Model $result )`
- `protected` `applyNextToken ( )`
- `protected` `determineNextToken ( Guzzle\Service\Resource\Model $result )`
- `protected` `getValueFromResult ( Guzzle\Service\Resource\Model $result, string $key )`

  Extracts the value from the result using Collection::getPath. Also adds some additional logic for keys that need to access n-1 indexes (e.g., ImportExport, Kinesis). The n-1 logic only works for the known cases. We will switch to a jmespath implementation in the future to cover all cases

## Methods detail

# `public `Guzzle\Service\Resource\Model`|null`
`getLastResult( )`

Provides access to the most recent result obtained by the iterator. This makes it easier to extract any additional information from the result which you do not have access to from the values emitted by the iterator

#### Returns

``Guzzle\Service\Resource\Model`|null`
# `protected array`
`sendRequest( )`

Send a request to retrieve the next page of results. Hook for subclasses to implement. This AWS specific version of the resource iterator provides a default implementation of the typical AWS iterator process. It relies on configuration and extension to implement the operation-specific logic of handling results and nextTokens. This method will loop until resources are acquired or there are no more iterations available.

#### Returns

`array`
Returns the newly loaded resources
# `protected`
`prepareRequest( )`
# `protected`
`handleResults( `Guzzle\Service\Resource\Model` $result )`
# `protected`
`applyNextToken( )`
# `protected`
`determineNextToken( `Guzzle\Service\Resource\Model` $result )`
# `protected mixed|null`
`getValueFromResult( `Guzzle\Service\Resource\Model` $result, string $key )`

Extracts the value from the result using Collection::getPath. Also adds some additional logic for keys that need to access n-1 indexes (e.g., ImportExport, Kinesis). The n-1 logic only works for the known cases. We will switch to a jmespath implementation in the future to cover all cases

#### Parameters

$result
  ``Guzzle\Service\Resource\Model``
  $result
$key
  `string`
  $key

#### Returns

`mixed|null`

### Methods inherited from Guzzle\Service\Resource\ResourceIterator

`__construct()`, `calculatePageSize()`, `count()`, `current()`, `get()`, `getAllEvents()`, `getNextToken()`, `getRequestCount()`, `key()`, `next()`, `resetState()`, `rewind()`, `set()`, `setLimit()`, `setPageSize()`, `toArray()`, `valid()`

### Methods inherited from Guzzle\Common\AbstractHasDispatcher

`addSubscriber()`, `dispatch()`, `getEventDispatcher()`, `setEventDispatcher()`

### Magic methods summary

## Properties summary

`protected `Guzzle\Service\Resource\Model`` | $lastResult | # Result of a command

### Properties inherited from Guzzle\Service\Resource\ResourceIterator

`$command`, `$data`, `$invalid`, `$iteratedCount`, `$limit`, `$nextToken`, `$originalCommand`, `$pageSize`, `$requestCount`, `$resources`, `$retrievedCount`

### Properties inherited from Guzzle\Common\AbstractHasDispatcher

`$eventDispatcher`