« 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
| |||||||||||
| 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
| |||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||