| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 2 |  |  | 2 |  | 11 | use strict; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 63 |  | 
| 2 | 2 |  |  | 2 |  | 10 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 96 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package Net::Amazon::Route53::ResourceRecordSet::Change; | 
| 5 |  |  |  |  |  |  | { | 
| 6 |  |  |  |  |  |  | $Net::Amazon::Route53::ResourceRecordSet::Change::VERSION = '0.123250'; | 
| 7 |  |  |  |  |  |  | } | 
| 8 | 2 |  |  | 2 |  | 9 | use Mouse; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 10 |  | 
| 9 |  |  |  |  |  |  | extends "Net::Amazon::Route53::ResourceRecordSet"; | 
| 10 | 2 |  |  | 2 |  | 552 | use HTML::Entities; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 723 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head2 SYNOPSIS | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | my $record_change = Net::Amazon::Route53::ResourceRecordSet::Change->new( | 
| 15 |  |  |  |  |  |  | name            => "example.com", | 
| 16 |  |  |  |  |  |  | ttl             => 600, | 
| 17 |  |  |  |  |  |  | type            => "A", | 
| 18 |  |  |  |  |  |  | values          => [ "new_value1","new_value2", ], | 
| 19 |  |  |  |  |  |  | original_values => [ "old_value1", "old_value2", ], | 
| 20 |  |  |  |  |  |  | ); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =cut | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head2 ATTRIBUTES | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =cut | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =head3 original_values | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | The values associated with this resource record. | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =cut | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | has 'original_values' => | 
| 35 |  |  |  |  |  |  | (is => 'rw', isa => 'ArrayRef', required => 1, default => sub {[]}); | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =head2 METHODS | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =cut | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =head3 change | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | This method changes the value of a record from original_value X to value Y. | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | my $record = Net::Amazon::Route53::ResourceRecordSet::Change->new( | 
| 46 |  |  |  |  |  |  | name            => "example.com", | 
| 47 |  |  |  |  |  |  | ttl             => 600, | 
| 48 |  |  |  |  |  |  | type            => "A", | 
| 49 |  |  |  |  |  |  | values          => [ "new_value1","new_value2", ], | 
| 50 |  |  |  |  |  |  | original_values => [ "old_value1", "old_value2", ], | 
| 51 |  |  |  |  |  |  | ); | 
| 52 |  |  |  |  |  |  | my $change = $record->change(1); # Set the 1 if you want to wait. | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | =cut | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub change { | 
| 57 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 58 | 0 |  |  |  |  |  | my $wait = shift; | 
| 59 | 0 | 0 |  |  |  |  | $wait = 0 if !defined $wait; | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 0 |  |  |  |  |  | my $request_xml_str = <<'ENDXML'; | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | This change batch updates the %s record from original_values to values | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | DELETE | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | %s | 
| 71 |  |  |  |  |  |  | %s | 
| 72 |  |  |  |  |  |  | %s | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | %s | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | CREATE | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | %s | 
| 82 |  |  |  |  |  |  | %s | 
| 83 |  |  |  |  |  |  | %s | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | %s | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | ENDXML | 
| 93 | 0 |  |  |  |  |  | my $request_xml = sprintf( | 
| 94 |  |  |  |  |  |  | $request_xml_str, | 
| 95 | 0 |  |  |  |  |  | (map {$_} ($self->type, $self->name, $self->type, $self->ttl,)), | 
| 96 |  |  |  |  |  |  | join("\n", | 
| 97 | 0 |  |  |  |  |  | map {"" . $_ . ""} | 
| 98 | 0 |  |  |  |  |  | @{ $self->original_values }), | 
| 99 | 0 |  |  |  |  |  | (map {$_} ($self->name, $self->type, $self->ttl,)), | 
| 100 |  |  |  |  |  |  | join("\n", | 
| 101 | 0 |  |  |  |  |  | map {"" . $_ . ""} | 
| 102 | 0 |  |  |  |  |  | @{ $self->values })); | 
| 103 |  |  |  |  |  |  |  | 
| 104 | 0 |  |  |  |  |  | my $resp = $self->route53->request( | 
| 105 |  |  |  |  |  |  | 'post', | 
| 106 |  |  |  |  |  |  | 'https://route53.amazonaws.com/2010-10-01/' | 
| 107 |  |  |  |  |  |  | . $self->hostedzone->id | 
| 108 |  |  |  |  |  |  | . '/rrset', | 
| 109 |  |  |  |  |  |  | Content => $request_xml | 
| 110 |  |  |  |  |  |  | ); | 
| 111 | 0 |  |  |  |  |  | my $change = Net::Amazon::Route53::Change->new( | 
| 112 |  |  |  |  |  |  | route53 => $self->route53, | 
| 113 |  |  |  |  |  |  | ( | 
| 114 | 0 |  |  |  |  |  | map {lc($_) => decode_entities($resp->{ChangeInfo}{$_})} | 
| 115 |  |  |  |  |  |  | qw/Id Status SubmittedAt/ | 
| 116 |  |  |  |  |  |  | ), | 
| 117 |  |  |  |  |  |  | ); | 
| 118 | 0 |  |  |  |  |  | $change->refresh(); | 
| 119 | 0 | 0 |  |  |  |  | return $change if !$wait; | 
| 120 |  |  |  |  |  |  |  | 
| 121 | 0 |  |  |  |  |  | while (lc($change->status) ne 'insync') { | 
| 122 | 0 |  |  |  |  |  | sleep 2; | 
| 123 | 0 |  |  |  |  |  | $change->refresh(); | 
| 124 |  |  |  |  |  |  | } | 
| 125 | 0 |  |  |  |  |  | return $change; | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  |  | 
| 128 | 2 |  |  | 2 |  | 9 | no Mouse; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 9 |  | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =head1 AUTHOR | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | Marco FONTANI | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | This software is copyright (c) 2011 by Marco FONTANI. | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 139 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =cut | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | 1; |