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