DNS-PunyDNS
view release on metacpan or search on metacpan
lib/DNS/PunyDNS.pm view on Meta::CPAN
DNS::PunyDNS->new( { 'username' => '<sapousername>', 'password' => '<sapopassword>' } )
Your SAPO username and password must be provided.
=head2 add_dns
Adds a dynamic DNS entry.
$dns->add_dns( $domain, $ip, $record_type );
This function returns false if the operation fails, the cause of the failure is set in C<< $dns->{'error'} >>.
=head2 update_dns
Updates a dynamic DNS entry.
$dns->update_dns( $domain, $ip, $record_type, [$old_record_type]);
This function returns false if the operation fails, the cause of the failure is set in C<< $dns->{'error'} >>.
=head2 get_dns_info
Gets DNS information of a specific entrry.
my $info = $dns->get_dns_info( $domain );
=head2 list_dns
Gets all the dynamic DNS entry names associated with your account.
my $list = $dns->list_dns();
=head2 list_dns_info
Gets all the dynamic DNS entrys information.
my $list_info = $dns->list_dns_info();
=head2 remove_dns
Removes a DNS entry.
$removed = $dns->remove_dns( $domain, [$record_type] );
This function returns false if the operation fails, the cause of the failure is set in C<< $dns->{'error'} >>.
=cut
sub new {
my ( $class, @args ) = @_;
my $self = {};
bless $self, $class || $class;
$self->{'username'} = $args[0]->{'username'} || die "No username provided";
$self->{'password'} = $args[0]->{'password'} || die "No password provided";
return $self;
}
sub update_dns {
my ( $self, $domain, $ip, $record_type, $old_record_type ) = @_;
die "You must provide a domain" if !$domain;
die "You must provide an IP address" if !$ip;
my %args = (
'domain' => $domain,
'ip' => $ip,
'record_type' => $record_type,
);
$args{'old_record_type'} = $old_record_type if $old_record_type;
my $response = $self->_get_it( $UPDATEDNS, \%args );
return $response;
}
sub remove_dns {
my ( $self, $domain, $record_type ) = @_;
die "You must provide a domain" if !$domain;
my %args = ( 'domain' => $domain );
$args{'record_type'} = $record_type if $record_type;
my $response = $self->_get_it( $REMOVEDNS, \%args );
return 0 if ( $self->{'error'} );
return 1;
}
sub add_dns {
my ( $self, $domain, $ip, $record_type ) = @_;
die "You must provide a domain" if !$domain;
die "You must provide an IP address" if !$ip;
die "You must provide a Record Type" if !$record_type;
my $response = $self->_get_it(
$ADDDNS,
{
'domain' => $domain,
'ip' => $ip,
'record_type' => $record_type
} );
return 0 if ( $self->{'error'} );
return 1;
}
sub get_dns_info {
my ( $self, $domain ) = @_;
die "You must provide a domain to check" if ( !$domain );
my $response = $self->_get_it( $GETDNSINFO, { 'domain' => $domain } );
return if ( $self->{'error'} );
my @domain_info = ();
my $info = $response->{'info'};
if ( ref($info) eq 'ARRAY' ) {
for my $dnsinfo ( @{$info} ) {
my %tmp_info;
$tmp_info{'domain'} = $response->{'domain'};
$tmp_info{'ip'} = $dnsinfo->{'ip'};
$tmp_info{'type'} = $dnsinfo->{'type'};
push @domain_info, \%tmp_info;
}
} else {
my %tmp_info = (
'domain' => $response->{'domain'},
'ip' => $info->{'ip'},
( run in 2.812 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )