blib/lib/VM/EC2/Region.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 22 CC 1 SCAR 6.9
CC
1
Cov
0%
primary_id
2.0
valid_fields
2.0
zones
2.0
CRAP 2.0
1 package VM::EC2::Region;
2  
3 =head1 NAME
4  
5 VM::EC2::Region - Object describing an Amazon region
6  
7 =head1 SYNOPSIS
8  
9 use VM::EC2;
10  
11 $ec2 = VM::EC2->new(...);
12 @regions = $ec2->describe_regions();
13  
14 $region = $regions[0];
15 $name = $region->regionName;
16 $url = $region->regionEndpoint;
17 @zones = $region->zones;
18  
19 =head1 DESCRIPTION
20  
21 This object represents an Amazon EC2 region, and is returned
22 by VM::EC2->describe_regions().
23  
24 =head1 METHODS
25  
26 These object methods are supported:
27  
28 regionName -- Name of the region, e.g. "eu-west-1"
29 regionEndpoint -- URL endpoint for AWS API calls, e.g.
30 "ec2.eu-west-1.amazonaws.com"
31 zones -- List of availability zones within this
32 region, as VM::EC2::AvailabilityZone
33 objects.
34  
35 Note that you should prefix the endpoint with http:// or https://
36 before using it to change the VM::EC2 endpoint with the endpoint()
37 call. If you do not do so, then https:// will be assumed.
38  
39 =head1 STRING OVERLOADING
40  
41 When used in a string context, this object will interpolate the
42 regionName.
43  
44 =head1 SEE ALSO
45  
46 L<VM::EC2>
47 L<VM::EC2::Generic>
48  
49 =head1 AUTHOR
50  
51 Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
52  
53 Copyright (c) 2011 Ontario Institute for Cancer Research
54  
55 This package and its accompanying libraries is free software; you can
56 redistribute it and/or modify it under the terms of the GPL (either
57 version 1, or at your option, any later version) or the Artistic
58 License 2.0. Refer to LICENSE for the full license text. In addition,
59 please see DISCLAIMER.txt for disclaimers of warranty.
60  
61 =cut
62  
63 use strict;
64 use base 'VM::EC2::Generic';
65  
66 sub primary_id {shift->regionName}
67  
68 sub valid_fields {
69 my $self = shift;
70 return qw(regionName regionEndpoint);
71 }
72  
73 sub zones {
74 my $self = shift;
75 my $aws = $self->aws;
76 # break encapsulation, but it is elegant this way
77 local $aws->{endpoint} = 'https://'.$self->regionEndpoint;
78 return $aws->describe_availability_zones(-filter=>{'region-name'=>$self});
79 }
80  
81 1;