dnsimple 2.2.0 → 3.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -1
  4. data/CHANGELOG.md +13 -2
  5. data/CONTRIBUTING.md +35 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +30 -82
  9. data/dnsimple.gemspec +2 -1
  10. data/lib/dnsimple.rb +0 -2
  11. data/lib/dnsimple/client.rb +64 -64
  12. data/lib/dnsimple/client/clients.rb +82 -58
  13. data/lib/dnsimple/client/contacts.rb +74 -37
  14. data/lib/dnsimple/client/domains.rb +82 -28
  15. data/lib/dnsimple/client/domains_email_forwards.rb +107 -0
  16. data/lib/dnsimple/client/identity.rb +38 -0
  17. data/lib/dnsimple/client/oauth.rb +42 -0
  18. data/lib/dnsimple/client/registrar.rb +64 -72
  19. data/lib/dnsimple/client/registrar_auto_renewal.rb +41 -0
  20. data/lib/dnsimple/client/registrar_whois_privacy.rb +74 -0
  21. data/lib/dnsimple/client/tlds.rb +88 -0
  22. data/lib/dnsimple/client/webhooks.rb +82 -0
  23. data/lib/dnsimple/client/zones.rb +68 -0
  24. data/lib/dnsimple/client/zones_records.rb +127 -0
  25. data/lib/dnsimple/default.rb +10 -17
  26. data/lib/dnsimple/error.rb +5 -8
  27. data/lib/dnsimple/extra.rb +1 -1
  28. data/lib/dnsimple/response.rb +80 -0
  29. data/lib/dnsimple/struct.rb +13 -14
  30. data/lib/dnsimple/struct/account.rb +13 -0
  31. data/lib/dnsimple/struct/contact.rb +6 -3
  32. data/lib/dnsimple/struct/domain.rb +10 -10
  33. data/lib/dnsimple/struct/domain_check.rb +16 -0
  34. data/lib/dnsimple/struct/email_forward.rb +11 -1
  35. data/lib/dnsimple/struct/oauth_token.rb +19 -0
  36. data/lib/dnsimple/struct/record.rb +25 -7
  37. data/lib/dnsimple/struct/tld.rb +22 -0
  38. data/lib/dnsimple/struct/user.rb +3 -7
  39. data/lib/dnsimple/struct/webhook.rb +13 -0
  40. data/lib/dnsimple/struct/whois_privacy.rb +8 -5
  41. data/lib/dnsimple/struct/zone.rb +25 -0
  42. data/lib/dnsimple/version.rb +1 -1
  43. data/spec/dnsimple/client/client_service_spec.rb +37 -0
  44. data/spec/dnsimple/client/contacts_spec.rb +108 -78
  45. data/spec/dnsimple/client/domains_email_forwards_spec.rb +190 -0
  46. data/spec/dnsimple/client/domains_spec.rb +121 -58
  47. data/spec/dnsimple/client/identity_spec.rb +56 -0
  48. data/spec/dnsimple/client/oauth_spec.rb +48 -0
  49. data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +80 -0
  50. data/spec/dnsimple/client/registrar_spec.rb +109 -122
  51. data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +119 -0
  52. data/spec/dnsimple/client/tlds_spec.rb +139 -0
  53. data/spec/dnsimple/client/webhooks_spec.rb +142 -0
  54. data/spec/dnsimple/client/zones_records_spec.rb +277 -0
  55. data/spec/dnsimple/client/zones_spec.rb +109 -0
  56. data/spec/dnsimple/client_spec.rb +34 -46
  57. data/spec/dnsimple/extra_spec.rb +22 -0
  58. data/spec/{files → fixtures.http}/badgateway.http +14 -14
  59. data/spec/fixtures.http/checkDomain/success.http +17 -0
  60. data/spec/fixtures.http/createContact/created.http +17 -0
  61. data/spec/fixtures.http/createDomain/created.http +16 -0
  62. data/spec/fixtures.http/createEmailForward/created.http +17 -0
  63. data/spec/fixtures.http/createWebhook/created.http +17 -0
  64. data/spec/fixtures.http/createZoneRecord/created.http +17 -0
  65. data/spec/fixtures.http/deleteContact/success.http +13 -0
  66. data/spec/fixtures.http/deleteDomain/success.http +13 -0
  67. data/spec/fixtures.http/deleteEmailForward/success.http +12 -0
  68. data/spec/fixtures.http/deleteWebhook/success.http +13 -0
  69. data/spec/fixtures.http/deleteZoneRecord/success.http +13 -0
  70. data/spec/fixtures.http/disableAutoRenewal/success.http +12 -0
  71. data/spec/fixtures.http/disableWhoisPrivacy/success.http +17 -0
  72. data/spec/fixtures.http/enableAutoRenewal/success.http +12 -0
  73. data/spec/fixtures.http/enableWhoisPrivacy/created.http +17 -0
  74. data/spec/fixtures.http/enableWhoisPrivacy/success.http +17 -0
  75. data/spec/fixtures.http/getContact/success.http +17 -0
  76. data/spec/fixtures.http/getDomain/success.http +16 -0
  77. data/spec/fixtures.http/getEmailForward/success.http +17 -0
  78. data/spec/fixtures.http/getTld/success.http +17 -0
  79. data/spec/fixtures.http/getTldExtendedAttributes/success-noattributes.http +17 -0
  80. data/spec/fixtures.http/getTldExtendedAttributes/success.http +17 -0
  81. data/spec/fixtures.http/getWebhook/success.http +17 -0
  82. data/spec/fixtures.http/getWhoisPrivacy/success.http +17 -0
  83. data/spec/fixtures.http/getZone/success.http +17 -0
  84. data/spec/fixtures.http/getZoneRecord/success.http +17 -0
  85. data/spec/fixtures.http/listContacts/success.http +17 -0
  86. data/spec/fixtures.http/listDomains/success.http +16 -0
  87. data/spec/fixtures.http/listEmailForwards/success.http +17 -0
  88. data/spec/fixtures.http/listTlds/success.http +17 -0
  89. data/spec/fixtures.http/listWebhooks/success.http +17 -0
  90. data/spec/fixtures.http/listZoneRecords/success.http +17 -0
  91. data/spec/fixtures.http/listZones/success.http +17 -0
  92. data/spec/fixtures.http/notfound-contact.http +12 -0
  93. data/spec/fixtures.http/notfound-domain.http +12 -0
  94. data/spec/fixtures.http/notfound-emailforward.http +12 -0
  95. data/spec/fixtures.http/notfound-record.http +12 -0
  96. data/spec/fixtures.http/notfound-webhook.http +12 -0
  97. data/spec/fixtures.http/notfound-zone.http +12 -0
  98. data/spec/fixtures.http/oauthAccessToken/success.http +17 -0
  99. data/spec/fixtures.http/pages-1of3.http +16 -0
  100. data/spec/fixtures.http/pages-2of3.http +16 -0
  101. data/spec/fixtures.http/pages-3of3.http +16 -0
  102. data/spec/fixtures.http/registerDomain/success.http +17 -0
  103. data/spec/fixtures.http/renewDomain/error-tooearly.http +15 -0
  104. data/spec/fixtures.http/renewDomain/success.http +17 -0
  105. data/spec/fixtures.http/resetDomainToken/success.http +17 -0
  106. data/spec/fixtures.http/response.http +16 -0
  107. data/spec/fixtures.http/transferDomain/error-indnsimple.http +15 -0
  108. data/spec/fixtures.http/transferDomain/error-missing-authcode.http +15 -0
  109. data/spec/fixtures.http/transferDomain/success.http +17 -0
  110. data/spec/fixtures.http/transferDomainOut/success.http +13 -0
  111. data/spec/fixtures.http/updateContact/success.http +17 -0
  112. data/spec/fixtures.http/updateZoneRecord/success.http +17 -0
  113. data/spec/fixtures.http/whoami/success.http +16 -0
  114. data/spec/fixtures.http/whoami/success_account.http +16 -0
  115. data/spec/fixtures.http/whoami/success_user.http +16 -0
  116. data/spec/spec_helper.rb +0 -6
  117. data/spec/support/helpers.rb +4 -4
  118. metadata +161 -238
  119. data/lib/dnsimple/client/certificates.rb +0 -100
  120. data/lib/dnsimple/client/domains_autorenewal.rb +0 -35
  121. data/lib/dnsimple/client/domains_forwards.rb +0 -71
  122. data/lib/dnsimple/client/domains_privacy.rb +0 -35
  123. data/lib/dnsimple/client/domains_records.rb +0 -90
  124. data/lib/dnsimple/client/domains_sharing.rb +0 -54
  125. data/lib/dnsimple/client/domains_zones.rb +0 -22
  126. data/lib/dnsimple/client/name_servers.rb +0 -71
  127. data/lib/dnsimple/client/services.rb +0 -37
  128. data/lib/dnsimple/client/services_domains.rb +0 -68
  129. data/lib/dnsimple/client/templates.rb +0 -88
  130. data/lib/dnsimple/client/templates_domains.rb +0 -23
  131. data/lib/dnsimple/client/templates_records.rb +0 -88
  132. data/lib/dnsimple/client/users.rb +0 -39
  133. data/lib/dnsimple/client/vanity_name_servers.rb +0 -39
  134. data/lib/dnsimple/compatibility.rb +0 -46
  135. data/lib/dnsimple/struct/certificate.rb +0 -56
  136. data/lib/dnsimple/struct/membership.rb +0 -22
  137. data/lib/dnsimple/struct/price.rb +0 -16
  138. data/lib/dnsimple/struct/service.rb +0 -19
  139. data/lib/dnsimple/struct/template.rb +0 -19
  140. data/lib/dnsimple/struct/template_record.rb +0 -24
  141. data/lib/dnsimple/struct/transfer_order.rb +0 -10
  142. data/spec/dnsimple/client/certificates_spec.rb +0 -196
  143. data/spec/dnsimple/client/domains_autorenewals_spec.rb +0 -72
  144. data/spec/dnsimple/client/domains_forwards_spec.rb +0 -146
  145. data/spec/dnsimple/client/domains_privacy_spec.rb +0 -74
  146. data/spec/dnsimple/client/domains_records_spec.rb +0 -191
  147. data/spec/dnsimple/client/domains_sharing_spec.rb +0 -109
  148. data/spec/dnsimple/client/domains_zones_spec.rb +0 -40
  149. data/spec/dnsimple/client/name_servers_spec.rb +0 -131
  150. data/spec/dnsimple/client/services_domains_spec.rb +0 -101
  151. data/spec/dnsimple/client/services_spec.rb +0 -69
  152. data/spec/dnsimple/client/templates_domains_spec.rb +0 -38
  153. data/spec/dnsimple/client/templates_records_spec.rb +0 -180
  154. data/spec/dnsimple/client/templates_spec.rb +0 -166
  155. data/spec/dnsimple/client/users_spec.rb +0 -70
  156. data/spec/dnsimple/client/vanity_name_servers_spec.rb +0 -61
  157. data/spec/dnsimple/compatibility_spec.rb +0 -57
  158. data/spec/files/2fa/error-badtoken.http +0 -22
  159. data/spec/files/2fa/error-required.http +0 -23
  160. data/spec/files/2fa/exchange-token.http +0 -22
  161. data/spec/files/certificates/configure/success.http +0 -19
  162. data/spec/files/certificates/get/success.http +0 -19
  163. data/spec/files/certificates/list/success.http +0 -19
  164. data/spec/files/certificates/notfound.http +0 -19
  165. data/spec/files/certificates/purchase/success.http +0 -19
  166. data/spec/files/certificates/submit/success.http +0 -19
  167. data/spec/files/contacts/contact/success.http +0 -19
  168. data/spec/files/contacts/contacts/success.http +0 -23
  169. data/spec/files/contacts/create_contact/badrequest-missingcontact.http +0 -19
  170. data/spec/files/contacts/create_contact/badrequest-validationerror.http +0 -19
  171. data/spec/files/contacts/create_contact/created.http +0 -22
  172. data/spec/files/contacts/delete_contact/success-204.http +0 -18
  173. data/spec/files/contacts/delete_contact/success.http +0 -19
  174. data/spec/files/contacts/notfound-contact.http +0 -19
  175. data/spec/files/contacts/update_contact/success.http +0 -21
  176. data/spec/files/domains/create_domain/created.http +0 -21
  177. data/spec/files/domains/create_forward/created.http +0 -22
  178. data/spec/files/domains/create_membership/success.http +0 -21
  179. data/spec/files/domains/create_record/created.http +0 -21
  180. data/spec/files/domains/delete_domain/success-204.http +0 -18
  181. data/spec/files/domains/delete_domain/success.http +0 -19
  182. data/spec/files/domains/delete_forward/success.http +0 -17
  183. data/spec/files/domains/delete_membership/success.http +0 -17
  184. data/spec/files/domains/delete_record/success-204.http +0 -18
  185. data/spec/files/domains/delete_record/success.http +0 -19
  186. data/spec/files/domains/disable_auto_renewal/success.http +0 -21
  187. data/spec/files/domains/disable_whois_privacy/success.http +0 -21
  188. data/spec/files/domains/domain/success.http +0 -21
  189. data/spec/files/domains/domains/success.http +0 -21
  190. data/spec/files/domains/enable_auto_renewal/success.http +0 -21
  191. data/spec/files/domains/enable_whois_privacy/success.http +0 -22
  192. data/spec/files/domains/forward/success.http +0 -21
  193. data/spec/files/domains/forwards/success.http +0 -21
  194. data/spec/files/domains/memberships/success.http +0 -21
  195. data/spec/files/domains/notfound-domain.http +0 -19
  196. data/spec/files/domains/notfound-forward.http +0 -19
  197. data/spec/files/domains/notfound-membership.http +0 -19
  198. data/spec/files/domains/record/success.http +0 -19
  199. data/spec/files/domains/records/success.http +0 -19
  200. data/spec/files/domains/update_record/success.http +0 -21
  201. data/spec/files/domains/zone/success.http +0 -21
  202. data/spec/files/nameservers/change/success.http +0 -23
  203. data/spec/files/nameservers/deregister/success.http +0 -17
  204. data/spec/files/nameservers/name_servers/success.http +0 -23
  205. data/spec/files/nameservers/notfound-domain.http +0 -19
  206. data/spec/files/nameservers/register/badrequest-valueerror.http +0 -19
  207. data/spec/files/nameservers/register/success.http +0 -21
  208. data/spec/files/nameservers/vanity_name_servers/disabled.http +0 -23
  209. data/spec/files/nameservers/vanity_name_servers/enabled.http +0 -23
  210. data/spec/files/registrar/check/available.http +0 -19
  211. data/spec/files/registrar/check/registered.http +0 -21
  212. data/spec/files/registrar/extended_attributes/success.http +0 -21
  213. data/spec/files/registrar/prices/success.http +0 -21
  214. data/spec/files/registrar/register/badrequest-missingdomain.http +0 -19
  215. data/spec/files/registrar/register/badrequest-missingregistrant.http +0 -19
  216. data/spec/files/registrar/register/success.http +0 -21
  217. data/spec/files/registrar/renew/badrequest-missingrenewal.http +0 -19
  218. data/spec/files/registrar/renew/badrequest-unable.http +0 -19
  219. data/spec/files/registrar/renew/success.http +0 -21
  220. data/spec/files/registrar/transfer/success.http +0 -21
  221. data/spec/files/services/applied/success.http +0 -21
  222. data/spec/files/services/apply/success.http +0 -21
  223. data/spec/files/services/available/success.http +0 -21
  224. data/spec/files/services/notfound-service.http +0 -19
  225. data/spec/files/services/service/success.http +0 -21
  226. data/spec/files/services/services/success.http +0 -21
  227. data/spec/files/services/unapply/success.http +0 -21
  228. data/spec/files/subscriptions/subscription/success.http +0 -21
  229. data/spec/files/templates/apply_template/success.http +0 -21
  230. data/spec/files/templates/create_template/created.http +0 -22
  231. data/spec/files/templates/delete_template/success-204.http +0 -21
  232. data/spec/files/templates/delete_template/success.http +0 -21
  233. data/spec/files/templates/notfound-template.http +0 -19
  234. data/spec/files/templates/template/success.http +0 -21
  235. data/spec/files/templates/templates/success.http +0 -21
  236. data/spec/files/templates/update_template/success.http +0 -21
  237. data/spec/files/templates_records/create_record/created.http +0 -22
  238. data/spec/files/templates_records/delete_record/success-204.http +0 -19
  239. data/spec/files/templates_records/delete_record/success.http +0 -21
  240. data/spec/files/templates_records/notfound-template-record.http +0 -19
  241. data/spec/files/templates_records/record/success.http +0 -21
  242. data/spec/files/templates_records/records/success.http +0 -21
  243. data/spec/files/templates_records/update_record/success.http +0 -21
  244. data/spec/files/users/user/success.http +0 -21
