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

NAME

WWW::DirectAdmin::API - Access the DirectAdmin API with Perl

VERSION

Version 0.01

SYNOPSIS

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";

METHODS

new

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)

error

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

uri

Returns URI object

debug_level( $boolean )

Set debug level after object construction.

At this time debugging can be enabled with '1' or disabled with '0'.

USER LEVEL API

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.

get_domains

Returns list of domains

  my @domains = $da->get_domains;

get_subdomains

Returns list of subdomains

  my @subdomains = $da->get_subdomains;

create_subdomain( subdomain => 'name' )

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

delete_subdomain( subdomain => 'name', contents => 'yes|no' )

Deletes subdomain and if contents are set to 'yes' (default) then directory underneath.

get_databases

Returns list of databases

create_database( %params )

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

delete_database( name => 'database name' )

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'

ADMIN LEVEL API

Very little of this is implemented today. More to come in later releases.

get_users

Retrieves list of users

AUTHOR

Lee Carmichael, <lcarmich at cpan.org>

BUGS

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.

SUPPORT

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

    perldoc WWW::DirectAdmin::API

You can also look for information at:

LICENSE AND COPYRIGHT

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.