« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Create.pm
↑ Summary
lib/WWW/Hetzner/Robot/CLI/Cmd/Traffic.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::LoadBalancer::Cmd::Describe; | ||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Describe a load balancer | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '0.102'; | |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use MooX::Cmd; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl load-balancer describe <id>'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON::MaybeXS qw(encode_json); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=18 SCAR=35.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl load-balancer describe <id>\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||
| 16 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 1 | my $lb = $cloud->load_balancers->get($id); | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 21 | 0 | print encode_json($lb->data), "\n"; | |||||||||||||||||||||||||||||||
| 22 | 0 | return; | |||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 1 | printf "ID: %s\n", $lb->id; | |||||||||||||||||||||||||||||||
| 26 | 1 | printf "Name: %s\n", $lb->name; | |||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | printf "Type: %s\n", $lb->type_name // '-'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$lb->type_name // "-"
MC/DC0%0/1
$lb->type_name // "-"
$lb->type_name
Truth table50%1/2
A
A= $lb->type_name
| |||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | printf "IPv4: %s\n", $lb->ipv4 // '-'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$lb->ipv4 // "-"
MC/DC0%0/1
$lb->ipv4 // "-"
$lb->ipv4
Truth table50%1/2
A
A= $lb->ipv4
| |||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | printf "IPv6: %s\n", $lb->ipv6 // '-'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$lb->ipv6 // "-"
MC/DC0%0/1
$lb->ipv6 // "-"
$lb->ipv6
Truth table50%1/2
A
A= $lb->ipv6
| |||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | printf "Location: %s\n", $lb->location_name // '-'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$lb->location_name // "-"
MC/DC0%0/1
$lb->location_name // "-"
$lb->location_name
Truth table50%1/2
A
A= $lb->location_name
| |||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | printf "Algorithm: %s\n", $lb->algorithm->{type} // '-'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$lb->algorithm->{"type"} // "-"
MC/DC0%0/1
$lb->algorithm->{"type"} // "-"
$lb->algorithm->{"type"}
Truth table50%1/2
A
A= $lb->algorithm->{"type"}
| |||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | printf "Created: %s\n", $lb->created // '-'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$lb->created // "-"
MC/DC0%0/1
$lb->created // "-"
$lb->created
Truth table50%1/2
A
A= $lb->created
| |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 1 | my $targets = $lb->targets; | |||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if ($targets && @$targets) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$targets and @$targets
MC/DC0%0/2
$targets and @$targets
$targets
@$targets
Truth table33%1/3
A and B
A= $targetsB= @$targets
| |||||||||||||||||||||||||||||||||
| 36 | 1 | print "\nTargets:\n"; | |||||||||||||||||||||||||||||||
| 37 | 1 | for my $t (@$targets) { | |||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | if ($t->{type} eq 'server' && $t->{server}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$t->{"type"} eq "server" and $t->{"server"}
MC/DC0%0/2
$t->{"type"} eq "server" and $t->{"server"}
$t->{"type"} eq "server"
$t->{"server"}
Truth table33%1/3
A and B
A= $t->{"type"} eq "server"B= $t->{"server"}
| |||||||||||||||||||||||||||||||||
| 39 | 1 | printf " - Server %d\n", $t->{server}{id}; | |||||||||||||||||||||||||||||||
| 40 | } elsif ($t->{type} eq 'label_selector') { | ||||||||||||||||||||||||||||||||
| 41 | 0 | printf " - Label: %s\n", $t->{label_selector}{selector}; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 1 | my $services = $lb->services; | |||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if ($services && @$services) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$services and @$services
MC/DC0%0/2
$services and @$services
$services
@$services
Truth table33%1/3
A and B
A= $servicesB= @$services
| |||||||||||||||||||||||||||||||||
| 48 | 1 | print "\nServices:\n"; | |||||||||||||||||||||||||||||||
| 49 | 1 | for my $s (@$services) { | |||||||||||||||||||||||||||||||
| 50 | printf " - %s :%d -> :%d\n", | ||||||||||||||||||||||||||||||||
| 51 | $s->{protocol}, | ||||||||||||||||||||||||||||||||
| 52 | $s->{listen_port}, | ||||||||||||||||||||||||||||||||
| 53 | 1 | $s->{destination_port}; | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||||||