« lib/WWW/Hetzner/CLI/Cmd/Volume/Cmd/Attach.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Network/Cmd/AddSubnet.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::LoadBalancer::Cmd::AddService; | ||||||||||
| 2 | # ABSTRACT: Add a service to a load balancer | ||||||||||
| 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 load-balancer add-service <id> --protocol <proto> --listen-port <port> --destination-port <port>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | with 'WWW::Hetzner::CLI::Role::WaitsForAction'; | |||||||||
| 10 | |||||||||||
| 11 | 1 | option protocol => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | format => 's', | ||||||||||
| 14 | required => 1, | ||||||||||
| 15 | doc => 'Protocol: tcp, http, https', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 1 | option 'listen_port' => ( | |||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | format => 'i', | ||||||||||
| 21 | required => 1, | ||||||||||
| 22 | long_doc => 'listen-port', | ||||||||||
| 23 | doc => 'Listen port', | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 1 | option 'destination_port' => ( | |||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | format => 'i', | ||||||||||
| 29 | required => 1, | ||||||||||
| 30 | long_doc => 'destination-port', | ||||||||||
| 31 | doc => 'Destination port', | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 35 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 36 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl load-balancer add-service <id> --protocol <proto> --listen-port <port> --destination-port <port>\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 1 | my $main = $chain->[0]; | |||||||||
| 39 | 1 | my $cloud = $main->cloud; | |||||||||
| 40 | |||||||||||
| 41 | 1 | print "Adding ", $self->protocol, " service to load balancer $id...\n"; | |||||||||
| 42 | 1 | my $action = $cloud->load_balancers->add_service($id, | |||||||||
| 43 | protocol => $self->protocol, | ||||||||||
| 44 | listen_port => $self->listen_port, | ||||||||||
| 45 | destination_port => $self->destination_port, | ||||||||||
| 46 | ); | ||||||||||
| 47 | 1 | $self->handle_action($action); | |||||||||
| 48 | 1 | ▶ | print $self->no_wait ? "Service add requested.\n" : "Service added.\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||