lib/WWW/Hetzner/CLI/Cmd/FloatingIp/Cmd/Describe.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 18 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 73 CC 5 SCAR 28.7
CC
5
Cov
0%
execute
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 17.6
1 package WWW::Hetzner::CLI::Cmd::FloatingIp::Cmd::Describe;
2 # ABSTRACT: Describe a floating IP
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 floating-ip describe <id>';
9 use JSON::MaybeXS qw(encode_json);
10  
11 sub execute {
12 my ($self, $args, $chain) = @_;
13 my $id = $args->[0] or die "Usage: hcloud.pl floating-ip describe <id>\n";
14  
15 my $main = $chain->[0];
16 my $cloud = $main->cloud;
17  
18 my $fip = $cloud->floating_ips->get($id);
19  
20 if ($main->output eq 'json') {
21 print encode_json($fip->data), "\n";
22 return;
23 }
24  
25 printf "ID: %s\n", $fip->id;
26 printf "Name: %s\n", $fip->name // '-';
27 printf "Description: %s\n", $fip->description // '-';
28 printf "IP: %s\n", $fip->ip;
29 printf "Type: %s\n", $fip->type;
30 printf "Location: %s\n", $fip->location // '-';
31 printf "Server: %s\n", $fip->server // 'not assigned';
32 printf "Blocked: %s\n", $fip->blocked ? 'yes' : 'no';
33 printf "Created: %s\n", $fip->created // '-';
34  
35 my $dns_ptr = $fip->dns_ptr;
36 if ($dns_ptr && @$dns_ptr) {
37 print "DNS PTR:\n";
38 for my $ptr (@$dns_ptr) {
39 printf " %s -> %s\n", $ptr->{ip}, $ptr->{dns_ptr};
40 }
41 }
42  
43 my $labels = $fip->labels;
44 if ($labels && %$labels) {
45 print "Labels:\n";
46 for my $k (sort keys %$labels) {
47 printf " %s: %s\n", $k, $labels->{$k};
48 }
49 }
50 }
51  
52 1;
53  
54 __END__