| 1 | package WWW::Hetzner::Cloud::Certificate; | ||||||||||||
| 2 | # ABSTRACT: Hetzner Cloud Certificate object | ||||||||||||
| 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::HasAction'; | |||||||||||
| 8 | 60 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 60 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | |||||||||||||
| 12 | 60 | has _client => ( | |||||||||||
| 13 | is => 'ro', | ||||||||||||
| 14 | required => 1, | ||||||||||||
| 15 | weak_ref => 1, | ||||||||||||
| 16 | init_arg => 'client', | ||||||||||||
| 17 | ); | ||||||||||||
| 18 | |||||||||||||
| 19 | 60 | has id => ( is => 'ro' ); | |||||||||||
| 20 | |||||||||||||
| 21 | |||||||||||||
| 22 | 60 | has name => ( is => 'rw' ); | |||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | 60 | has certificate => ( is => 'ro' ); | |||||||||||
| 26 | |||||||||||||
| 27 | |||||||||||||
| 28 | 0 | ▶ | has domain_names => ( is => 'ro', default => sub { [] } ); | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | 60 | has fingerprint => ( is => 'ro' ); | |||||||||||
| 32 | |||||||||||||
| 33 | |||||||||||||
| 34 | 0 | ▶ | has status => ( is => 'ro', default => sub { {} } ); | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | 60 | has type => ( is => 'ro' ); | |||||||||||
| 38 | |||||||||||||
| 39 | |||||||||||||
| 40 | 0 | ▶ | has labels => ( is => 'rw', default => sub { {} } ); | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 41 | |||||||||||||
| 42 | |||||||||||||
| 43 | 60 | has created => ( is => 'ro' ); | |||||||||||
| 44 | |||||||||||||
| 45 | |||||||||||||
| 46 | 60 | has not_valid_before => ( is => 'ro' ); | |||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | 60 | has not_valid_after => ( is => 'ro' ); | |||||||||||
| 50 | |||||||||||||
| 51 | |||||||||||||
| 52 | # Convenience | ||||||||||||
| 53 | 2 | ▶ | sub is_managed { shift->type eq 'managed' } | ||||||||||
|
Subroutine
is_managed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 54 | |||||||||||||
| 55 | |||||||||||||
| 56 | 0 | ▶ | sub is_valid { (shift->status->{issuance} // '') eq 'completed' } | ||||||||||
|
Subroutine
is_valid: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
+(shift())->status->{"issuance"} // ""
MC/DC0%0/1
+(shift())->status->{"issuance"} // ""
+(shift())->status->{"issuance"}
Truth table0%0/2
A
A= +(shift())->status->{"issuance"}
| |||||||||||||
| 57 | |||||||||||||
| 58 | |||||||||||||
| 59 | # Actions | ||||||||||||
| 60 | 0 | ▶ | sub update { | ||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 61 | 0 | my ($self) = @_; | |||||||||||
| 62 | 0 | ▶ | croak "Cannot update certificate without ID" unless $self->id; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | |||||||||||||
| 64 | 0 | $self->_client->put("/certificates/" . $self->id, { | |||||||||||
| 65 | name => $self->name, | ||||||||||||
| 66 | labels => $self->labels, | ||||||||||||
| 67 | }); | ||||||||||||
| 68 | 0 | return $self; | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | |||||||||||||
| 72 | 0 | ▶ | sub delete { | ||||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 73 | 0 | my ($self) = @_; | |||||||||||
| 74 | 0 | ▶ | croak "Cannot delete certificate without ID" unless $self->id; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 75 | |||||||||||||
| 76 | 0 | $self->_client->delete("/certificates/" . $self->id); | |||||||||||
| 77 | 0 | return 1; | |||||||||||
| 78 | } | ||||||||||||
| 79 | |||||||||||||
| 80 | |||||||||||||
| 81 | 1 | ▶ | sub retry { | ||||||||||
|
Subroutine
retry: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||
| 82 | 1 | my ($self) = @_; | |||||||||||
| 83 | 1 | ▶ | croak "Cannot retry certificate without ID" unless $self->id; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 84 | 1 | ▶ | croak "Only managed certificates can be retried" unless $self->is_managed; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 85 | |||||||||||||
| 86 | 1 | return $self->_client->certificates->retry($self->id); | |||||||||||
| 87 | } | ||||||||||||
| 88 | |||||||||||||
| 89 | |||||||||||||
| 90 | 0 | ▶ | sub data { | ||||||||||
|
Subroutine
data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 91 | 0 | my ($self) = @_; | |||||||||||
| 92 | return { | ||||||||||||
| 93 | 0 | id => $self->id, | |||||||||||
| 94 | name => $self->name, | ||||||||||||
| 95 | certificate => $self->certificate, | ||||||||||||
| 96 | domain_names => $self->domain_names, | ||||||||||||
| 97 | fingerprint => $self->fingerprint, | ||||||||||||
| 98 | status => $self->status, | ||||||||||||
| 99 | type => $self->type, | ||||||||||||
| 100 | labels => $self->labels, | ||||||||||||
| 101 | created => $self->created, | ||||||||||||
| 102 | not_valid_before => $self->not_valid_before, | ||||||||||||
| 103 | not_valid_after => $self->not_valid_after, | ||||||||||||
| 104 | }; | ||||||||||||
| 105 | } | ||||||||||||
| 106 | |||||||||||||
| 107 | |||||||||||||
| 108 | |||||||||||||
| 109 | 60 | 1. | |||||||||||
| 110 | |||||||||||||
| 111 | __END__ | ||||||||||||