File Coverage

blib/lib/WWW/Hetzner/Cloud/Zone.pm
Criterion Covered Total %
statement 12 28 42.8
branch 0 8 0.0
condition n/a
subroutine 4 9 44.4
pod 5 5 100.0
total 21 50 42.0


line stmt bran cond sub pod time code
1             package WWW::Hetzner::Cloud::Zone;
2             # ABSTRACT: Hetzner Cloud DNS Zone object
3              
4             our $VERSION = '0.100';
5              
6 25     25   168 use Moo;
  25         51  
  25         158  
7 25     25   9364 use Carp qw(croak);
  25         54  
  25         1568  
8 25     25   164 use WWW::Hetzner::Cloud::API::RRSets;
  25         45  
  25         650  
9 25     25   111 use namespace::clean;
  25         53  
  25         200  
10              
11              
12             has _client => (
13             is => 'ro',
14             required => 1,
15             weak_ref => 1,
16             init_arg => 'client',
17             );
18              
19             has id => ( is => 'ro' );
20              
21              
22             has name => ( is => 'rw' );
23              
24              
25             has status => ( is => 'ro' );
26              
27              
28             has ttl => ( is => 'rw' );
29              
30              
31             has created => ( is => 'ro' );
32              
33              
34             has ns => ( is => 'ro', default => sub { [] } );
35              
36              
37             has records_count => ( is => 'ro' );
38              
39              
40             has is_secondary_dns => ( is => 'ro' );
41              
42              
43             has labels => ( is => 'rw', default => sub { {} } );
44              
45              
46             sub update {
47 0     0 1   my ($self) = @_;
48 0 0         croak "Cannot update zone without ID" unless $self->id;
49              
50 0           $self->_client->put("/zones/" . $self->id, {
51             name => $self->name,
52             labels => $self->labels,
53             });
54 0           return $self;
55             }
56              
57              
58             sub delete {
59 0     0 1   my ($self) = @_;
60 0 0         croak "Cannot delete zone without ID" unless $self->id;
61              
62 0           $self->_client->delete("/zones/" . $self->id);
63 0           return 1;
64             }
65              
66              
67             sub rrsets {
68 0     0 1   my ($self) = @_;
69 0 0         croak "Cannot get rrsets without zone ID" unless $self->id;
70              
71 0           return WWW::Hetzner::Cloud::API::RRSets->new(
72             client => $self->_client,
73             zone_id => $self->id,
74             );
75             }
76              
77              
78             sub export {
79 0     0 1   my ($self) = @_;
80 0 0         croak "Cannot export zone without ID" unless $self->id;
81              
82 0           return $self->_client->get("/zones/" . $self->id . "/export");
83             }
84              
85              
86             sub data {
87 0     0 1   my ($self) = @_;
88             return {
89 0           id => $self->id,
90             name => $self->name,
91             status => $self->status,
92             ttl => $self->ttl,
93             created => $self->created,
94             ns => $self->ns,
95             records_count => $self->records_count,
96             is_secondary_dns => $self->is_secondary_dns,
97             labels => $self->labels,
98             };
99             }
100              
101              
102              
103             1.
104              
105             __END__