| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Update; | ||||||||||
| 2 | # ABSTRACT: Update a Storage Box | ||||||||||
| 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 update --name <name> <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 | |||||||||||
| 11 | 1 | option name => ( is => 'ro', format => 's', required => 1, doc => 'New Storage Box name' ); | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||
| 14 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 15 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box update --name <name> <storage-box>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 1 | my $main = $chain->[0]; | |||||||||
| 17 | 1 | my $box = $main->storage->storage_boxes->update($id, name => $self->name); | |||||||||
| 18 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | print encode_json($box->data), "\n"; | |||||||||
| 20 | 0 | return; | |||||||||
| 21 | } | ||||||||||
| 22 | 1 | print "Storage Box updated:\n"; | |||||||||
| 23 | 1 | printf " ID: %s\n", $box->id; | |||||||||
| 24 | 1 | printf " Name: %s\n", $box->name; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 1 | 1; | |||||||||
| 28 | |||||||||||
| 29 | __END__ | ||||||||||