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