lib/WWW/Hetzner/CLI/Cmd/LoadBalancer/Cmd/Create.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 25 CC 1 SCAR 6.9
CC
1
Cov
0%
execute
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package WWW::Hetzner::CLI::Cmd::LoadBalancer::Cmd::Create;
2 # ABSTRACT: Create a load balancer
3  
4 our $VERSION = '0.100';
5  
6 use Moo;
7 use MooX::Cmd;
8 use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl load-balancer create --name <name> --type <type> --location <loc>';
9  
10 option name => (
11 is => 'ro',
12 format => 's',
13 required => 1,
14 doc => 'Load balancer name',
15 );
16  
17 option type => (
18 is => 'ro',
19 format => 's',
20 required => 1,
21 doc => 'Load balancer type (e.g. lb11)',
22 );
23  
24 option location => (
25 is => 'ro',
26 format => 's',
27 required => 1,
28 doc => 'Location (e.g. fsn1)',
29 );
30  
31 sub execute {
32 my ($self, $args, $chain) = @_;
33  
34 my $main = $chain->[0];
35 my $cloud = $main->cloud;
36  
37 print "Creating load balancer '", $self->name, "'...\n";
38 my $lb = $cloud->load_balancers->create(
39 name => $self->name,
40 load_balancer_type => $self->type,
41 location => $self->location,
42 );
43 print "Load balancer created with ID ", $lb->id, "\n";
44 }
45  
46 1;
47  
48 __END__