Net/SecurityCenter/API/Ticket.pm

filter: Statementstmt 67.3% 35 / 52 Branchbran 35.7% 5 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 100% 4 / 4 totaltotal 63.7% 51 / 80 CC 8 SCAR 13.3
CC
8
Cov
61%
list
6.9
edit
6.0
get
3.0
CRAP 3.8
« Net/SecurityCenter/API/Notification.pm ↑ Summary Net/SecurityCenter/API/System.pm »
1 package Net::SecurityCenter::API::Ticket;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use parent 'Net::SecurityCenter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Net::SecurityCenter::Utils qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $VERSION = '0.311';
13  
14 my $common_template = {
15  
16 id => {
17 required => 1,
18 allow => qr/^\d+$/,
19 messages => {
20 required => 'Ticket ID is required',
21 allow => 'Invalid Ticket ID',
22 },
23 },
24  
25 fields => {
26 filter => \&sc_filter_array_to_string,
27 },
28  
29 assignee => {
30 allow => qr/\d+/,
31 errors => { allow => 'Invalid Asignee ID' },
32 0 ▶ filter => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 0 return { 'id' => $_[0] };
34 }
35 },
36  
37 2 status => {
38 allow => [ 'assigned', 'resolved', 'feedback', 'na', 'duplicate', 'closed' ]
39 },
40  
41 classification => {
42 allow => [
43 'Information',
44 'Configuration',
45 'Patch',
46 'Disable',
47 'Firewall',
48 'Schedule',
49 'IDS',
50 'Other',
51 'Accept Risk',
52 'Recast Risk',
53 'Re-scan Request',
54 'False Positive',
55 'System Probe',
56 'External Probe',
57 'Investigation Needed',
58 'Compromised System',
59 'Virus Incident',
60 'Bad Credentials',
61 'Unauthorized Software',
62 'Unauthorized System',
63 'Unauthorized User'
64 ]
65 },
66  
67 };
68  
69 #-------------------------------------------------------------------------------
70 # METHODS
71 #-------------------------------------------------------------------------------
72  
73 1 ▶sub list {
Subroutine list: called CC=5 SCAR=19.3
Pod documented
74  
75 1 my ( $self, %args ) = @_;
76  
77 my $tmpl = {
78 1 fields => $common_template->{'fields'},
79 raw => {},
80 };
81  
82 1 my $params = sc_check_params( $tmpl, \%args );
83 1 my $raw = delete( $params->{'raw'} );
84 1 my $tickets = $self->client->get( '/ticket', $params );
85  
86 1 ▶ return if ( !$tickets );
Branch: 1 branch
BranchTrueFalseTotal
unless $tickets 0 1 1
87  
88 1 ▶ if ($raw) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raw) 0 1 1
89 0 ▶ return wantarray ? @{$tickets} : $tickets;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
90 }
91  
92 0 ▶ return wantarray ? @{ sc_merge($tickets) } : sc_merge($tickets);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
93  
94 }
95  
96 #-------------------------------------------------------------------------------
97  
98 1 ▶sub get {
Subroutine get: called CC=3 SCAR=11.1
Pod documented
99  
100 1 my ( $self, %args ) = @_;
101  
102 my $tmpl = {
103 fields => $common_template->{'fields'},
104 1 id => $common_template->{'id'},
105 raw => {},
106 };
107  
108 1 my $params = sc_check_params( $tmpl, \%args );
109 1 my $raw = delete( $params->{'raw'} );
110 1 my $ticket_id = delete( $params->{'id'} );
111 1 my $ticket = $self->client->get( "/ticket/$ticket_id", $params );
112  
113 1 ▶ return if ( !$ticket );
Branch: 1 branch
BranchTrueFalseTotal
unless $ticket 0 1 1
114 1 ▶ return $ticket if ($raw);
Branch: 1 branch
BranchTrueFalseTotal
if $raw 0 1 1
115 1 return sc_normalize_hash($ticket);
116  
117 }
118  
119 #-------------------------------------------------------------------------------
120  
121 0 ▶sub add {
Subroutine add: not called CC=1 SCAR=6.9
Pod documented
122  
123 0 my ( $self, %args ) = @_;
124  
125 my $tmpl = {
126 name => {
127 required => 1,
128 errors => { required => 'Specify ticket name' }
129 },
130 assignee => $common_template->{'asignee'},
131 status => $common_template->{'status'},
132 0 classification => $common_template->{'classification'},
133 description => {},
134 notes => {},
135 queries => {},
136 query => {}
137 };
138  
139 0 my $params = sc_check_params( $tmpl, \%args );
140  
141 0 my $result = $self->client->post( '/ticket', $params );
142  
143 0 return $result->{id};
144  
145 }
146  
147 #-------------------------------------------------------------------------------
148  
149 0 ▶sub edit {
Subroutine edit: not called CC=2 SCAR=17.9
Pod documented
150  
151 0 my ( $self, %args ) = @_;
152  
153 my $tmpl = {
154 id => $common_template->{'id'},
155 name => {},
156 assignee => $common_template->{'asignee'},
157 status => $common_template->{'status'},
158 0 classification => $common_template->{'classification'},
159 description => {},
160 notes => {},
161 queries => {},
162 query => {},
163 raw => {}
164 };
165  
166 0 my $params = sc_check_params( $tmpl, \%args );
167 0 my $ticket_id = delete( $params->{'id'} );
168 0 my $raw = delete( $params->{'raw'} );
169  
170 0 my $ticket = $self->client->patch( "/ticket/$ticket_id", $params );
171  
172 0 ▶ return $ticket if ($raw);
Branch: 1 branch
BranchTrueFalseTotal
if $raw 0 0 0
173 0 return sc_normalize_hash($ticket);
174  
175 }
176  
177 2 1;
178  
179 __END__
« Net/SecurityCenter/API/Notification.pm ↑ Summary Net/SecurityCenter/API/System.pm »