lib/WWW/Hetzner/Cloud/RRSet.pm

filter: Statementstmt 66.6% 24 / 36 Branchbran 25.0% 3 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 100% 4 / 4 totaltotal 60.0% 36 / 60 CC 7 SCAR 20.1
CC
7
Cov
56%
update
20.0
delete
4.3
values
2.0
CRAP 7.5
« lib/WWW/Hetzner/Cloud/API/PrimaryIPs.pm ↑ Summary lib/WWW/Hetzner/Role/Pagination.pm »
1 package WWW::Hetzner::Cloud::RRSet;
2 # ABSTRACT: Hetzner Cloud DNS RRSet object
3  
4 60 our $VERSION = '0.102';
5  
6 60 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 60 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 60 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 60 has _client => (
12 is => 'ro',
13 required => 1,
14 weak_ref => 1,
15 init_arg => 'client',
16 );
17  
18 60 has zone_id => ( is => 'ro', required => 1 );
19  
20  
21 60 has name => ( is => 'ro' );
22  
23  
24 60 has type => ( is => 'ro' );
25  
26  
27 60 has ttl => ( is => 'rw' );
28  
29  
30 0 ▶has records => ( is => 'rw', default => sub { [] } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
31  
32  
33 0 ▶sub update {
Subroutine update: not called CC=4 SCAR=30.0
Pod documented
34 0 my ($self) = @_;
35 0 ▶ croak "Cannot update RRSet without zone_id" unless $self->zone_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->zone_id 0 0 0
36 0 ▶ croak "Cannot update RRSet without name" unless $self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 0 0
37 0 ▶ croak "Cannot update RRSet without type" unless $self->type;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->type 0 0 0
38  
39 0 my $path = "/zones/" . $self->zone_id . "/rrsets/" . $self->name . "/" . $self->type;
40 0 $self->_client->put($path, {
41 ttl => $self->ttl,
42 records => $self->records,
43 });
44 0 return $self;
45 }
46  
47  
48 1 ▶sub delete {
Subroutine delete: called CC=4 SCAR=14.6
Pod documented
49 1 my ($self) = @_;
50 1 ▶ croak "Cannot delete RRSet without zone_id" unless $self->zone_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->zone_id 0 1 1
51 1 ▶ croak "Cannot delete RRSet without name" unless $self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 1 1
52 1 ▶ croak "Cannot delete RRSet without type" unless $self->type;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->type 0 1 1
53  
54 1 return $self->_client->zones->rrsets($self->zone_id)
55 ->delete($self->name, $self->type);
56 }
57  
58  
59 0 ▶sub values {
Subroutine values: not called CC=1 SCAR=6.9
Pod documented
60 0 my ($self) = @_;
61 0 return [ map { $_->{value} } @{$self->records} ];
62 }
63  
64  
65 5 ▶sub data {
Subroutine data: called CC=1 SCAR=0.0
Pod documented
66 5 my ($self) = @_;
67 return {
68 5 zone_id => $self->zone_id,
69 name => $self->name,
70 type => $self->type,
71 ttl => $self->ttl,
72 records => $self->records,
73 };
74 }
75  
76  
77  
78 60 1.
79  
80 __END__
« lib/WWW/Hetzner/Cloud/API/PrimaryIPs.pm ↑ Summary lib/WWW/Hetzner/Role/Pagination.pm »