« lib/WWW/Hetzner/CLI/Cmd/Record/Cmd/Describe.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Delete.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Snapshot::Cmd::Create; | ||||||||||
| 2 | # ABSTRACT: Create a Storage Box snapshot | ||||||||||
| 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 snapshot create [--description <description>] <storage-box>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use WWW::Hetzner::Storage::API::Snapshots; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | with 'WWW::Hetzner::CLI::Role::WaitsForAction'; | |||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 1 | option description => ( | |||||||||
| 14 | is => 'ro', | ||||||||||
| 15 | format => 's', | ||||||||||
| 16 | doc => 'Snapshot description', | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||
| 20 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 21 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot create <storage-box>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | |||||||||||
| 23 | 1 | my %params; | |||||||||
| 24 | 1 | ▶ | $params{description} = $self->description if defined $self->description; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 1 | print "Creating snapshot for Storage Box $id...\n"; | |||||||||
| 27 | 1 | my $snapshots = WWW::Hetzner::Storage::API::Snapshots->new( | |||||||||
| 28 | client => $chain->[0]->storage, | ||||||||||
| 29 | storage_box_id => $id, | ||||||||||
| 30 | ); | ||||||||||
| 31 | 1 | my $snapshot = $snapshots->create(%params); | |||||||||
| 32 | 1 | $self->handle_action($snapshot->action); | |||||||||
| 33 | 1 | ▶ | print $self->no_wait ? "Snapshot creation requested.\n" : "Snapshot created.\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||