| 1 | package WWW::Hetzner::Cloud::SSHKey; | ||||||||||
| 2 | # ABSTRACT: Hetzner Cloud SSHKey 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 id => ( is => 'ro' ); | |||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | 60 | has name => ( is => 'rw' ); | |||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | 60 | has public_key => ( is => 'ro' ); | |||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 60 | has fingerprint => ( is => 'ro' ); | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | 60 | has created => ( is => 'ro' ); | |||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | 4 | ▶ | has labels => ( is => 'rw', default => sub { {} } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub update { | ||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 37 | 0 | my ($self) = @_; | |||||||||
| 38 | 0 | ▶ | croak "Cannot update SSH key without ID" unless $self->id; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | $self->_client->put("/ssh_keys/" . $self->id, { | |||||||||
| 41 | name => $self->name, | ||||||||||
| 42 | labels => $self->labels, | ||||||||||
| 43 | }); | ||||||||||
| 44 | 0 | return $self; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 49 | 0 | my ($self) = @_; | |||||||||
| 50 | 0 | ▶ | croak "Cannot delete SSH key without ID" unless $self->id; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | $self->_client->delete("/ssh_keys/" . $self->id); | |||||||||
| 53 | 0 | return 1; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 1 | ▶ | sub data { | ||||||||
|
Subroutine
data: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 1 | my ($self) = @_; | |||||||||
| 59 | return { | ||||||||||
| 60 | 1 | id => $self->id, | |||||||||
| 61 | name => $self->name, | ||||||||||
| 62 | public_key => $self->public_key, | ||||||||||
| 63 | fingerprint => $self->fingerprint, | ||||||||||
| 64 | created => $self->created, | ||||||||||
| 65 | labels => $self->labels, | ||||||||||
| 66 | }; | ||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | |||||||||||
| 71 | 60 | 1. | |||||||||
| 72 | |||||||||||
| 73 | __END__ | ||||||||||