lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/EnableSnapshotPlan.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 86.8% 33 / 38 CC 5 SCAR 13.2
CC
5
Cov
88%
execute
5.4
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« lib/WWW/Hetzner/Cloud/API/Volumes.pm ↑ Summary lib/WWW/Hetzner/Cloud/LoadBalancer.pm »
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
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box enable-snapshot-plan --max-snapshots <count> --minute <minute> --hour <hour> <storage-box>\n" 1 0 1
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
BranchTrueFalseTotal
if defined $self->day_of_week 1 0 1
26 1 ▶ $params{day_of_month} = $self->day_of_month if defined $self->day_of_month;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->day_of_month 1 0 1
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
BranchTrueFalseTotal
$self->no_wait ? : 1 0 1
30 }
31  
32 1 1;
33  
34 __END__
« lib/WWW/Hetzner/Cloud/API/Volumes.pm ↑ Summary lib/WWW/Hetzner/Cloud/LoadBalancer.pm »