| 1 | package WWW::Hetzner::CLI::Cmd::PrimaryIp::Cmd::Describe; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Describe a primary IP | ||||||||||||||||||||||||||||
| 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 primary-ip 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=16 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||
| 13 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl primary-ip describe <id>\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||
| 16 | 1 | my $cloud = $main->cloud; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | my $pip = $cloud->primary_ips->get($id); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | print encode_json($pip->data), "\n"; | |||||||||||||||||||||||||||
| 22 | 0 | return; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | printf "ID: %s\n", $pip->id; | |||||||||||||||||||||||||||
| 26 | 1 | ▶ | printf "Name: %s\n", $pip->name // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pip->name // "-"
MC/DC0%0/1
$pip->name // "-"
$pip->name
Truth table50%1/2
A
A= $pip->name
| |||||||||||||||||||||||||||||
| 27 | 1 | printf "IP: %s\n", $pip->ip; | |||||||||||||||||||||||||||
| 28 | 1 | printf "Type: %s\n", $pip->type; | |||||||||||||||||||||||||||
| 29 | 1 | ▶ | printf "Datacenter: %s\n", $pip->datacenter_name // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pip->datacenter_name // "-"
MC/DC0%0/1
$pip->datacenter_name // "-"
$pip->datacenter_name
Truth table50%1/2
A
A= $pip->datacenter_name
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | printf "Assignee ID: %s\n", $pip->assignee_id // 'not assigned'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pip->assignee_id // "not assigned"
MC/DC0%0/1
$pip->assignee_id // "not assigned"
$pip->assignee_id
Truth table50%1/2
A
A= $pip->assignee_id
| |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | printf "Assignee Type:%s\n", $pip->assignee_type // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pip->assignee_type // "-"
MC/DC0%0/1
$pip->assignee_type // "-"
$pip->assignee_type
Truth table50%1/2
A
A= $pip->assignee_type
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | printf "Auto Delete: %s\n", $pip->auto_delete ? 'yes' : 'no'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | printf "Blocked: %s\n", $pip->blocked ? 'yes' : 'no'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | printf "Created: %s\n", $pip->created // '-'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pip->created // "-"
MC/DC0%0/1
$pip->created // "-"
$pip->created
Truth table50%1/2
A
A= $pip->created
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | my $dns_ptr = $pip->dns_ptr; | |||||||||||||||||||||||||||
| 37 | 1 | ▶ | if ($dns_ptr && @$dns_ptr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dns_ptr and @$dns_ptr
MC/DC0%0/2
$dns_ptr and @$dns_ptr
$dns_ptr
@$dns_ptr
Truth table33%1/3
A and B
A= $dns_ptrB= @$dns_ptr
| |||||||||||||||||||||||||||||
| 38 | 1 | print "DNS PTR:\n"; | |||||||||||||||||||||||||||
| 39 | 1 | for my $ptr (@$dns_ptr) { | |||||||||||||||||||||||||||
| 40 | 1 | printf " %s -> %s\n", $ptr->{ip}, $ptr->{dns_ptr}; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | my $labels = $pip->labels; | |||||||||||||||||||||||||||
| 45 | 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
| |||||||||||||||||||||||||||||
| 46 | 1 | print "Labels:\n"; | |||||||||||||||||||||||||||
| 47 | 1 | for my $k (sort keys %$labels) { | |||||||||||||||||||||||||||
| 48 | 1 | printf " %s: %s\n", $k, $labels->{$k}; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||