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

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