| 1 | package WWW::Hetzner::Storage::API::StorageBoxTypes; | ||||||||||||
| 2 | # ABSTRACT: Hetzner Storage Box Types 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 WWW::Hetzner::Storage::StorageBoxType; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 11 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | |||||||||||||
| 12 | 11 | has client => ( | |||||||||||
| 13 | is => 'ro', | ||||||||||||
| 14 | required => 1, | ||||||||||||
| 15 | weak_ref => 1, | ||||||||||||
| 16 | ); | ||||||||||||
| 17 | |||||||||||||
| 18 | 11 | with 'WWW::Hetzner::Role::Pagination'; | |||||||||||
| 19 | |||||||||||||
| 20 | 6 | ▶ | sub _wrap { | ||||||||||
|
Subroutine
_wrap: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 6 | my ($self, $data) = @_; | |||||||||||
| 22 | 6 | return WWW::Hetzner::Storage::StorageBoxType->new( | |||||||||||
| 23 | client => $self->client, | ||||||||||||
| 24 | %$data, | ||||||||||||
| 25 | ); | ||||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | 5 | ▶ | sub _wrap_list { | ||||||||||
|
Subroutine
_wrap_list: called CC=2 SCAR=7.0
| |||||||||||||
| 29 | 5 | my ($self, $list) = @_; | |||||||||||
| 30 | 5 | ▶ | return [ map { $self->_wrap($_) } @{ $list // [] } ]; | ||||||||||
|
Condition50%1/2
$list // []
MC/DC0%0/1
$list // []
$list
Truth table50%1/2
A
A= $list
| |||||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 5 | ▶ | sub _list_page { | ||||||||||
|
Subroutine
_list_page: called CC=2 SCAR=7.1
| |||||||||||||
| 34 | 5 | my ($self, %params) = @_; | |||||||||||
| 35 | |||||||||||||
| 36 | 5 | my $result = $self->client->get('/storage_box_types', params => \%params); | |||||||||||
| 37 | 5 | ▶ | return ($self->_wrap_list($result->{storage_box_types} // []), $result->{meta}); | ||||||||||
|
Condition50%1/2
$result->{"storage_box_types"} // []
MC/DC0%0/1
$result->{"storage_box_types"} // []
$result->{"storage_box_types"}
Truth table50%1/2
A
A= $result->{"storage_box_types"}
| |||||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | |||||||||||||
| 41 | 1 | ▶ | sub list { | ||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 42 | 1 | my ($self, %params) = @_; | |||||||||||
| 43 | |||||||||||||
| 44 | 1 | my ($entities) = $self->_list_page(%params); | |||||||||||
| 45 | 1 | return $entities; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | 1 | ▶ | sub get { | ||||||||||
|
Subroutine
get: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 50 | 1 | my ($self, $id) = @_; | |||||||||||
| 51 | 1 | ▶ | croak 'Storage Box Type ID required' unless $id; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | |||||||||||||
| 53 | 1 | my $result = $self->client->get("/storage_box_types/$id"); | |||||||||||
| 54 | 1 | return $self->_wrap($result->{storage_box_type}); | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | |||||||||||||
| 58 | 1 | ▶ | sub get_by_name { | ||||||||||
|
Subroutine
get_by_name: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||
| 59 | 1 | my ($self, $name) = @_; | |||||||||||
| 60 | 1 | ▶ | croak 'Name required' unless $name; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 61 | |||||||||||||
| 62 | 1 | my $types = $self->list_all(name => $name); | |||||||||||
| 63 | 1 | for my $type (@$types) { | |||||||||||
| 64 | 2 | ▶ | return $type if $type->name eq $name; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | } | ||||||||||||
| 66 | 0 | return; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | |||||||||||||
| 70 | 11 | 1; | |||||||||||
| 71 | |||||||||||||
| 72 | __END__ | ||||||||||||