« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/List.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/PrimaryIp/Cmd/Describe.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Storage Box commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 <command> [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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | option name => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | short => 'n', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | doc => 'Filter by Storage Box name', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | option selector => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | format => 's', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | short => 'l', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | doc => 'Filter by label selector', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | $self->_list($chain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | sub _list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list: called CC=13 SCAR=33.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | my ($self, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $params{name} = $self->name if defined $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | $params{label_selector} = $self->selector if defined $self->selector; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my $boxes = $main->storage->storage_boxes->list_all(%params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | print encode_json([map { $_->data } @$boxes]), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | if (!@$boxes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | print "No Storage Boxes found.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | printf "%-10s %-25s %-12s %-12s %s\n", 'ID', 'NAME', 'TYPE', 'LOCATION', 'STATUS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | print '-' x 78, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | for my $box (@$boxes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | my $type = $box->storage_box_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $location = $box->location; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | printf "%-10s %-25s %-12s %-12s %s\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $box->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $box->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ref $type eq 'HASH' ? ($type->{name} // '-') : ($type // '-'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $box->status // '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||