lib/API/DirectAdmin/Mysql.pm

filter: Statementstmt 60.6% 20 / 33 Branchbran 18.7% 3 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 3 totaltotal 47.4% 28 / 59 CC 9 SCAR 22.2
CC
9
Cov
47%
deldb
20.0
list
12.0
adddb
4.5
CRAP 9.2
« lib/API/DirectAdmin.pm ↑ Summary lib/API/DirectAdmin/Domain.pm »
1 package API::DirectAdmin::Mysql;
2  
3 1 ▶use Modern::Perl '2010';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base 'API::DirectAdmin::Component';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = 0.05;
10  
11 # Create database for user
12 # Connection data MUST BE for user: auth_user => 'admin_login|user_login'
13 # auth_passwd => 'admin_passwd'
14 # INPUT
15 # name => 'DBNAME',
16 # passwd => 'DBPASSWD',
17 # passwd2 => 'DBPASSWD',
18 # user => 'DBLOGIN',
19 1 ▶sub adddb {
Subroutine adddb: called CC=4 SCAR=15.0
Pod undocumented
20 1 my ($self, $params ) = @_;
21
22 1 $params->{action} = 'create';
23
24 1 ▶ carp 'params ' . Dumper($params) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 1 1
25
26 1 my $responce = $self->directadmin->query(
27 command => 'CMD_API_DATABASES',
28 method => 'POST',
29 params => $params,
30 allowed_fields => 'action
31 name
32 passwd
33 passwd2
34 user',
35 );
36
37 1 ▶ carp '$responce ' . Dumper(\$responce) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 1 1
38
39 1 ▶ return $responce if $responce;
Branch: 1 branch
BranchTrueFalseTotal
if $responce 1 0 1
40  
41 0 return 'FAIL';
42 }
43  
44 # Delete database for user
45 # Connection data MUST BE for user: auth_user => 'admin_login|user_login'
46 # auth_passwd => 'admin_passwd'
47 # INPUT
48 # select0 => 'DBNAME',
49 # domain => 'DOMAIN.COM',
50 0 ▶sub deldb {
Subroutine deldb: not called CC=4 SCAR=30.0
Pod undocumented
51 0 my ($self, $params ) = @_;
52
53 0 $params->{action} = 'delete';
54  
55 0 ▶ carp 'params ' . Dumper($params) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
56  
57 0 my $responce = $self->directadmin->query(
58 command => 'CMD_API_DATABASES',
59 method => 'POST',
60 params => $params,
61 allowed_fields => 'action
62 select0',
63 );
64
65 0 ▶ carp '$responce ' . Dumper(\$responce) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
66
67 0 ▶ return $responce if $responce;
Branch: 1 branch
BranchTrueFalseTotal
if $responce 0 0 0
68  
69 0 return 'FAIL';
70 }
71  
72 # Get list of databases for authorized user.
73 # No params.
74 0 ▶sub list {
Subroutine list: not called CC=3 SCAR=24.8
Pod undocumented
75 0 my ($self ) = @_;
76  
77 0 my $responce = $self->directadmin->query(
78 command => 'CMD_API_DATABASES',
79 method => 'GET',
80 );
81  
82 0 ▶ carp '$responce ' . Dumper($responce) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
83  
84 0 ▶ return $responce->{list} if ref $responce eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $responce eq "HASH" 0 0 0
85 0 return [];
86 }
87  
88 1 1;
« lib/API/DirectAdmin.pm ↑ Summary lib/API/DirectAdmin/Domain.pm »