« blib/lib/VM/EC2/ReservedInstance/Modification/Result.pm
↑ Summary
blib/lib/VM/EC2/Security/FederatedUser.pm »
| 1 | package VM::EC2::ReservedInstance::Offering; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::ReservedInstance::Offering - Object describing an Amazon EC2 reserved instance offering | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | $ec2 = VM::EC2->new(...); | ||
| 12 | @offerings = $ec2->describe_reserved_instances_offerings(); | ||
| 13 | for my $o (@offerings) { | ||
| 14 | print $o->reservedInstancesOfferingId,"\n"; | ||
| 15 | print $o->instanceType,"\n"; | ||
| 16 | print $o->availabilityZone,"\n"; | ||
| 17 | print $o->duration,"\n"; | ||
| 18 | print $o->fixedPrice,"\n"; | ||
| 19 | print $o->usagePrice,"\n"; | ||
| 20 | print $o->productDescription,"\n"; | ||
| 21 | print $o->instanceTenancy,"\n"; | ||
| 22 | print $o->currencyCode,"\n"; | ||
| 23 | } | ||
| 24 | |||
| 25 | # purchase the first one | ||
| 26 | $offerings[0]->purchase() && print "offer purchased\n"; | ||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | This object represents an Amazon EC2 reserved instance offering, as | ||
| 31 | returned by VM::EC2->describe_reserved_instances_offerings. | ||
| 32 | |||
| 33 | =head1 METHODS | ||
| 34 | |||
| 35 | These object methods are supported: | ||
| 36 | |||
| 37 | reservedInstancesOfferingId -- ID of this offer | ||
| 38 | |||
| 39 | instanceType -- The instance type on which this reserved | ||
| 40 | instance can be used. | ||
| 41 | |||
| 42 | availabilityZone -- The availability zone in which this reserved | ||
| 43 | instance can be used. | ||
| 44 | |||
| 45 | duration -- The duration of the reserved instance contract, in seconds. | ||
| 46 | |||
| 47 | fixedPrice -- The purchase price of the reserved instance for the indicated | ||
| 48 | version. | ||
| 49 | |||
| 50 | usagePrice -- The usage price of the reserved instance, per hour. | ||
| 51 | |||
| 52 | productDescription -- The reserved instance description. One of "Linux/UNIX", | ||
| 53 | "Linux/UNIX (Amazon VPC)", "Windows", and "Windows (Amazon | ||
| 54 | VPC)" | ||
| 55 | |||
| 56 | instanceTenancy -- The tenancy of the reserved instance (VPC only). | ||
| 57 | |||
| 58 | currencyCode -- The currency of the reserved instance offering prices. | ||
| 59 | |||
| 60 | In addition, this object supports the purchase() method: | ||
| 61 | |||
| 62 | =head2 $boolean = $offering->purchase($count) | ||
| 63 | |||
| 64 | Purchases the offering and returns true on success. The optional | ||
| 65 | $count argument specifies the number of reserved instances to purchase | ||
| 66 | (default 1). | ||
| 67 | |||
| 68 | =head1 STRING OVERLOADING | ||
| 69 | |||
| 70 | When used in a string context, this object will interpolate the | ||
| 71 | reservedInstancesOfferingId. | ||
| 72 | |||
| 73 | =head1 SEE ALSO | ||
| 74 | |||
| 75 | L<VM::EC2> | ||
| 76 | L<VM::EC2::Generic> | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 81 | |||
| 82 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||
| 83 | |||
| 84 | This package and its accompanying libraries is free software; you can | ||
| 85 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 86 | version 1, or at your option, any later version) or the Artistic | ||
| 87 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 88 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | use strict; | ||
| 93 | use base 'VM::EC2::Generic'; | ||
| 94 | |||
| 95 | sub primary_id {shift->reservedInstancesOfferingId} | ||
| 96 | |||
| 97 | sub valid_fields { | ||
| 98 | my $self = shift; | ||
| 99 | return qw(reservedInstancesOfferingId instanceType availabilityZone | ||
| 100 | duration fixedPrice usagePrice productDescription instanceTenancy | ||
| 101 | currencyCode); | ||
| 102 | } | ||
| 103 | |||
| 104 | sub purchase { | ||
| 105 | my $self = shift; | ||
| 106 | my $count = shift || 1; | ||
| 107 | return $self->ec2->purchase_reserved_instances_offering | ||
| 108 | (-instance_count=>$count, | ||
| 109 | -reserved_instances_offering_id=>$self->reservedInstancesOfferingId | ||
| 110 | ); | ||
| 111 | } | ||
| 112 | |||
| 113 | 1; |