« lib/WWW/Hetzner/Cloud/API/Certificates.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Firewall/Cmd/List.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Certificate::Cmd::Describe; | ||
| 2 | # ABSTRACT: Describe a certificate | ||
| 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 certificate 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 certificate describe <id>\n"; | ||
| 14 | |||
| 15 | my $main = $chain->[0]; | ||
| 16 | my $cloud = $main->cloud; | ||
| 17 | |||
| 18 | my $cert = $cloud->certificates->get($id); | ||
| 19 | |||
| 20 | if ($main->output eq 'json') { | ||
| 21 | print encode_json($cert->data), "\n"; | ||
| 22 | return; | ||
| 23 | } | ||
| 24 | |||
| 25 | printf "ID: %s\n", $cert->id; | ||
| 26 | printf "Name: %s\n", $cert->name; | ||
| 27 | printf "Type: %s\n", $cert->type; | ||
| 28 | printf "Fingerprint: %s\n", $cert->fingerprint // '-'; | ||
| 29 | printf "Valid From: %s\n", $cert->not_valid_before // '-'; | ||
| 30 | printf "Valid Until: %s\n", $cert->not_valid_after // '-'; | ||
| 31 | printf "Created: %s\n", $cert->created // '-'; | ||
| 32 | |||
| 33 | my $domains = $cert->domain_names; | ||
| 34 | if ($domains && @$domains) { | ||
| 35 | print "Domains:\n"; | ||
| 36 | for my $d (@$domains) { | ||
| 37 | print " - $d\n"; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; | ||
| 43 | |||
| 44 | __END__ |