| 1 | package WWW::Hetzner::Storage::Snapshot; | ||||||||||
| 2 | # ABSTRACT: Hetzner Storage Box Snapshot object | ||||||||||
| 3 | |||||||||||
| 4 | 11 | our $VERSION = '0.102'; | |||||||||
| 5 | |||||||||||
| 6 | 11 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 11 | with 'WWW::Hetzner::Role::HasAction'; | |||||||||
| 8 | 11 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 11 | ▶ | use WWW::Hetzner::Storage::API::Snapshots; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 11 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 11 | has _client => ( | |||||||||
| 14 | is => 'ro', | ||||||||||
| 15 | required => 1, | ||||||||||
| 16 | weak_ref => 1, | ||||||||||
| 17 | init_arg => 'client', | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | 11 | has _storage_box_id => ( | |||||||||
| 21 | is => 'ro', | ||||||||||
| 22 | required => 1, | ||||||||||
| 23 | init_arg => 'storage_box_id', | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 11 | has id => ( is => 'ro' ); | |||||||||
| 27 | 11 | has storage_box => ( is => 'ro' ); | |||||||||
| 28 | 11 | has name => ( is => 'ro' ); | |||||||||
| 29 | 11 | has description => ( is => 'rw' ); | |||||||||
| 30 | 11 | has labels => ( is => 'rw' ); | |||||||||
| 31 | 11 | has stats => ( is => 'ro' ); | |||||||||
| 32 | 11 | has is_automatic => ( is => 'ro' ); | |||||||||
| 33 | 11 | has created => ( is => 'ro' ); | |||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 2 | ▶ | sub _require_id { | ||||||||
|
Subroutine
_require_id: called CC=2 SCAR=7.2
| |||||||||||
| 44 | 2 | my ($self) = @_; | |||||||||
| 45 | 2 | ▶ | croak 'Cannot use snapshot without ID' unless $self->id; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 2 | ▶ | sub _controller { | ||||||||
|
Subroutine
_controller: called CC=1 SCAR=0.0
| |||||||||||
| 49 | 2 | my ($self) = @_; | |||||||||
| 50 | 2 | return WWW::Hetzner::Storage::API::Snapshots->new( | |||||||||
| 51 | client => $self->_client, | ||||||||||
| 52 | storage_box_id => $self->_storage_box_id, | ||||||||||
| 53 | ); | ||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 1 | ▶ | sub update { | ||||||||
|
Subroutine
update: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 1 | my ($self) = @_; | |||||||||
| 59 | 1 | $self->_require_id; | |||||||||
| 60 | |||||||||||
| 61 | 1 | return $self->_controller->update( | |||||||||
| 62 | $self->id, | ||||||||||
| 63 | description => $self->description, | ||||||||||
| 64 | labels => $self->labels, | ||||||||||
| 65 | ); | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | 1 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | 1 | my ($self) = @_; | |||||||||
| 71 | 1 | $self->_require_id; | |||||||||
| 72 | 1 | return $self->_controller->delete($self->id); | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | 2 | ▶ | sub data { | ||||||||
|
Subroutine
data: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 77 | 2 | my ($self) = @_; | |||||||||
| 78 | return { | ||||||||||
| 79 | 2 | id => $self->id, | |||||||||
| 80 | storage_box => $self->storage_box, | ||||||||||
| 81 | name => $self->name, | ||||||||||
| 82 | description => $self->description, | ||||||||||
| 83 | labels => $self->labels, | ||||||||||
| 84 | stats => $self->stats, | ||||||||||
| 85 | is_automatic => $self->is_automatic, | ||||||||||
| 86 | created => $self->created, | ||||||||||
| 87 | }; | ||||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | |||||||||||
| 91 | 11 | 1; | |||||||||
| 92 | |||||||||||
| 93 | __END__ | ||||||||||