dnsimple 2.0.0.alpha2 → 2.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +6 -2
- data/README.markdown +32 -30
- data/dnsimple.gemspec +1 -2
- data/lib/dnsimple.rb +2 -13
- data/lib/dnsimple/client.rb +164 -53
- data/lib/dnsimple/client/certificates_service.rb +98 -0
- data/lib/dnsimple/client/client_service.rb +8 -0
- data/lib/dnsimple/client/contacts_service.rb +82 -0
- data/lib/dnsimple/client/domains_service.rb +333 -0
- data/lib/dnsimple/client/name_servers_service.rb +69 -0
- data/lib/dnsimple/client/registrars_service.rb +105 -0
- data/lib/dnsimple/client/services_service.rb +95 -0
- data/lib/dnsimple/client/templates_service.rb +180 -0
- data/lib/dnsimple/client/users_service.rb +37 -0
- data/lib/dnsimple/compatibility.rb +46 -0
- data/lib/dnsimple/default.rb +86 -0
- data/lib/dnsimple/error.rb +7 -11
- data/lib/dnsimple/extra.rb +54 -0
- data/lib/dnsimple/struct.rb +29 -0
- data/lib/dnsimple/struct/certificate.rb +56 -0
- data/lib/dnsimple/struct/contact.rb +61 -0
- data/lib/dnsimple/struct/domain.rb +40 -0
- data/lib/dnsimple/struct/email_forward.rb +14 -0
- data/lib/dnsimple/struct/extended_attribute.rb +39 -0
- data/lib/dnsimple/struct/membership.rb +22 -0
- data/lib/dnsimple/struct/price.rb +16 -0
- data/lib/dnsimple/struct/record.rb +22 -0
- data/lib/dnsimple/struct/service.rb +19 -0
- data/lib/dnsimple/struct/template.rb +19 -0
- data/lib/dnsimple/struct/template_record.rb +24 -0
- data/lib/dnsimple/struct/transfer_order.rb +10 -0
- data/lib/dnsimple/struct/user.rb +17 -0
- data/lib/dnsimple/struct/whois_privacy.rb +19 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/certificates_service_spec.rb +196 -0
- data/spec/dnsimple/client/contacts_service_spec.rb +179 -0
- data/spec/dnsimple/client/domains_service_spec.rb +662 -0
- data/spec/dnsimple/client/name_servers_service_spec.rb +131 -0
- data/spec/dnsimple/client/registrars_service_spec.rb +160 -0
- data/spec/dnsimple/client/services_service_spec.rb +162 -0
- data/spec/dnsimple/client/templates_service_spec.rb +371 -0
- data/spec/dnsimple/client/users_service_spec.rb +70 -0
- data/spec/dnsimple/client_spec.rb +108 -99
- data/spec/dnsimple/compatibility_spec.rb +57 -0
- data/spec/files/2fa/exchange-token.http +8 -11
- data/spec/files/badgateway.http +14 -0
- data/spec/files/certificates/configure/success.http +19 -0
- data/spec/files/certificates/index/success.http +1 -1
- data/spec/files/certificates/notfound.http +19 -0
- data/spec/files/certificates/purchase/success.http +19 -0
- data/spec/files/certificates/show/success.http +1 -1
- data/spec/files/certificates/submit/success.http +19 -0
- data/spec/files/contacts/create/badrequest-missingcontact.http +19 -0
- data/spec/files/contacts/create/badrequest-validationerror.http +19 -0
- data/spec/files/contacts/create/created.http +22 -0
- data/spec/files/contacts/delete/success-204.http +18 -0
- data/spec/files/{extended_attributes/com.http → contacts/delete/success.http} +5 -5
- data/spec/files/{domains/auto_renewal_enable → contacts/index}/success.http +6 -6
- data/spec/files/contacts/notfound.http +19 -0
- data/spec/files/contacts/update/success.http +21 -0
- data/spec/files/domains/create/created.http +21 -0
- data/spec/files/domains/index/success.http +11 -9
- data/spec/files/domains/notfound.http +11 -9
- data/spec/files/domains/show/success.http +12 -10
- data/spec/files/domains_autorenewal/disable/success.http +21 -0
- data/spec/files/domains_autorenewal/enable/success.http +21 -0
- data/spec/files/domains_autorenewal/notfound-domain.http +19 -0
- data/spec/files/domains_forwards/create/created.http +22 -0
- data/spec/files/domains_forwards/delete/success.http +17 -0
- data/spec/files/domains_forwards/get/success.http +21 -0
- data/spec/files/domains_forwards/list/success.http +21 -0
- data/spec/files/domains_forwards/notfound-domain.http +19 -0
- data/spec/files/domains_forwards/notfound.http +19 -0
- data/spec/files/domains_records/create/created.http +21 -0
- data/spec/files/domains_records/delete/success-204.http +18 -0
- data/spec/files/{contacts/show/notfound.http → domains_records/delete/success.http} +9 -7
- data/spec/files/{records → domains_records}/index/success.http +0 -0
- data/spec/files/{records/show → domains_records}/notfound.http +1 -1
- data/spec/files/{records → domains_records}/show/success.http +0 -0
- data/spec/files/domains_records/update/success.http +21 -0
- data/spec/files/domains_sharing/create/success.http +21 -0
- data/spec/files/domains_sharing/delete/success.http +17 -0
- data/spec/files/domains_sharing/list/success.http +21 -0
- data/spec/files/domains_sharing/notfound-domain.http +19 -0
- data/spec/files/domains_sharing/notfound.http +19 -0
- data/spec/files/domains_whois_privacy/disable/success.http +21 -0
- data/spec/files/domains_whois_privacy/enable/success.http +22 -0
- data/spec/files/domains_zones/get/success.http +21 -0
- data/spec/files/domains_zones/notfound-domain.http +19 -0
- data/spec/files/{domains/auto_renewal_disable/notfound.http → nameservers/change/success.http} +23 -21
- data/spec/files/nameservers/deregister/success.http +17 -0
- data/spec/files/{domains/auto_renewal_enable/notfound.http → nameservers/list/success.http} +23 -21
- data/spec/files/nameservers/notfound-domain.http +19 -0
- data/spec/files/nameservers/register/badrequest-valueerror.http +19 -0
- data/spec/files/nameservers/register/success.http +21 -0
- data/spec/files/registrars/check/available.http +19 -0
- data/spec/files/registrars/check/registered.http +21 -0
- data/spec/files/registrars/register/badrequest-missingdomain.http +19 -0
- data/spec/files/registrars/register/badrequest-missingregistrant.http +19 -0
- data/spec/files/registrars/register/success.http +21 -0
- data/spec/files/registrars/renew/badrequest-missingrenewal.http +19 -0
- data/spec/files/registrars/renew/badrequest-unable.http +19 -0
- data/spec/files/registrars/renew/success.http +21 -0
- data/spec/files/registrars/transfer/success.http +21 -0
- data/spec/files/registrars_extended_attributes/list/success.http +21 -0
- data/spec/files/registrars_prices/list/success.http +21 -0
- data/spec/files/services/applied/success.http +21 -0
- data/spec/files/services/apply/success.http +21 -0
- data/spec/files/services/available/success.http +21 -0
- data/spec/files/services/index/success.http +21 -0
- data/spec/files/services/notfound.http +19 -0
- data/spec/files/services/show/success.http +21 -0
- data/spec/files/services/unapply/success.http +21 -0
- data/spec/files/subscription/show/success.http +21 -0
- data/spec/files/templates/apply/success.http +21 -0
- data/spec/files/templates/create/created.http +22 -0
- data/spec/files/templates/delete/success-204.http +21 -0
- data/spec/files/templates/delete/success.http +21 -0
- data/spec/files/templates/index/success.http +21 -0
- data/spec/files/templates/notfound.http +19 -0
- data/spec/files/templates/show/success.http +12 -10
- data/spec/files/templates/update/success.http +21 -0
- data/spec/files/templates_records/create/created.http +22 -0
- data/spec/files/templates_records/delete/success-204.http +19 -0
- data/spec/files/templates_records/delete/success.http +21 -0
- data/spec/files/templates_records/index/success.http +21 -0
- data/spec/files/templates_records/notfound.http +19 -0
- data/spec/files/templates_records/show/success.http +21 -0
- data/spec/files/templates_records/update/success.http +21 -0
- data/spec/files/users/user/success.http +21 -0
- data/spec/spec_helper.rb +0 -2
- metadata +206 -73
- data/lib/dnsimple/base.rb +0 -10
- data/lib/dnsimple/certificate.rb +0 -143
- data/lib/dnsimple/contact.rb +0 -157
- data/lib/dnsimple/domain.rb +0 -252
- data/lib/dnsimple/extended_attribute.rb +0 -52
- data/lib/dnsimple/record.rb +0 -94
- data/lib/dnsimple/service.rb +0 -42
- data/lib/dnsimple/template.rb +0 -65
- data/lib/dnsimple/template_record.rb +0 -80
- data/lib/dnsimple/transfer_order.rb +0 -34
- data/lib/dnsimple/user.rb +0 -50
- data/spec/dnsimple/certificate_spec.rb +0 -59
- data/spec/dnsimple/contact_spec.rb +0 -45
- data/spec/dnsimple/domain_spec.rb +0 -241
- data/spec/dnsimple/extended_attributes_spec.rb +0 -54
- data/spec/dnsimple/record_spec.rb +0 -51
- data/spec/dnsimple/template_spec.rb +0 -31
- data/spec/dnsimple/user_spec.rb +0 -70
- data/spec/files/account/user/success.http +0 -19
- data/spec/files/certificates/show/notfound.http +0 -17
- data/spec/files/domains/auto_renewal_disable/success.http +0 -23
- data/spec/files/domains/create/success.http +0 -19
- data/spec/files/extended_attributes/ca.http +0 -19
- data/spec/files/extended_attributes/success.http +0 -19
- data/spec/files/templates/show/notfound.http +0 -17
@@ -0,0 +1,82 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
class ContactsService < ClientService
|
4
|
+
|
5
|
+
# Lists the contacts in the account.
|
6
|
+
#
|
7
|
+
# @see http://developer.dnsimple.com/contacts/#list
|
8
|
+
#
|
9
|
+
# @return [Array<Struct::Contact>]
|
10
|
+
# @raise [RequestError] When the request fails.
|
11
|
+
def list
|
12
|
+
response = client.get("v1/contacts")
|
13
|
+
|
14
|
+
response.map { |r| Struct::Contact.new(r["contact"]) }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Creates a contact in the account.
|
18
|
+
#
|
19
|
+
# @see http://developer.dnsimple.com/contacts/#create
|
20
|
+
#
|
21
|
+
# @param [Hash] attributes
|
22
|
+
#
|
23
|
+
# @return [Struct::Contact]
|
24
|
+
# @raise [RequestError] When the request fails.
|
25
|
+
def create(attributes = {})
|
26
|
+
Extra.validate_mandatory_attributes(attributes, [:first_name, :last_name, :address1, :city, :state_province, :postal_code, :country, :phone, :email_address])
|
27
|
+
options = { contact: attributes }
|
28
|
+
response = client.post("v1/contacts", options)
|
29
|
+
|
30
|
+
Struct::Contact.new(response["contact"])
|
31
|
+
end
|
32
|
+
|
33
|
+
# Gets a contact from the account.
|
34
|
+
#
|
35
|
+
# @see http://developer.dnsimple.com/contacts/#get
|
36
|
+
#
|
37
|
+
# @param [Fixnum] contact The contact id.
|
38
|
+
#
|
39
|
+
# @return [Struct::Contact]
|
40
|
+
# @raise [RecordNotFound]
|
41
|
+
# @raise [RequestError] When the request fails.
|
42
|
+
def find(contact)
|
43
|
+
response = client.get("v1/contacts/#{contact}")
|
44
|
+
|
45
|
+
Struct::Contact.new(response["contact"])
|
46
|
+
end
|
47
|
+
|
48
|
+
# Updates a contact in the account.
|
49
|
+
#
|
50
|
+
# @see http://developer.dnsimple.com/contacts/#update
|
51
|
+
#
|
52
|
+
# @param [Fixnum] contact The contact id.
|
53
|
+
# @param [Hash] attributes
|
54
|
+
#
|
55
|
+
# @return [Struct::Contact]
|
56
|
+
# @raise [RecordNotFound]
|
57
|
+
# @raise [RequestError] When the request fails.
|
58
|
+
def update(contact, attributes = {})
|
59
|
+
options = { contact: attributes }
|
60
|
+
response = client.put("v1/contacts/#{contact}", options)
|
61
|
+
|
62
|
+
Struct::Contact.new(response["contact"])
|
63
|
+
end
|
64
|
+
|
65
|
+
# Deletes a contact from the account.
|
66
|
+
#
|
67
|
+
# WARNING: this cannot be undone.
|
68
|
+
#
|
69
|
+
# @see http://developer.dnsimple.com/contacts/#delete
|
70
|
+
#
|
71
|
+
# @param [Fixnum] contact The contact id.
|
72
|
+
#
|
73
|
+
# @return [void]
|
74
|
+
# @raise [RecordNotFound]
|
75
|
+
# @raise [RequestError] When the request fails.
|
76
|
+
def delete(contact)
|
77
|
+
client.delete("v1/contacts/#{contact}")
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,333 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
class DomainsService < ClientService
|
4
|
+
|
5
|
+
# Lists the domains in the account.
|
6
|
+
#
|
7
|
+
# @see http://developer.dnsimple.com/domains/#list
|
8
|
+
#
|
9
|
+
# @return [Array<Struct::Domain>]
|
10
|
+
# @raise [RequestError] When the request fails.
|
11
|
+
def list(options = {})
|
12
|
+
response = client.get("v1/domains", options)
|
13
|
+
|
14
|
+
response.map { |r| Struct::Domain.new(r["domain"]) }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Gets a domain from the account.
|
18
|
+
#
|
19
|
+
# @see http://developer.dnsimple.com/domains/#get
|
20
|
+
#
|
21
|
+
# @param [#to_s] domain The domain id or domain name.
|
22
|
+
#
|
23
|
+
# @return [Struct::Domain]
|
24
|
+
# @raise [RecordNotFound]
|
25
|
+
# @raise [RequestError] When the request fails.
|
26
|
+
def find(domain)
|
27
|
+
response = client.get("v1/domains/#{domain}")
|
28
|
+
|
29
|
+
Struct::Domain.new(response["domain"])
|
30
|
+
end
|
31
|
+
|
32
|
+
# Creates a domain in the account.
|
33
|
+
#
|
34
|
+
# @see http://developer.dnsimple.com/domains/#create
|
35
|
+
#
|
36
|
+
# @param [Hash] attributes
|
37
|
+
#
|
38
|
+
# @return [Struct::Domain]
|
39
|
+
# @raise [RequestError] When the request fails.
|
40
|
+
def create(attributes = {})
|
41
|
+
Extra.validate_mandatory_attributes(attributes, [:name])
|
42
|
+
options = { domain: attributes }
|
43
|
+
response = client.post("v1/domains", options)
|
44
|
+
|
45
|
+
Struct::Domain.new(response["domain"])
|
46
|
+
end
|
47
|
+
|
48
|
+
# Deletes a domain from the account.
|
49
|
+
#
|
50
|
+
# WARNING: this cannot be undone.
|
51
|
+
#
|
52
|
+
# @see http://developer.dnsimple.com/domains/#delete
|
53
|
+
#
|
54
|
+
# @param [#to_s] domain The domain id or domain name.
|
55
|
+
#
|
56
|
+
# @return [void]
|
57
|
+
# @raise [RecordNotFound]
|
58
|
+
# @raise [RequestError] When the request fails.
|
59
|
+
def delete(domain)
|
60
|
+
client.delete("v1/domains/#{domain}")
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# Lists the records for a domain.
|
65
|
+
#
|
66
|
+
# @see http://developer.dnsimple.com/domains/records/#list
|
67
|
+
#
|
68
|
+
# @param [#to_s] domain The domain id or domain name.
|
69
|
+
# @param [Hash] options
|
70
|
+
#
|
71
|
+
# @return [Array<Struct::Record>]
|
72
|
+
# @raise [RecordNotFound]
|
73
|
+
# @raise [RequestError] When the request fails.
|
74
|
+
def list_records(domain, options = {})
|
75
|
+
response = client.get("v1/domains/#{domain}/records", options)
|
76
|
+
|
77
|
+
response.map { |r| Struct::Record.new(r["record"]) }
|
78
|
+
end
|
79
|
+
|
80
|
+
# Creates a record for a domain.
|
81
|
+
#
|
82
|
+
# @see http://developer.dnsimple.com/domains/records/#create
|
83
|
+
#
|
84
|
+
# @param [#to_s] domain The domain id or domain name.
|
85
|
+
# @param [Hash] attributes
|
86
|
+
#
|
87
|
+
# @return [Struct::Record]
|
88
|
+
# @raise [RecordNotFound]
|
89
|
+
# @raise [RequestError] When the request fails.
|
90
|
+
def create_record(domain, attributes = {})
|
91
|
+
Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
|
92
|
+
options = { record: attributes }
|
93
|
+
response = client.post("v1/domains/#{domain}/records", options)
|
94
|
+
|
95
|
+
Struct::Record.new(response["record"])
|
96
|
+
end
|
97
|
+
|
98
|
+
# Gets a record for a domain.
|
99
|
+
#
|
100
|
+
# @see http://developer.dnsimple.com/domains/records/#get
|
101
|
+
#
|
102
|
+
# @param [#to_s] domain The domain id or domain name.
|
103
|
+
# @param [Fixnum] record The record id.
|
104
|
+
#
|
105
|
+
# @return [Struct::Record]
|
106
|
+
# @raise [RecordNotFound]
|
107
|
+
# @raise [RequestError] When the request fails.
|
108
|
+
def find_record(domain, record)
|
109
|
+
response = client.get("v1/domains/#{domain}/records/#{record}")
|
110
|
+
|
111
|
+
Struct::Record.new(response["record"])
|
112
|
+
end
|
113
|
+
|
114
|
+
# Updates a record for a domain.
|
115
|
+
#
|
116
|
+
# @see http://developer.dnsimple.com/domains/records/#update
|
117
|
+
#
|
118
|
+
# @param [#to_s] domain The domain id or domain name.
|
119
|
+
# @param [Fixnum] record The record id.
|
120
|
+
# @param [Hash] attributes
|
121
|
+
#
|
122
|
+
# @return [Struct::Record]
|
123
|
+
# @raise [RecordNotFound]
|
124
|
+
# @raise [RequestError] When the request fails.
|
125
|
+
def update_record(domain, record, attributes = {})
|
126
|
+
options = { record: attributes }
|
127
|
+
response = client.put("v1/domains/#{domain}/records/#{record}", options)
|
128
|
+
|
129
|
+
Struct::Record.new(response["record"])
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deletes a record for a domain.
|
133
|
+
#
|
134
|
+
# @see http://developer.dnsimple.com/domains/records/#delete
|
135
|
+
#
|
136
|
+
# @param [#to_s] domain The domain id or domain name.
|
137
|
+
# @param [Fixnum] record The record id.
|
138
|
+
#
|
139
|
+
# @return [void]
|
140
|
+
# @raise [RecordNotFound]
|
141
|
+
# @raise [RequestError] When the request fails.
|
142
|
+
def delete_record(domain, record)
|
143
|
+
client.delete("v1/domains/#{domain}/records/#{record}")
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
# Enables auto-renewal for a domain.
|
148
|
+
#
|
149
|
+
# @see http://developer.dnsimple.com/domains/autorenewal/#enable
|
150
|
+
#
|
151
|
+
# @param [#to_s] domain The domain id or domain name.
|
152
|
+
#
|
153
|
+
# @return [Struct::Domain]
|
154
|
+
# @raise [RequestError] When the request fails.
|
155
|
+
def enable_auto_renewal(domain)
|
156
|
+
response = client.post("v1/domains/#{domain}/auto_renewal")
|
157
|
+
|
158
|
+
Struct::Domain.new(response["domain"])
|
159
|
+
end
|
160
|
+
|
161
|
+
# Disables auto-renewal for a domain.
|
162
|
+
#
|
163
|
+
# @see http://developer.dnsimple.com/domains/autorenewal/#disable
|
164
|
+
#
|
165
|
+
# @param [#to_s] domain The domain id or domain name.
|
166
|
+
#
|
167
|
+
# @return [Struct::Domain]
|
168
|
+
# @raise [RequestError] When the request fails.
|
169
|
+
def disable_auto_renewal(domain)
|
170
|
+
response = client.delete("v1/domains/#{domain}/auto_renewal")
|
171
|
+
|
172
|
+
Struct::Domain.new(response["domain"])
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
# Enables WHOIS privacy for a domain.
|
177
|
+
#
|
178
|
+
# @see http://developer.dnsimple.com/domains/privacy/#enable
|
179
|
+
#
|
180
|
+
# @param [#to_s] domain The domain id or domain name.
|
181
|
+
#
|
182
|
+
# @return [Struct::WhoisPrivacy]
|
183
|
+
# @raise [RequestError] When the request fails.
|
184
|
+
def enable_whois_privacy(domain)
|
185
|
+
response = client.post("v1/domains/#{domain}/whois_privacy")
|
186
|
+
|
187
|
+
Struct::WhoisPrivacy.new(response["whois_privacy"])
|
188
|
+
end
|
189
|
+
|
190
|
+
# Disables WHOIS privacy for a domain.
|
191
|
+
#
|
192
|
+
# @see http://developer.dnsimple.com/domains/privacy/#disable
|
193
|
+
#
|
194
|
+
# @param [#to_s] domain The domain id or domain name.
|
195
|
+
#
|
196
|
+
# @return [Struct::WhoisPrivacy]
|
197
|
+
# @raise [RequestError] When the request fails.
|
198
|
+
def disable_whois_privacy(domain)
|
199
|
+
response = client.delete("v1/domains/#{domain}/whois_privacy")
|
200
|
+
|
201
|
+
Struct::WhoisPrivacy.new(response["whois_privacy"])
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
# Lists the memberships.
|
206
|
+
#
|
207
|
+
# @see http://developer.dnsimple.com/domains/sharing/#list
|
208
|
+
#
|
209
|
+
# @param [#to_s] domain The domain id or domain name.
|
210
|
+
#
|
211
|
+
# @return [Array<Struct::Membership>]
|
212
|
+
# @raise [RecordNotFound]
|
213
|
+
# @raise [RequestError] When the request fails.
|
214
|
+
def list_memberships(domain)
|
215
|
+
response = client.get("v1/domains/#{domain}/memberships")
|
216
|
+
|
217
|
+
response.map { |r| Struct::Membership.new(r["membership"]) }
|
218
|
+
end
|
219
|
+
|
220
|
+
# Shares a domain.
|
221
|
+
#
|
222
|
+
# @see http://developer.dnsimple.com/domains/sharing/#create
|
223
|
+
#
|
224
|
+
# @param [#to_s] domain The domain id or domain name.
|
225
|
+
# @param [String] email
|
226
|
+
#
|
227
|
+
# @return [Struct::Membership]
|
228
|
+
# @raise [RecordNotFound]
|
229
|
+
# @raise [RequestError] When the request fails.
|
230
|
+
def create_membership(domain, email)
|
231
|
+
options = { membership: { email: email }}
|
232
|
+
response = client.post("v1/domains/#{domain}/memberships", options)
|
233
|
+
|
234
|
+
Struct::Membership.new(response["membership"])
|
235
|
+
end
|
236
|
+
|
237
|
+
# Un-shares a domain.
|
238
|
+
#
|
239
|
+
# @see http://developer.dnsimple.com/domains/sharing/#delete
|
240
|
+
#
|
241
|
+
# @param [#to_s] domain The domain id or domain name.
|
242
|
+
# @param [Fixnum] membership The membership id.
|
243
|
+
#
|
244
|
+
# @return [void]
|
245
|
+
# @raise [RecordNotFound]
|
246
|
+
# @raise [RequestError] When the request fails.
|
247
|
+
def delete_membership(domain, membership)
|
248
|
+
client.delete("v1/domains/#{domain}/memberships/#{membership}")
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
# Lists the email forwards for a domain.
|
253
|
+
#
|
254
|
+
# @see http://developer.dnsimple.com/domains/forwards/#list
|
255
|
+
#
|
256
|
+
# @param [#to_s] domain The domain id or domain name.
|
257
|
+
#
|
258
|
+
# @return [Array<Struct::EmailForward>]
|
259
|
+
# @raise [RecordNotFound]
|
260
|
+
# @raise [RequestError] When the request fails.
|
261
|
+
def list_email_forwards(domain)
|
262
|
+
response = client.get("v1/domains/#{domain}/email_forwards")
|
263
|
+
|
264
|
+
response.map { |r| Struct::EmailForward.new(r["email_forward"]) }
|
265
|
+
end
|
266
|
+
|
267
|
+
# Creates an email forward for a domain.
|
268
|
+
#
|
269
|
+
# @see http://developer.dnsimple.com/domains/forwards/#create
|
270
|
+
#
|
271
|
+
# @param [#to_s] domain The domain id or domain name.
|
272
|
+
# @param [Hash] attributes
|
273
|
+
#
|
274
|
+
# @return [Struct::EmailForward]
|
275
|
+
# @raise [RecordNotFound]
|
276
|
+
# @raise [RequestError] When the request fails.
|
277
|
+
def create_email_forward(domain, attributes = {})
|
278
|
+
Extra.validate_mandatory_attributes(attributes, [:from, :to])
|
279
|
+
options = { email_forward: attributes }
|
280
|
+
response = client.post("v1/domains/#{domain}/email_forwards", options)
|
281
|
+
|
282
|
+
Struct::EmailForward.new(response["email_forward"])
|
283
|
+
end
|
284
|
+
|
285
|
+
# Gets an email forward for a domain.
|
286
|
+
#
|
287
|
+
# @see http://developer.dnsimple.com/domains/forwards/#get
|
288
|
+
#
|
289
|
+
# @param [#to_s] domain The domain id or domain name.
|
290
|
+
# @param [Fixnum] forward The forward id.
|
291
|
+
#
|
292
|
+
# @return [Struct::EmailForward]
|
293
|
+
# @raise [RecordNotFound]
|
294
|
+
# @raise [RequestError] When the request fails.
|
295
|
+
def find_email_forward(domain, forward)
|
296
|
+
response = client.get("v1/domains/#{domain}/email_forwards/#{forward}")
|
297
|
+
|
298
|
+
Struct::EmailForward.new(response["email_forward"])
|
299
|
+
end
|
300
|
+
|
301
|
+
# Deletes an email forward for a domain.
|
302
|
+
#
|
303
|
+
# @see http://developer.dnsimple.com/domains/forwards/#delete
|
304
|
+
#
|
305
|
+
# @param [#to_s] domain The domain id or domain name.
|
306
|
+
# @param [Fixnum] forward The forward id.
|
307
|
+
#
|
308
|
+
# @return [void]
|
309
|
+
# @raise [RecordNotFound]
|
310
|
+
# @raise [RequestError] When the request fails.
|
311
|
+
def delete_email_forward(domain, forward)
|
312
|
+
client.delete("v1/domains/#{domain}/email_forwards/#{forward}")
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
# Gets a domain zone as zone file.
|
317
|
+
#
|
318
|
+
# @see http://developer.dnsimple.com/domains/zones/#get
|
319
|
+
#
|
320
|
+
# @param [#to_s] domain The domain id or domain name.
|
321
|
+
#
|
322
|
+
# @return [String]
|
323
|
+
# @raise [RecordNotFound]
|
324
|
+
# @raise [RequestError] When the request fails.
|
325
|
+
def zone(domain)
|
326
|
+
response = client.get("v1/domains/#{domain}/zone")
|
327
|
+
|
328
|
+
response["zone"]
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
class NameServersService < ClientService
|
4
|
+
|
5
|
+
# Lists the name servers for a domain.
|
6
|
+
#
|
7
|
+
# @see http://developer.dnsimple.com/domains/nameservers/#list
|
8
|
+
#
|
9
|
+
# @param [#to_s] domain The domain id or domain name.
|
10
|
+
#
|
11
|
+
# @return [Array<String>] The delegates name servers.
|
12
|
+
# @raise [RecordNotFound]
|
13
|
+
# @raise [RequestError] When the request fails.
|
14
|
+
def list(domain)
|
15
|
+
response = client.get("v1/domains/#{domain}/name_servers")
|
16
|
+
|
17
|
+
response.parsed_response
|
18
|
+
end
|
19
|
+
|
20
|
+
# Changes the name servers for a domain.
|
21
|
+
#
|
22
|
+
# @see http://developer.dnsimple.com/domains/nameservers/#change
|
23
|
+
#
|
24
|
+
# @param [#to_s] domain The domain id or domain name.
|
25
|
+
# @param [Array<String>] servers The name server list.
|
26
|
+
#
|
27
|
+
# @return [Array<String>] The delegates name servers.
|
28
|
+
# @raise [RecordNotFound]
|
29
|
+
# @raise [RequestError] When the request fails.
|
30
|
+
def change(domain, servers)
|
31
|
+
servers = servers.inject({}) { |hash, server| hash.merge("ns#{hash.length + 1}" => server) }
|
32
|
+
options = { name_servers: servers }
|
33
|
+
response = client.post("v1/domains/#{domain}/name_servers", options)
|
34
|
+
|
35
|
+
response.parsed_response
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# Registers a name server at the registry.
|
40
|
+
#
|
41
|
+
# @see http://developer.dnsimple.com/nameservers/#register
|
42
|
+
#
|
43
|
+
# @param [#to_s] domain The domain id or domain name.
|
44
|
+
# @param [String] name The hostname to register.
|
45
|
+
# @param [String] ip The hostname IP address.
|
46
|
+
#
|
47
|
+
# @return [void]
|
48
|
+
# @raise [RequestError] When the request fails.
|
49
|
+
def register(domain, name, ip)
|
50
|
+
options = { name_server: { name: name, ip: ip } }
|
51
|
+
client.post("v1/domains/#{domain}/registry_name_servers", options)
|
52
|
+
end
|
53
|
+
|
54
|
+
# De-registers a name server at the registry.
|
55
|
+
#
|
56
|
+
# @see http://developer.dnsimple.com/nameservers/#deregister
|
57
|
+
#
|
58
|
+
# @param [#to_s] domain The domain id or domain name.
|
59
|
+
# @param [String] name The hostname to register.
|
60
|
+
#
|
61
|
+
# @return [void]
|
62
|
+
# @raise [RequestError] When the request fails.
|
63
|
+
def deregister(domain, name)
|
64
|
+
client.delete("v1/domains/#{domain}/registry_name_servers/#{name}")
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|