lib/WWW/Hetzner/Storage.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod n/a totaltotal 98.0% 51 / 52 CC 2 SCAR 1.3
CC
2
Cov
100%
_check_auth
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/WWW/Hetzner/Storage/Snapshot.pm ↑ Summary lib/WWW/Hetzner/Cloud/Pricing.pm »
1 package WWW::Hetzner::Storage;
2 # ABSTRACT: Perl client for Hetzner Storage Box API
3  
4 7 our $VERSION = '0.102';
5  
6 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use WWW::Hetzner::Storage::API::Actions;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use WWW::Hetzner::Storage::API::StorageBoxes;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use WWW::Hetzner::Storage::API::StorageBoxTypes;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 has token => (
14 is => 'ro',
15 1 ▶ default => sub { $ENV{HETZNER_API_TOKEN} },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 7 );
17  
18  
19 123 ▶sub _check_auth {
Subroutine _check_auth: called CC=2 SCAR=6.9
20 123 my ($self) = @_;
21 123 ▶ unless ($self->token) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->token) 1 122 123
22 1 die "No Storage API token configured.\n\n" .
23 "Set token via:\n" .
24 " Environment: HETZNER_API_TOKEN\n" .
25 " Option: --token\n\n" .
26 "Get token at: https://console.hetzner.cloud/ -> Select project -> Security -> API tokens\n";
27 }
28 }
29  
30 7 has base_url => (
31 is => 'ro',
32 default => 'https://api.hetzner.com/v1',
33 );
34  
35  
36 7 with 'WWW::Hetzner::Role::HTTP';
37  
38 123 ▶around _request => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
39 123 my ($orig, $self, @args) = @_;
40 123 $self->_check_auth;
41 122 return $self->$orig(@args);
42 7 };
43  
44 has storage_boxes => (
45 is => 'lazy',
46 6 ▶ builder => sub { WWW::Hetzner::Storage::API::StorageBoxes->new(client => shift) },
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _build_storage_boxes: called CC=1 SCAR=0.0
47 7 );
48  
49  
50 has storage_box_types => (
51 is => 'lazy',
52 1 ▶ builder => sub { WWW::Hetzner::Storage::API::StorageBoxTypes->new(client => shift) },
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _build_storage_box_types: not called CC=1 SCAR=0.0
53 7 );
54  
55  
56 has actions => (
57 is => 'lazy',
58 3 ▶ builder => sub { WWW::Hetzner::Storage::API::Actions->new(client => shift) },
Subroutine __ANON__: called CC=1 SCAR=0.0
59 7 );
60  
61  
62  
63 7 1;
64  
65 __END__
« lib/WWW/Hetzner/Storage/Snapshot.pm ↑ Summary lib/WWW/Hetzner/Cloud/Pricing.pm »