File Coverage

blib/lib/Net/SecurityCenter/API/Credential.pm
Criterion Covered Total %
statement 15 30 50.0
branch 0 6 0.0
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 22 45 48.8


line stmt bran cond sub pod time code
1             package Net::SecurityCenter::API::Credential;
2              
3 2     2   721 use warnings;
  2         4  
  2         57  
4 2     2   9 use strict;
  2         3  
  2         32  
5              
6 2     2   8 use Carp;
  2         3  
  2         88  
7              
8 2     2   8 use parent 'Net::SecurityCenter::Base';
  2         4  
  2         10  
9              
10 2     2   109 use Net::SecurityCenter::Utils qw(:all);
  2         4  
  2         804  
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 => 'Credential ID is required',
21             allow => 'Invalid Credential ID',
22             },
23             },
24              
25             filter => {
26             allow => [ 'usable', 'manageable' ],
27             },
28              
29             fields => {
30             filter => \&sc_filter_array_to_string,
31             },
32              
33             };
34              
35             #-------------------------------------------------------------------------------
36             # METHODS
37             #-------------------------------------------------------------------------------
38              
39             sub list {
40              
41 0     0 1   my ( $self, %args ) = @_;
42              
43             my $tmpl = {
44             filter => $common_template->{'filter'},
45 0           fields => $common_template->{'fields'},
46             raw => {}
47             };
48              
49 0           my $params = sc_check_params( $tmpl, \%args );
50 0           my $credentials = $self->client->get( '/credential', $params );
51 0           my $raw = delete( $params->{'raw'} );
52              
53 0 0         return if ( !$credentials );
54 0 0         return $credentials if ($raw);
55 0           return sc_merge($credentials);
56              
57             }
58              
59             #-------------------------------------------------------------------------------
60              
61             sub get {
62              
63 0     0 1   my ( $self, %args ) = @_;
64              
65             my $tmpl = {
66             fields => $common_template->{'fields'},
67 0           id => $common_template->{'id'},
68             };
69              
70 0           my $params = sc_check_params( $tmpl, \%args );
71 0           my $credential_id = delete( $params->{'id'} );
72 0           my $credential = $self->client->get( "/credential/$credential_id", $params );
73              
74 0 0         return if ( !$credential );
75 0           return $credential;
76              
77             }
78              
79             #-------------------------------------------------------------------------------
80              
81             1;
82              
83             __END__