| 1 | package WWW::Hetzner::CLI::Cmd::FloatingIp::Cmd::Describe; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Describe a floating IP | ||||||||||||||||||||||||||||
| 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 floating-ip 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=15 SCAR=30.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||
| 13 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl floating-ip describe <id>\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||
| 16 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | my $fip = $cloud->floating_ips->get($id); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | print encode_json($fip->data), "\n"; | |||||||||||||||||||||||||||
| 22 | 0 | return; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | printf "ID: %s\n", $fip->id; | |||||||||||||||||||||||||||
| 26 | 1 | ▶ | printf "Name: %s\n", $fip->name // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$fip->name // "-"
MC/DC0%0/1
$fip->name // "-"
$fip->name
Truth table50%1/2
A
A= $fip->name
| |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | printf "Description: %s\n", $fip->description // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$fip->description // "-"
MC/DC0%0/1
$fip->description // "-"
$fip->description
Truth table50%1/2
A
A= $fip->description
| |||||||||||||||||||||||||||||
| 28 | 1 | printf "IP: %s\n", $fip->ip; | |||||||||||||||||||||||||||
| 29 | 1 | printf "Type: %s\n", $fip->type; | |||||||||||||||||||||||||||
| 30 | 1 | ▶ | printf "Location: %s\n", $fip->location // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$fip->location // "-"
MC/DC0%0/1
$fip->location // "-"
$fip->location
Truth table50%1/2
A
A= $fip->location
| |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | printf "Server: %s\n", $fip->server // 'not assigned'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$fip->server // "not assigned"
MC/DC0%0/1
$fip->server // "not assigned"
$fip->server
Truth table50%1/2
A
A= $fip->server
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | printf "Blocked: %s\n", $fip->blocked ? 'yes' : 'no'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | printf "Created: %s\n", $fip->created // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$fip->created // "-"
MC/DC0%0/1
$fip->created // "-"
$fip->created
Truth table50%1/2
A
A= $fip->created
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | my $dns_ptr = $fip->dns_ptr; | |||||||||||||||||||||||||||
| 36 | 1 | ▶ | if ($dns_ptr && @$dns_ptr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dns_ptr and @$dns_ptr
MC/DC0%0/2
$dns_ptr and @$dns_ptr
$dns_ptr
@$dns_ptr
Truth table33%1/3
A and B
A= $dns_ptrB= @$dns_ptr
| |||||||||||||||||||||||||||||
| 37 | 1 | print "DNS PTR:\n"; | |||||||||||||||||||||||||||
| 38 | 1 | for my $ptr (@$dns_ptr) { | |||||||||||||||||||||||||||
| 39 | 1 | printf " %s -> %s\n", $ptr->{ip}, $ptr->{dns_ptr}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1 | my $labels = $fip->labels; | |||||||||||||||||||||||||||
| 44 | 1 | ▶ | if ($labels && %$labels) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$labels and %$labels
MC/DC0%0/2
$labels and %$labels
$labels
%$labels
Truth table33%1/3
A and B
A= $labelsB= %$labels
| |||||||||||||||||||||||||||||
| 45 | 1 | print "Labels:\n"; | |||||||||||||||||||||||||||
| 46 | 1 | for my $k (sort keys %$labels) { | |||||||||||||||||||||||||||
| 47 | 1 | printf " %s: %s\n", $k, $labels->{$k}; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 1 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||