« lib/WWW/Hetzner/CLI/Cmd/PrimaryIp/Cmd/Unassign.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/Delete.pm »
| 1 | package WWW::Hetzner::CLI::Cmd::Record::Cmd::Delete; | ||
| 2 | # ABSTRACT: Delete a DNS record | ||
| 3 | |||
| 4 | our $VERSION = '0.100'; | ||
| 5 | |||
| 6 | use Moo; | ||
| 7 | use MooX::Cmd; | ||
| 8 | use MooX::Options usage_string => 'USAGE: hcloud.pl record delete --zone <zone-id> --name <name> --type <type>'; | ||
| 9 | |||
| 10 | option zone => ( | ||
| 11 | is => 'ro', | ||
| 12 | format => 's', | ||
| 13 | short => 'z', | ||
| 14 | required => 1, | ||
| 15 | doc => 'Zone ID', | ||
| 16 | ); | ||
| 17 | |||
| 18 | option name => ( | ||
| 19 | is => 'ro', | ||
| 20 | format => 's', | ||
| 21 | short => 'n', | ||
| 22 | required => 1, | ||
| 23 | doc => 'Record name', | ||
| 24 | ); | ||
| 25 | |||
| 26 | option type => ( | ||
| 27 | is => 'ro', | ||
| 28 | format => 's', | ||
| 29 | short => 't', | ||
| 30 | required => 1, | ||
| 31 | doc => 'Record type (A, AAAA, CNAME, MX, TXT, etc.)', | ||
| 32 | ); | ||
| 33 | |||
| 34 | sub execute { | ||
| 35 | my ($self, $args, $chain) = @_; | ||
| 36 | |||
| 37 | my $main = $chain->[0]; | ||
| 38 | my $cloud = $main->cloud; | ||
| 39 | |||
| 40 | my $rrsets = $cloud->zones->rrsets($self->zone); | ||
| 41 | $rrsets->delete($self->name, uc($self->type)); | ||
| 42 | |||
| 43 | print "Record ", $self->name, "/", uc($self->type), " deleted.\n"; | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; | ||
| 47 | |||
| 48 | __END__ |