line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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: Host.pm,v 1.3 2011/01/23 12:26:24 gavin Exp $ |
6
|
|
|
|
|
|
|
package Net::EPP::Frame::Command::Update::Host; |
7
|
1
|
|
|
1
|
|
5
|
use base qw(Net::EPP::Frame::Command::Update); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
65
|
|
8
|
1
|
|
|
1
|
|
4
|
use Net::EPP::Frame::ObjectSpec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
9
|
1
|
|
|
1
|
|
2
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
415
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Net::EPP::Frame::Command::Update::Host - an instance of L |
16
|
|
|
|
|
|
|
for host objects. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Net::EPP::Frame::Command::Update::Host; |
21
|
|
|
|
|
|
|
use strict; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $info = Net::EPP::Frame::Command::Update::Host->new; |
24
|
|
|
|
|
|
|
$info->setHost('ns0.example.tld'); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
print $info->toString(1); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This results in an XML document like this: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
xmlns:host="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
|
|
|
|
|
|
|
example-1.tldE/host:name> |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
0cf1b8f7e14547d26f03b7641660c641d9e79f45 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 OBJECT HIERARCHY |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L |
51
|
|
|
|
|
|
|
+----L |
52
|
|
|
|
|
|
|
+----L |
53
|
|
|
|
|
|
|
+----L |
54
|
|
|
|
|
|
|
+----L |
55
|
|
|
|
|
|
|
+----L |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
60
|
0
|
|
|
0
|
0
|
|
my $package = shift; |
61
|
0
|
|
|
|
|
|
my $self = bless($package->SUPER::new('update'), $package); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $host = $self->addObject(Net::EPP::Frame::ObjectSpec->spec('host')); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# 'chg' element's contents are not optional for hosts, so we'll add |
66
|
|
|
|
|
|
|
# this element only when we plan to use it (accessor is overriden) |
67
|
0
|
|
|
|
|
|
foreach my $grp (qw(add rem)) { |
68
|
0
|
|
|
|
|
|
my $el = $self->createElement(sprintf('host:%s', $grp)); |
69
|
0
|
|
|
|
|
|
$self->getNode('update')->getChildNodes->shift->appendChild($el); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=pod |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 METHODS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$frame->setHost($host_name); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This specifies the host object to be updated. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub setHost { |
86
|
0
|
|
|
0
|
0
|
|
my ($self, $host) = @_; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $name = $self->createElement('host:name'); |
89
|
0
|
|
|
|
|
|
$name->appendText($host); |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $n = $self->getNode('update')->getChildNodes->shift; |
92
|
0
|
|
|
|
|
|
$n->insertBefore($name, $n->firstChild); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$frame->addStatus($type, $info); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Add a status of $type with the optional extra $info. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub addStatus { |
106
|
0
|
|
|
0
|
0
|
|
my ($self, $type, $info) = @_; |
107
|
0
|
|
|
|
|
|
my $status = $self->createElement('host:status'); |
108
|
0
|
|
|
|
|
|
$status->setAttribute('s', $type); |
109
|
0
|
|
|
|
|
|
$status->setAttribute('lang', 'en'); |
110
|
0
|
0
|
|
|
|
|
if ($info) { |
111
|
0
|
|
|
|
|
|
$status->appendText($info); |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
$self->getElementsByLocalName('host:add')->shift->appendChild($status); |
114
|
0
|
|
|
|
|
|
return 1; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=pod |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$frame->remStatus($type); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Remove a status of $type. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub remStatus { |
126
|
0
|
|
|
0
|
0
|
|
my ($self, $type) = @_; |
127
|
0
|
|
|
|
|
|
my $status = $self->createElement('host:status'); |
128
|
0
|
|
|
|
|
|
$status->setAttribute('s', $type); |
129
|
0
|
|
|
|
|
|
$self->getElementsByLocalName('host:rem')->shift->appendChild($status); |
130
|
0
|
|
|
|
|
|
return 1; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=pod |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$frame->addAddr({ 'ip' => '10.0.0.1', 'version' => 'v4' }); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Add a set of IP addresses to the host object. EPP supports multiple |
139
|
|
|
|
|
|
|
addresses of different versions. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub addAddr { |
144
|
0
|
|
|
0
|
0
|
|
my ($self, @addr) = @_; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
foreach my $ip (@addr) { |
147
|
0
|
|
|
|
|
|
my $el = $self->createElement('host:addr'); |
148
|
0
|
|
|
|
|
|
$el->appendText($ip->{ip}); |
149
|
0
|
|
|
|
|
|
$el->setAttribute('ip', $ip->{version}); |
150
|
0
|
|
|
|
|
|
$self->getElementsByLocalName('host:add')->shift->appendChild($el); |
151
|
|
|
|
|
|
|
} |
152
|
0
|
|
|
|
|
|
return 1; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=pod |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
$frame->remAddr({ 'ip' => '10.0.0.2', 'version' => 'v4' }); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Remove a set of IP addresses from the host object. EPP supports multiple |
160
|
|
|
|
|
|
|
addresses of different versions. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub remAddr { |
165
|
0
|
|
|
0
|
0
|
|
my ($self, @addr) = @_; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
foreach my $ip (@addr) { |
168
|
0
|
|
|
|
|
|
my $el = $self->createElement('host:addr'); |
169
|
0
|
|
|
|
|
|
$el->appendText($ip->{ip}); |
170
|
0
|
|
|
|
|
|
$el->setAttribute('ip', $ip->{version}); |
171
|
0
|
|
|
|
|
|
$self->getElementsByLocalName('host:rem')->shift->appendChild($el); |
172
|
|
|
|
|
|
|
} |
173
|
0
|
|
|
|
|
|
return 1; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=pod |
178
|
|
|
|
|
|
|
my $el = $frame->chg; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Lazy-building of 'host:chg'element. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
sub chg { |
184
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
my $chg = $self->getElementsByLocalName('host:chg')->shift; |
187
|
0
|
0
|
|
|
|
|
if ( $chg ) { |
188
|
0
|
|
|
|
|
|
return $chg; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
else { |
191
|
0
|
|
|
|
|
|
my $el = $self->createElement('host:chg'); |
192
|
0
|
|
|
|
|
|
$self->getNode('update')->getChildNodes->shift->appendChild($el); |
193
|
0
|
|
|
|
|
|
return $el; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=pod |
198
|
|
|
|
|
|
|
$frame->chgName('ns2.example.com'); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Change a name of host. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
sub chgName { |
204
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
205
|
0
|
|
|
|
|
|
my $el = $self->createElement('host:name'); |
206
|
0
|
|
|
|
|
|
$el->appendText($name); |
207
|
0
|
|
|
|
|
|
$self->chg->appendChild($el); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=pod |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 AUTHOR |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
CentralNic Ltd (http://www.centralnic.com/). |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 COPYRIGHT |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This module is (c) 2016 CentralNic Ltd. This module is free software; you can |
220
|
|
|
|
|
|
|
redistribute it and/or modify it under the same terms as Perl itself. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 SEE ALSO |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item * L |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=back |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=cut |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
1; |