NAME

API::DirectAdmin - interface to the DirectAdmin Hosting Panel API ( http://www.directadmin.com )

SYNOPSIS

use API::DirectAdmin;

my %auth = (
   auth_user   => 'admin_name',
   auth_passwd => 'admin_passwd',
   host        => '11.22.33.44',
);

# init
my $da = API::DirectAdmin->new(%auth);

### Get all panel IP
my $ip_list = $da->ip->list();

unless ($ip_list && ref $ip_list eq 'ARRAY' && scalar @$ip_list) {
   die 'Cannot get ip list from DirectAdmin';
}

my $ip  = $ip_list->[0];
my $dname  = 'perlaround.ru';
my $user_name = 'user1';
my $email = 'user1@example.com';
my $package = 'newpackage';

my $client_creation_result = $da->user->create( {
   username => $user_name,
   passwd   => 'user_password',
   passwd2  => 'user_password',
   domain   => $dname,
   email    => $email,
   package  => $package,
   ip       => $ip,
});

# Switch off account:
my $suspend_result = $da->user->disable( {
   select0 => $user_name,
} );

if ( $suspend_result->{error} == 1 ) {
   die "Cannot  suspend account $suspend_result->{text}";
}



# Switch on account
my $resume_result = $da->user->enable( {
   select0 => $user_name,
} );

if ( $resume_result->{error} == 1 ) {
   die "Cannot Resume account $resume_result->{text}";
}



# Delete account
my $delete_result = $da->user->delete( {
   select0 => $user_name,
} );

if ( $delete_result->{error} == 1 ) {
   die "Cannot delete account $delete_result->{text}";
}

INSTALLATION

To install this module type the following:

perl Makefile.PL
make
make test
make install

DEPENDENCIES

This module requires these other modules and libraries: LWP::UserAgent HTTP::Request URI Carp Data::Dumper

COPYRIGHT AND LICENCE

Put the correct copyright and licence information here.

Copyright (C) 2012 by Andrey "Chips" Kuzmin

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.