| 1 | package Net::EPP::Frame::Command::Create::Host; | ||||||||||
| 2 | 1 | ▶ | use List::Util qw(any); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use base qw(Net::EPP::Frame::Command::Create); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Net::EPP::Frame::ObjectSpec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | =pod | ||||||||||
| 8 | |||||||||||
| 9 | =head1 NAME | ||||||||||
| 10 | |||||||||||
| 11 | Net::EPP::Frame::Command::Create::Host - an instance of L<Net::EPP::Frame::Command::Create> | ||||||||||
| 12 | for host objects. | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Net::EPP::Frame::Command::Create::Host; | ||||||||||
| 17 | use strict; | ||||||||||
| 18 | |||||||||||
| 19 | my $create = Net::EPP::Frame::Command::Create::Host->new; | ||||||||||
| 20 | $create->setHost('ns1.example.uk.com); | ||||||||||
| 21 | |||||||||||
| 22 | print $create->toString(1); | ||||||||||
| 23 | |||||||||||
| 24 | This results in an XML document like this: | ||||||||||
| 25 | |||||||||||
| 26 | <?xml version="1.0" encoding="UTF-8"?> | ||||||||||
| 27 | <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" | ||||||||||
| 28 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||||||
| 29 | xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 | ||||||||||
| 30 | epp-1.0.xsd"> | ||||||||||
| 31 | <command> | ||||||||||
| 32 | <create> | ||||||||||
| 33 | <host:create | ||||||||||
| 34 | xmlns:contact="urn:ietf:params:xml:ns:host-1.0" | ||||||||||
| 35 | xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 | ||||||||||
| 36 | host-1.0.xsd"> | ||||||||||
| 37 | <host:name>ns1.example.uk.com</host:name> | ||||||||||
| 38 | </domain:create> | ||||||||||
| 39 | </create> | ||||||||||
| 40 | <clTRID>0cf1b8f7e14547d26f03b7641660c641d9e79f45</clTRIDE> | ||||||||||
| 41 | </command> | ||||||||||
| 42 | </epp> | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | =head1 OBJECT HIERARCHY | ||||||||||
| 46 | |||||||||||
| 47 | L<XML::LibXML::Node> | ||||||||||
| 48 | +----L<XML::LibXML::Document> | ||||||||||
| 49 | +----L<Net::EPP::Frame> | ||||||||||
| 50 | +----L<Net::EPP::Frame::Command> | ||||||||||
| 51 | +----L<Net::EPP::Frame::Command::Create> | ||||||||||
| 52 | +----L<Net::EPP::Frame::Command::Create::Host> | ||||||||||
| 53 | |||||||||||
| 54 | =cut | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | 0 | my $package = shift; | |||||||||
| 58 | 0 | my $self = bless($package->SUPER::new('create'), $package); | |||||||||
| 59 | |||||||||||
| 60 | 0 | $self->addObject(Net::EPP::Frame::ObjectSpec->spec('host')); | |||||||||
| 61 | |||||||||||
| 62 | 0 | return $self; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | =pod | ||||||||||
| 66 | |||||||||||
| 67 | =head1 METHODS | ||||||||||
| 68 | |||||||||||
| 69 | my $element = $frame->setHost($host_name); | ||||||||||
| 70 | |||||||||||
| 71 | This sets the name of the object to be created. Returns the | ||||||||||
| 72 | <E<lt>host:nameE<gt>> element. | ||||||||||
| 73 | |||||||||||
| 74 | =cut | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub setHost { | ||||||||
|
Subroutine
setHost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 77 | 0 | my ($self, $host) = @_; | |||||||||
| 78 | |||||||||||
| 79 | 0 | my $name = $self->createElement('host:name'); | |||||||||
| 80 | 0 | $name->appendText($host); | |||||||||
| 81 | |||||||||||
| 82 | 0 | $self->getNode('create')->getChildNodes->shift->appendChild($name); | |||||||||
| 83 | |||||||||||
| 84 | 0 | return 1; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | =pod | ||||||||||
| 88 | |||||||||||
| 89 | $frame->setAddr({ 'ip' => '10.0.0.1', 'version' => 'v4' }); | ||||||||||
| 90 | |||||||||||
| 91 | This adds an IP address to the host object. EPP supports multiple | ||||||||||
| 92 | addresses of different versions. | ||||||||||
| 93 | |||||||||||
| 94 | =cut | ||||||||||
| 95 | |||||||||||
| 96 | 0 | ▶ | sub setAddr { | ||||||||
|
Subroutine
setAddr: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 97 | 0 | my ($self, @addr) = @_; | |||||||||
| 98 | |||||||||||
| 99 | 0 | foreach my $ip (@addr) { | |||||||||
| 100 | 0 | my $hostAttr = $self->createElement('host:addr'); | |||||||||
| 101 | 0 | $hostAttr->appendText($ip->{ip}); | |||||||||
| 102 | 0 | $hostAttr->setAttribute('ip', $ip->{version}); | |||||||||
| 103 | 0 | $self->getNode('create')->getChildNodes->shift->appendChild($hostAttr); | |||||||||
| 104 | } | ||||||||||
| 105 | 0 | return 1; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | =pod | ||||||||||
| 109 | |||||||||||
| 110 | =head2 TTL Extension | ||||||||||
| 111 | |||||||||||
| 112 | $frame->setTTLs({ | ||||||||||
| 113 | A => 3600, | ||||||||||
| 114 | AAAA => 900, | ||||||||||
| 115 | }); | ||||||||||
| 116 | |||||||||||
| 117 | Specify TTLs for glue records. The server must support the | ||||||||||
| 118 | TTL extension. | ||||||||||
| 119 | |||||||||||
| 120 | =cut | ||||||||||
| 121 | |||||||||||
| 122 | 0 | ▶ | sub setTTLs { | ||||||||
|
Subroutine
setTTLs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 123 | 0 | my ($self, $ttls) = @_; | |||||||||
| 124 | |||||||||||
| 125 | 0 | foreach my $type (keys(%{$ttls})) { | |||||||||
| 126 | 0 | my $ttl = $self->createExtensionElementFor(Net::EPP::Frame::ObjectSpec->xmlns('ttl'))->appendChild($self->createElement('ttl')); | |||||||||
| 127 | 0 | $ttl->appendText($ttls->{$type}); | |||||||||
| 128 | 0 | ▶ | if (any { $type eq $_ } qw(NS DS DNAME A AAAA)) { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 129 | 0 | $ttl->setAttribute('for', $type); | |||||||||
| 130 | |||||||||||
| 131 | } else { | ||||||||||
| 132 | 0 | $ttl->setAttribute('for', 'custom'); | |||||||||
| 133 | 0 | $ttl->setAttribute('custom', $type); | |||||||||
| 134 | |||||||||||
| 135 | } | ||||||||||
| 136 | } | ||||||||||
| 137 | } | ||||||||||
| 138 | |||||||||||
| 139 | 1 | 1; | |||||||||