| 1 | package WWW::Hetzner::CLI::Cmd::PrimaryIp::Cmd::List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: List primary IPs | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | our $VERSION = '0.102'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use MooX::Cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl primary-ip list'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use JSON::MaybeXS qw(encode_json); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=9 SCAR=26.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | my $pips = $cloud->primary_ips->list_all; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | print encode_json([ map { $_->data } @$pips ]), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | if (!@$pips) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | print "No primary IPs found.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | printf "%-8s %-20s %-6s %-18s %-12s %-10s\n", 'ID', 'NAME', 'TYPE', 'IP', 'LOCATION', 'ASSIGNEE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | printf "%-8s %-20s %-6s %-18s %-12s %-10s\n", '-' x 8, '-' x 20, '-' x 6, '-' x 18, '-' x 12, '-' x 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | for my $pip (@$pips) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | printf "%-8s %-20s %-6s %-18s %-12s %-10s\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%6/10
$pip->name // "-"
$pip->type // "-"
$pip->ip // "-"
$pip->location // "-"
$pip->assignee_id // "-"
MC/DC0%0/1
$pip->name // "-"
$pip->name
MC/DC0%0/1
$pip->type // "-"
$pip->type
MC/DC0%0/1
$pip->ip // "-"
$pip->ip
MC/DC100%1/1
$pip->location // "-"
$pip->location
MC/DC0%0/1
$pip->assignee_id // "-"
$pip->assignee_id
Truth table50%1/2
A
A= $pip->name
Truth table50%1/2
A
A= $pip->type
Truth table50%1/2
A
A= $pip->ip
Truth table100%2/2
A
A= $pip->location
Truth table50%1/2
A
A= $pip->assignee_id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | $pip->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $pip->name // '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $pip->type // '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $pip->ip // '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $pip->location // '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $pip->assignee_id // '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||