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

filter: Statementstmt 93.7% 30 / 32 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 76.7% 43 / 56 CC 8 SCAR 18.9
CC
8
Cov
80%
execute
10.1
BEGIN
1.0
BEGIN
1.0
CRAP 6.6
« lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/RemoveLabel.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Snapshot::Cmd::Update;
2 # ABSTRACT: Update 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 update [--description <description>] <storage-box> <snapshot>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use WWW::Hetzner::Storage::API::Snapshots;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 1 option description => (
14 is => 'ro',
15 format => 's',
16 required => 1,
17 doc => 'New snapshot description',
18 );
19  
20 1 ▶sub execute {
Subroutine execute: called CC=8 SCAR=23.2
Pod undocumented
21 1 my ($self, $args, $chain) = @_;
22 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot update <storage-box> <snapshot>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot update <storage-box> <snapshot>\n" 1 0 1
23 1 ▶ my $snap = $args->[1] or die "Usage: hcloud.pl storage-box snapshot update <storage-box> <snapshot>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $snap = $args->[1] or die "Usage: hcloud.pl storage-box snapshot update <storage-box> <snapshot>\n" 1 0 1
24 1 my $main = $chain->[0];
25  
26 1 my $snapshots = WWW::Hetzner::Storage::API::Snapshots->new(
27 client => $main->storage,
28 storage_box_id => $id,
29 );
30 1 my $snapshot = $snapshots->update(
31 $snap,
32 description => $self->description,
33 );
34  
35 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
36 0 print encode_json($snapshot->data), "\n";
37 0 return;
38 }
39  
40 1 print "Snapshot updated:\n";
41 1 printf " ID: %s\n", $snapshot->id;
42 1 ▶ printf " Name: %s\n", $snapshot->name // '-';
Condition50%1/2
$snapshot->name // "-"
l!l
10
MC/DC0%0/1
$snapshot->name // "-"
$snapshot->name
Truth table50%1/2
A
A= $snapshot->name
Aresult
11
00
43 1 ▶ printf " Description: %s\n", ($snapshot->description // '') ne '' ? $snapshot->description : '-';
Branch: 1 branch
BranchTrueFalseTotal
($snapshot->description // '') ne '' ? : 1 0 1
Condition50%1/2
$snapshot->description // ""
l!l
10
MC/DC0%0/1
$snapshot->description // ""
$snapshot->description
Truth table50%1/2
A
A= $snapshot->description
Aresult
11
00
44 1 ▶ printf " Created: %s\n", $snapshot->created // '-';
Condition50%1/2
$snapshot->created // "-"
l!l
10
MC/DC0%0/1
$snapshot->created // "-"
$snapshot->created
Truth table50%1/2
A
A= $snapshot->created
Aresult
11
00
45 }
46  
47 1 1;
48  
49 __END__
« lib/WWW/Hetzner/CLI/Cmd/PlacementGroup/Cmd/List.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/RemoveLabel.pm »