blib/lib/VM/EC2/Volume/StatusItem.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 68 CC 1 SCAR 6.9
CC
1
Cov
0%
valid_fields
2.0
volume
2.0
volumeStatus
2.0
CRAP 2.0
1 package VM::EC2::Volume::StatusItem;
2  
3 =head1 NAME
4  
5 VM::EC2::Volume::StatusItem - Object describing a volume status event
6  
7 =head1 SYNOPSIS
8  
9 @status_items = $ec2->describe_volume_status();
10 for my $i (@status_items) {
11 print $i->volume_id,': ',$i->status,"\n";
12 if (my $e = $i->events) {
13 print $i->volume_id,' event = ',$e;
14 }
15 }
16  
17 =head1 DESCRIPTION
18  
19 This object represents an volume status returned by
20 $ec2->describe_volume_status().
21  
22 =head1 METHODS
23  
24 These object methods are supported:
25  
26 volumeId -- The ID of the affected volume.
27 volume -- The VM::EC2::Volume object corresponding to the volume_id.
28  
29 availability_zone -- The availability zone of this volume.
30  
31 volumeStatus -- A VM::EC2::Volume::Status object indicating the status of the volume.
32 status -- Shorter version of the above.
33  
34 actionsSet -- The list of actions that you might wish to take
35 in response to this status, represented as
36 VM::EC2::Volume::Status::Action objects.
37 actions -- Shorter version of the above.
38  
39 eventsSet -- A list of VM::EC2::Volume::Status::Event objects
40 which provide information about the nature and time
41 of the event.
42 events -- Shorter version of the above.
43  
44  
45 NOTE: There are a number of inconsistencies in the AWS documentation
46 for this data type. The event and action fields are described as being
47 named eventSet and actionSet, but the XML example and practical
48 experience show the fields being named eventsSet and actionsSet. The
49 volumeStatus is documented as being a list, but practice shows that it
50 is a single value only.
51  
52 =head1 SEE ALSO
53  
54 L<VM::EC2>
55 L<VM::EC2::Generic>
56 L<VM::EC2::Instance>
57 L<VM::EC2::Tag>
58  
59 =head1 AUTHOR
60  
61 Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
62  
63 Copyright (c) 2012 Ontario Institute for Cancer Research
64  
65 This package and its accompanying libraries is free software; you can
66 redistribute it and/or modify it under the terms of the GPL (either
67 version 1, or at your option, any later version) or the Artistic
68 License 2.0. Refer to LICENSE for the full license text. In addition,
69 please see DISCLAIMER.txt for disclaimers of warranty.
70  
71 =cut
72  
73 use strict;
74 use base 'VM::EC2::Generic';
75 use VM::EC2::Volume::Status;
76 use VM::EC2::Volume::Status::Event;
77 use VM::EC2::Volume::Status::Action;
78  
79 sub valid_fields {
80 my $self = shift;
81 return qw(volumeId availabilityZone volumeStatus eventsSet actionsSet);
82 }
83  
84 sub volume {
85 my $self = shift;
86 return $self->ec2->describe_volumes($self->volumeId);
87 }
88  
89 sub volumeStatus {
90 my $self = shift;
91 my $s = $self->SUPER::volumeStatus or return;
92 return VM::EC2::Volume::Status->new($s,$self->ec2);
93 }
94  
95 sub status { shift->volumeStatus }
96  
97 sub eventsSet {
98 my $self = shift;
99 my $e = $self->SUPER::eventsSet or return;
100 return map {VM::EC2::Volume::Status::Event->new($_,$self->ec2)} @{$e->{item}};
101 }
102  
103 sub events { shift->eventsSet }
104  
105 sub actionsSet {
106 my $self = shift;
107 my $e = $self->SUPER::actionsSet or return;
108 return map {VM::EC2::Volume::Status::Action->new($_,$self->ec2)} @{$e->{item}};
109 }
110  
111 sub actions { shift->actionsSet }
112  
113 sub short_name {
114 my $self = shift;
115 my $volume = $self->volumeId;
116 my $status = ($self->status)[0];
117 return "$volume: $status";
118 }
119  
120  
121 1;
122