| 1 | package WWW::Hetzner::CLI::Cmd::PrimaryIp::Cmd::Create; | ||||||||||
| 2 | # ABSTRACT: Create 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 create --name <name> --type <ipv4|ipv6> --datacenter <dc>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | with 'WWW::Hetzner::CLI::Role::WaitsForAction'; | |||||||||
| 10 | |||||||||||
| 11 | 1 | option name => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | format => 's', | ||||||||||
| 14 | required => 1, | ||||||||||
| 15 | doc => 'Primary IP name', | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 1 | option type => ( | |||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | format => 's', | ||||||||||
| 21 | required => 1, | ||||||||||
| 22 | doc => 'IP type: ipv4 or ipv6', | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 1 | option datacenter => ( | |||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | format => 's', | ||||||||||
| 28 | required => 1, | ||||||||||
| 29 | doc => 'Datacenter (e.g. fsn1-dc14)', | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | 1 | option 'auto_delete' => ( | |||||||||
| 33 | is => 'ro', | ||||||||||
| 34 | long_doc => 'auto-delete', | ||||||||||
| 35 | doc => 'Auto delete when server is deleted', | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 39 | 1 | my ($self, $args, $chain) = @_; | |||||||||
| 40 | |||||||||||
| 41 | 1 | my $main = $chain->[0]; | |||||||||
| 42 | 1 | my $cloud = $main->cloud; | |||||||||
| 43 | |||||||||||
| 44 | 1 | print "Creating primary IP...\n"; | |||||||||
| 45 | 1 | ▶ | my $pip = $cloud->primary_ips->create( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | name => $self->name, | ||||||||||
| 47 | type => $self->type, | ||||||||||
| 48 | assignee_type => 'server', | ||||||||||
| 49 | datacenter => $self->datacenter, | ||||||||||
| 50 | ($self->auto_delete ? (auto_delete => 1) : ()), | ||||||||||
| 51 | ); | ||||||||||
| 52 | 1 | $self->handle_action($pip->action); | |||||||||
| 53 | 1 | print "Primary IP created with ID ", $pip->id, " (", $pip->ip, ")\n"; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | 1; | |||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||