Example usage for com.amazonaws.services.ec2.model SpotPrice getProductDescription

List of usage examples for com.amazonaws.services.ec2.model SpotPrice getProductDescription

Introduction

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

Prototype


public String getProductDescription() 

Source Link

Document

A general description of the AMI.

Usage

From source file:org.excalibur.service.aws.ec2.EC2.java

License:Open Source License

public List<SpotPriceHistory> getSpotPriceHistory(SpotPriceHistoryRequest request) {
    List<SpotPriceHistory> history = new ArrayList<SpotPriceHistory>();

    DescribeSpotPriceHistoryRequest spotPriceRequest = new DescribeSpotPriceHistoryRequest()
            .withEndTime(request.getUntil()).withStartTime(request.getFrom())
            .withAvailabilityZone(request.getRegion() != null ? request.getRegion().getName() : null)
            .withMaxResults(request.getMaxResult()).withProductDescriptions(request.getImageTypes());

    List<InstanceType> types = request.getInstanceTypes();
    String[] instanceTypes = new String[types.size()];

    for (int i = 0; i < instanceTypes.length; i++) {
        instanceTypes[i] = types.get(i).getName();
    }// w w  w . j  a v a 2 s. c o m

    spotPriceRequest.withInstanceTypes(instanceTypes);

    DescribeSpotPriceHistoryResult describeSpotPriceHistory = ec2_.describeSpotPriceHistory(spotPriceRequest);

    for (SpotPrice spot : describeSpotPriceHistory.getSpotPriceHistory()) {
        history.add(new SpotPriceHistory().withInstanceType(new InstanceType().setName(spot.getInstanceType()))
                .withPrice(spot.getSpotPrice()).withImageTypeDescription(spot.getProductDescription())
                .withRegion(new Region(spot.getAvailabilityZone())).withTime(spot.getTimestamp()));
    }

    return history;
}