API-DirectAdmin
view release on metacpan or search on metacpan
lib/API/DirectAdmin.pm view on Meta::CPAN
passwd => 'user_password',
passwd2 => 'user_password',
domain => 'example.com',
email => 'email@example.com',
package => 'package_name',
ip => 'IP.ADD.RE.SS',
});
=item delete
Delete DirectAdmin user and all user's data
Note: Some DirectAdmin's API methods required parameter "select0" for choose value from list. Like list of users, databases, ip, etc.
Example:
my $result = $da->user->delete( {
select0 => 'username',
} );
=item disable/enable
Two different methods for disable and enable users with same params.
lib/API/DirectAdmin.pm view on Meta::CPAN
$result = $da->domain->add({
domain => 'newdomain.com',
php => 'ON',
cgi => 'ON',
});
=back
=head2 API::DirectAdmin::Mysql
Control users mysql databases
=over
=item list
List of databases from user. Return empty array if databases not found.
Example:
print $da->mysql->list();
=item adddb
Add database to user. Prefix "username_" will be added to 'name' and 'user';
Example:
my %auth = (
auth_user => 'admin_name|customer',
auth_passwd => 'admin_passwd',
host => '11.22.33.44',
);
# init
lib/API/DirectAdmin.pm view on Meta::CPAN
my $result = $da->mysql->adddb( {
name => 'default', # will be 'customer_default'
user => 'default', # will be 'customer_default'
passwd => 'password',
passwd2 => 'password',
} );
=item deldb
Delete selected database from user.
Example:
my $result = $da->mysql->deldb({ select0 => 'database_name' });
=back
=head2 API::DirectAdmin::Ip
=over
=item list
Return array reference of list ip adresses;
lib/API/DirectAdmin/DNS.pm view on Meta::CPAN
my $zentry = qr/^
(\S+)\s+ # name
(
(?: (?: IN | CH | HS ) \s+ \d+ \s+ ) |
(?: \d+ \s+ (?: IN | CH | HS ) \s+ ) |
(?: (?: IN | CH | HS ) \s+ ) |
(?: \d+ \s+ ) |
)? # <ttl> <class> or <class> <ttl>
(\S+)\s+ # type
(.*) # rdata
$/ix;
foreach ( split /\n+/, $zonetext ) {
chomp;
s/;.*$//;
next if /^\s*$/;
s/\s+/ /g;
s/^\@ /$origin /g;
lib/API/DirectAdmin/DNS.pm view on Meta::CPAN
$mrow.=$_;
next;
}
if(/^ /) {
s/^/$prev/;
}
$origin = $1, next if(/^\$ORIGIN ([\w\-\.]+)\s*$/i);
my($name,$ttlclass,$type,$rdata) = /$zentry/;
my($ttl, $class);
if(defined $ttlclass) {
($ttl) = $ttlclass=~/(\d+)/o;
($class) = $ttlclass=~/(CH|IN|HS)/io;
$ttlclass=~s/\d+//;
$ttlclass=~s/(?:CH|IN|HS)//;
$ttlclass=~s/\s//g;
if($ttlclass) {
next;
}
}
$ttl = defined $ttl ? $ttl : 14400;
next if (!$name || !$type || !$rdata);
$prev=$name;
$name.=".$origin" if $name ne $origin && $name !~ /\.$/;
if($type =~ /^(?:cname|afsdb|mx|ns)$/i and
$rdata ne $origin and $rdata !~ /\.$/) {
$rdata.=".$origin";
}
push(@{$zone{lc $name}{lc $type}{rdata}}, $rdata);
push(@{$zone{lc $name}{lc $type}{ttl}}, $ttl);
push(@{$zone{lc $name}{lc $type}{class}}, $class);
}
return \%zone;
}
1;
lib/API/DirectAdmin/Domain.pm view on Meta::CPAN
use Modern::Perl '2010';
use Data::Dumper;
use base 'API::DirectAdmin::Component';
our $VERSION = 0.05;
# Return domains list
# INPUT
# connection data for USER, not admin
sub list {
my ($self ) = @_;
my $responce = $self->directadmin->query(
command => 'CMD_API_SHOW_DOMAINS',
);
return $responce->{list} if ref $responce eq 'HASH';
return [];
}
lib/API/DirectAdmin/Mysql.pm view on Meta::CPAN
package API::DirectAdmin::Mysql;
use Modern::Perl '2010';
use Data::Dumper;
use Carp;
use base 'API::DirectAdmin::Component';
our $VERSION = 0.05;
# Create database for user
# Connection data MUST BE for user: auth_user => 'admin_login|user_login'
# auth_passwd => 'admin_passwd'
# INPUT
# name => 'DBNAME',
# passwd => 'DBPASSWD',
# passwd2 => 'DBPASSWD',
# user => 'DBLOGIN',
sub adddb {
my ($self, $params ) = @_;
$params->{action} = 'create';
lib/API/DirectAdmin/Mysql.pm view on Meta::CPAN
user',
);
carp '$responce ' . Dumper(\$responce) if $self->{debug};
return $responce if $responce;
return 'FAIL';
}
# Delete database for user
# Connection data MUST BE for user: auth_user => 'admin_login|user_login'
# auth_passwd => 'admin_passwd'
# INPUT
# select0 => 'DBNAME',
# domain => 'DOMAIN.COM',
sub deldb {
my ($self, $params ) = @_;
$params->{action} = 'delete';
carp 'params ' . Dumper($params) if $self->{debug};
lib/API/DirectAdmin/Mysql.pm view on Meta::CPAN
select0',
);
carp '$responce ' . Dumper(\$responce) if $self->{debug};
return $responce if $responce;
return 'FAIL';
}
# Get list of databases for authorized user.
# No params.
sub list {
my ($self ) = @_;
my $responce = $self->directadmin->query(
command => 'CMD_API_DATABASES',
method => 'GET',
);
carp '$responce ' . Dumper($responce) if $self->{debug};
t/01-test.t view on Meta::CPAN
my $ip_list = $da->ip->list();
my $main_shared_ip = $ip_list->[0];
ok($ip_list && ref $ip_list eq 'ARRAY' && scalar @$ip_list, 'API::DirectAdmin::Ip::list');
my %answer = (
text => "User $manipulate_user created",
error => 0,
details => 'Unix User created successfully
Users System Quotas set
Users data directory created successfully
Domains directory created successfully
Domains directory created successfully in users home
Domain Created Successfully');
$da->{fake_answer} = ! $ONLINE ? \%answer : undef;
# User
use_ok('API::DirectAdmin::User');
my $result = $da->user->create(
( run in 0.646 second using v1.01-cache-2.11-cpan-8d75d55dd25 )