nominet-epp 0.0.12 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.travis.yml +14 -0
- data/.yardopts +8 -2
- data/Gemfile +22 -0
- data/Gemfile.lock +64 -0
- data/HISTORY.md +78 -0
- data/LICENSE +1 -1
- data/README.md +23 -0
- data/Rakefile +2 -37
- data/gemfiles/Gemfile.ruby18 +13 -0
- data/lib/nominet-epp/client.rb +364 -0
- data/lib/nominet-epp/notification.rb +346 -0
- data/lib/nominet-epp/operations.rb +2 -7
- data/lib/nominet-epp/request.rb +165 -0
- data/lib/nominet-epp/requests/contact/check.rb +9 -0
- data/lib/nominet-epp/requests/contact/create.rb +60 -0
- data/lib/nominet-epp/requests/contact/delete.rb +9 -0
- data/lib/nominet-epp/requests/contact/info.rb +9 -0
- data/lib/nominet-epp/requests/contact/release.rb +33 -0
- data/lib/nominet-epp/requests/contact/update.rb +63 -0
- data/lib/nominet-epp/requests/custom/handshake.rb +36 -0
- data/lib/nominet-epp/requests/custom/list.rb +38 -0
- data/lib/nominet-epp/requests/custom/tag_list.rb +25 -0
- data/lib/nominet-epp/requests/domain/check.rb +98 -0
- data/lib/nominet-epp/requests/domain/create.rb +97 -0
- data/lib/nominet-epp/requests/domain/delete.rb +9 -0
- data/lib/nominet-epp/requests/domain/info.rb +9 -0
- data/lib/nominet-epp/requests/domain/release.rb +33 -0
- data/lib/nominet-epp/requests/domain/renew.rb +9 -0
- data/lib/nominet-epp/requests/domain/unrenew.rb +33 -0
- data/lib/nominet-epp/requests/domain/update.rb +134 -0
- data/lib/nominet-epp/requests/host/check.rb +9 -0
- data/lib/nominet-epp/requests/host/create.rb +9 -0
- data/lib/nominet-epp/requests/host/delete.rb +9 -0
- data/lib/nominet-epp/requests/host/info.rb +9 -0
- data/lib/nominet-epp/requests/host/update.rb +9 -0
- data/lib/nominet-epp/responses/contact/check_response.rb +10 -0
- data/lib/nominet-epp/responses/contact/create_response.rb +14 -0
- data/lib/nominet-epp/responses/contact/delete_response.rb +10 -0
- data/lib/nominet-epp/responses/contact/info_response.rb +89 -0
- data/lib/nominet-epp/responses/contact/release_response.rb +10 -0
- data/lib/nominet-epp/responses/contact/update_response.rb +10 -0
- data/lib/nominet-epp/responses/custom/handshake_response.rb +33 -0
- data/lib/nominet-epp/responses/custom/list_response.rb +29 -0
- data/lib/nominet-epp/responses/custom/tag_list_response.rb +37 -0
- data/lib/nominet-epp/responses/domain/check_response.rb +40 -0
- data/lib/nominet-epp/responses/domain/create_response.rb +10 -0
- data/lib/nominet-epp/responses/domain/delete_response.rb +10 -0
- data/lib/nominet-epp/responses/domain/info_response.rb +128 -0
- data/lib/nominet-epp/responses/domain/release_response.rb +10 -0
- data/lib/nominet-epp/responses/domain/renew_response.rb +10 -0
- data/lib/nominet-epp/responses/domain/unrenew_response.rb +26 -0
- data/lib/nominet-epp/responses/domain/update_response.rb +10 -0
- data/lib/nominet-epp/responses/host/check_response.rb +10 -0
- data/lib/nominet-epp/responses/host/create_response.rb +14 -0
- data/lib/nominet-epp/responses/host/delete_response.rb +10 -0
- data/lib/nominet-epp/responses/host/info_response.rb +14 -0
- data/lib/nominet-epp/responses/host/update_response.rb +10 -0
- data/lib/nominet-epp/responses/response.rb +27 -0
- data/lib/nominet-epp/version.rb +4 -0
- data/lib/nominet-epp.rb +60 -161
- data/nominet-epp.gemspec +15 -65
- data/test/helper.rb +57 -0
- data/test/notifications/test_contact_deleted_notification.rb +23 -0
- data/test/notifications/test_domain_cancelled_notification.rb +23 -0
- data/test/notifications/test_domains_released_notification.rb +34 -0
- data/test/notifications/test_domains_suspended_notification.rb +30 -0
- data/test/notifications/test_handshake_rejected_notification.rb +34 -0
- data/test/notifications/test_registrant_transfer_notification.rb +78 -0
- data/test/notifications/test_registrar_change_notification.rb +119 -0
- data/test/requests/contact/test_contact_check_request.rb +25 -0
- data/test/requests/contact/test_contact_create_request.rb +104 -0
- data/test/requests/contact/test_contact_delete_request.rb +20 -0
- data/test/requests/contact/test_contact_info_request.rb +20 -0
- data/test/requests/contact/test_contact_release_request.rb +29 -0
- data/test/requests/contact/test_contact_update_request.rb +111 -0
- data/test/requests/custom/test_custom_handshake_request.rb +42 -0
- data/test/requests/custom/test_custom_list_request.rb +44 -0
- data/test/requests/custom/test_custom_tag_list_request.rb +21 -0
- data/test/requests/domain/test_domain_check_request.rb +140 -0
- data/test/requests/domain/test_domain_create_request.rb +136 -0
- data/test/requests/domain/test_domain_delete_request.rb +20 -0
- data/test/requests/domain/test_domain_info_request.rb +20 -0
- data/test/requests/domain/test_domain_release_request.rb +29 -0
- data/test/requests/domain/test_domain_renew_request.rb +15 -0
- data/test/requests/domain/test_domain_unrenew_request.rb +32 -0
- data/test/requests/domain/test_domain_update_request.rb +163 -0
- data/test/requests/host/test_host_check_request.rb +25 -0
- data/test/requests/host/test_host_create_request.rb +33 -0
- data/test/requests/host/test_host_delete_request.rb +20 -0
- data/test/requests/host/test_host_info_request.rb +20 -0
- data/test/requests/host/test_host_update_request.rb +55 -0
- data/test/responses/contact/test_contact_check_response.rb +28 -0
- data/test/responses/contact/test_contact_create_response.rb +28 -0
- data/test/responses/contact/test_contact_delete_response.rb +18 -0
- data/test/responses/contact/test_contact_info_response.rb +79 -0
- data/test/responses/contact/test_contact_release_response.rb +18 -0
- data/test/responses/contact/test_contact_update_response.rb +18 -0
- data/test/responses/custom/test_custom_handshake_response.rb +27 -0
- data/test/responses/custom/test_custom_list_response.rb +44 -0
- data/test/responses/custom/test_custom_tag_list_response.rb +43 -0
- data/test/responses/domain/test_domain_check_response.rb +56 -0
- data/test/responses/domain/test_domain_create_response.rb +34 -0
- data/test/responses/domain/test_domain_delete_response.rb +18 -0
- data/test/responses/domain/test_domain_info_response.rb +76 -0
- data/test/responses/domain/test_domain_release_response.rb +18 -0
- data/test/responses/domain/test_domain_renew_response.rb +27 -0
- data/test/responses/domain/test_domain_unrenew_response.rb +32 -0
- data/test/responses/domain/test_domain_update_response.rb +18 -0
- data/test/responses/host/test_host_check_response.rb +28 -0
- data/test/responses/host/test_host_create_response.rb +28 -0
- data/test/responses/host/test_host_delete_response.rb +18 -0
- data/test/responses/host/test_host_info_response.rb +28 -0
- data/test/responses/host/test_host_update_response.rb +18 -0
- data/test/support/responses/contact/check.xml +23 -0
- data/test/support/responses/contact/create.xml +23 -0
- data/test/support/responses/contact/delete.xml +12 -0
- data/test/support/responses/contact/info.xml +46 -0
- data/test/support/responses/contact/release.xml +12 -0
- data/test/support/responses/contact/update.xml +12 -0
- data/test/support/responses/custom/handshake.xml +24 -0
- data/test/support/responses/custom/list.xml +28 -0
- data/test/support/responses/custom/list_empty.xml +21 -0
- data/test/support/responses/custom/tag_list.xml +28 -0
- data/test/support/responses/domain/check-direct-rights.xml +1 -0
- data/test/support/responses/domain/check.xml +25 -0
- data/test/support/responses/domain/create.xml +24 -0
- data/test/support/responses/domain/delete.xml +12 -0
- data/test/support/responses/domain/info.xml +45 -0
- data/test/support/responses/domain/release.xml +12 -0
- data/test/support/responses/domain/renew.xml +24 -0
- data/test/support/responses/domain/unrenew.xml +26 -0
- data/test/support/responses/domain/update.xml +12 -0
- data/test/support/responses/host/check.xml +23 -0
- data/test/support/responses/host/create.xml +18 -0
- data/test/support/responses/host/delete.xml +12 -0
- data/test/support/responses/host/info.xml +25 -0
- data/test/support/responses/host/update.xml +12 -0
- data/test/support/responses/notifications/abuse-feed.xml +31 -0
- data/test/support/responses/notifications/account-change.xml +39 -0
- data/test/support/responses/notifications/contact-deleted.xml +22 -0
- data/test/support/responses/notifications/data-quality.xml +53 -0
- data/test/support/responses/notifications/domain-cancelled.xml +22 -0
- data/test/support/responses/notifications/domains-released.xml +31 -0
- data/test/support/responses/notifications/domains-suspended.xml +26 -0
- data/test/support/responses/notifications/handshake-rejected.xml +31 -0
- data/test/support/responses/notifications/handshake-request.xml +65 -0
- data/test/support/responses/notifications/hosts-cancelled.xml +28 -0
- data/test/support/responses/notifications/referral-accepted.xml +23 -0
- data/test/support/responses/notifications/referral-rejected.xml +22 -0
- data/test/support/responses/notifications/registrant-transfer.xml +54 -0
- data/test/support/responses/notifications/registrar-change.xml +67 -0
- data/test/support/schemas/README +12 -0
- data/test/support/schemas/RELEASENOTES +54 -0
- data/test/support/schemas/contact-1.0.xsd +387 -0
- data/test/support/schemas/contact-nom-ext-1.0.xsd +144 -0
- data/test/support/schemas/domain-1.0.xsd +432 -0
- data/test/support/schemas/domain-nom-ext-1.2.xsd +215 -0
- data/test/support/schemas/epp-1.0.xsd +403 -0
- data/test/support/schemas/eppcom-1.0.xsd +93 -0
- data/test/support/schemas/host-1.0.xsd +240 -0
- data/test/support/schemas/nom-abuse-feed-1.0.xsd +46 -0
- data/test/support/schemas/nom-direct-rights-1.0.xsd +48 -0
- data/test/support/schemas/nom-root-std-1.0.7.xsd +47 -0
- data/test/support/schemas/nom-root-tag-1.0.xsd +31 -0
- data/test/support/schemas/nom-tag-1.0.xsd +71 -0
- data/test/support/schemas/secDNS-1.1.xsd +127 -0
- data/test/support/schemas/std-contact-id-1.0.xsd +35 -0
- data/test/support/schemas/std-fork-1.0.xsd +31 -0
- data/test/support/schemas/std-handshake-1.0.xsd +61 -0
- data/test/support/schemas/std-list-1.0.xsd +55 -0
- data/test/support/schemas/std-locks-1.0.xsd +53 -0
- data/test/support/schemas/std-notifications-1.2.xsd +197 -0
- data/test/support/schemas/std-release-1.0.xsd +39 -0
- data/test/support/schemas/std-unrenew-1.0.xsd +26 -0
- data/test/support/schemas/std-warning-1.1.xsd +145 -0
- data/test/test_nominet-epp.rb +3 -3
- metadata +324 -104
- data/History.rdoc +0 -78
- data/README.rdoc +0 -23
- data/VERSION +0 -1
- data/lib/nominet-epp/operations/check.rb +0 -39
- data/lib/nominet-epp/operations/create.rb +0 -138
- data/lib/nominet-epp/operations/delete.rb +0 -20
- data/lib/nominet-epp/operations/fork.rb +0 -53
- data/lib/nominet-epp/operations/hello.rb +0 -11
- data/lib/nominet-epp/operations/info.rb +0 -93
- data/lib/nominet-epp/operations/list.rb +0 -83
- data/lib/nominet-epp/operations/lock.rb +0 -56
- data/lib/nominet-epp/operations/merge.rb +0 -41
- data/lib/nominet-epp/operations/poll.rb +0 -64
- data/lib/nominet-epp/operations/renew.rb +0 -40
- data/lib/nominet-epp/operations/transfer.rb +0 -84
- data/lib/nominet-epp/operations/unlock.rb +0 -56
- data/lib/nominet-epp/operations/unrenew.rb +0 -36
- data/lib/nominet-epp/operations/update.rb +0 -176
@@ -1,84 +0,0 @@
|
|
1
|
-
module NominetEPP
|
2
|
-
module Operations
|
3
|
-
# EPP Transfer Operation
|
4
|
-
module Transfer
|
5
|
-
# @overload transfer(:release, name, tag, to_account_id = nil)
|
6
|
-
# @param [String] name Domain to release
|
7
|
-
# @param [String] tag TAG to release the domain to
|
8
|
-
# @param [String] to_account_id Specific account ID to release to
|
9
|
-
# @return [Hash] +{:result => true|:handshake}+ if successfully transferred or pending
|
10
|
-
# @return [false] transfer failed
|
11
|
-
# @overload transfer(:approve, case_id)
|
12
|
-
# @param [String] case_id Transfer case to approve
|
13
|
-
# @return [false] failed
|
14
|
-
# @return [Hash] of +:case_id+ and array of +:domains+
|
15
|
-
# @overload transfer(:reject, case_id)
|
16
|
-
# @param [String] case_id Transfer case to reject
|
17
|
-
# @return [false] failed
|
18
|
-
# @return [Hash] of +:case_id+ and array of +:domains+
|
19
|
-
# @param [Symbol] type Type of transfer operation
|
20
|
-
# @raise [ArgumentError] type is not one of +:release+, +:approve+ or +:reject+
|
21
|
-
# @see transfer_release
|
22
|
-
# @see transfer_approve
|
23
|
-
# @see transfer_reject
|
24
|
-
def transfer(type, *args)
|
25
|
-
raise ArgumentError, "type must be :release, :approve, :reject" unless [:release, :approve, :reject].include?(type)
|
26
|
-
|
27
|
-
@resp = @client.transfer do |transfer|
|
28
|
-
transfer['op'] = type.to_s
|
29
|
-
transfer << self.send(:"transfer_#{type}", *args)
|
30
|
-
end
|
31
|
-
|
32
|
-
if type == :release
|
33
|
-
case @resp.code
|
34
|
-
when 1000
|
35
|
-
{ :result => true }
|
36
|
-
when 1001
|
37
|
-
{ :result => :handshake }
|
38
|
-
else
|
39
|
-
false
|
40
|
-
end
|
41
|
-
else
|
42
|
-
return false unless @resp.success?
|
43
|
-
nCase, domainList = @resp.data
|
44
|
-
{ :case_id => node_value(nCase,'//n:Case/n:case-id'),
|
45
|
-
:domains => domainList.find('//n:domain-name', namespaces).map{|n| n.content.strip} }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
# @param [String] name Domain to release
|
51
|
-
# @param [String] tag TAG to release the domain to
|
52
|
-
# @param [String] to_account_id Specific account ID to release to
|
53
|
-
# @return [XML::Node] +domain:transfer+ payload
|
54
|
-
def transfer_release(name, tag, to_account_id = nil)
|
55
|
-
domain('transfer') do |node, ns|
|
56
|
-
node << XML::Node.new('name', name, ns)
|
57
|
-
node << XML::Node.new('registrar-tag', tag, ns)
|
58
|
-
|
59
|
-
unless to_account_id.nil?
|
60
|
-
account = XML::Node.new('account', nil, ns)
|
61
|
-
account << XML::Node.new('account-id', to_account_id, ns)
|
62
|
-
node << account
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# @param [String] case_id Transfer case to approve
|
68
|
-
# @return [XML::Node] +notification:case+ payload
|
69
|
-
def transfer_approve(case_id)
|
70
|
-
notification('Case') do |node, ns|
|
71
|
-
node << XML::Node.new('case-id', case_id, ns)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# @param [String] case_id Transfer case to reject
|
76
|
-
# @return [XML::Node] +notification:case+ payload
|
77
|
-
def transfer_reject(case_id)
|
78
|
-
notification('Case') do |node, ns|
|
79
|
-
node << XML::Node.new('case-id', case_id, ns)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module NominetEPP
|
2
|
-
module Operations
|
3
|
-
# EPP Unlock Operation
|
4
|
-
module Unlock
|
5
|
-
# Unlock domain or account 'investigation' or 'opt-out'
|
6
|
-
#
|
7
|
-
# @param [Symbol] entity Entity to unlock
|
8
|
-
# @param [String] type Type of unlock
|
9
|
-
# @param [String] id Domain name or account ID
|
10
|
-
# @raise [ArgumentError] entity is not +:domain+ or +:account+
|
11
|
-
# @raise [ArgumentError] type is not 'investigation' or 'opt-out'
|
12
|
-
# @return [Boolean] unlocking successful
|
13
|
-
def unlock(entity, type, id)
|
14
|
-
raise ArgumentError, "entity must be :domain or :account" unless [:domain, :account].include?(entity)
|
15
|
-
raise ArgumentError, "type must be 'investigation' or 'opt-out'" unless %w(investigation opt-out).include?(type)
|
16
|
-
|
17
|
-
@resp = @client.update do
|
18
|
-
case type
|
19
|
-
when 'investigation'
|
20
|
-
lock_investigation(entity, id)
|
21
|
-
when 'opt-out'
|
22
|
-
lock_opt_out(entity, id)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
return @resp.success?
|
27
|
-
end
|
28
|
-
private
|
29
|
-
# Create +account:unlock+ XML element for opt-out lock
|
30
|
-
# @param [Symbol] entity Entity to set opt out lock on
|
31
|
-
# @param [String] id Domain name or Account ID to lock
|
32
|
-
# @return [XML::Node] +account:unlock+ element
|
33
|
-
def unlock_opt_out(entity, id)
|
34
|
-
account('unlock') do |node, ns|
|
35
|
-
node['type'] = 'opt-out'
|
36
|
-
node << XML::Node.new((entity == :domain ? 'domain-name' : 'roid'), id, ns)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# Create +unlock+ XML element for investigation lock
|
41
|
-
#
|
42
|
-
# We don't support 'investigation' on account:domain-name as this ability
|
43
|
-
# is already provided via domain:name
|
44
|
-
#
|
45
|
-
# @param [Symbol] entity Entity to set investigation unlock on
|
46
|
-
# @param [String] id Domain name or account ID to set unlock on
|
47
|
-
# @return [XML::Node] +lock+ element
|
48
|
-
def unlock_investigation(entity, id)
|
49
|
-
self.send(entity, 'unlock') do |node, ns|
|
50
|
-
node['type'] = 'investigation'
|
51
|
-
node << XML::Node.new((entity == :domain ? 'name' : 'roid'), id, ns)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module NominetEPP
|
2
|
-
module Operations
|
3
|
-
# EPP Unrenew Operation
|
4
|
-
module Unrenew
|
5
|
-
# Reverse a renewal request for one or more domain names.
|
6
|
-
#
|
7
|
-
# Unrenew commands will only be processed if the renewal invoice
|
8
|
-
# has not yet been generated. If the operation is successful, an
|
9
|
-
# email will be sent to the registrant of the domain name notifying
|
10
|
-
# them of the renewal reversal.
|
11
|
-
#
|
12
|
-
# @param [String, ...] *names Domain names to unrenew
|
13
|
-
# @return [false] unrenew failed
|
14
|
-
# @return [Hash<String, Time>] hash of domains and expiry times
|
15
|
-
def unrenew(*names)
|
16
|
-
@resp = @client.update do
|
17
|
-
domain('unrenew') do |node, ns|
|
18
|
-
names.each do |name|
|
19
|
-
node << XML::Node.new('name', name, ns)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
return false unless @resp.success?
|
25
|
-
|
26
|
-
hash = {}
|
27
|
-
@resp.data.find('//domain:renData', namespaces).each do |node|
|
28
|
-
renName = node_value(node, 'domain:name')
|
29
|
-
renExp = node_value(node, 'domain:exDate')
|
30
|
-
hash[renName] = Time.parse(renExp)
|
31
|
-
end
|
32
|
-
hash
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
module NominetEPP
|
2
|
-
module Operations
|
3
|
-
# == EPP Update Operation
|
4
|
-
#
|
5
|
-
# === Domain Update
|
6
|
-
# The +id+ field for domain updates is the domain name to be modified.
|
7
|
-
#
|
8
|
-
# Fields options
|
9
|
-
# - (Hash) +:account+ -- Hash of account details to be updated
|
10
|
-
# - (String,Hash) +:ns+ -- Single or array of nameservers to set on the domain
|
11
|
-
# - (String) +:first_bill+ -- Set first-bill
|
12
|
-
# - (String) +:recur_bill+ -- Set recur-bill
|
13
|
-
# - (String) +:auto_bill+ -- Set auto-bill
|
14
|
-
# - (String) +:purchase_order+ -- Set purchase-oder
|
15
|
-
# - (String) +:notes+ -- Notes about the domain
|
16
|
-
# - (Boolean) +:renew_not_required+ -- Mark a domain as no longer needed
|
17
|
-
# - (String) +:reseller+ -- Set reseller
|
18
|
-
# ... etc ... any other permitted account fields
|
19
|
-
#
|
20
|
-
# === Account Update
|
21
|
-
# The +id+ field for account updates is the ROID identifying
|
22
|
-
# the account record on the remote endpoint.
|
23
|
-
#
|
24
|
-
# Fields options
|
25
|
-
# - (Array) +:contacts+ -- Array of contacts to create on the account
|
26
|
-
# - (Hash) +:addr+ -- Hash of address fields to modify on the account
|
27
|
-
# - (String) +:name+ -- Account holder name
|
28
|
-
# ... etc ... any other permitted account fields
|
29
|
-
#
|
30
|
-
# === Contact Update
|
31
|
-
# The +id+ field for contact updates is the ROID identifying
|
32
|
-
# the contact record on the remote endpoint.
|
33
|
-
#
|
34
|
-
# Fields options
|
35
|
-
# - (String) +:name+ -- Contacts new name
|
36
|
-
# - (String) +:email+ -- Contacts new email address
|
37
|
-
# - (String) +:phone+ -- Contacts new phone number
|
38
|
-
# - (String) +:mobile+ -- Contacts new mobile number
|
39
|
-
#
|
40
|
-
# === Nameserver Update
|
41
|
-
# The +id+ field for nameserver updates is the fully qualified
|
42
|
-
# hostname for the name server you wish to update.
|
43
|
-
#
|
44
|
-
# Fields options
|
45
|
-
# - (Hash) +:add+ -- Addresses to add to the nameserver
|
46
|
-
# - (Hash) +:rem+ -- Addresses to remove from the nameserver
|
47
|
-
# - (String) +:chg+ -- New hostname of the nameserver
|
48
|
-
#
|
49
|
-
# Fields +:add+ and +:rem+ options
|
50
|
-
# - (String) +:v4+ -- IPv4 address to add or remove from the nameserver
|
51
|
-
# - (String) +:v6+ -- IPv6 address to add or remove from the nameserver
|
52
|
-
#
|
53
|
-
# Example:
|
54
|
-
#
|
55
|
-
# fields = {:chg => 'new.ns.example.com',
|
56
|
-
# :add => {:v4 => '192.168.1.45', :v6 => '2001:db8::1'},
|
57
|
-
# :rem => {:v4 => '192.168.1.14', :v6 => '2001:db8::b'}}
|
58
|
-
#
|
59
|
-
module Update
|
60
|
-
# @param [Symbol] entity Entity to update, one of domain, account, contact or nameserver
|
61
|
-
# @param [String] id Domain, Account, Contact or Nameserver to update
|
62
|
-
# @param [Hash] fields Fields to update
|
63
|
-
# @return [Boolean] request successful
|
64
|
-
def update(entity, id, fields = {})
|
65
|
-
@resp = @client.update do
|
66
|
-
self.send(:"update_#{entity}", id, fields)
|
67
|
-
end
|
68
|
-
|
69
|
-
return @resp.success?
|
70
|
-
end
|
71
|
-
private
|
72
|
-
# Generate +domain:update+ payload
|
73
|
-
# @param [String] name Domain name to update
|
74
|
-
# @param [Hash] fields Fields to update on the domain
|
75
|
-
# @return [XML::Node] +domain:update+ payload
|
76
|
-
def update_domain(name, fields)
|
77
|
-
keys = [:auto_period, :account, :ns, :first_bill, :recur_bill,
|
78
|
-
:auto_bill, :next_bill, :renew_not_required, :notes, :reseller]
|
79
|
-
|
80
|
-
domain('update') do |node, ns|
|
81
|
-
node << XML::Node.new('name', name, ns)
|
82
|
-
keys.each do |k|
|
83
|
-
next if fields[k].nil?
|
84
|
-
case k
|
85
|
-
when :account
|
86
|
-
node << (d_acct = XML::Node.new('account', nil, ns))
|
87
|
-
d_acct << account('update') do |acct, a_ns|
|
88
|
-
account_update_xml(fields[k], acct, a_ns)
|
89
|
-
end
|
90
|
-
when :ns
|
91
|
-
node << domain_ns_xml(fields[k], ns)
|
92
|
-
else
|
93
|
-
node << generic_field_to_xml(k, fields[k], ns) unless fields[k] == ''
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Generate +account:update+ payload
|
100
|
-
# @param [String] roid Account ID
|
101
|
-
# @param [Hash] fields Fields to update on the account
|
102
|
-
# @return [XML::Node] +account:update+ payload
|
103
|
-
def update_account(roid, fields = {})
|
104
|
-
account('update') do |node, ns|
|
105
|
-
node << XML::Node.new('roid', roid, ns)
|
106
|
-
account_fields_xml(fields, node, ns)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# Generate +contact:update+ payload
|
111
|
-
# @param [String] roid Contact ID
|
112
|
-
# @param [Hash] fields Fields to update on the contact
|
113
|
-
# @raise [ArgumentError] invalid keys
|
114
|
-
# @return [XML::Node] XML +contact:update+ element
|
115
|
-
def update_contact(roid, fields = {})
|
116
|
-
contact_to_xml(fields.merge(:roid => roid))
|
117
|
-
end
|
118
|
-
|
119
|
-
# Generate +host:update+ payload to modify a nameserver entry
|
120
|
-
# ---
|
121
|
-
# We need to know nameserver old data as well.
|
122
|
-
# If we are changing the nameserver name and keeping the info the same
|
123
|
-
# then we do a host:chg. If we are adding an IPv{4,6} address we use
|
124
|
-
# the host:add wrapper, and to remove we do a host:rem. As Nominet only
|
125
|
-
# allow one IPv{4,6} address per nameserver we should remove the old
|
126
|
-
# IP address from the server before adding the one. Alternatively if
|
127
|
-
# Nominet will automatically drop previous address then we need only
|
128
|
-
# do a host:add call.
|
129
|
-
# +++
|
130
|
-
#
|
131
|
-
# Fields options
|
132
|
-
# - (Hash) +:add+ -- Addresses to add to the nameserver
|
133
|
-
# - (Hash) +:rem+ -- Addresses to remove from the nameserver
|
134
|
-
# - (String) +:chg+ -- New hostname of the nameserver
|
135
|
-
#
|
136
|
-
# Fields +:add+ and +:rem+ options
|
137
|
-
# - (String) +:v4+ -- IPv4 address to add or remove from the nameserver
|
138
|
-
# - (String) +:v6+ -- IPv6 address to add or remove from the nameserver
|
139
|
-
#
|
140
|
-
# @param [String] name Nameserver host to update
|
141
|
-
# @param [Hash] fields Nameserver update information
|
142
|
-
# @raise [ArgumentError] invalid keys, either on fields or fields[:add] or fields[:rem]
|
143
|
-
# @return [XML::Node] +host:update+ payload
|
144
|
-
def update_nameserver(name, fields = {})
|
145
|
-
raise ArgumentError, "allowed keys :add, :rem, :chg" unless (fields.keys - [:add, :rem, :chg]).empty?
|
146
|
-
|
147
|
-
host('update') do |node, ns|
|
148
|
-
node << XML::Node.new('name', name, ns)
|
149
|
-
|
150
|
-
if fields.has_key?(:add) && fields[:add].kind_of?(Hash)
|
151
|
-
raise ArgumentError, "allowed :add keys are :v4 and :v6" unless (fields[:add].keys - [:v4, :v6]).empty?
|
152
|
-
node << (add = XML::Node.new('add', nil, ns))
|
153
|
-
fields[:add].each do |k,v|
|
154
|
-
add << (n = XML::Node.new('addr', v, ns))
|
155
|
-
n['ip'] = k.to_s
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
if fields.has_key?(:rem) && fields[:rem].kind_of?(Hash)
|
160
|
-
raise ArgumentError, "allowed :rem keys are :v4 and :v6" unless (fields[:rem].keys - [:v4, :v6]).empty?
|
161
|
-
node << (rem = XML::Node.new('rem', nil, ns))
|
162
|
-
fields[:rem].each do |k,v|
|
163
|
-
rem << (n = XML::Node.new('addr', v, ns))
|
164
|
-
n['ip'] = k.to_s
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
if fields.has_key?(:chg) && fields[:chg].kind_of?(String)
|
169
|
-
node << (chg = XML::Node.new('chg', nil, ns))
|
170
|
-
chg << XML::Node.new('name', fields[:chg], ns)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|