« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Snapshot/Cmd/RemoveLabel.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Zone/Cmd/Describe.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Snapshot; | ||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Storage Box snapshot commands | ||||||||||||||||||||||||||||||||||||||||
| 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 storage-box snapshot <command> [options] <storage-box>'; | ||||||||||||||||||||||||||||||||||||||
|
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 | 1 | ▶ | use WWW::Hetzner::Storage::API::Snapshots; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||
| 15 | 1 | $self->_list($args, $chain); | |||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | sub _list { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list: called CC=9 SCAR=26.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my ($self, $args, $chain) = @_; | |||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | my $id = $args->[0] or die "Usage: hcloud.pl storage-box snapshot list <storage-box>\n"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $snapshots = WWW::Hetzner::Storage::API::Snapshots->new( | |||||||||||||||||||||||||||||||||||||||
| 23 | client => $main->storage, | ||||||||||||||||||||||||||||||||||||||||
| 24 | storage_box_id => $id, | ||||||||||||||||||||||||||||||||||||||||
| 25 | )->list; | ||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | if ($main->output eq 'json') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | print encode_json([map { $_->data } @$snapshots]), "\n"; | |||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if (!@$snapshots) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | print "No snapshots found.\n"; | |||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | printf "%-10s %-30s %-25s %s\n", 'ID', 'NAME', 'DESCRIPTION', 'CREATED'; | |||||||||||||||||||||||||||||||||||||||
| 38 | 1 | print '-' x 90, "\n"; | |||||||||||||||||||||||||||||||||||||||
| 39 | 1 | for my $snap (@$snapshots) { | |||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | printf "%-10s %-30s %-25s %s\n", | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$snap->name // "-"
$snap->description // ""
$snap->created // "-"
MC/DC0%0/1
$snap->name // "-"
$snap->name
MC/DC0%0/1
$snap->description // ""
$snap->description
MC/DC0%0/1
$snap->created // "-"
$snap->created
Truth table50%1/2
A
A= $snap->name
Truth table50%1/2
A
A= $snap->description
Truth table50%1/2
A
A= $snap->created
| |||||||||||||||||||||||||||||||||||||||||
| 41 | $snap->id, | ||||||||||||||||||||||||||||||||||||||||
| 42 | $snap->name // '-', | ||||||||||||||||||||||||||||||||||||||||
| 43 | ($snap->description // '') ne '' ? $snap->description : '-', | ||||||||||||||||||||||||||||||||||||||||
| 44 | $snap->created // '-'; | ||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||||||||||||||