« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Describe.pm
↑ Summary
lib/WWW/Hetzner/Robot/CLI/Cmd/Boot/Cmd/Linux.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Subaccount::Cmd::Update; | ||||||||||||||||||||
| 2 | # ABSTRACT: Update a Storage Box subaccount | ||||||||||||||||||||
| 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 update [--name <name>] [--description <description>] <storage-box> <subaccount>'; | ||||||||||||||||||
|
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 | option name => ( | |||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||
| 15 | format => 's', | ||||||||||||||||||||
| 16 | doc => 'New subaccount name', | ||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 1 | option description => ( | |||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||
| 21 | format => 's', | ||||||||||||||||||||
| 22 | doc => 'New subaccount description', | ||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | ▶ | sub execute { | ||||||||||||||||||
|
Subroutine
execute: called CC=12 SCAR=28.3
Pod
undocumented
| |||||||||||||||||||||
| 26 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||
| 27 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount update <storage-box> <subaccount>\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 1 | ▶ | my $sub = $args->[1] or die "Usage: hcloud.pl storage-box subaccount update <storage-box> <subaccount>\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 1 | my $main = $chain->[0]; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | my %body; | |||||||||||||||||||
| 32 | 1 | ▶ | $body{name} = $self->name if defined $self->name; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 1 | ▶ | $body{description} = $self->description if defined $self->description; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 1 | my $subaccounts = WWW::Hetzner::Storage::API::Subaccounts->new( | |||||||||||||||||||
| 36 | client => $main->storage, | ||||||||||||||||||||
| 37 | storage_box_id => $id, | ||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||
| 39 | 1 | my $subaccount = $subaccounts->update($sub, %body); | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 0 | print encode_json($subaccount->data), "\n"; | |||||||||||||||||||
| 43 | 0 | return; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 1 | print "Subaccount updated:\n"; | |||||||||||||||||||
| 47 | 1 | printf " ID: %s\n", $subaccount->id; | |||||||||||||||||||
| 48 | 1 | ▶ | printf " Name: %s\n", ($subaccount->name // '') ne '' ? $subaccount->name : '-'; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$subaccount->name // ""
MC/DC0%0/1
$subaccount->name // ""
$subaccount->name
Truth table50%1/2
A
A= $subaccount->name
| |||||||||||||||||||||
| 49 | 1 | ▶ | printf " Username: %s\n", $subaccount->username // '-'; | ||||||||||||||||||
|
Condition50%1/2
$subaccount->username // "-"
MC/DC0%0/1
$subaccount->username // "-"
$subaccount->username
Truth table50%1/2
A
A= $subaccount->username
| |||||||||||||||||||||
| 50 | 1 | ▶ | printf " Home Directory: %s\n", $subaccount->home_directory // '-'; | ||||||||||||||||||
|
Condition50%1/2
$subaccount->home_directory // "-"
MC/DC0%0/1
$subaccount->home_directory // "-"
$subaccount->home_directory
Truth table50%1/2
A
A= $subaccount->home_directory
| |||||||||||||||||||||
| 51 | 1 | ▶ | printf " Description: %s\n", ($subaccount->description // '') ne '' ? $subaccount->description : '-'; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$subaccount->description // ""
MC/DC0%0/1
$subaccount->description // ""
$subaccount->description
Truth table50%1/2
A
A= $subaccount->description
| |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 1 | 1; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||