« lib/WWW/Hetzner/Cloud/API/Firewalls.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/Describe.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Volume::Cmd::List; | ||||||||||||||||||||||
| 2 | # ABSTRACT: List volumes | ||||||||||||||||||||||
| 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 volume 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 | ▶ | sub execute { | ||||||||||||||||||||
|
Subroutine
execute: called CC=6 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||
| 15 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | 1 | my $volumes = $cloud->volumes->list_all; | |||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 20 | 0 | print encode_json([map { $_->data } @$volumes]), "\n"; | |||||||||||||||||||||
| 21 | 0 | return; | |||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 1 | ▶ | if (!@$volumes) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 25 | 0 | print "No volumes found.\n"; | |||||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||
| 28 | |||||||||||||||||||||||
| 29 | 1 | printf "%-10s %-25s %-8s %-10s %-10s %s\n", | |||||||||||||||||||||
| 30 | 'ID', 'NAME', 'SIZE', 'SERVER', 'LOCATION', 'STATUS'; | ||||||||||||||||||||||
| 31 | 1 | print "-" x 80, "\n"; | |||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | 1 | for my $v (@$volumes) { | |||||||||||||||||||||
| 34 | 2 | ▶ | printf "%-10s %-25s %-8s %-10s %-10s %s\n", | ||||||||||||||||||||
|
Condition75%3/4
$v->server // "-"
$v->location // "-"
MC/DC100%1/1
$v->server // "-"
$v->server
MC/DC0%0/1
$v->location // "-"
$v->location
Truth table100%2/2
A
A= $v->server
Truth table50%1/2
A
A= $v->location
| |||||||||||||||||||||||
| 35 | $v->id, | ||||||||||||||||||||||
| 36 | $v->name, | ||||||||||||||||||||||
| 37 | $v->size . ' GB', | ||||||||||||||||||||||
| 38 | $v->server // '-', | ||||||||||||||||||||||
| 39 | $v->location // '-', | ||||||||||||||||||||||
| 40 | $v->status; | ||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||