1# Copyright (c) 2016 CentralNic Ltd. All rights reserved. This program is 2# free software; you can redistribute it and/or modify it under the same 3# terms as Perl itself. 4# 5# $Id$ 6package Net::EPP::Frame::Command::Create::Host; 7use base qw(Net::EPP::Frame::Command::Create); 8use Net::EPP::Frame::ObjectSpec; 9use strict; 10 11=pod 12 13=head1 NAME 14 15Net::EPP::Frame::Command::Create::Host - an instance of L<Net::EPP::Frame::Command::Create> 16for host objects. 17 18=head1 SYNOPSIS 19 20 use Net::EPP::Frame::Command::Create::Host; 21 use strict; 22 23 my $create = Net::EPP::Frame::Command::Create::Host->new; 24 $create->setHost('ns1.example.uk.com); 25 26 print $create->toString(1); 27 28This results in an XML document like this: 29 30 <?xml version="1.0" encoding="UTF-8"?> 31 <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" 32 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 33 xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 34 epp-1.0.xsd"> 35 <command> 36 <create> 37 <host:create 38 xmlns:contact="urn:ietf:params:xml:ns:host-1.0" 39 xsi:schemaLocation="urn:ietf:params:xml:ns:host-1.0 40 host-1.0.xsd"> 41 <host:name>ns1.example.uk.com</host:name> 42 </domain:create> 43 </create> 44 <clTRID>0cf1b8f7e14547d26f03b7641660c641d9e79f45</clTRIDE> 45 </command> 46 </epp> 47 48 49=head1 OBJECT HIERARCHY 50 51 L<XML::LibXML::Node> 52 +----L<XML::LibXML::Document> 53 +----L<Net::EPP::Frame> 54 +----L<Net::EPP::Frame::Command> 55 +----L<Net::EPP::Frame::Command::Create> 56 +----L<Net::EPP::Frame::Command::Create::Host> 57 58=cut 59 60sub new { 61 my $package = shift; 62 my $self = bless($package->SUPER::new('create'), $package); 63 64 $self->addObject(Net::EPP::Frame::ObjectSpec->spec('host')); 65 66 return $self; 67} 68 69=pod 70 71=head1 METHODS 72 73 my $element = $frame->setHost($host_name); 74 75This sets the name of the object to be created. Returns the 76<E<lt>host:nameE<gt>> element. 77 78=cut 79 80 81sub setHost { 82 my ($self, $host) = @_; 83 84 my $name = $self->createElement('host:name'); 85 $name->appendText($host); 86 87 $self->getNode('create')->getChildNodes->shift->appendChild($name); 88 89 return 1; 90} 91 92=pod 93 94 $frame->setAddr({ 'ip' => '10.0.0.1', 'version' => 'v4' }); 95 96This adds an IP address to the host object. EPP supports multiple 97addresses of different versions. 98 99=cut 100 101sub setAddr { 102 my ($self, @addr) = @_; 103 104 foreach my $ip (@addr) { 105 my $hostAttr = $self->createElement('host:addr'); 106 $hostAttr->appendText($ip->{ip}); 107 $hostAttr->setAttribute('ip', $ip->{version}); 108 $self->getNode('create')->getChildNodes->shift->appendChild($hostAttr); 109 } 110 return 1; 111} 112 113=pod 114 115=head1 AUTHOR 116 117CentralNic Ltd (http://www.centralnic.com/). 118 119United Domains AG (http://www.united-domains.de/) provided the original version of Net::EPP::Frame::Command::Create::Host. 120 121=head1 COPYRIGHT 122 123This module is (c) 2016 CentralNic Ltd. This module is free software; you can 124redistribute it and/or modify it under the same terms as Perl itself. 125 126=head1 SEE ALSO 127 128=over 129 130=item * L<Net::EPP::Frame> 131 132=back 133 134=cut 135 1361; 137