« lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Detach.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/Delete.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Volume::Cmd::Resize; | ||
| 2 | # ABSTRACT: Resize a volume | ||
| 3 | |||
| 4 | our $VERSION = '0.100'; | ||
| 5 | |||
| 6 | use Moo; | ||
| 7 | use MooX::Cmd; | ||
| 8 | use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl volume resize <id> --size <gb>'; | ||
| 9 | |||
| 10 | option size => ( | ||
| 11 | is => 'ro', | ||
| 12 | format => 'i', | ||
| 13 | required => 1, | ||
| 14 | doc => 'New size in GB (can only increase)', | ||
| 15 | ); | ||
| 16 | |||
| 17 | sub execute { | ||
| 18 | my ($self, $args, $chain) = @_; | ||
| 19 | my $id = $args->[0] or die "Usage: hcloud.pl volume resize <id> --size <gb>\n"; | ||
| 20 | |||
| 21 | my $main = $chain->[0]; | ||
| 22 | my $cloud = $main->cloud; | ||
| 23 | |||
| 24 | print "Resizing volume $id to ", $self->size, " GB...\n"; | ||
| 25 | $cloud->volumes->resize($id, $self->size); | ||
| 26 | print "Volume resized.\n"; | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |