File Coverage

blib/lib/Net/SecurityCenter/API/Zone.pm
Criterion Covered Total %
statement 32 35 91.4
branch 5 12 41.6
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 46 56 82.1


line stmt bran cond sub pod time code
1             package Net::SecurityCenter::API::Zone;
2              
3 2     2   728 use warnings;
  2         4  
  2         52  
4 2     2   10 use strict;
  2         2  
  2         40  
5              
6 2     2   8 use Carp;
  2         4  
  2         83  
7              
8 2     2   10 use parent 'Net::SecurityCenter::Base';
  2         3  
  2         8  
9              
10 2     2   125 use Net::SecurityCenter::Utils qw(:all);
  2         3  
  2         923  
11              
12             our $VERSION = '0.310';
13              
14             my $common_template = {
15              
16             id => {
17             required => 1,
18             allow => qr/^\d+$/,
19             messages => {
20             required => 'Scan Zone ID is required',
21             allow => 'Invalid Scan Zone ID',
22             },
23             },
24              
25             fields => {
26             filter => \&sc_filter_array_to_string
27             }
28              
29             };
30              
31             #-------------------------------------------------------------------------------
32             # METHODS
33             #-------------------------------------------------------------------------------
34              
35             sub list {
36              
37 1     1 1 3 my ( $self, %args ) = @_;
38              
39             my $tmpl = {
40 1         5 fields => $common_template->{'fields'},
41             raw => {},
42             };
43              
44 1         4 my $params = sc_check_params( $tmpl, \%args );
45 1         3 my $raw = delete( $params->{'raw'} );
46 1         11 my $zones = $self->client->get( '/zone', $params );
47              
48 1 50       4 return if ( !$zones );
49              
50 1 50       4 if ($raw) {
51 0 0       0 return wantarray ? @{$zones} : $zones;
  0         0  
52             }
53              
54 1 50       5 return wantarray ? @{ sc_normalize_array($zones) } : sc_normalize_array($zones);
  0         0  
55              
56             }
57              
58             #-------------------------------------------------------------------------------
59              
60             sub get {
61              
62 1     1 1 4 my ( $self, %args ) = @_;
63              
64             my $tmpl = {
65             fields => $common_template->{'fields'},
66 1         5 id => $common_template->{'id'},
67             raw => {},
68             };
69              
70 1         4 my $params = sc_check_params( $tmpl, \%args );
71 1         4 my $zone_id = delete( $params->{'id'} );
72 1         2 my $raw = delete( $params->{'raw'} );
73 1         4 my $zone = $self->client->get( "/zone/$zone_id", $params );
74              
75 1 50       4 return if ( !$zone );
76 1 50       5 return $zone if ($raw);
77 1         4 return sc_normalize_hash($zone);
78              
79             }
80              
81             1;
82              
83             __END__