The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Namecheap::DNS - Namecheap API DNS methods

SYNOPSIS

Namecheap API DNS methods.

See WWW::Namecheap::API for main documentation.

    use WWW::Namecheap::DNS;

    my $dns = WWW::Namecheap::DNS->new(API => $api);
    $dns->sethosts(...);
    ...

SUBROUTINES/METHODS

WWW::Namecheap::Domain->new(API => $api)

Instantiate a new DNS object for making DNS-related API calls. Requires a WWW::Namecheap::API object.

$dns->setnameservers(%hash)

Set the nameservers used by a domain under your management. They may be set to custom nameservers or the Namecheap default nameservers.

    my $result = $dns->setnameservers(
        DomainName => 'example.com',
        Nameservers => [
            'ns1.example.com',
            'ns2.example.com',
        ],
        DefaultNS => 0,
    );

or, for the Namecheap default:

    my $result = $dns->setnameservers(
        DomainName => 'example.com',
        DefaultNS => 1,
    );

$result is a small hashref confirming back the domain that was modified and whether the operation was successful or not:

    $result = {
        Domain => 'example.com',
        Update => 'true',
    };

$dns->getnameservers(DomainName => 'example.com')

Get a list of nameservers currently associated with a domain under your management. Returns a data structure that looks like this:

    $nameservers = {
        Domain => 'example.com',
        IsUsingOurDNS => 'true', # if using the "default NS" option
        Nameserver => [
            'ns1.example.com',
            'ns2.example.com',
        ],
    };

$dns->gethosts(DomainName => 'example.com')

Get a list of DNS hosts for a domain name under management and using the Namecheap provided DNS service. Returns a data structure as follows:

    $hosts = {
        Domain => 'example.com',
        IsUsingOurDNS => 'true',
        Host => [
            {
                HostId => '10',
                Name => '@',
                Type => 'A',
                Address => '1.2.3.4',
                MXPref => 10, # yes, even for non-MX records
            },
            ...
        ],
    };

See the documentation for the sethosts() method for more details of the possible values of each of these fields.

$dns->sethosts

Set DNS hosts for a domain.

IMPORTANT NOTE: You must include all hosts for the domain in your sethosts command, any hosts not present in the command but previously present in the domain configuration will be deleted. You can simply modify the arrayref you get back from gethosts and pass it back in, we'll even strip out the HostIds for you! :)

    my $result = $dns->sethosts(
        DomainName => 'example.com',
        Hosts => [
            {
                Name => 'foo', # do not include domain name
                Type => 'A',
                Address => '1.2.3.4',
                TTL => 1800, # optional, default 1800
            },
            {
                Name => '@', # for example.com itself
                Type => 'MX',
                Address => 'mail.example.com',
                MXPref => 10,
            },
        ],
        EmailType => 'MX', # or 'MXE' or 'FWD'
    );

Results in a not very useful response:

    $result = {
        Domain => 'example.com',
        IsSuccess => 'true', # or false
    };

Further verification can be performed using a subsequent gethosts() call.

Possible values for "Type" are listed below. All relevant data (including URLs for the URL, URL301, and FRAME types) goes into the "Address" field.

 * A
 * AAAA
 * CNAME
 * MX
 * MXE
 * TXT
 * URL
 * URL301
 * FRAME

Type=MXE expects an IP address and synthesizes appropriate MX and host records.

$dns->api()

Accessor for internal API object.

AUTHOR

Tim Wilde, <twilde at cpan.org>

BUGS

Please report any bugs or feature requests to bug-www-namecheap-api at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Namecheap-API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc WWW::Namecheap::DNS

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Tim Wilde.

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.