@@ -1,37 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module Services
4
-
5
- # Lists the supported services.
6
- #
7
- # @see http://developer.dnsimple.com/v1/services/#list
8
- #
9
- # @return [Array<Struct::Service>]
10
- #
11
- # @raise [RequestError] When the request fails.
12
- def services(options = {})
13
- response = client.get(Client.versioned("services"), options)
14
-
15
- response.map { |r| Struct::Service.new(r["service"]) }
16
- end
17
- alias :list :services
18
- alias :list_services :services
19
-
20
- # Gets a service.
21
- #
22
- # @see http://developer.dnsimple.com/v1/services/#get
23
- #
24
- # @param [Fixnum] service The service id.
25
- # @return [Struct::Service]
26
- #
27
- # @raise [NotFoundError]
28
- # @raise [RequestError] When the request fails.
29
- def service(service, options = {})
30
- response = client.get(Client.versioned("services/#{service}"), options)
31
-
32
- Struct::Service.new(response["service"])
33
- end
34
-
35
- end
36
- end
37
- end
@@ -1,68 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module ServicesDomains
4
-
5
- # Lists the services applied to a domain.
6
- #
7
- # @see http://developer.dnsimple.com/v1/services/#applied
8
- #
9
- # @param [#to_s] domain The domain id or domain name.
10
- # @return [Array<Struct::Service>]
11
- #
12
- # @raise [NotFoundError]
13
- # @raise [RequestError] When the request fails.
14
- def applied(domain, options = {})
15
- response = client.get(Client.versioned("domains/#{domain}/applied_services"), options)
16
-
17
- response.map { |r| Struct::Service.new(r["service"]) }
18
- end
19
-
20
- # Lists the services not applied to a domain.
21
- #
22
- # @see http://developer.dnsimple.com/v1/services/#available
23
- #
24
- # @param [#to_s] domain The domain id or domain name.
25
- # @return [Array<Struct::Service>]
26
- #
27
- # @raise [NotFoundError]
28
- # @raise [RequestError] When the request fails.
29
- def available(domain, options = {})
30
- response = client.get(Client.versioned("domains/#{domain}/available_services"), options)
31
-
32
- response.map { |r| Struct::Service.new(r["service"]) }
33
- end
34
-
35
- # Applies a service to a domain.
36
- #
37
- # @see http://developer.dnsimple.com/v1/services/#apply
38
- #
39
- # @param [#to_s] domain The domain id or domain name.
40
- # @param [Fixnum] service The service id.
41
- # @return [void]
42
- #
43
- # @raise [NotFoundError]
44
- # @raise [RequestError] When the request fails.
45
- def apply(domain, service, options = {})
46
- options = Extra.deep_merge(options, { service: { id: service }})
47
- response = client.post(Client.versioned("domains/#{domain}/applied_services"), options)
48
- response.code == 200
49
- end
50
-
51
- # Un-applies a service from a domain.
52
- #
53
- # @see http://developer.dnsimple.com/v1/services/#unapply
54
- #
55
- # @param [#to_s] domain The domain id or domain name.
56
- # @param [Fixnum] service The service id.
57
- # @return [void]
58
- #
59
- # @raise [NotFoundError]
60
- # @raise [RequestError] When the request fails.
61
- def unapply(domain, service, options = {})
62
- response = client.delete(Client.versioned("domains/#{domain}/applied_services/#{service}"), options)
63
- response.code == 200
64
- end
65
-
66
- end
67
- end
68
- end
@@ -1,88 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module Templates
4
-
5
- # Lists the templates in the account.
6
- #
7
- # @see http://developer.dnsimple.com/v1/templates/#list
8
- #
9
- # @return [Array<Struct::Template>]
10
- #
11
- # @raise [RequestError] When the request fails.
12
- def templates(options = {})
13
- response = client.get(Client.versioned("templates"), options)
14
-
15
- response.map { |r| Struct::Template.new(r["dns_template"]) }
16
- end
17
- alias :list :templates
18
- alias :list_templates :templates
19
-
20
- # Creates a template in the account.
21
- #
22
- # @see http://developer.dnsimple.com/v1/templates/#create
23
- #
24
- # @param [Hash] attributes
25
- # @return [Struct::Template]
26
- #
27
- # @raise [RequestError] When the request fails.
28
- def create_template(attributes = {}, options = {})
29
- Extra.validate_mandatory_attributes(attributes, [:name, :short_name])
30
- options = options.merge({ dns_template: attributes })
31
- response = client.post(Client.versioned("templates"), options)
32
-
33
- Struct::Template.new(response["dns_template"])
34
- end
35
- alias :create :create_template
36
-
37
- # Gets a template from the account.
38
- #
39
- # @see http://developer.dnsimple.com/v1/templates/#get
40
- #
41
- # @param [#to_s] template The template id or short-name.
42
- # @return [Struct::Template]
43
- #
44
- # @raise [NotFoundError]
45
- # @raise [RequestError] When the request fails.
46
- def template(template, options = {})
47
- response = client.get(Client.versioned("templates/#{template}"), options)
48
-
49
- Struct::Template.new(response["dns_template"])
50
- end
51
-
52
- # Updates a template in the account.
53
- #
54
- # @see http://developer.dnsimple.com/v1/templates/#update
55
- #
56
- # @param [#to_s] template The template id or short-name.
57
- # @param [Hash] attributes
58
- # @return [Struct::Template]
59
- #
60
- # @raise [NotFoundError]
61
- # @raise [RequestError] When the request fails.
62
- def update_template(template, attributes = {}, options = {})
63
- options = options.merge({ dns_template: attributes })
64
- response = client.put(Client.versioned("templates/#{template}"), options)
65
-
66
- Struct::Template.new(response["dns_template"])
67
- end
68
- alias :update :update_template
69
-
70
- # Deletes a template from the account.
71
- #
72
- # WARNING: this cannot be undone.
73
- #
74
- # @see http://developer.dnsimple.com/v1/templates/#delete
75
- #
76
- # @param [#to_s] template The template id or short-name.
77
- # @return [void]
78
- #
79
- # @raise [NotFoundError]
80
- # @raise [RequestError] When the request fails.
81
- def delete_template(template, options = {})
82
- client.delete(Client.versioned("templates/#{template}"), options)
83
- end
84
- alias :delete :delete_template
85
-
86
- end
87
- end
88
- end
@@ -1,23 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module TemplatesDomains
4
-
5
- # Applies the template to the domain.
6
- #
7
- # @see http://developer.dnsimple.com/v1/templates/#apply
8
- #
9
- # @param [#to_s] domain The domain id or domain name.
10
- # @param [#to_s] template The template id or short-name.
11
- # @return [void]
12
- #
13
- # @raise [NotFoundError]
14
- # @raise [RequestError] When the request fails.
15
- def apply_template(domain, template, options = {})
16
- response = client.post(Client.versioned("/domains/#{domain}/templates/#{template}/apply"), options)
17
- response.code == 200
18
- end
19
- alias :apply :apply_template
20
-
21
- end
22
- end
23
- end
@@ -1,88 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module TemplatesRecords
4
-
5
- # Lists the records for a template.
6
- #
7
- # @see http://developer.dnsimple.com/v1/templates/records/#list
8
- #
9
- # @param [#to_s] template The template id or short-name.
10
- # @return [Array<Struct::TemplateRecord>]
11
- #
12
- # @raise [NotFoundError]
13
- # @raise [RequestError] When the request fails.
14
- def records(template, options = {})
15
- response = client.get(Client.versioned("/templates/#{template}/records"), options)
16
-
17
- response.map { |r| Struct::TemplateRecord.new(r["dns_template_record"]) }
18
- end
19
-
20
- # Creates a record for a template.
21
- #
22
- # @see http://developer.dnsimple.com/v1/templates/records/#create
23
- #
24
- # @param [#to_s] template The template id or short-name.
25
- # @param [Hash] attributes
26
- # @return [Struct::TemplateRecord]
27
- #
28
- # @raise [NotFoundError]
29
- # @raise [RequestError] When the request fails.
30
- def create_record(template, attributes = {}, options = {})
31
- Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
32
- options = options.merge({ dns_template_record: attributes })
33
- response = client.post(Client.versioned("/templates/#{template}/records"), options)
34
-
35
- Struct::TemplateRecord.new(response["dns_template_record"])
36
- end
37
-
38
- # Gets a record for a template.
39
- #
40
- # @see http://developer.dnsimple.com/v1/templates/records/#delete
41
- #
42
- # @param [#to_s] template The template id or short-name.
43
- # @param [Fixnum] record The record id.
44
- # @return [Struct::TemplateRecord]
45
- #
46
- # @raise [NotFoundError]
47
- # @raise [RequestError] When the request fails.
48
- def record(template, record, options = {})
49
- response = client.get(Client.versioned("/templates/#{template}/records/#{record}"), options)
50
-
51
- Struct::TemplateRecord.new(response["dns_template_record"])
52
- end
53
-
54
- # Updates a record for a template.
55
- #
56
- # @see http://developer.dnsimple.com/v1/templates/#update
57
- #
58
- # @param [#to_s] template The template id or short-name.
59
- # @param [Fixnum] record The record id.
60
- # @param [Hash] attributes
61
- # @return [Struct::TemplateRecord]
62
- #
63
- # @raise [NotFoundError]
64
- # @raise [RequestError] When the request fails.
65
- def update_record(template, record, attributes = {}, options = {})
66
- options = options.merge({ dns_template_record: attributes })
67
- response = client.put(Client.versioned("/templates/#{template}/records/#{record}"), options)
68
-
69
- Struct::TemplateRecord.new(response["dns_template_record"])
70
- end
71
-
72
- # Deletes a record for a template.
73
- #
74
- # @see http://developer.dnsimple.com/v1/templates/records/#get
75
- #
76
- # @param [#to_s] template The template id or short-name.
77
- # @param [Fixnum] record The record id.
78
- # @return [Template]
79
- #
80
- # @raise [NotFoundError]
81
- # @raise [RequestError] When the request fails.
82
- def delete_record(template, record, options = {})
83
- client.delete(Client.versioned("/templates/#{template}/records/#{record}"), options)
84
- end
85
-
86
- end
87
- end
88
- end
@@ -1,39 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module Users
4
-
5
- # Fetches the information about the authenticated user.
6
- #
7
- # @return [Struct::User] The authenticated user.
8
- #
9
- # @raise [RequestError] When the request fails.
10
- def user(options = {})
11
- response = client.get(Client.versioned("/user"), options)
12
-
13
- Struct::User.new(response["user"])
14
- end
15
-
16
- # Requests a new two-factor authentication exchange token.
17
- #
18
- # The exchange-token is required to validate API requests
19
- # using HTTP Basic Authentication when the account has two-factor authentication enabled.
20
- #
21
- # @see http://developer.dnsimple.com/v1/authentication/#twofa
22
- #
23
- # @example Request an Exchange Token
24
- # Dnsimple::User.two_factor_exchange_token('0000000')
25
- # # => "cda038832591e34f5df642ce2b61dc78"
26
- #
27
- # @param [String] otp_token the two-factor one time (OTP) token.
28
- # @return [String] The two-factor API exchange token.
29
- #
30
- # @raise [AuthenticationFailed] if the provided OTP token is invalid.
31
- def exchange_token(otp_token, options = {})
32
- options = Extra.deep_merge(options, headers: { Client::HEADER_2FA_STRICT => "1", Client::HEADER_OTP_TOKEN => otp_token })
33
- response = client.get(Client.versioned("/user"), options)
34
- response.headers[Client::HEADER_EXCHANGE_TOKEN]
35
- end
36
-
37
- end
38
- end
39
- end
@@ -1,39 +0,0 @@
1
- module Dnsimple
2
- class Client
3
- module VanityNameServers
4
-
5
- # Enable vanity name servers for a domain.
6
- #
7
- # @see https://developer.dnsimple.com/v1/nameservers/vanity-nameservers/#enable
8
- #
9
- # @param [#to_s] domain The domain id or domain name.
10
- # @param [Hash] names A hash of up to 4 external name servers; hash keys
11
- # are ns1 through ns4, e.g.
12
- # {
13
- # "ns1" => "ns1.example.com",
14
- # "ns2" => "ns2.example.com"
15
- # }
16
- #
17
- # @return [void]
18
- # @raise [RequestError] When the request fails.
19
- def enable_vanity_name_servers(domain, names, options={})
20
- options["vanity_nameserver_configuration"] = {"server_source" => "external"}
21
- options["vanity_nameserver_configuration"].merge!(names)
22
- client.post(Client.versioned("domains/#{domain}/vanity_name_servers"), options)
23
- end
24
-
25
- # Disable vanity name servers for a domain.
26
- #
27
- # @see https://developer.dnsimple.com/v1/nameservers/vanity-nameservers/#disable
28
- #
29
- # @param [#to_s] domain The domain id or domain name.
30
- #
31
- # @return [void]
32
- # @raise [RequestError] When the request fails.
33
- def disable_vanity_name_servers(domain, options={})
34
- client.delete("v1/domains/#{domain}/vanity_name_servers", options)
35
- end
36
-
37
- end
38
- end
39
- end
@@ -1,46 +0,0 @@
1
- module Dnsimple
2
-
3
- # {Client} backwards compatibility
4
- module Compatibility
5
- def self.included(base)
6
- base.extend ClassMethods
7
- base.class_eval do
8
- class << self
9
- attr_accessor :base_uri, :username, :password, :exchange_token, :api_token, :domain_api_token
10
- end
11
- end
12
- end
13
-
14
- module ClassMethods
15
- def client
16
- options = {}
17
- options[:api_endpoint] = base_uri if base_uri
18
- options[:username] = username if username
19
- options[:password] = password if password
20
- options[:api_token] = api_token if api_token
21
- options[:domain_api_token] = domain_api_token if domain_api_token
22
- options[:exchange_token] = exchange_token if exchange_token
23
-
24
- new(options)
25
- end
26
-
27
- def get(*args)
28
- client.get(*args)
29
- end
30
-
31
- def post(*args)
32
- client.post(*args)
33
- end
34
-
35
- def put(*args)
36
- client.put(*args)
37
- end
38
-
39
- def delete(*args)
40
- client.delete(*args)
41
- end
42
- end
43
-
44
- end
45
-
46
- end
@@ -1,56 +0,0 @@
1
- module Dnsimple
2
- module Struct
3
-
4
- class Certificate < Base
5
- # @return [Fixnum] The certificate ID in DNSimple.
6
- attr_accessor :id
7
-
8
- # @return [Fixnum] The associated domain ID.
9
- attr_accessor :domain_id
10
-
11
- # The Fixnum associated contact ID.
12
- attr_accessor :contact_id
13
-
14
- # The String subdomain on the certificate.
15
- attr_accessor :name
16
-
17
- # The String state.
18
- attr_accessor :state
19
-
20
- # The String Certificate Signing Request.
21
- attr_accessor :csr
22
-
23
- # The String SSL certificate.
24
- # It is set only if the order issued by the Certificate Authority.
25
- attr_accessor :ssl_certificate
26
-
27
- # The String private key.
28
- # It is set only if DNSimple generated the Certificate Signing Request.
29
- attr_accessor :private_key
30
-
31
- # The String approver email address
32
- # It is set only if the state is submitted.
33
- attr_accessor :approver_email
34
-
35
- # The Array of all emails that can be used to approve the certificate.
36
- # It is set only if the state is configured.
37
- attr_accessor :approver_emails
38
-
39
- # @return [String] When the certificate was created in DNSimple.
40
- attr_accessor :created_at
41
-
42
- # @return [String] When the certificate was last updated in DNSimple.
43
- attr_accessor :updated_at
44
-
45
- # The Date the certificate was configured.
46
- attr_accessor :configured_at
47
-
48
- # The Date the certificate will expire.
49
- attr_accessor :expires_on
50
-
51
- # The associated Domain.
52
- attr_accessor :domain
53
- end
54
-
55
- end
56
- end