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

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

Introduction

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

Prototype


public java.util.Date getTimestamp() 

Source Link

Document

The date and time the request was created, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ).

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 ww . j a  v a 2 s  .co 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;
}