| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::EnableSnapshotPlan; | ||||||||||
| 2 | # ABSTRACT: Enable a Storage Box snapshot plan | ||||||||||
| 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 enable-snapshot-plan --max-snapshots <count> --minute <minute> --hour <hour> [options] <storage-box>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | with 'WWW::Hetzner::CLI::Role::WaitsForAction'; | |||||||||
| 10 | |||||||||||
| 11 | 1 | option max_snapshots => ( is => 'ro', format => 'i', required => 1, doc => 'Maximum retained snapshots' ); | |||||||||
| 12 | 1 | option minute => ( is => 'ro', format => 'i', required => 1, doc => 'Minute of scheduled snapshot' ); | |||||||||
| 13 | 1 | option hour => ( is => 'ro', format => 'i', required => 1, doc => 'Hour of scheduled snapshot' ); | |||||||||
| 14 | 1 | option day_of_week => ( is => 'ro', format => 's', doc => 'Day of week for scheduled snapshot' ); | |||||||||
| 15 | 1 | option day_of_month => ( is => 'ro', format => 'i', doc => 'Day of month for scheduled snapshot' ); | |||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||
| 18 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 19 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box enable-snapshot-plan --max-snapshots <count> --minute <minute> --hour <hour> <storage-box>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 1 | my %params = ( | |||||||||
| 21 | max_snapshots => $self->max_snapshots, | ||||||||||
| 22 | minute => $self->minute, | ||||||||||
| 23 | hour => $self->hour, | ||||||||||
| 24 | ); | ||||||||||
| 25 | 1 | ▶ | $params{day_of_week} = $self->day_of_week if defined $self->day_of_week; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 1 | ▶ | $params{day_of_month} = $self->day_of_month if defined $self->day_of_month; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 1 | my $action = $chain->[0]->storage->storage_boxes->enable_snapshot_plan($id, %params); | |||||||||
| 28 | 1 | $self->handle_action($action); | |||||||||
| 29 | 1 | ▶ | print $self->no_wait ? "Storage Box snapshot plan enable requested.\n" : "Storage Box snapshot plan enabled.\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 1 | 1; | |||||||||
| 33 | |||||||||||
| 34 | __END__ | ||||||||||