| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Giraffi::API; |
|
2
|
12
|
|
|
12
|
|
8105
|
use strict; |
|
|
12
|
|
|
|
|
25
|
|
|
|
12
|
|
|
|
|
412
|
|
|
3
|
12
|
|
|
12
|
|
63
|
use warnings; |
|
|
12
|
|
|
|
|
21
|
|
|
|
12
|
|
|
|
|
370
|
|
|
4
|
12
|
|
|
12
|
|
453
|
use 5.010000; |
|
|
12
|
|
|
|
|
40
|
|
|
|
12
|
|
|
|
|
1139
|
|
|
5
|
|
|
|
|
|
|
use Class::XSAccessor |
|
6
|
12
|
|
|
|
|
186
|
constructor => "new", |
|
7
|
|
|
|
|
|
|
accessors => { |
|
8
|
|
|
|
|
|
|
apikey => "apikey", |
|
9
|
|
|
|
|
|
|
timeout => "timeout", |
|
10
|
|
|
|
|
|
|
default_endpoint => "default_endpoint", |
|
11
|
|
|
|
|
|
|
applogs_endpoint => "applogs_endpoint", |
|
12
|
|
|
|
|
|
|
monitoringdata_endpoint => "monitoringdata_endpoint", |
|
13
|
|
|
|
|
|
|
verbose => "verbose", |
|
14
|
|
|
|
|
|
|
ssl_verify_hostname => "ssl_verify_hostname", |
|
15
|
|
|
|
|
|
|
use_time_piece => "use_time_piece", |
|
16
|
|
|
|
|
|
|
}, |
|
17
|
|
|
|
|
|
|
#true => [qw(verbose)], |
|
18
|
12
|
|
|
12
|
|
19062
|
replace => 1; |
|
|
12
|
|
|
|
|
48304
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#has apikey => ( is => "rw", isa => "Str" ); |
|
21
|
|
|
|
|
|
|
#has timeout => ( is => "rw", isa => "Num" ); |
|
22
|
|
|
|
|
|
|
#has verbose => ( is => "rw", isa => "Num" ); |
|
23
|
|
|
|
|
|
|
#has ssl_verify_hostname => ( is => "rw", isa => "Num"); |
|
24
|
12
|
|
|
12
|
|
20480
|
use Module::Pluggable search_path => [__PACKAGE__]; |
|
|
12
|
|
|
|
|
198908
|
|
|
|
12
|
|
|
|
|
101
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.2_04'; |
|
27
|
|
|
|
|
|
|
our $AGENT = sprintf "%s/%s", __PACKAGE__, $VERSION; |
|
28
|
|
|
|
|
|
|
our $SSL_VERIFY_HOSTNAME = 1; |
|
29
|
|
|
|
|
|
|
our $TIMEOUT = 30; |
|
30
|
|
|
|
|
|
|
our $USE_TIME_PIECE = 1; |
|
31
|
|
|
|
|
|
|
our $DEFAULT_ENDPOINT = "https://papi.giraffi.jp"; |
|
32
|
|
|
|
|
|
|
our $MONITORINGDATA_ENDPOINT = "https://okapi.giraffi.jp:3007"; |
|
33
|
|
|
|
|
|
|
our $APPLOGS_ENDPOINT = "https://lapi.giraffi.jp:3443"; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub import { |
|
36
|
|
|
|
|
|
|
|
|
37
|
12
|
|
|
12
|
|
92
|
my $class = shift; |
|
38
|
12
|
|
|
|
|
84
|
foreach my $pkg ( $class->plugins ) { |
|
39
|
144
|
100
|
|
|
|
106014
|
next if $pkg eq "${class}::Request"; |
|
40
|
132
|
|
|
|
|
3284
|
$pkg =~ /^${class}::([a-zA-Z]+)$/; |
|
41
|
132
|
|
|
|
|
255
|
my $method = lc $1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
12
|
|
|
12
|
|
3000
|
no strict "refs"; ## no critic |
|
|
12
|
|
|
|
|
25
|
|
|
|
12
|
|
|
|
|
351
|
|
|
44
|
12
|
|
|
12
|
|
57
|
no warnings "redefine"; ## no critic |
|
|
12
|
|
|
|
|
25
|
|
|
|
12
|
|
|
|
|
4983
|
|
|
45
|
132
|
|
|
|
|
10409
|
*{ __PACKAGE__ . "::$method" } = sub { |
|
46
|
10
|
|
|
10
|
|
53
|
my $self = shift; |
|
47
|
10
|
|
33
|
|
|
232
|
my %options = ( |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
48
|
|
|
|
|
|
|
apikey => $self->apikey, |
|
49
|
|
|
|
|
|
|
agent => $AGENT, |
|
50
|
|
|
|
|
|
|
ssl_verify_hostname => $self->ssl_verify_hostname // $SSL_VERIFY_HOSTNAME, |
|
51
|
|
|
|
|
|
|
use_time_piece => $self->use_time_piece // $USE_TIME_PIECE, |
|
52
|
|
|
|
|
|
|
timeout => $self->timeout // $TIMEOUT, |
|
53
|
|
|
|
|
|
|
default_endpoint => $self->default_endpoint // $DEFAULT_ENDPOINT, |
|
54
|
|
|
|
|
|
|
monitoringdata_endpoint => $self->monitoringdata_endpoint // $MONITORINGDATA_ENDPOINT, |
|
55
|
|
|
|
|
|
|
applogs_endpoint => $self->applogs_endpoint //$APPLOGS_ENDPOINT, |
|
56
|
|
|
|
|
|
|
verbose => $self->verbose, |
|
57
|
|
|
|
|
|
|
); |
|
58
|
10
|
|
|
|
|
49
|
return $self->_require_request_method( $pkg, %options ); |
|
59
|
132
|
|
|
|
|
915
|
}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
{ |
|
64
|
|
|
|
|
|
|
my %cached; ## static hash |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _require_request_method { |
|
67
|
|
|
|
|
|
|
|
|
68
|
10
|
|
|
10
|
|
54
|
my ( $self, $pkg, %options ) = @_; |
|
69
|
10
|
|
|
|
|
53
|
( my $file = $pkg ) =~ s/::/\//g; |
|
70
|
10
|
50
|
|
|
|
28
|
if ( !exists $cached{$pkg} ) { |
|
71
|
10
|
50
|
|
|
|
647
|
eval "require '$file.pm'" or die $@; ## no critic |
|
72
|
10
|
|
|
|
|
112
|
$pkg->import; |
|
73
|
10
|
|
|
|
|
184
|
$cached{$pkg} = $pkg->new(%options); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
10
|
|
|
|
|
106
|
return $cached{$pkg}; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
|
80
|
|
|
|
|
|
|
__END__ |