lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Create.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 89.1% 33 / 37 CC 4 SCAR 9.4
CC
4
Cov
90%
execute
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.6
« 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
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot create <storage-box>\n" 1 0 1
22  
23 1 my %params;
24 1 ▶ $params{description} = $self->description if defined $self->description;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->description 1 0 1
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
BranchTrueFalseTotal
$self->no_wait ? : 0 1 1
34 }
35  
36 1 1;
37  
38 __END__
« lib/WWW/Hetzner/CLI/Cmd/Record/Cmd/Describe.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/Delete.pm »