Example usage for com.amazonaws.services.ec2.model DescribeReservedInstancesOfferingsRequest withNextToken

List of usage examples for com.amazonaws.services.ec2.model DescribeReservedInstancesOfferingsRequest withNextToken

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DescribeReservedInstancesOfferingsRequest withNextToken.

Prototype


public DescribeReservedInstancesOfferingsRequest withNextToken(String nextToken) 

Source Link

Document

The token to retrieve the next page of results.

Usage

From source file:com.kenlin.awsec2offering.App.java

License:Open Source License

private void addReservedOfferings(ArrayNode array, String availabilityZone, String productDescription,
        String offeringType, String instanceType) {
    DescribeReservedInstancesOfferingsRequest req = new DescribeReservedInstancesOfferingsRequest()
            .withIncludeMarketplace(false).withInstanceTenancy(Tenancy.Default); // Not Tenancy.Dedicated
    if (availabilityZone != null)
        req.setAvailabilityZone(availabilityZone);
    if (productDescription != null)
        req.setProductDescription(productDescription);
    if (offeringType != null)
        req.setOfferingType(offeringType);
    if (instanceType != null)
        req.setInstanceType(parseInstanceType(instanceType));

    String nextToken = null;//from   ww w .j  av  a 2  s . c om
    do {
        DescribeReservedInstancesOfferingsResult res = ec2.describeReservedInstancesOfferings(req);
        for (ReservedInstancesOffering o : res.getReservedInstancesOfferings()) {
            Offering offering = new Offering(o);
            try {
                array.add(offering.toJsonNode());
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        nextToken = res.getNextToken();
        req.withNextToken(nextToken);
    } while (nextToken != null);
}