WWW::DirectAdmin::API - Access the DirectAdmin API with Perl
Version 0.01
This will provide access to the DirectAdmin API. The DirectAdmin API has three levels Admin, Reseller and User functions.
At this time, this API only implements the User level functions. I am open to adding others but at time of initial creation I didn't need those.
Please read http://www.directadmin.com/api.html for details.
use WWW::DirectAdmin::API; my $da = WWW::DirectAdmin::API->new( host => 'example.com', user => 'username', pass => 'password', domain => 'example-example.com' ); my @domains = $da->get_domains; print "You have: ", join( ',', @domains ), "\n"; my @subdomains = $da->get_subdomains; print "You have: ", join( ',', @subdomains ), "\n";
Creates new WWW::DirectAdmin::API object. Parameters are passed in as name value pairs. e.g. host => 'example.com'
host
port (optional, default: 2222)
username
password
domain - user's require this for most user actions (e.g. example.com)
ua - LWP::UserAgent object (optional)
https - set to true to use HTTPS (default: false)
debug - Output debug logging (optional)
Returns hash with error keys from API calls. This is not always populated since maybe calls don't return error messages.
Usage:
if ( defined $da->error->{details} ) { print "Error details: ", $da->error->{details}, "\n"; }
These are possible keys:
text
details
Returns URI object
Set debug level after object construction.
At this time debugging can be enabled with '1' or disabled with '0'.
User level API commands.
All create or delete commands return true on success and throw exception in case of error.
You can check error method for hash of error details.
error
Returns list of domains
my @domains = $da->get_domains;
Returns list of subdomains
my @subdomains = $da->get_subdomains;
Creates new subdomain
if ( create_subdomain( subdomain => 'perlrocks' ) { print "Created subdomain\n"; } else { print "Booo! failed to create subdomain\n"; print "Error: ", $da->error->{details}, "\n"; }
Returns true on success, false on error
Deletes subdomain and if contents are set to 'yes' (default) then directory underneath.
Returns list of databases
Create new database with user
Parameters
name - database name
user - database username (according to API doc will append current username to it)
passwd - password
passwd2 - confirm password
Deletes database
Note: Database names have current username automatically prefixed when created by DirectAdmin. In delete call name must include username prefix. e.g. 'username_dbname'
Very little of this is implemented today. More to come in later releases.
Retrieves list of users
Lee Carmichael, <lcarmich at cpan.org>
<lcarmich at cpan.org>
Please report any bugs or feature requests to bug-www-directadmin-api at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-DirectAdmin-API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-www-directadmin-api at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc WWW::DirectAdmin::API
You can also look for information at:
DirectAdmin API http://www.directadmin.com/api.html
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-DirectAdmin-API
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WWW-DirectAdmin-API
CPAN Ratings
http://cpanratings.perl.org/d/WWW-DirectAdmin-API
Search CPAN
http://search.cpan.org/dist/WWW-DirectAdmin-API/
Copyright 2012 Lee Carmichael.
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.
To install WWW::DirectAdmin::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::DirectAdmin::API
CPAN shell
perl -MCPAN -e shell install WWW::DirectAdmin::API
For more information on module installation, please visit the detailed CPAN module installation guide.