line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Reactio::Incident; |
2
|
2
|
|
|
2
|
|
1078
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
48
|
|
4
|
2
|
|
|
2
|
|
889
|
use utf8; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
52
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
740
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub create_incident { |
9
|
2
|
|
|
2
|
0
|
2365
|
my ($self, $name, $options) = @_; |
10
|
2
|
100
|
|
|
|
109
|
Carp::croak '[ERROR] Incident name is required' unless $name; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
50
|
|
|
4
|
my $params = $options || {}; |
13
|
1
|
|
|
|
|
3
|
$params->{name} = $name; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
6
|
$self->_request('POST', '/api/v1/incidents', $params); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub incident { |
19
|
2
|
|
|
2
|
0
|
2006
|
my ($self, $incident_id) = @_; |
20
|
2
|
100
|
|
|
|
123
|
Carp::croak '[ERROR] Incident id is required' unless $incident_id; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
6
|
$self->_request('GET', '/api/v1/incidents/'.$incident_id); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub incidents { |
26
|
1
|
|
|
1
|
0
|
790
|
my ($self, $options) = @_; |
27
|
1
|
|
50
|
|
|
5
|
my $params = $options || {}; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
6
|
$self->_request('GET', '/api/v1/incidents', $params); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub notify_incident { |
33
|
6
|
|
|
6
|
0
|
4762
|
my ($self, $incident_id, $text, $options) = @_; |
34
|
6
|
100
|
|
|
|
275
|
Carp::croak '[ERROR] Incident id is required' unless $incident_id; |
35
|
4
|
100
|
|
|
|
215
|
Carp::croak '[ERROR] Notification text is required' unless $text; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
50
|
|
|
6
|
my $params = $options || {}; |
38
|
2
|
|
|
|
|
5
|
$params->{incident_id} = $incident_id; |
39
|
2
|
|
|
|
|
3
|
$params->{notification_text} = $text; |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
9
|
$self->_request('POST', '/api/v1/notifications', $params); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub send_message { |
45
|
0
|
|
|
0
|
0
|
|
my ($self, $incident_id, $text) = @_; |
46
|
0
|
0
|
|
|
|
|
Carp::croak '[ERROR] Incident id is required' unless $incident_id; |
47
|
0
|
0
|
|
|
|
|
Carp::croak '[ERROR] Message is required' unless $text; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $params = { |
50
|
|
|
|
|
|
|
incident_id => $incident_id, |
51
|
|
|
|
|
|
|
message => $text, |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->_request('POST', '/api/v1/messages', $params); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |