« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/AddLabel.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Describe.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Subaccount; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Storage Box subaccount 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 protect_argv => 0, usage_string => 'USAGE: hcloud.pl storage-box subaccount <command> [options] <storage-box>'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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 | 1 | ▶ | use WWW::Hetzner::Storage::API::Subaccounts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | $self->_list($args, $chain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | sub _list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list: called CC=11 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount list <storage-box>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $subaccounts = WWW::Hetzner::Storage::API::Subaccounts->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | client => $main->storage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | storage_box_id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | )->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | print encode_json([map { $_->data } @$subaccounts]), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if (!@$subaccounts) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | print "No subaccounts found.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | printf "%-10s %-25s %-25s %-40s %s\n", 'ID', 'NAME', 'USERNAME', 'HOME_DIRECTORY', 'DESCRIPTION'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | print '-' x 120, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | for my $sub (@$subaccounts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | printf "%-10s %-25s %-25s %-40s %s\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%4/8
$sub->name // ""
$sub->username // "-"
$sub->home_directory // "-"
$sub->description // ""
MC/DC0%0/1
$sub->name // ""
$sub->name
MC/DC0%0/1
$sub->username // "-"
$sub->username
MC/DC0%0/1
$sub->home_directory // "-"
$sub->home_directory
MC/DC0%0/1
$sub->description // ""
$sub->description
Truth table50%1/2
A
A= $sub->name
Truth table50%1/2
A
A= $sub->username
Truth table50%1/2
A
A= $sub->home_directory
Truth table50%1/2
A
A= $sub->description
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | $sub->id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ($sub->name // '') ne '' ? $sub->name : '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $sub->username // '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | $sub->home_directory // '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ($sub->description // '') ne '' ? $sub->description : '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||