20 Jan 2009 13:24:46 UTC
- Distribution: UltraDNS
- Module version: 0.06
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (409 / 2 / 13)
- KwaliteeBus factor: 0
- 88.00% Coverage
- License: unknown
- Activity24 month
- Download (20.48KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionTIMB Tim Bunce
Why not adopt me?This distribution is up for adoption! If you're interested then please contact the PAUSE module admins via email.
- LICENCE AND COPYRIGHT
- DISCLAIMER OF WARRANTY
UltraDNS - Client API for the NeuStar UltraDNS Transaction Protocol
use UltraDNS; # establish a secure connection my $udns = UltraDNS->connect("$host:$port", $sponsor, $username, $password); # Queue up one or more actions to be performed $udns->CreateARecord($zone); $udns->CreateCNAMERecord($zone); # Send actions as a single transaction $udns->commit(...); # throws exception on error # queue up and commit more requests on the same connection
Getting multiple results:
# Actions can return results. Each return value is a reference # to where the result will be stored when commit() is called. $result_ref1 = $udns->GetZoneInfo($zone); $result_ref2 = $udns->GetMXRecordsOfZone($zone); $udns->commit(...); # $result_ref values above now refer to the RPC::XML results for # each method, use ($$result_ref1)->value to get the value
Getting a single result:
# utility method that calls commit and returns the dereferenced result $result = $udns->do( ...some method that queues a request... ); $result = $udns->do( $udns->AutoSerialUpdateState ); # $result is either 1 or 0 (no need to deref or call value() method) # also works for multiple method calls @results = $udns->do( ...multiple method calls... );
A simple and efficient client for the NeuStar UltraDNS Transaction Protocol as defined in http://www.ultradns.net/api/NUS_API_XML.pdf (version 3.0, dated September 5, 2008).
All requests are batched and performed in transactions. A single secure connection is established and reused for any number of transactions. Multiple concurrent connections can be used if required.
All errors are reported via exceptions.
All UltraDNS methods are supported.
Experimentation and feedback are encouraged.
$udns = UltraDNS->connect($host_and_port, $sponsor, $username, $password, $attr);
Establish a secure
httpsconnection to the specified UltraDNS host and port, and login using the specified $sponsor, $username, $password.
UltraDNSobject. Throws an exception on error.
The optional $attr parameter is a reference to a hash of attributes:
Specifies the integer trace (debug) level. 0 for none, 1 for basic tracing, and 2 and above for more detailed, and more verbose, tracing. Trace messages are output via
Sets $Net::SSLeay::trace. 0=no warns, 1=only errors, 2=ciphers, 3=progress, 4=dump data. See Net::SSLeay for more information.
Specifies the protocol version argument value used in the
See UltraDNS::Methods for a list of the UltraDNS Transaction Protocol methods you can call once a connection is established.
Submits the queued requests. An exception is thown on error.
Discards the queued requests.
$result = $udns->do( $udns->SomeMethodThatReturnsAResult(...) );
A convienience method that calls commit() and returns the de-referenced argument. The one-line call has the same effect as these three lines:
$result_ref = $udns->SomeMethodThatReturnsAResult(...); $udns->commit; $result = $$result_ref; # de-reference to get return value
but is much more convienient when you just want to get a value from the server.
Multiple calls can be combined into a single request like this:
my ($a, $b, $c) = $udns->do( $udns->MethodReturningA(...), $udns->MethodReturningB(...), $udns->MethodReturningC(...) );
Just like the "do" method except any exception will be caught. This is useful for cases where an error is expected, such as deleting a record in the server that may not exist.
XXX currently it catches all exceptions, it's expected that in future it will only catch exceptions due to server-reported error.
$err = $udns->err;
Returns the error code from the server for the last transaction, else 0.
$errstr = $udns->errstr;
Returns the error message from the server for the last transaction, else an empty string.
$udns->trace($level); $prev = $udns->trace($level); $prev = $udns->trace;
Sets the new trace level, if a value is supplied. 0 = off, 1 = basic overview, 2+ = more details. Returns the previous level.
A transaction can only contain 10 requests by default because the UltraDNS module calls UDNS_NoAutoCommit on connection, to ensure reliability, and NeuStar impose the 10 requests per transaction limit. This shouldn't be a problem in practice because transactions are cheap (since they reuse the same connection) so you can issue your requests grouped into multiple transactions.
The NeuStar UltraDNS documentation never mentions character encoding. So, for better or worse, we don't explicitly use any either. That ought to mean UTF-8 encoding, but I've not tried to test what UltraDNS does on the server side. The underlying RPC::XML code (as of version 0.64) uses "us-ascii" but doesn't perform entity encoding. Overall it seems likely that non-ASCII values might get mangled.
NeuStar have dug a hole for themselves and their users with the handling of the boolean type. At the start of the docs it says:
Boolean (0-false, 1-true)
and, indeed, that all what their examples use. All, that is, except the "Zone ACL Requests" methods. For those the docs say:
Note: Specify Boolean values as either True or False.
Clearly something's wrong! Currently I'm taking the view that those methods should be changed to use a standard boolean, or a new UltraDNS specific type. So, for now, you're out of luck if you want to call those methods, unless you want to do a little hacking to get the UltraDNS code to treat the args to those methods as strings.
Please report any bugs or feature requests to
email@example.com, or through the web interface at http://rt.cpan.org.
Copyright (c) 2009, TigerLead.com. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.