line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VM::HetznerCloud; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
487308
|
use v5.20; |
|
3
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Perl library to work with the API for the Hetzner Cloud |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1809
|
use Moo; |
|
3
|
|
|
|
|
36213
|
|
|
3
|
|
|
|
|
15
|
|
8
|
3
|
|
|
3
|
|
6239
|
use Mojo::UserAgent; |
|
3
|
|
|
|
|
1360634
|
|
|
3
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
166
|
use Carp; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
214
|
|
11
|
3
|
|
|
3
|
|
2187
|
use Types::Standard qw(Str); |
|
3
|
|
|
|
|
370639
|
|
|
3
|
|
|
|
|
45
|
|
12
|
3
|
|
|
3
|
|
9395
|
use Types::Mojo qw(:all); |
|
3
|
|
|
|
|
145050
|
|
|
3
|
|
|
|
|
29
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
10687
|
use Mojo::Base -strict, -signatures; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
56
|
|
15
|
3
|
|
|
3
|
|
13770
|
use Mojo::Loader qw(find_modules load_class); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
172
|
|
16
|
3
|
|
|
3
|
|
18
|
use Mojo::UserAgent; |
|
3
|
|
|
|
|
19
|
|
|
3
|
|
|
|
|
24
|
|
17
|
3
|
|
|
3
|
|
97
|
use Mojo::Util qw(decamelize); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
175
|
|
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
23
|
use experimental 'postderef'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
36
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.0.3'; # VERSION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has token => ( is => 'ro', isa => Str, required => 1 ); |
24
|
|
|
|
|
|
|
has host => ( is => 'ro', isa => MojoURL["https?"], default => sub { 'https://api.hetzner.cloud' }, coerce => 1 ); |
25
|
|
|
|
|
|
|
has base_uri => ( is => 'ro', isa => Str, default => sub { 'v1' } ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has client => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
lazy => 1, |
30
|
|
|
|
|
|
|
isa => MojoUserAgent, |
31
|
|
|
|
|
|
|
default => sub { |
32
|
|
|
|
|
|
|
Mojo::UserAgent->new, |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__PACKAGE__->_load_namespace; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
3
|
|
11
|
sub _load_namespace ($package) { |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
7
|
|
39
|
3
|
|
|
|
|
29
|
my @modules = find_modules $package . '::API', { recursive => 1 }; |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
21686
|
for my $module ( @modules ) { |
42
|
54
|
|
|
|
|
1856
|
load_class( $module ); |
43
|
|
|
|
|
|
|
|
44
|
54
|
|
|
|
|
1418
|
my $base = (split /::/, $module)[-1]; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
|
1346
|
no strict 'refs'; ## no critic |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
577
|
|
47
|
54
|
|
|
2
|
|
327
|
*{ $package . '::' . decamelize( $base ) } = sub ($api) { |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3641
|
|
|
2
|
|
|
|
|
9
|
|
48
|
2
|
|
|
|
|
57
|
state $object = $module->new( |
49
|
|
|
|
|
|
|
token => $api->token, |
50
|
|
|
|
|
|
|
base_uri => $api->base_uri, |
51
|
|
|
|
|
|
|
client => $api->client, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
756
|
return $object; |
55
|
54
|
|
|
|
|
334
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
87
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |