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

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

Introduction

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

Prototype


public void setOfferingType(OfferingTypeValues offeringType) 

Source Link

Document

The Reserved Instance offering type.

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  w  ww  .  j a va2  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);
}