| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: List Storage Boxes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 usage_string => 'USAGE: hcloud.pl storage-box list [options]'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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 | option name => ( is => 'ro', format => 's', short => 'n', doc => 'Filter by Storage Box name' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | option selector => ( is => 'ro', format => 's', short => 'l', doc => 'Filter by label selector' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=13 SCAR=33.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | $params{name} = $self->name if defined $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | $params{label_selector} = $self->selector if defined $self->selector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $boxes = $main->storage->storage_boxes->list_all(%params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | print encode_json([map { $_->data } @$boxes]), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | if (!@$boxes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | print "No Storage Boxes found.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | printf "%-10s %-25s %-12s %-12s %s\n", 'ID', 'NAME', 'TYPE', 'LOCATION', 'STATUS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | print '-' x 78, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | for my $box (@$boxes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | my $type = $box->storage_box_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my $location = $box->location; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | printf "%-10s %-25s %-12s %-12s %s\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $box->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $box->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ref $type eq 'HASH' ? ($type->{name} // '-') : ($type // '-'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | ref $location eq 'HASH' ? ($location->{name} // '-') : ($location // '-'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition30%3/10
$type->{"name"} // "-"
$type // "-"
$location->{"name"} // "-"
$location // "-"
$box->status // "-"
MC/DC0%0/1
$type->{"name"} // "-"
$type->{"name"}
MC/DC0%0/1
$type // "-"
$type
MC/DC0%0/1
$location->{"name"} // "-"
$location->{"name"}
MC/DC0%0/1
$location // "-"
$location
MC/DC0%0/1
$box->status // "-"
$box->status
Truth table50%1/2
A
A= $type->{"name"}
Truth table0%0/2
A
A= $type
Truth table50%1/2
A
A= $location->{"name"}
Truth table0%0/2
A
A= $location
Truth table50%1/2
A
A= $box->status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | $box->status // '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||