| 1 | package WWW::Hetzner::Storage::API::Actions; | ||||||||||||
| 2 | # ABSTRACT: Hetzner Storage Box Actions API | ||||||||||||
| 3 | |||||||||||||
| 4 | 11 | our $VERSION = '0.102'; | |||||||||||
| 5 | |||||||||||||
| 6 | 11 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 11 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 11 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | |||||||||||||
| 11 | 11 | has client => ( | |||||||||||
| 12 | is => 'ro', | ||||||||||||
| 13 | required => 1, | ||||||||||||
| 14 | weak_ref => 1, | ||||||||||||
| 15 | ); | ||||||||||||
| 16 | |||||||||||||
| 17 | 11 | has storage_box_id => ( is => 'ro' ); | |||||||||||
| 18 | |||||||||||||
| 19 | 11 | with 'WWW::Hetzner::Role::HasActions'; | |||||||||||
| 20 | 11 | with 'WWW::Hetzner::Role::Pagination'; | |||||||||||
| 21 | |||||||||||||
| 22 | has '+action_poll_path' => ( | ||||||||||||
| 23 | 4 | ▶ | default => sub { '/storage_boxes/actions' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 11 | ); | |||||||||||
| 25 | |||||||||||||
| 26 | 6 | ▶ | sub _base_path { | ||||||||||
|
Subroutine
_base_path: called CC=2 SCAR=6.9
| |||||||||||||
| 27 | 6 | my ($self) = @_; | |||||||||||
| 28 | 6 | ▶ | return defined $self->storage_box_id | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | ? '/storage_boxes/' . $self->storage_box_id . '/actions' | ||||||||||||
| 30 | : '/storage_boxes/actions'; | ||||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 6 | ▶ | sub _list_page { | ||||||||||
|
Subroutine
_list_page: called CC=2 SCAR=7.1
| |||||||||||||
| 34 | 6 | my ($self, %params) = @_; | |||||||||||
| 35 | |||||||||||||
| 36 | 6 | my $result = $self->client->get($self->_base_path, params => \%params); | |||||||||||
| 37 | 6 | ▶ | return ($self->_wrap_actions($result->{actions} // []), $result->{meta}); | ||||||||||
|
Condition50%1/2
$result->{"actions"} // []
MC/DC0%0/1
$result->{"actions"} // []
$result->{"actions"}
Truth table50%1/2
A
A= $result->{"actions"}
| |||||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | |||||||||||||
| 41 | 2 | ▶ | sub list { | ||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 42 | 2 | my ($self, %params) = @_; | |||||||||||
| 43 | |||||||||||||
| 44 | 2 | my ($entities) = $self->_list_page(%params); | |||||||||||
| 45 | 2 | return $entities; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | 7 | ▶ | sub get { | ||||||||||
|
Subroutine
get: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 50 | 7 | my ($self, $id) = @_; | |||||||||||
| 51 | 7 | ▶ | croak 'Action ID required' unless $id; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | |||||||||||||
| 53 | 7 | my $result = $self->client->get("/storage_boxes/actions/$id"); | |||||||||||
| 54 | 6 | return $self->_wrap_action($result->{action}); | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | |||||||||||||
| 58 | 11 | 1; | |||||||||||
| 59 | |||||||||||||
| 60 | __END__ | ||||||||||||