API-DirectAdmin

 view release on metacpan or  search on metacpan

lib/API/DirectAdmin/User.pm  view on Meta::CPAN

package API::DirectAdmin::User;

use Modern::Perl '2010';
use Carp;

use base 'API::DirectAdmin::Component';

our $VERSION = 0.06;

# Return list of users (only usernames)
sub list {
    my ($self ) = @_;

    my $responce = $self->directadmin->query(
	command => 'CMD_API_SHOW_ALL_USERS',
    );

    return $responce->{list} if ref $responce eq 'HASH';
    return [];
}

# Create a New User
# params: username, domain, passwd, passwd2, package, ip, email
sub create {
    my ($self, $params ) = @_;
    
    my %add_params = (
	action   => 'create',
	add      => 'submit',
	notify 	 => 'no',
    );
    
    my %params = (%$params, %add_params);

    my $responce = $self->directadmin->query(
	params         => \%params,
	command        => 'CMD_API_ACCOUNT_USER',
	allowed_fields =>
	   'action
	    add
	    notify
	    username
	    domain
	    passwd
	    passwd2
	    package
	    ip
	    email',
    );

    carp "Creating account: $responce->{text}, $responce->{details}" if $self->{debug};
    return $responce;
}

# Suspend user
# params: select0
sub disable {
    my ($self, $params ) = @_;
     
     my %add_params = (
	suspend	 => 'Suspend',
	location => 'CMD_SELECT_USERS',
    );

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.341 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )