API-DirectAdmin
view release on metacpan or search on metacpan
lib/API/DirectAdmin.pm view on Meta::CPAN
}
my $ip = $ip_list->[0];
my $dname = 'reg.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,
} );
lib/API/DirectAdmin.pm view on Meta::CPAN
my $users_list = $da->users->list();
=item create
Create a new user in DirectAdmin panel.
Example:
my $result = $da->user->create( {
username => 'username',
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
lib/API/DirectAdmin.pm view on Meta::CPAN
Example:
my $disable_result = $da->user->disable( {
select0 => 'username',
} );
my $enable_result = $da->user->enable( {
select0 => 'username',
} );
=item change_password
Change password for user
Example:
my $result = $da->user->change_password( {
username => 'username',
passwd => 'new_password',
passwd2 => 'new_password',
} );
=item change_package
Change package (tariff plan) for user
Example:
my $result = $da->user->change_package( {
username => 'username',
package => 'new_package',
} );
=item show_packages
Return list of available packages.
Note: If you created packages through administrator user - you must use admin's login and password for authorisation. Obviously, if packages was created by reseller user - use reseller authorisation.
Example:
my $packages = $da->user->show_packages();
=item show_user_config
Return all user settings.
Example:
lib/API/DirectAdmin.pm view on Meta::CPAN
Return list of domains on server.
Example:
my $domains = $da->domain->list();
=item add
Add new domain to user through you connect to server.
Note: For adding domains for customers and you don't khow their password use: auth_user = 'admin_name|customer_name' in auth hash.
Example:
my %auth = (
auth_user => 'admin_name|customer_name',
auth_passwd => 'admin_passwd',
host => '11.22.33.44',
);
# init
lib/API/DirectAdmin.pm view on Meta::CPAN
auth_passwd => 'admin_passwd',
host => '11.22.33.44',
);
# init
my $da = API::DirectAdmin->new(%auth);
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' });
lib/API/DirectAdmin/User.pm view on Meta::CPAN
delete
select0',
);
carp "Delete account: $responce->{text}, $responce->{details}" if $self->{debug};
return $responce;
}
# Change passwd
# params: username, passwd, passwd2
sub change_password {
my ($self, $params ) = @_;
my $responce = $self->directadmin->query(
command => 'CMD_API_USER_PASSWD',
method => 'POST',
params => $params,
allowed_fields => 'passwd
passwd2
username',
);
t/01-test.t view on Meta::CPAN
is_deeply( $result, \%answer, 'API::DirectAdmin::User::create repeat');
%answer = (
text => 'Password Changed',
error => 0,
details => 'Password successfully changed'
);
$da->{fake_answer} = ! $ONLINE ? \%answer : undef;
$result = $da->user->change_password(
{
user => $manipulate_user,
pass => 'sdfdsfsdfhsdfj',
}
);
is_deeply( $result, \%answer, 'API::DirectAdmin::User::change_password');
%answer = (
text => 'Success',
error => 0,
details => 'All selected Users have been suspended',
);
$da->{fake_answer} = ! $ONLINE ? \%answer : undef;
$result = $da->user->disable(
( run in 0.755 second using v1.01-cache-2.11-cpan-49f99fa48dc )