DNS-PunyDNS
view release on metacpan or search on metacpan
lib/DNS/PunyDNS.pm view on Meta::CPAN
'type' => $info->{'type'},
);
push @domain_info, \%tmp_info;
}
return \@domain_info;
} ## end sub get_dns_info
sub list_dns_info {
my ($self) = @_;
my $response = $self->_get_it($LISTDNSINFO);
my @domains = ();
if ( $response->{'domains'}{'domain'} ) {
if ( ref( $response->{'domains'}{'domain'} ) eq 'ARRAY' ) {
push @domains, @{ $response->{'domains'}{'domain'} };
} else {
push @domains, $response->{'domains'}{'domain'};
}
}
return \@domains;
}
sub list_dns {
my ($self) = @_;
my $response = $self->_get_it($LISTDNS);
my @domains = ();
if ( $response->{'domain'} ) {
if ( ref( $response->{'domains'} ) eq 'ARRAY' ) {
push @domains, @{ $response->{'domain'} };
} else {
push @domains, $response->{'domain'};
}
}
return \@domains;
}
sub _build_request {
my ( $self, $endpoint, $args ) = @_;
$args->{'ESBUsername'} = $self->{'username'};
$args->{'ESBPassword'} = $self->{'password'};
$args->{'lang'} = 'en';
my @keys = keys %{$args};
my $url = $BASE_URL . $endpoint . '?' . join( '&', map { $_ . '=' . $args->{$_} } @keys );
return $url;
}
sub _get_it {
my ( $self, $endpoint, $args ) = @_;
my $url = $self->_build_request( $endpoint, $args );
delete $self->{'error'};
my $ua = new LWP::UserAgent();
my $req = new HTTP::Request( 'GET', $url );
my $response = $ua->request($req);
if ( $response->is_success ) {
my $content = $response->content;
my $decoded_content = XMLin( \$content, KeyAttr => 'domain' );
if ( $decoded_content->{'error'} ) {
$self->{'error'} = $decoded_content->{'error'};
}
return $decoded_content;
} else {
die "There was a problem with the request\n" . $response->status_line;
}
} ## end sub _get_it
=head1 AUTHOR
Bruno Martins, C<< <bruno-martins at telecom.pt> >>
=head1 NOTES
=head2 Handling Errors
There are several ways that the operations can fail, for example, you can try to add a dns entry that already exists or you can try to update a dns entry that is not under your account, etc.
Each time an operation is executed and raises an error C<< $dns->{'error'} >> is set with the error reason.
=head2 SAPO dynamic DNS API authentication
SAPO dynamic DNS API is only available over https, so your username and password are not sent I<clean>
=head2 Record Types
SAPO dynamic DNS API only allows A and AAAA record types
=head2 Domain names
At this time, SAPO dynamic DNS only allows .sl.pt domains
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc DNS::PunyDNS
You can also look for information at:
=over 4
=item * Search CPAN
L<http://search.cpan.org/dist/DNS::PunyDNS/>
=back
=head1 LICENSE AND COPYRIGHT
Copyright 2011 Bruno Martins C<< <bruno-martins at telecom.pt> >> and SAPO L<http://www.sapo.pt>, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
( run in 1.915 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )