| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
71
|
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
101
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Net::Amazon::Route53::HostedZone; |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$Net::Amazon::Route53::HostedZone::VERSION = '0.123250'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
2
|
|
|
2
|
|
9
|
use Mouse; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
11
|
|
|
9
|
2
|
|
|
2
|
|
484
|
use HTML::Entities; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
132
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
891
|
use Net::Amazon::Route53::Change; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
52
|
|
|
12
|
2
|
|
|
2
|
|
1377
|
use Net::Amazon::Route53::ResourceRecordSet; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
1729
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $hostedzone = Net::Amazon::Route53::HostedZone->new(...); |
|
17
|
|
|
|
|
|
|
# use methods on $hostedzone |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head3 route53 |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
A L object, needed and used to perform requests |
|
28
|
|
|
|
|
|
|
to Amazon's Route 53 service |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'route53' => (is => 'rw', isa => 'Net::Amazon::Route53', required => 1,); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head3 id |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The hosted zone's id |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 name |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The hosted zone's name; ends in a dot, i.e. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
example.com. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 callerreference |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The CallerReference attribute for the hosted zone |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head3 comment |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Any Comment given when the zone is created |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'id' => (is => 'rw', isa => 'Str', required => 1, default => ''); |
|
55
|
|
|
|
|
|
|
has 'name' => (is => 'rw', isa => 'Str', required => 1, default => ''); |
|
56
|
|
|
|
|
|
|
has 'callerreference' => |
|
57
|
|
|
|
|
|
|
(is => 'rw', isa => 'Str', required => 1, default => ''); |
|
58
|
|
|
|
|
|
|
has 'comment' => (is => 'rw', isa => 'Str', required => 1, default => ''); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head3 nameservers |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Lazily loaded, returns a list of the nameservers authoritative for this zone |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has 'nameservers' => ( |
|
67
|
|
|
|
|
|
|
is => 'rw', |
|
68
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
69
|
|
|
|
|
|
|
lazy => 1, |
|
70
|
|
|
|
|
|
|
default => sub { |
|
71
|
|
|
|
|
|
|
my $self = shift; |
|
72
|
|
|
|
|
|
|
my $resp = $self->route53->request('get', |
|
73
|
|
|
|
|
|
|
'https://route53.amazonaws.com/2010-10-01/' . $self->id); |
|
74
|
|
|
|
|
|
|
my @nameservers = |
|
75
|
|
|
|
|
|
|
map {decode_entities($_)} |
|
76
|
|
|
|
|
|
|
@{ $resp->{DelegationSet}{NameServers}{NameServer} }; |
|
77
|
|
|
|
|
|
|
\@nameservers; |
|
78
|
|
|
|
|
|
|
}); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head3 resource_record_sets |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Lazily loaded, returns a list of the resource record sets |
|
83
|
|
|
|
|
|
|
(L objects) for this zone. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has 'resource_record_sets' => ( |
|
88
|
|
|
|
|
|
|
is => 'rw', |
|
89
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
90
|
|
|
|
|
|
|
lazy => 1, |
|
91
|
|
|
|
|
|
|
default => sub { |
|
92
|
|
|
|
|
|
|
my $self = shift; |
|
93
|
|
|
|
|
|
|
my $next_record_name = ''; |
|
94
|
|
|
|
|
|
|
my @resource_record_sets; |
|
95
|
|
|
|
|
|
|
while (1) { |
|
96
|
|
|
|
|
|
|
my $resp = $self->route53->request('get', |
|
97
|
|
|
|
|
|
|
'https://route53.amazonaws.com/2010-10-01/' |
|
98
|
|
|
|
|
|
|
. $self->id |
|
99
|
|
|
|
|
|
|
. '/rrset?maxitems=100' |
|
100
|
|
|
|
|
|
|
. $next_record_name); |
|
101
|
|
|
|
|
|
|
my $set = $resp->{ResourceRecordSets}{ResourceRecordSet}; |
|
102
|
|
|
|
|
|
|
my @results = ref($set) eq 'ARRAY' ? @$set : ($set); |
|
103
|
|
|
|
|
|
|
for my $res (@results) { |
|
104
|
|
|
|
|
|
|
push @resource_record_sets, |
|
105
|
|
|
|
|
|
|
Net::Amazon::Route53::ResourceRecordSet->new( |
|
106
|
|
|
|
|
|
|
route53 => $self->route53, |
|
107
|
|
|
|
|
|
|
hostedzone => $self, |
|
108
|
|
|
|
|
|
|
name => decode_entities($res->{Name}), |
|
109
|
|
|
|
|
|
|
ttl => $res->{TTL} || 0, |
|
110
|
|
|
|
|
|
|
type => decode_entities($res->{Type}), |
|
111
|
|
|
|
|
|
|
values => [ |
|
112
|
|
|
|
|
|
|
map {decode_entities($_->{Value})} @{ |
|
113
|
|
|
|
|
|
|
ref $res->{ResourceRecords}{ResourceRecord} eq |
|
114
|
|
|
|
|
|
|
'ARRAY' |
|
115
|
|
|
|
|
|
|
? $res->{ResourceRecords}{ResourceRecord} |
|
116
|
|
|
|
|
|
|
: [ $res->{ResourceRecords}{ResourceRecord} ] } |
|
117
|
|
|
|
|
|
|
], |
|
118
|
|
|
|
|
|
|
); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
last unless $resp->{NextRecordName}; |
|
121
|
|
|
|
|
|
|
$next_record_name = '&name=' . $resp->{NextRecordName}; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
\@resource_record_sets; |
|
124
|
|
|
|
|
|
|
}); |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 METHODS |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head3 create |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Creates a new zone. Needs all the attributes (name, callerreference and comment). |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Takes an optional boolean parameter, C, to indicate whether the request should |
|
135
|
|
|
|
|
|
|
return straightaway (default, or when C is C<0>) or it should wait until the |
|
136
|
|
|
|
|
|
|
request is C according to the Change's status. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns a L object representing the change requested. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub create { |
|
143
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
144
|
0
|
|
|
|
|
|
my $wait = shift; |
|
145
|
0
|
0
|
|
|
|
|
$wait = 0 if !defined $wait; |
|
146
|
0
|
0
|
|
|
|
|
$self->name =~ /\.$/ |
|
147
|
|
|
|
|
|
|
or die "Zone name needs to end in a dot, to be created\n"; |
|
148
|
0
|
|
|
|
|
|
my $request_xml_str = <<'ENDXML'; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
%s |
|
152
|
|
|
|
|
|
|
%s |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
%s |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
ENDXML |
|
158
|
0
|
|
|
|
|
|
my $request_xml = sprintf($request_xml_str, |
|
159
|
0
|
|
|
|
|
|
map {$_} $self->name, |
|
160
|
|
|
|
|
|
|
$self->callerreference, $self->comment); |
|
161
|
0
|
|
|
|
|
|
my $resp = $self->route53->request( |
|
162
|
|
|
|
|
|
|
'post', |
|
163
|
|
|
|
|
|
|
'https://route53.amazonaws.com/2010-10-01/hostedzone', |
|
164
|
|
|
|
|
|
|
'content-type' => 'text/xml; charset=UTF-8', |
|
165
|
|
|
|
|
|
|
Content => $request_xml, |
|
166
|
|
|
|
|
|
|
); |
|
167
|
0
|
|
|
|
|
|
$self->id($resp->{HostedZone}{Id}); |
|
168
|
0
|
|
|
|
|
|
my $change = Net::Amazon::Route53::Change->new( |
|
169
|
|
|
|
|
|
|
route53 => $self->route53, |
|
170
|
|
|
|
|
|
|
( |
|
171
|
0
|
|
|
|
|
|
map {lc($_) => decode_entities($resp->{ChangeInfo}{$_})} |
|
172
|
|
|
|
|
|
|
qw/Id Status SubmittedAt/ |
|
173
|
|
|
|
|
|
|
), |
|
174
|
|
|
|
|
|
|
); |
|
175
|
0
|
|
|
|
|
|
$change->refresh(); |
|
176
|
0
|
0
|
|
|
|
|
return $change if !$wait; |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
while (lc($change->status) ne 'insync') { |
|
179
|
0
|
|
|
|
|
|
sleep 2; |
|
180
|
0
|
|
|
|
|
|
$change->refresh(); |
|
181
|
|
|
|
|
|
|
} |
|
182
|
0
|
|
|
|
|
|
return $change; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head3 delete |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Deletes the zone. A zone can only be deleted by Amazon's Route 53 service if it |
|
188
|
|
|
|
|
|
|
contains no records other than a SOA or NS. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Takes an optional boolean parameter, C, to indicate whether the request should |
|
191
|
|
|
|
|
|
|
return straightaway (default, or when C is C<0>) or it should wait until the |
|
192
|
|
|
|
|
|
|
request is C according to the Change's status. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Returns a L object representing the change requested. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub delete { |
|
199
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
200
|
0
|
|
|
|
|
|
my $wait = shift; |
|
201
|
0
|
0
|
|
|
|
|
$wait = 0 if !defined $wait; |
|
202
|
0
|
|
|
|
|
|
my $resp = |
|
203
|
|
|
|
|
|
|
$self->route53->request('delete', |
|
204
|
|
|
|
|
|
|
'https://route53.amazonaws.com/2010-10-01/' . $self->id, |
|
205
|
|
|
|
|
|
|
); |
|
206
|
0
|
|
|
|
|
|
my $change = Net::Amazon::Route53::Change->new( |
|
207
|
|
|
|
|
|
|
route53 => $self->route53, |
|
208
|
|
|
|
|
|
|
( |
|
209
|
0
|
|
|
|
|
|
map {lc($_) => decode_entities($resp->{ChangeInfo}{$_})} |
|
210
|
|
|
|
|
|
|
qw/Id Status SubmittedAt/ |
|
211
|
|
|
|
|
|
|
), |
|
212
|
|
|
|
|
|
|
); |
|
213
|
0
|
|
|
|
|
|
$change->refresh(); |
|
214
|
0
|
0
|
|
|
|
|
return $change if !$wait; |
|
215
|
0
|
|
|
|
|
|
while (lc($change->status) ne 'insync') { |
|
216
|
0
|
|
|
|
|
|
sleep 2; |
|
217
|
0
|
|
|
|
|
|
$change->refresh(); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
0
|
|
|
|
|
|
return $change; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
2
|
|
|
2
|
|
12
|
no Mouse; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
10
|
|
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 AUTHOR |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Marco FONTANI |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Marco FONTANI. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
233
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; |