line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## workaround for PkgVersion |
4
|
|
|
|
|
|
|
## no critic |
5
|
|
|
|
|
|
|
package WebService::PagerDuty::Event; |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$WebService::PagerDuty::Event::VERSION = '1.20131219.1627'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
## use critic |
10
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
80
|
|
11
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
77
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
11
|
use base qw/ WebService::PagerDuty::Base /; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
343
|
|
14
|
2
|
|
|
2
|
|
11
|
use URI; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
15
|
2
|
|
|
2
|
|
1395
|
use WebService::PagerDuty::Request; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
16
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors( |
18
|
|
|
|
|
|
|
qw/ |
19
|
|
|
|
|
|
|
url |
20
|
|
|
|
|
|
|
service_key |
21
|
|
|
|
|
|
|
incident_key |
22
|
|
|
|
|
|
|
description |
23
|
|
|
|
|
|
|
/ |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my @__method_definitions = ( |
27
|
|
|
|
|
|
|
## method_name => required_arg ], |
28
|
|
|
|
|
|
|
[ trigger => 'description' ], |
29
|
|
|
|
|
|
|
[ acknowledge => 'incident_key' ], |
30
|
|
|
|
|
|
|
[ resolve => 'incident_key' ], |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__construct_method(@$_) for @__method_definitions; |
34
|
|
|
|
|
|
|
*ack = \&acknowledge; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub __construct_method { |
37
|
6
|
|
|
6
|
|
12
|
my ( $method_name, $required_arg ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
2
|
|
284
|
no strict 'refs'; ## no critic |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
197
|
|
40
|
|
|
|
|
|
|
|
41
|
6
|
|
|
|
|
22
|
my $method = 'sub { |
42
|
|
|
|
|
|
|
my ( $self, %details ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $incident_key = delete $details{incident_key} || $self->incident_key || undef; |
45
|
|
|
|
|
|
|
my $description = delete $details{description} || $self->description || undef; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
die("WebService::PagerDuty::Event::' . $method_name . '(): ' . $required_arg . ' is required") |
48
|
|
|
|
|
|
|
unless defined \$' . $required_arg . '; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return WebService::PagerDuty::Request->new->post_data( |
51
|
|
|
|
|
|
|
url => $self->url, |
52
|
|
|
|
|
|
|
event_type => "' . $method_name . '", |
53
|
|
|
|
|
|
|
service_key => $self->service_key, |
54
|
|
|
|
|
|
|
( $description ? ( description => $description ) : () ), |
55
|
|
|
|
|
|
|
( $incident_key ? ( incident_key => $incident_key ) : () ), |
56
|
|
|
|
|
|
|
( %details ? ( details => \%details ) : () ), |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
}'; |
59
|
|
|
|
|
|
|
|
60
|
6
|
0
|
0
|
0
|
|
1372
|
*$method_name = eval $method; ## no critic |
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |