lib/WWW/Hetzner/Storage/API/Actions.pm

filter: Statementstmt 100% 29 / 29 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 93.4% 43 / 46 CC 4 SCAR 4.4
CC
4
Cov
94%
_list_page
2.0
get
2.0
_base_path
2.0
CRAP 1.6
« lib/WWW/Hetzner/Role/HasActions.pm ↑ Summary lib/WWW/Hetzner/Robot/Key.pm »
1 package WWW::Hetzner::Storage::API::Actions;
2 # ABSTRACT: Hetzner Storage Box Actions API
3  
4 11 our $VERSION = '0.102';
5  
6 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 11 has client => (
12 is => 'ro',
13 required => 1,
14 weak_ref => 1,
15 );
16  
17 11 has storage_box_id => ( is => 'ro' );
18  
19 11 with 'WWW::Hetzner::Role::HasActions';
20 11 with 'WWW::Hetzner::Role::Pagination';
21  
22 has '+action_poll_path' => (
23 4 ▶ default => sub { '/storage_boxes/actions' },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 11 );
25  
26 6 ▶sub _base_path {
Subroutine _base_path: called CC=2 SCAR=6.9
27 6 my ($self) = @_;
28 6 ▶ return defined $self->storage_box_id
Branch: 1 branch
BranchTrueFalseTotal
defined $self->storage_box_id ? : 3 3 6
29 ? '/storage_boxes/' . $self->storage_box_id . '/actions'
30 : '/storage_boxes/actions';
31 }
32  
33 6 ▶sub _list_page {
Subroutine _list_page: called CC=2 SCAR=7.1
34 6 my ($self, %params) = @_;
35  
36 6 my $result = $self->client->get($self->_base_path, params => \%params);
37 6 ▶ return ($self->_wrap_actions($result->{actions} // []), $result->{meta});
Condition50%1/2
$result->{"actions"} // []
l!l
60
MC/DC0%0/1
$result->{"actions"} // []
$result->{"actions"}
Truth table50%1/2
A
A= $result->{"actions"}
Aresult
11
00
38 }
39  
40  
41 2 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
42 2 my ($self, %params) = @_;
43  
44 2 my ($entities) = $self->_list_page(%params);
45 2 return $entities;
46 }
47  
48  
49 7 ▶sub get {
Subroutine get: called CC=2 SCAR=7.0
Pod documented
50 7 my ($self, $id) = @_;
51 7 ▶ croak 'Action ID required' unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 7 7
52  
53 7 my $result = $self->client->get("/storage_boxes/actions/$id");
54 6 return $self->_wrap_action($result->{action});
55 }
56  
57  
58 11 1;
59  
60 __END__
« lib/WWW/Hetzner/Role/HasActions.pm ↑ Summary lib/WWW/Hetzner/Robot/Key.pm »