Module: EPPClient::Domain
- Included in:
- Base
- Defined in:
- lib/epp-client/domain.rb
Instance Method Summary collapse
-
#domain_check(*domains) ⇒ Object
Check the availability of domains.
-
#domain_check_process(xml) ⇒ Object
:nodoc:.
-
#domain_check_xml(*domains) ⇒ Object
:nodoc:.
-
#domain_contacts_xml(xml, args) ⇒ Object
:nodoc:.
-
#domain_create(args) ⇒ Object
Creates a domain.
-
#domain_create_process(xml) ⇒ Object
:nodoc:.
-
#domain_create_xml(args) ⇒ Object
:nodoc:.
-
#domain_delete(domain) ⇒ Object
Deletes a domain.
-
#domain_delete_xml(domain) ⇒ Object
:nodoc:.
-
#domain_info(args) ⇒ Object
Returns the informations about a domain.
-
#domain_info_process(xml) ⇒ Object
:nodoc:.
-
#domain_info_xml(args) ⇒ Object
:nodoc:.
-
#domain_nss_xml(xml, nss) ⇒ Object
:nodoc:.
-
#domain_pending_action_process(xml) ⇒ Object
:nodoc:.
-
#domain_transfer(args) ⇒ Object
Transfers a domain.
-
#domain_transfer_response(xml) ⇒ Object
:nodoc:.
-
#domain_transfer_xml(args) ⇒ Object
:nodoc:.
-
#domain_update(args) ⇒ Object
Updates a domain.
-
#domain_update_xml(args) ⇒ Object
:nodoc:.
Instance Method Details
#domain_check(*domains) ⇒ Object
Check the availability of domains
takes a list of domains as arguments
returns an array of hashes containing three fields :
:name-
The domain name
:avail-
Wether the domain is available or not.
:reason-
The reason for non availability, if given.
26 27 28 29 30 31 |
# File 'lib/epp-client/domain.rb', line 26 def domain_check(*domains) domains.flatten! response = send_request(domain_check_xml(*domains)) get_result(:xml => response, :callback => :domain_check_process) end |
#domain_check_process(xml) ⇒ Object
:nodoc:
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/epp-client/domain.rb', line 33 def domain_check_process(xml) # :nodoc: xml.xpath('epp:resData/domain:chkData/domain:cd', EPPClient::SCHEMAS_URL).map do |dom| ret = { :name => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).text, :avail => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).attr('avail').value == '1', } unless (reason = dom.xpath('domain:reason', EPPClient::SCHEMAS_URL).text).empty? ret[:reason] = reason end ret end end |
#domain_check_xml(*domains) ⇒ Object
:nodoc:
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/epp-client/domain.rb', line 6 def domain_check_xml(*domains) # :nodoc: command do |xml| xml.check do xml.check('xmlns' => EPPClient::SCHEMAS_URL['domain-1.0']) do domains.each do |dom| xml.name(dom) end end end end end |
#domain_contacts_xml(xml, args) ⇒ Object
:nodoc:
205 206 207 208 209 210 211 |
# File 'lib/epp-client/domain.rb', line 205 def domain_contacts_xml(xml, args) #:nodoc: args.each do |type,contacts| contacts.each do |c| xml.contact({:type => type}, c) end end end |
#domain_create(args) ⇒ Object
Creates a domain
Takes a hash as an argument, containing the following keys :
:name-
the domain name
:period-
an optionnal hash containing the period for witch the domain is registered with the following keys :
:unit-
the unit of time, either “m”onth or “y”ear.
:number-
the number of unit of time.
:ns-
an optional array containing nameservers informations, which can either be an array of strings containing the nameserver’s hostname, or an array of hashes containing the following keys :
:hostName-
the hostname of the nameserver.
:hostAddrv4-
an optionnal array of ipv4 addresses.
:hostAddrv6-
an optionnal array of ipv6 addresses.
:registrant-
an optionnal registrant nic handle.
:contacts-
an optionnal hash which keys are choosen between
admin,billingandtechand which values are arrays of nic handles for the corresponding contact types. :authInfo-
the password associated with the domain.
Returns a hash with the following keys :
:name-
the fully qualified name of the domain object.
:crDate-
the date and time of domain object creation.
:exDate-
the date and time identifying the end of the domain object’s registration period.
272 273 274 275 276 |
# File 'lib/epp-client/domain.rb', line 272 def domain_create(args) response = send_request(domain_create_xml(args)) get_result(:xml => response, :callback => :domain_create_process) end |
#domain_create_process(xml) ⇒ Object
:nodoc:
278 279 280 281 282 283 284 285 |
# File 'lib/epp-client/domain.rb', line 278 def domain_create_process(xml) #:nodoc: dom = xml.xpath('epp:resData/domain:creData', EPPClient::SCHEMAS_URL) ret = { :name => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).text, :crDate => DateTime.parse(dom.xpath('domain:crDate', EPPClient::SCHEMAS_URL).text), :upDate => DateTime.parse(dom.xpath('domain:crDate', EPPClient::SCHEMAS_URL).text), } end |
#domain_create_xml(args) ⇒ Object
:nodoc:
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/epp-client/domain.rb', line 213 def domain_create_xml(args) #:nodoc: command do |xml| xml.create do xml.create('xmlns' => EPPClient::SCHEMAS_URL['domain-1.0']) do xml.name args[:name] if args.key?(:period) xml.period({:unit => args[:period][:unit]}, args[:period][:number]) end if args.key?(:ns) domain_nss_xml(xml, args[:ns]) end xml.registrant args[:registrant] if args.key?(:registrant) if args.key?(:contacts) domain_contacts_xml(xml, args[:contacts]) end xml.authInfo do xml.pw args[:authInfo] end end end end end |
#domain_delete(domain) ⇒ Object
Deletes a domain
Takes a single fully qualified domain name for argument.
Returns true on success, or raises an exception.
302 303 304 305 306 |
# File 'lib/epp-client/domain.rb', line 302 def domain_delete(domain) response = send_request(domain_delete_xml(domain)) get_result(response) end |
#domain_delete_xml(domain) ⇒ Object
:nodoc:
287 288 289 290 291 292 293 294 295 |
# File 'lib/epp-client/domain.rb', line 287 def domain_delete_xml(domain) #:nodoc: command do |xml| xml.delete do xml.delete('xmlns' => EPPClient::SCHEMAS_URL['domain-1.0']) do xml.name domain end end end end |
#domain_info(args) ⇒ Object
Returns the informations about a domain
Takes either a unique argument, a string, representing the domain, or a hash with : :name the domain name, and optionnaly :authInfo the authentication information and possibly :roid the contact the authInfo is about.
Returned is a hash mapping as closely as possible the result expected from the command as per Section 3.1.2 of RFC 5731 :
:name-
The fully qualified name of the domain object.
:roid-
The Repository Object IDentifier assigned to the domain object when the object was created.
:status-
an optionnal array of elements that contain the current status descriptors associated with the domain.
:registrant-
one optionnal registrant nic handle.
:contacts-
an optionnal hash which keys are choosen between
admin,billingandtechand which values are arrays of nic handles for the corresponding contact types. :ns-
an optional array containing nameservers informations, which can either be an array of strings containing the the fully qualified name of a host, or an array of hashes containing the following keys :
:hostName-
the fully qualified name of a host.
:hostAddrv4-
an optionnal array of ipv4 addresses to be associated with the host.
:hostAddrv6-
an optionnal array of ipv6 addresses to be associated with the host.
:host-
an optionnal array of fully qualified names of the subordinate host objects that exist under this superordinate domain object.
:clID-
the identifier of the sponsoring client.
:crID-
an optional identifier of the client that created the domain object.
:crDate-
an optional date and time of domain object creation.
:exDate-
the date and time identifying the end of the domain object’s registration period.
:upID-
the identifier of the client that last updated the domain object.
:upDate-
the date and time of the most recent domain-object modification.
:trDate-
the date and time of the most recent successful domain-object transfer.
:authInfo-
authorization information associated with the domain object.
115 116 117 118 119 120 121 122 |
# File 'lib/epp-client/domain.rb', line 115 def domain_info(args) if String === args args = {:name => args} end response = send_request(domain_info_xml(args)) get_result(:xml => response, :callback => :domain_info_process) end |
#domain_info_process(xml) ⇒ Object
:nodoc:
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/epp-client/domain.rb', line 124 def domain_info_process(xml) # :nodoc: dom = xml.xpath('epp:resData/domain:infData', EPPClient::SCHEMAS_URL) ret = { :name => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).text, :roid => dom.xpath('domain:roid', EPPClient::SCHEMAS_URL).text, } if (status = dom.xpath('domain:status', EPPClient::SCHEMAS_URL)).size > 0 ret[:status] = status.map {|s| s.attr('s')} end if (registrant = dom.xpath('domain:registrant', EPPClient::SCHEMAS_URL)).size > 0 ret[:registrant] = registrant.text end if (contact = dom.xpath('domain:contact', EPPClient::SCHEMAS_URL)).size > 0 ret[:contacts] = contact.inject({}) do |a,c| s = c.attr('type').to_sym a[s] ||= [] a[s] << c.text a end end if (ns = dom.xpath('domain:ns', EPPClient::SCHEMAS_URL)).size > 0 if (hostObj = ns.xpath('domain:hostObj', EPPClient::SCHEMAS_URL)).size > 0 ret[:ns] = hostObj.map {|h| h.text} elsif (hostAttr = ns.xpath('domain:hostAttr', EPPClient::SCHEMAS_URL)).size > 0 ret[:ns] = hostAttr.map do |h| r = { :hostName => h.xpath('domain:hostName', EPPClient::SCHEMAS_URL).text } if (v4 = h.xpath('domain:hostAddr[@ip="v4"]', EPPClient::SCHEMAS_URL)).size > 0 r[:hostAddrv4] = v4.map {|v| v.text} end if (v6 = h.xpath('domain:hostAddr[@ip="v6"]', EPPClient::SCHEMAS_URL)).size > 0 r[:hostAddrv6] = v6.map {|v| v.text} end r end end end if (host = dom.xpath('domain:host', EPPClient::SCHEMAS_URL)).size > 0 ret[:host] = host.map {|h| h.text} end %w(clID upID).each do |val| if (r = dom.xpath("domain:#{val}", EPPClient::SCHEMAS_URL)).size > 0 ret[val.to_sym] = r.text end end %w(crDate exDate upDate trDate).each do |val| if (r = dom.xpath("domain:#{val}", EPPClient::SCHEMAS_URL)).size > 0 ret[val.to_sym] = DateTime.parse(r.text) end end if (authInfo = dom.xpath('domain:authInfo', EPPClient::SCHEMAS_URL)).size > 0 ret[:authInfo] = authInfo.xpath('domain:pw', EPPClient::SCHEMAS_URL).text end return ret end |
#domain_info_xml(args) ⇒ Object
:nodoc:
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/epp-client/domain.rb', line 46 def domain_info_xml(args) # :nodoc: command do |xml| xml.info do xml.info('xmlns' => EPPClient::SCHEMAS_URL['domain-1.0']) do xml.name(args[:name]) if args.key?(:authInfo) xml.authInfo do if args.key?(:roid) xml.pw({:roid => args[:roid]}, args[:authInfo]) else xml.pw(args[:authInfo]) end end end end end end end |
#domain_nss_xml(xml, nss) ⇒ Object
:nodoc:
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/epp-client/domain.rb', line 179 def domain_nss_xml(xml, nss) #:nodoc: xml.ns do if nss.first.is_a?(Hash) nss.each do |ns| xml.hostAttr do xml.hostName ns[:hostName] if ns.key?(:hostAddrv4) ns[:hostAddrv4].each do |v4| xml.hostAddr({:ip => :v4}, v4) end end if ns.key?(:hostAddrv6) ns[:hostAddrv6].each do |v6| xml.hostAddr({:ip => :v6}, v6) end end end end else nss.each do |ns| xml.hostObj ns end end end end |
#domain_pending_action_process(xml) ⇒ Object
:nodoc:
387 388 389 390 391 392 393 394 395 |
# File 'lib/epp-client/domain.rb', line 387 def domain_pending_action_process(xml) #:nodoc: dom = xml.xpath('epp:resData/domain:panData', EPPClient::SCHEMAS_URL) ret = { :name => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).text, :paResult => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).attribute('paResult').value, :paTRID => get_trid(dom.xpath('domain:paTRID', EPPClient::SCHEMAS_URL)), :paDate => DateTime.parse(dom.xpath('domain:paDate', EPPClient::SCHEMAS_URL).text), } end |
#domain_transfer(args) ⇒ Object
Transfers a domain
Takes a hash with :
:name-
The domain name
:op-
An operation that can either be “query” or “request”.
:authInfo-
The authentication information and possibly
:roidthe contact the authInfo is about. The:authInfoinformation is optional when the operation type is “query” and mandatory when it is “request”. :period-
An optionnal hash containing the period for witch the domain is registered with the following keys :
:unit-
the unit of time, either “m”onth or “y”ear.
:number-
the number of unit of time.
Returned is a hash mapping as closely as possible the result expected from the command as per Section 3.1.3 and 3.2.4 of RFC 5731 :
:name-
The fully qualified name of the domain object.
:trStatus-
The state of the most recent transfer request.
:reID-
The identifier of the client that requested the object transfer.
:reDate-
The date and time that the transfer was requested.
:acID-
The identifier of the client that SHOULD act upon a PENDING transfer request. For all other status types, the value identifies the client that took the indicated action.
:acDate-
The date and time of a required or completed response. For a PENDING request, the value identifies the date and time by which a response is required before an automated response action will be taken by the server. For all other status types, the value identifies the date and time when the request was completed.
:exDate-
Optionnaly, the end of the domain object’s validity period if the <transfer> command caused or causes a change in the validity period.
477 478 479 480 481 |
# File 'lib/epp-client/domain.rb', line 477 def domain_transfer(args) response = send_request(domain_transfer_xml(args)) get_result(:xml => response, :callback => :domain_transfer_response) end |
#domain_transfer_response(xml) ⇒ Object
:nodoc:
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/epp-client/domain.rb', line 397 def domain_transfer_response(xml) #:nodoc: dom = xml.xpath('epp:resData/domain:trnData', EPPClient::SCHEMAS_URL) ret = { :name => dom.xpath('domain:name', EPPClient::SCHEMAS_URL).text, :trStatus => dom.xpath('domain:trStatus', EPPClient::SCHEMAS_URL).text, :reID => dom.xpath('domain:reID', EPPClient::SCHEMAS_URL).text, :reDate => DateTime.parse(dom.xpath('domain:reDate', EPPClient::SCHEMAS_URL).text), :acID => dom.xpath('domain:acID', EPPClient::SCHEMAS_URL).text, :acDate => DateTime.parse(dom.xpath('domain:acDate', EPPClient::SCHEMAS_URL).text) } if (exDate = dom.xpath('domain:exDate', EPPClient::SCHEMAS_URL)).size > 0 ret[:exDate] = DateTime.parse(exDate) end ret end |
#domain_transfer_xml(args) ⇒ Object
:nodoc:
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/epp-client/domain.rb', line 413 def domain_transfer_xml(args) # :nodoc: command do |xml| xml.transfer('op' => args[:op]) do xml.transfer('xmlns' => EPPClient::SCHEMAS_URL['domain-1.0']) do xml.name(args[:name]) if args.key?(:period) xml.period('unit' => args[:period][:unit]) do args[:period][:number] end end if args.key?(:authInfo) xml.authInfo do if args.key?(:roid) xml.pw({:roid => args[:roid]}, args[:authInfo]) else xml.pw(args[:authInfo]) end end end end end end end |
#domain_update(args) ⇒ Object
Updates a domain
Takes a hash with the name, and at least one of the following keys :
:name-
the fully qualified name of the domain object to be updated.
:add/:rem-
adds / removes the following data to/from the domain object :
:ns-
an optional array containing nameservers informations, which can either be an array of strings containing the nameserver’s hostname, or an array of hashes containing the following keys :
:hostName-
the hostname of the nameserver.
:hostAddrv4-
an optionnal array of ipv4 addresses.
:hostAddrv6-
an optionnal array of ipv6 addresses.
:contacts-
an optionnal hash which keys are choosen between
admin,billingandtechand which values are arrays of nic handles for the corresponding contact types. :status-
an optional hash with status values to be applied to or removed from the object. When specifying a value to be removed, only the attribute value is significant; element text is not required to match a value for removal.
:chg-
changes the following in the domain object.
:registrant-
an optionnal registrant nic handle.
:authInfo-
an optional password associated with the domain.
Returns true on success, or raises an exception.
380 381 382 383 384 |
# File 'lib/epp-client/domain.rb', line 380 def domain_update(args) response = send_request(domain_update_xml(args)) get_result(response) end |
#domain_update_xml(args) ⇒ Object
:nodoc:
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/epp-client/domain.rb', line 308 def domain_update_xml(args) #:nodoc: command do |xml| xml.update do xml.update('xmlns' => EPPClient::SCHEMAS_URL['domain-1.0']) do xml.name args[:name] [:add, :rem].each do |ar| if args.key?(ar) && (args[ar].key?(:ns) || args[ar].key?(:contacts) || args[ar].key?(:status)) xml.__send__(ar) do if args[ar].key?(:ns) domain_nss_xml(xml, args[ar][:ns]) end if args[ar].key?(:contacts) domain_contacts_xml(xml, args[ar][:contacts]) end if args[ar].key?(:status) args[ar][:status].each do |st,text| if text.nil? xml.status(:s => st) else xml.status({:s => st}, text) end end end end end end if args.key?(:chg) && (args[:chg].key?(:registrant) || args[:chg].key?(:authInfo)) xml.chg do if args[:chg].key?(:registrant) xml.registrant args[:chg][:registrant] end if args[:chg].key?(:authInfo) xml.authInfo do xml.pw args[:chg][:authInfo] end end end end end end end end |