File Coverage

blib/lib/WWW/Hetzner/Cloud/RRSet.pm
Criterion Covered Total %
statement 9 29 31.0
branch 0 12 0.0
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 16 52 30.7


line stmt bran cond sub pod time code
1             package WWW::Hetzner::Cloud::RRSet;
2             # ABSTRACT: Hetzner Cloud DNS RRSet object
3              
4             our $VERSION = '0.100';
5              
6 25     25   170 use Moo;
  25         53  
  25         153  
7 25     25   9408 use Carp qw(croak);
  25         48  
  25         1565  
8 25     25   142 use namespace::clean;
  25         38  
  25         159  
9              
10              
11             has _client => (
12             is => 'ro',
13             required => 1,
14             weak_ref => 1,
15             init_arg => 'client',
16             );
17              
18             has zone_id => ( is => 'ro', required => 1 );
19              
20              
21             has name => ( is => 'ro' );
22              
23              
24             has type => ( is => 'ro' );
25              
26              
27             has ttl => ( is => 'rw' );
28              
29              
30             has records => ( is => 'rw', default => sub { [] } );
31              
32              
33             sub update {
34 0     0 1   my ($self) = @_;
35 0 0         croak "Cannot update RRSet without zone_id" unless $self->zone_id;
36 0 0         croak "Cannot update RRSet without name" unless $self->name;
37 0 0         croak "Cannot update RRSet without type" unless $self->type;
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             sub delete {
49 0     0 1   my ($self) = @_;
50 0 0         croak "Cannot delete RRSet without zone_id" unless $self->zone_id;
51 0 0         croak "Cannot delete RRSet without name" unless $self->name;
52 0 0         croak "Cannot delete RRSet without type" unless $self->type;
53              
54 0           my $path = "/zones/" . $self->zone_id . "/rrsets/" . $self->name . "/" . $self->type;
55 0           $self->_client->delete($path);
56 0           return 1;
57             }
58              
59              
60             sub values {
61 0     0 1   my ($self) = @_;
62 0           return [ map { $_->{value} } @{$self->records} ];
  0            
  0            
63             }
64              
65              
66             sub data {
67 0     0 1   my ($self) = @_;
68             return {
69 0           zone_id => $self->zone_id,
70             name => $self->name,
71             type => $self->type,
72             ttl => $self->ttl,
73             records => $self->records,
74             };
75             }
76              
77              
78              
79             1.
80              
81             __END__