lib/WWW/Hetzner/Robot/API/Keys.pm

filter: Statementstmt 65.7% 23 / 35 Branchbran 0.0% 0 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 70.0% 7 / 10 Podpod 100% 4 / 4 totaltotal 58.3% 35 / 60 CC 6 SCAR 15.4
CC
6
Cov
53%
create
12.0
get
6.0
delete
6.0
CRAP 4.7
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Folders.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Volume.pm »
1 package WWW::Hetzner::Robot::API::Keys;
2 # ABSTRACT: Hetzner Robot SSH Keys API
3  
4 58 our $VERSION = '0.102';
5  
6 58 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 58 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 58 ▶use WWW::Hetzner::Robot::Key;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 58 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 58 has client => (
13 is => 'ro',
14 required => 1,
15 weak_ref => 1,
16 );
17  
18 4 ▶sub _wrap {
Subroutine _wrap: called CC=1 SCAR=0.0
19 4 my ($self, $data) = @_;
20 4 return WWW::Hetzner::Robot::Key->new(
21 client => $self->client,
22 %$data,
23 );
24 }
25  
26 2 ▶sub _wrap_list {
Subroutine _wrap_list: called CC=1 SCAR=0.0
27 2 my ($self, $list) = @_;
28 2 return [ map { $self->_wrap($_->{key}) } @$list ];
29 }
30  
31 2 ▶sub list {
Subroutine list: called CC=2 SCAR=7.1
Pod documented
32 2 my ($self) = @_;
33 2 my $result = $self->client->get('/key');
34 2 ▶ return $self->_wrap_list($result // []);
Condition50%1/2
$result // []
l!l
20
MC/DC0%0/1
$result // []
$result
Truth table50%1/2
A
A= $result
Aresult
11
00
35 }
36  
37  
38 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
39 0 my ($self, $fingerprint) = @_;
40 0 ▶ croak "Fingerprint required" unless $fingerprint;
Branch: 1 branch
BranchTrueFalseTotal
unless $fingerprint 0 0 0
41 0 my $result = $self->client->get("/key/$fingerprint");
42 0 return $self->_wrap($result->{key});
43 }
44  
45  
46 0 ▶sub create {
Subroutine create: not called CC=3 SCAR=24.8
Pod documented
47 0 my ($self, %params) = @_;
48 0 ▶ croak "name required" unless $params{name};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"name"} 0 0 0
49 0 ▶ croak "data required" unless $params{data};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"data"} 0 0 0
50  
51 my $result = $self->client->post('/key', {
52 name => $params{name},
53 data => $params{data},
54 0 });
55 0 return $self->_wrap($result->{key});
56 }
57  
58  
59 0 ▶sub delete {
Subroutine delete: not called CC=2 SCAR=17.9
Pod documented
60 0 my ($self, $fingerprint) = @_;
61 0 ▶ croak "Fingerprint required" unless $fingerprint;
Branch: 1 branch
BranchTrueFalseTotal
unless $fingerprint 0 0 0
62 0 return $self->client->delete("/key/$fingerprint");
63 }
64  
65  
66  
67 58 1.
68  
69 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Folders.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Volume.pm »