File Coverage

lib/API/DirectAdmin/Ip.pm
Criterion Covered Total %
statement 9 18 50.0
branch 1 2 50.0
condition n/a
subroutine 3 5 60.0
pod 0 3 0.0
total 13 28 46.4


line stmt bran cond sub pod time code
1             package API::DirectAdmin::Ip;
2              
3 1     1   818 use Modern::Perl '2010';
  1         2  
  1         10  
4              
5 1     1   176 use base 'API::DirectAdmin::Component';
  1         2  
  1         4213  
6              
7             our $VERSION = 0.05;
8              
9             # Return list of IP
10             # INPUT
11             # Admin connect params
12             sub list {
13 1     1 0 3 my ($self ) = @_;
14              
15 1         7 my $responce = $self->directadmin->query(
16             command => 'CMD_API_SHOW_RESELLER_IPS',
17             );
18              
19 1 50       6 return $responce->{list} if ref $responce eq 'HASH';
20 0           return [];
21             }
22              
23             # Add Ip
24             # INPUT
25             # Admin connect params
26             # ip = 'IP.AD.DRE.SS'
27             # status = free|shared|owned (optional)
28             sub add {
29 0     0 0   my ($self, $params ) = @_;
30            
31 0           my %add_params = (
32             action => 'add',
33             add => 'Submit',
34             netmask => '255.255.255.0',
35             notify => 'no',
36             );
37            
38 0           my %params = (%$params, %add_params);
39            
40 0           return $self->directadmin->query(
41             params => \%params,
42             method => 'POST',
43             command => 'CMD_API_IP_MANAGER',
44             allowed_fields => 'ip
45             action
46             add
47             netmask
48             notify
49             status',
50             );
51             }
52              
53             # Delete Ip
54             # INPUT
55             # Admin connect params
56             # select0 = 'IP.AD.DRE.SS'
57             sub remove {
58 0     0 0   my ($self, $params ) = @_;
59            
60 0           my %add_params = (
61             action => 'select',
62             delete => 'Delete',
63             );
64            
65 0           my %params = (%$params, %add_params);
66            
67 0           return $self->directadmin->query(
68             params => \%params,
69             method => 'POST',
70             command => 'CMD_API_IP_MANAGER',
71             allowed_fields => 'select0
72             action
73             delete',
74             );
75             }
76              
77             1;