@Generated(value="software.amazon.awssdk:codegen") public class DescribeInstanceStatusIterable extends Object implements SdkIterable<DescribeInstanceStatusResponse>
Represents the output for the
EC2Client.describeInstanceStatusPaginator(software.amazon.awssdk.services.ec2.model.DescribeInstanceStatusRequest)
operation which is a paginated operation. This class is an iterable of
DescribeInstanceStatusResponse
that can be used to iterate through
all the response pages of the operation.
When the operation is called, an instance of this class is returned. At this point, no service calls are made yet and so there is no guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response pages by making service calls until there are no pages left or your iteration stops. If there are errors in your request, you will see the failures only after you start iterating through the iterable.
The following are few ways to iterate through the response pages:
1) Using a Stream
software.amazon.awssdk.services.ec2.paginators.DescribeInstanceStatusIterable responses = client.describeInstanceStatusPaginator(request);
responses.stream().forEach(....);
2) Using For loop
{ @code software.amazon.awssdk.services.ec2.paginators.DescribeInstanceStatusIterable responses = client .describeInstanceStatusPaginator(request); for (software.amazon.awssdk.services.ec2.model.DescribeInstanceStatusResponse response : responses) { // do something; } }3) Use iterator directly
software.amazon.awssdk.services.ec2.paginators.DescribeInstanceStatusIterable responses = client.describeInstanceStatusPaginator(request);
responses.iterator().forEachRemaining(....);
Note: If you prefer to have control on service calls, use the
#describeInstanceStatus(software.amazon.awssdk.services.ec2.model.DescribeInstanceStatusRequest)
operation.
Constructor and Description |
---|
DescribeInstanceStatusIterable(EC2Client client,
DescribeInstanceStatusRequest firstRequest) |
Modifier and Type | Method and Description |
---|---|
SdkIterable<InstanceStatus> |
instanceStatuses()
Returns an iterable to iterate through the paginated
DescribeInstanceStatusResponse.instanceStatuses()
member. |
Iterator<DescribeInstanceStatusResponse> |
iterator() |
DescribeInstanceStatusIterable |
resume(DescribeInstanceStatusResponse lastSuccessfulPage)
A helper method to resume the pages in case of unexpected failures.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
stream
forEach, spliterator
public DescribeInstanceStatusIterable(EC2Client client, DescribeInstanceStatusRequest firstRequest)
public Iterator<DescribeInstanceStatusResponse> iterator()
iterator
in interface Iterable<DescribeInstanceStatusResponse>
public final SdkIterable<InstanceStatus> instanceStatuses()
DescribeInstanceStatusResponse.instanceStatuses()
member. The returned iterable is used to iterate through the results across all response pages and not a single
page.
This method is useful if you are interested in iterating over the paginated member in the response pages instead
of the top level pages. Similar to iteration over pages, this method internally makes service calls to get the
next list of results until the iteration stops or there are no more results.public final DescribeInstanceStatusIterable resume(DescribeInstanceStatusResponse lastSuccessfulPage)
A helper method to resume the pages in case of unexpected failures. The method takes the last successful response
page as input and returns an instance of DescribeInstanceStatusIterable
that can be used to retrieve the
consecutive pages that follows the input page.
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.