lib/WWW/Hetzner/CLI/Cmd/Firewall/Cmd/ApplyTo.pm

filter: Statementstmt 100% 21 / 21 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 93.3% 28 / 30 CC 3 SCAR 6.9
CC
3
Cov
96%
execute
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/Delete.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Update.pm »
1 package WWW::Hetzner::CLI::Cmd::Firewall::Cmd::ApplyTo;
2 # ABSTRACT: Apply a firewall to a server
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 firewall apply-to <firewall-id> --server <server-id>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 with 'WWW::Hetzner::CLI::Role::WaitsForAction';
10  
11 1 option server => (
12 is => 'ro',
13 format => 'i',
14 required => 1,
15 doc => 'Server ID to apply firewall to',
16 );
17  
18 2 ▶sub execute {
Subroutine execute: called CC=3 SCAR=11.0
Pod undocumented
19 2 my ($self, $args, $chain) = @_;
20 2 ▶ my $id = $args->[0] or die "Usage: hcloud.pl firewall apply-to <firewall-id> --server <server-id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl firewall apply-to <firewall-id> --server <server-id>\n" 2 0 2
21  
22 2 my $main = $chain->[0];
23 2 my $cloud = $main->cloud;
24  
25 2 print "Applying firewall $id to server ", $self->server, "...\n";
26 2 my $actions = $cloud->firewalls->apply_to_resources($id,
27 { type => 'server', server => { id => $self->server } },
28 );
29 2 $self->handle_action($actions);
30 2 ▶ print $self->no_wait ? "Firewall apply requested.\n" : "Firewall applied.\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->no_wait ? : 1 1 2
31 }
32  
33 1 1;
34  
35 __END__
« lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/Delete.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Update.pm »