| 1 | package WWW::Hetzner::CLI::Cmd::Network::Cmd::Describe; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Describe a network | ||||||||||||||||||||||||||||
| 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 network describe <id>'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON::MaybeXS qw(encode_json); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=15 SCAR=30.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||
| 13 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl network describe <id>\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||
| 16 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | my $network = $cloud->networks->get($id); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | print encode_json($network->data), "\n"; | |||||||||||||||||||||||||||
| 22 | 0 | return; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | printf "ID: %s\n", $network->id; | |||||||||||||||||||||||||||
| 26 | 1 | printf "Name: %s\n", $network->name; | |||||||||||||||||||||||||||
| 27 | 1 | printf "IP Range: %s\n", $network->ip_range; | |||||||||||||||||||||||||||
| 28 | 1 | ▶ | printf "Created: %s\n", $network->created // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$network->created // "-"
MC/DC0%0/1
$network->created // "-"
$network->created
Truth table50%1/2
A
A= $network->created
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | my $servers = $network->servers; | |||||||||||||||||||||||||||
| 31 | 1 | ▶ | if ($servers && @$servers) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$servers and @$servers
MC/DC0%0/2
$servers and @$servers
$servers
@$servers
Truth table33%1/3
A and B
A= $serversB= @$servers
| |||||||||||||||||||||||||||||
| 32 | 1 | printf "Servers: %s\n", join(', ', @$servers); | |||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||
| 34 | 0 | print "Servers: none\n"; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | my $subnets = $network->subnets; | |||||||||||||||||||||||||||
| 38 | 1 | ▶ | if ($subnets && @$subnets) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$subnets and @$subnets
MC/DC0%0/2
$subnets and @$subnets
$subnets
@$subnets
Truth table33%1/3
A and B
A= $subnetsB= @$subnets
| |||||||||||||||||||||||||||||
| 39 | 1 | print "\nSubnets:\n"; | |||||||||||||||||||||||||||
| 40 | 1 | for my $s (@$subnets) { | |||||||||||||||||||||||||||
| 41 | printf " - %s (%s, %s)\n", | ||||||||||||||||||||||||||||
| 42 | $s->{ip_range}, | ||||||||||||||||||||||||||||
| 43 | $s->{network_zone}, | ||||||||||||||||||||||||||||
| 44 | 1 | $s->{type}; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | my $routes = $network->routes; | |||||||||||||||||||||||||||
| 49 | 1 | ▶ | if ($routes && @$routes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$routes and @$routes
MC/DC0%0/2
$routes and @$routes
$routes
@$routes
Truth table33%1/3
A and B
A= $routesB= @$routes
| |||||||||||||||||||||||||||||
| 50 | 1 | print "\nRoutes:\n"; | |||||||||||||||||||||||||||
| 51 | 1 | for my $r (@$routes) { | |||||||||||||||||||||||||||
| 52 | 1 | printf " - %s via %s\n", $r->{destination}, $r->{gateway}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | my $labels = $network->labels; | |||||||||||||||||||||||||||
| 57 | 1 | ▶ | if ($labels && %$labels) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$labels and %$labels
MC/DC0%0/2
$labels and %$labels
$labels
%$labels
Truth table33%1/3
A and B
A= $labelsB= %$labels
| |||||||||||||||||||||||||||||
| 58 | 1 | print "\nLabels:\n"; | |||||||||||||||||||||||||||
| 59 | 1 | for my $k (sort keys %$labels) { | |||||||||||||||||||||||||||
| 60 | 1 | printf " %s: %s\n", $k, $labels->{$k}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||