/usr/share/perl5/VM/EC2/REST/reserved_instance.pm is in libvm-ec2-perl 1.28-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | package VM::EC2::REST::reserved_instance;
use strict;
use VM::EC2 ''; # important not to import anything!
package VM::EC2; # add methods to VM::EC2
require VM::EC2::ReservedInstance::ParmParser;
VM::EC2::Dispatch->register(
CancelReservedInstancesListing => 'fetch_items,reservedInstancesListingsSet,VM::EC2::ReservedInstance::Listing',
CreateReservedInstancesListing => 'fetch_items,reservedInstancesListingsSet,VM::EC2::ReservedInstance::Listing',
DescribeReservedInstances => 'fetch_items,reservedInstancesSet,VM::EC2::ReservedInstance',
DescribeReservedInstancesListings => 'fetch_items,reservedInstancesListingsSet,VM::EC2::ReservedInstance::Listing',
DescribeReservedInstancesModifications =>
'fetch_items,reservedInstancesModificationsSet,VM::EC2::ReservedInstance::Modification',
DescribeReservedInstancesOfferings => 'fetch_items,reservedInstancesOfferingsSet,VM::EC2::ReservedInstance::Offering',
ModifyReservedInstances => sub { my ($data,$ec2) = @_;
return $data->{reservedInstancesModificationId}; },
PurchaseReservedInstancesOffering => sub { my ($data,$ec2) = @_;
my $ri_id = $data->{reservedInstancesId} or return;
return $ec2->describe_reserved_instances($ri_id); },
);
my $VEP = 'VM::EC2::ReservedInstance::ParmParser';
=head1 NAME VM::EC2::REST::reserved_instance - Describing, purchasing and using Reserved Instances
=head1 SYNOPSIS
use VM::EC2 ':misc'
=head1 METHODS
These methods apply to describing, purchasing and using Reserved Instances.
Implemented:
CancelReservedInstancesListing
DescribeReservedInstances
DescribeReservedInstancesListings
DescribeReservedInstancesModifications
DescribeReservedInstancesOfferings
ModifyReservedInstances
PurchaseReservedInstancesOffering
CreateReservedInstancesListing
Unimplemented:
(none)
=head2 @offerings = $ec2->describe_reserved_instances_offerings(@offering_ids)
=head2 @offerings = $ec2->describe_reserved_instances_offerings(%args)
This method returns a list of the reserved instance offerings
currently available for purchase. The arguments allow you to filter
the offerings according to a variety of filters.
All arguments are optional. If no named arguments are used, then the
arguments are treated as Reserved Instance Offering IDs.
-reserved_instances_offering_id A scalar or arrayref of reserved
instance offering IDs
-instance_type The instance type on which the
reserved instance can be used,
e.g. "c1.medium"
-availability_zone, -zone The availability zone in which the
reserved instance can be used.
-product_description The reserved instance description.
Valid values are "Linux/UNIX",
"Linux/UNIX (Amazon VPC)",
"Windows", and "Windows (Amazon
VPC)"
-instance_tenancy The tenancy of the reserved instance
offering, either "default" or
"dedicated". (VPC instances only)
-offering_type The reserved instance offering type, one of
"Heavy Utilization", "Medium Utilization",
or "Light Utilization".
-filter A set of filters to apply.
For available filters, see http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstancesOfferings.html.
The returned objects are of type L<VM::EC2::ReservedInstance::Offering>
This can be combined with the Offering purchase() method as shown here:
@offerings = $ec2->describe_reserved_instances_offerings(
{'availability-zone' => 'us-east-1a',
'instance-type' => 'c1.medium',
'product-description' =>'Linux/UNIX',
'duration' => 31536000, # this is 1 year
});
$offerings[0]->purchase(5) and print "Five reserved instances purchased\n";
=cut
sub describe_reserved_instances_offerings {
my $self = shift;
my %args = $VEP->args(-reserved_instances_offering_id,@_);
$args{-availability_zone} ||= $args{-zone};
my @param = $VEP->format_parms(\%args,
{
list_parm => 'ReservedInstancesOfferingId',
single_parm => [qw(ProductDescription InstanceType AvailabilityZone
InstanceTenancy OfferingType)],
filter_parm => 'Filter',
});
return $self->call('DescribeReservedInstancesOfferings',@param);
}
=head2 $id = $ec2->purchase_reserved_instances_offering($offering_id)
=head2 $id = $ec2->purchase_reserved_instances_offering(%args)
Purchase one or more reserved instances based on an offering.
Arguments:
-reserved_instances_offering_id, -id -- The reserved instance offering ID
to purchase (required).
-instance_count, -count -- Number of instances to reserve
under this offer (optional, defaults
to 1).
Returns a Reserved Instances Id on success, undef on failure. Also see the purchase() method of
L<VM::EC2::ReservedInstance::Offering>.
=cut
sub purchase_reserved_instances_offering {
my $self = shift;
my %args = $VEP->args(-reserved_instances_offering_id,@_);
$args{-reserved_instances_offering_id} ||= $args{-id};
$args{-reserved_instances_offering_id} or
croak "purchase_reserved_instances_offering(): the -reserved_instances_offering_id argument is required";
$args{-instance_count} ||= $args{-count};
my @param = $VEP->format_parms(\%args,
{
single_parm => [qw(ReservedInstancesOfferingId InstanceCount)],
});
return $self->call('PurchaseReservedInstancesOffering',@param);
}
=head2 @res_instances = $ec2->describe_reserved_instances(@res_instance_ids)
=head2 @res_instances = $ec2->describe_reserved_instances(%args)
This method returns a list of the reserved instances that you
currently own. The information returned includes the type of
instances that the reservation allows you to launch, the availability
zone, and the cost per hour to run those reserved instances.
All arguments are optional. If no named arguments are used, then the
arguments are treated as Reserved Instance IDs.
-reserved_instances_id -- A scalar or arrayref of reserved
instance IDs
-filter -- A set of filters to apply.
For available filters, see http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstances.html.
The returned objects are of type L<VM::EC2::ReservedInstance>
=cut
sub describe_reserved_instances {
my $self = shift;
my %args = $VEP->args(-reserved_instances_id,@_);
my @param = $VEP->format_parms(\%args,
{
list_parm => 'ReservedInstancesId',
filter_parm => 'Filter',
});
return $self->call('DescribeReservedInstances',@param);
}
=head2 $id = $ec2->modify_reserved_instances(%args)
Modifies the Availability Zone, instance count, instance type, or network
platform (EC2-Classic or EC2-VPC) of your Reserved Instances. The Reserved
Instances to be modified must be identical, except for Availability Zone,
network platform, and instance type.
Required arguments:
-reserved_instances_id -- The IDs of the Reserved Instances to modify
Can be scalar or arrayref.
-target_configuration -- The configuration settings for the Reserved
Instances to modify
Must be a hashref or arrayref of hashes with
one or more of the following values:
AvailabilityZone, Platform, InstanceType
The following is also REQUIRED:
InstanceCount
-id -- Alias for -reserved_instances_id
Returns the reserved instances modification ID string.
=cut
sub modify_reserved_instances {
my $self = shift;
my %args = @_;
$args{-reserved_instances_id} ||= $args{-id};
$args{-reserved_instances_id} or
croak "modify_reserved_instances(): -reserved_instances_id argument required";
$args{-target_configuration} or
croak "modify_reserved_instances(): -target_configuration argument required";
my @param = $VEP->format_parms(\%args,
{
list_parm => 'ReservedInstancesId',
ri_target_config_parm => 'TargetConfiguration',
});
return $self->call('ModifyReservedInstances',@param);
}
=head2 @mods = $ec2->describe_reserved_instances_modifications(@ids)
=head2 @mods = $ec2->describe_reserved_instances_modifications(%args)
Describes the modifications made to your Reserved Instances.
All arguments are optional. If no named arguments are used, then the
arguments are treated as Reserved Instance Modification IDs.
-reserved_instances_modification_id -- A scalar or arrayref of reserved
instance modification IDs
-filter -- A set of filters to apply.
-id -- Alias for -reserved_instances_modification_id
For available filters, see:
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstancesModifications.html
The returned objects are of type L<VM::EC2::ReservedInstance::Modification>
=cut
sub describe_reserved_instances_modifications {
my $self = shift;
my %args = $VEP->args(-reserved_instances_modification_id,@_);
$args{-reserved_instances_modification_id} ||= $args{-id};
my @param = $VEP->format_parms(\%args,
{
list_parm => 'ReservedInstancesModificationId',
filter_parm => 'Filter',
});
return $self->call('DescribeReservedInstancesModifications',@param);
}
=head2 @list = $ec2->describe_reserved_instances_listings(%args)
Describes the account's Reserved Instance listings in the Reserved Instance
Marketplace.
All arguments are optional. If no named arguments are used, then the
arguments are treated as Reserved Instance Listing IDs.
-reserved_instances_listing_id -- A scalar or arrayref of reserved
instance listing IDs
-reserved_instances_id -- A scalar or arrayref of reserved
instance IDs
-filter -- A set of filters to apply.
For available filters, see:
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstancesListings.html
The returned objects are of type L<VM::EC2::ReservedInstance::Listing>
=cut
sub describe_reserved_instances_listings {
my $self = shift;
my %args = $VEP->args(-reserved_instances_listing_id,@_);
my @param = $VEP->format_parms(\%args,
{
list_parm => [qw(ReservedInstancesListingId ReservedInstancesId)],
filter_parm => 'Filter',
});
return $self->call('DescribeReservedInstancesListings',@param);
}
=head2 $listing = $ec2->cancel_reserved_instances_listing(%args)
Cancels the specified Reserved Instance listing in the Reserved Instance
Marketplace.
Required arguments:
-reserved_instances_listing_id -- The ID of the Reserved Instance listing
to be canceled
Returns an object of type L<VM::EC2::ReservedInstance::Listing>
=cut
sub cancel_reserved_instances_listing {
my $self = shift;
my %args = $VEP->args(-reserved_instances_listing_id,@_);
my @param = $VEP->format_parms(\%args,
{
single_parm => 'ReservedInstancesListingId',
});
return $self->call('CancelReservedInstancesListing',@param);
}
=head2 $listing = $ec2->create_reserved_instances_listing(%args)
Creates a listing for Amazon EC2 Reserved Instances to be sold in the Reserved
Instance Marketplace. Only one Reserved Instance listing may be created at a
time.
Required arguments:
-reserved_instances_id -- The ID of the active Reserved Instance
-instance_count -- The number of instances to be listed in the
Reserved Instance Marketplace. This number
should be less than or equal to the instance count
associated with the Reserved Instance ID specified
-price_schedules -- hashref containing term/price pairs for months
the Reserved Instance has remaining in its term
For example, with a RI with 11 months to go:
{ 11 => 2.5,
8 => 2.0,
5 => 1.5,
3 => 0.7,
1 => 0.1 }
For months 11,10,9 the price is $2.50, 8,7,6 is
$2.00, 5,4 is $1.50, 3,2 is $0.70 and the last
month is $0.10.
For more details, see the API docs at:
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateReservedInstancesListing.html
-client_token -- Unique, case-sensitive identifier to ensure
idempotency of listings
Returns an object of type L<VM::EC2::ReservedInstance::Listing>
=cut
sub create_reserved_instances_listing {
my $self = shift;
my %args = $VEP->args(-reserved_instances_listing_id,@_);
$args{-reserved_instances_id} or
croak "create_reserved_instances_listing(): -reserved_instances_id argument required";
$args{-instance_count} or
croak "create_reserved_instances_listing(): -instance_count argument required";
$args{-price_schedules} or
croak "create_reserved_instances_listing(): -price_schedules argument required";
$args{-client_token} or
croak "create_reserved_instances_listing(): -client_token argument required";
ref $args{-price_schedules} eq 'HASH' or
croak "create_reserved_instances_listing(): -price_schedules argument must be hashref";
my @param = $VEP->format_parms(\%args,
{
single_parm => [qw(ReservedInstancesId InstanceCount
ClientToken)],
ri_price_sched_parm => 'PriceSchedules',
});
return $self->call('CreateReservedInstancesListing',@param);
}
=head1 SEE ALSO
L<VM::EC2>
=head1 AUTHOR
Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>.
Copyright (c) 2011 Ontario Institute for Cancer Research
Copyright (c) 2014 Loyalty Methods, Inc.
This package and its accompanying libraries is free software; you can
redistribute it and/or modify it under the terms of the GPL (either
version 1, or at your option, any later version) or the Artistic
License 2.0. Refer to LICENSE for the full license text. In addition,
please see DISCLAIMER.txt for disclaimers of warranty.
=cut
1;
|