dnsimple 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +4 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.markdown +8 -5
- data/dnsimple.gemspec +2 -2
- data/lib/dnsimple/client.rb +13 -1
- data/lib/dnsimple/client/certificates.rb +7 -7
- data/lib/dnsimple/client/contacts.rb +10 -10
- data/lib/dnsimple/client/domains.rb +8 -8
- data/lib/dnsimple/client/domains_autorenewal.rb +4 -4
- data/lib/dnsimple/client/domains_forwards.rb +8 -8
- data/lib/dnsimple/client/domains_privacy.rb +4 -4
- data/lib/dnsimple/client/domains_records.rb +10 -10
- data/lib/dnsimple/client/domains_sharing.rb +6 -6
- data/lib/dnsimple/client/domains_zones.rb +2 -2
- data/lib/dnsimple/client/name_servers.rb +8 -8
- data/lib/dnsimple/client/registrar.rb +13 -13
- data/lib/dnsimple/client/services.rb +4 -4
- data/lib/dnsimple/client/services_domains.rb +8 -8
- data/lib/dnsimple/client/templates.rb +10 -10
- data/lib/dnsimple/client/templates_domains.rb +2 -2
- data/lib/dnsimple/client/templates_records.rb +10 -10
- data/lib/dnsimple/client/users.rb +3 -3
- data/lib/dnsimple/extra.rb +7 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/extra_spec.rb +24 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2264602abbc1ed64a8305352440157f9342b477b
|
4
|
+
data.tar.gz: 9cf9c92fb33974cc00a5e2d6afc91b6dcf177df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 397d9277aa26d777c87f8f31bcc82460978bc075b4b5ec870189621e51743d1824baa6bb7229e7edecf8a2cbe48e23ff78fdc08268dd56d0802812c6afb6486e
|
7
|
+
data.tar.gz: e5b17e381439cbab47dddbf02cf956be72d1498575bfa64f0b3cd3c59ca6e4afe1ddca20670669de405cc45975646459492feeeefb63d0134e43578c13c5e09d
|
data/CHANGELOG.markdown
CHANGED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# DNSimple Ruby Client
|
2
2
|
|
3
|
-
A Ruby client for the [DNSimple API](
|
3
|
+
A Ruby client for the [DNSimple API](https://developer.dnsimple.com/).
|
4
4
|
|
5
5
|
[](https://travis-ci.org/aetrion/dnsimple-ruby)
|
6
6
|
[](https://coveralls.io/r/aetrion/dnsimple-ruby?branch=master)
|
@@ -18,9 +18,7 @@ $ gem install dnsimple
|
|
18
18
|
|
19
19
|
## Getting Started
|
20
20
|
|
21
|
-
This library is a Ruby client you can use to interact with the [DNSimple API](
|
22
|
-
|
23
|
-
Here's a short example.
|
21
|
+
This library is a Ruby client you can use to interact with the [DNSimple API](https://developer.dnsimple.com/). Here are some examples.
|
24
22
|
|
25
23
|
```ruby
|
26
24
|
require 'dnsimple'
|
@@ -79,7 +77,7 @@ client.users.user
|
|
79
77
|
|
80
78
|
#### HTTP Basic with two-factor authentication enabled
|
81
79
|
|
82
|
-
See the [2FA API documentation](
|
80
|
+
See the [2FA API documentation](https://developer.dnsimple.com/authentication/#twofa).
|
83
81
|
|
84
82
|
```ruby
|
85
83
|
# Request the 2FA exchange token
|
@@ -100,3 +98,8 @@ client = Dnsimple::Client.new(username: 'YOUR_USERNAME', api_token: 'YOUR_TOKEN'
|
|
100
98
|
client.users.user
|
101
99
|
# => Dnsimple::Struct::User
|
102
100
|
```
|
101
|
+
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
Copyright (c) 2010-2015 Aetrion LLC. This is Free Software distributed under the MIT license.
|
data/dnsimple.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ['Anthony Eden', 'Simone Carletti']
|
9
9
|
s.email = ['anthony.eden@dnsimple.com', 'simone.carletti@dnsimple.com']
|
10
10
|
s.homepage = 'https://github.com/aetrion/dnsimple-ruby'
|
11
|
-
s.summary = '
|
12
|
-
s.description = '
|
11
|
+
s.summary = 'The DNSimple API client for Ruby'
|
12
|
+
s.description = 'The DNSimple API client for Ruby.'
|
13
13
|
|
14
14
|
s.required_ruby_version = ">= 1.9.3"
|
15
15
|
|
data/lib/dnsimple/client.rb
CHANGED
@@ -18,6 +18,18 @@ module Dnsimple
|
|
18
18
|
HEADER_EXCHANGE_TOKEN = "X-DNSimple-OTP-Token"
|
19
19
|
|
20
20
|
|
21
|
+
# @return [String] The current API version.
|
22
|
+
API_VERSION = "v1"
|
23
|
+
|
24
|
+
|
25
|
+
# Prepends the correct API version to +path+.
|
26
|
+
#
|
27
|
+
# @return [String] The versioned path.
|
28
|
+
def self.versioned(path)
|
29
|
+
File.join(API_VERSION, path)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
21
33
|
# @!attribute api_endpoint
|
22
34
|
# @return [String] Base URL for API requests. (default: https://api.dnsimple.com/)
|
23
35
|
# @!attribute username
|
@@ -144,7 +156,7 @@ module Dnsimple
|
|
144
156
|
|
145
157
|
# @return [String] Base URL for API requests.
|
146
158
|
def api_endpoint
|
147
|
-
|
159
|
+
Extra.join_uri(@api_endpoint, "")
|
148
160
|
end
|
149
161
|
|
150
162
|
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the certificates for a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/certificates/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/certificates/#list
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @param [Hash] options
|
@@ -13,7 +13,7 @@ module Dnsimple
|
|
13
13
|
# @raise [NotFoundError]
|
14
14
|
# @raise [RequestError] When the request fails.
|
15
15
|
def certificates(domain, options = {})
|
16
|
-
response = client.get("
|
16
|
+
response = client.get(Client.versioned("/domains/#{domain}/certificates"), options)
|
17
17
|
|
18
18
|
response.map { |r| Struct::Certificate.new(r["certificate"]) }
|
19
19
|
end
|
@@ -22,7 +22,7 @@ module Dnsimple
|
|
22
22
|
|
23
23
|
# Gets a certificate for a domain.
|
24
24
|
#
|
25
|
-
# @see http://developer.dnsimple.com/domains/certificates/#get
|
25
|
+
# @see http://developer.dnsimple.com/v1/domains/certificates/#get
|
26
26
|
#
|
27
27
|
# @param [#to_s] domain The domain id or domain name.
|
28
28
|
# @param [Fixnum] certificate_id The certificate ID.
|
@@ -31,7 +31,7 @@ module Dnsimple
|
|
31
31
|
# @raise [NotFoundError]
|
32
32
|
# @raise [RequestError] When the request fails.
|
33
33
|
def certificate(domain, certificate_id, options = {})
|
34
|
-
response = client.get("
|
34
|
+
response = client.get(Client.versioned("/domains/#{domain}/certificates/#{certificate_id}"), options)
|
35
35
|
|
36
36
|
Struct::Certificate.new(response["certificate"])
|
37
37
|
end
|
@@ -60,7 +60,7 @@ module Dnsimple
|
|
60
60
|
# @raise [RequestError] When the request fails.
|
61
61
|
def purchase(domain, name, contact_id, options = {})
|
62
62
|
options = Extra.deep_merge(options, { certificate: { name: name, contact_id: contact_id }})
|
63
|
-
response = client.post("
|
63
|
+
response = client.post(Client.versioned("/domains/#{domain}/certificates"), options)
|
64
64
|
|
65
65
|
Struct::Certificate.new(response["certificate"])
|
66
66
|
end
|
@@ -74,7 +74,7 @@ module Dnsimple
|
|
74
74
|
# @raise [NotFoundError]
|
75
75
|
# @raise [RequestError] When the request fails.
|
76
76
|
def configure(domain, certificate_id, options = {})
|
77
|
-
response = client.put("
|
77
|
+
response = client.put(Client.versioned("/domains/#{domain}/certificates/#{certificate_id}/configure"), options)
|
78
78
|
|
79
79
|
Struct::Certificate.new(response["certificate"])
|
80
80
|
end
|
@@ -90,7 +90,7 @@ module Dnsimple
|
|
90
90
|
# @raise [RequestError] When the request fails.
|
91
91
|
def submit(domain, certificate_id, email, options = {})
|
92
92
|
options = options.merge(certificate: { approver_email: email })
|
93
|
-
response = client.put("
|
93
|
+
response = client.put(Client.versioned("/domains/#{domain}/certificates/#{certificate_id}/submit"), options)
|
94
94
|
|
95
95
|
Struct::Certificate.new(response["certificate"])
|
96
96
|
end
|
@@ -4,13 +4,13 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the contacts in the account.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/contacts/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/contacts/#list
|
8
8
|
#
|
9
9
|
# @return [Array<Struct::Contact>]
|
10
10
|
#
|
11
11
|
# @raise [RequestError] When the request fails.
|
12
12
|
def contacts(options = {})
|
13
|
-
response = client.get("
|
13
|
+
response = client.get(Client.versioned("/contacts"), options)
|
14
14
|
|
15
15
|
response.map { |r| Struct::Contact.new(r["contact"]) }
|
16
16
|
end
|
@@ -19,7 +19,7 @@ module Dnsimple
|
|
19
19
|
|
20
20
|
# Creates a contact in the account.
|
21
21
|
#
|
22
|
-
# @see http://developer.dnsimple.com/contacts/#create
|
22
|
+
# @see http://developer.dnsimple.com/v1/contacts/#create
|
23
23
|
#
|
24
24
|
# @param [Hash] attributes
|
25
25
|
# @return [Struct::Contact]
|
@@ -28,7 +28,7 @@ module Dnsimple
|
|
28
28
|
def create_contact(attributes = {}, options = {})
|
29
29
|
Extra.validate_mandatory_attributes(attributes, [:first_name, :last_name, :address1, :city, :state_province, :postal_code, :country, :phone, :email_address])
|
30
30
|
options = options.merge(contact: attributes)
|
31
|
-
response = client.post("
|
31
|
+
response = client.post(Client.versioned("/contacts"), options)
|
32
32
|
|
33
33
|
Struct::Contact.new(response["contact"])
|
34
34
|
end
|
@@ -36,7 +36,7 @@ module Dnsimple
|
|
36
36
|
|
37
37
|
# Gets a contact from the account.
|
38
38
|
#
|
39
|
-
# @see http://developer.dnsimple.com/contacts/#get
|
39
|
+
# @see http://developer.dnsimple.com/v1/contacts/#get
|
40
40
|
#
|
41
41
|
# @param [Fixnum] contact The contact id.
|
42
42
|
# @return [Struct::Contact]
|
@@ -44,14 +44,14 @@ module Dnsimple
|
|
44
44
|
# @raise [NotFoundError]
|
45
45
|
# @raise [RequestError] When the request fails.
|
46
46
|
def contact(contact, options = {})
|
47
|
-
response = client.get("
|
47
|
+
response = client.get(Client.versioned("/contacts/#{contact}"), options)
|
48
48
|
|
49
49
|
Struct::Contact.new(response["contact"])
|
50
50
|
end
|
51
51
|
|
52
52
|
# Updates a contact in the account.
|
53
53
|
#
|
54
|
-
# @see http://developer.dnsimple.com/contacts/#update
|
54
|
+
# @see http://developer.dnsimple.com/v1/contacts/#update
|
55
55
|
#
|
56
56
|
# @param [Fixnum] contact The contact id.
|
57
57
|
# @param [Hash] attributes
|
@@ -61,7 +61,7 @@ module Dnsimple
|
|
61
61
|
# @raise [RequestError] When the request fails.
|
62
62
|
def update_contact(contact, attributes = {}, options = {})
|
63
63
|
options = options.merge(contact: attributes)
|
64
|
-
response = client.put("
|
64
|
+
response = client.put(Client.versioned("/contacts/#{contact}"), options)
|
65
65
|
|
66
66
|
Struct::Contact.new(response["contact"])
|
67
67
|
end
|
@@ -71,7 +71,7 @@ module Dnsimple
|
|
71
71
|
#
|
72
72
|
# WARNING: this cannot be undone.
|
73
73
|
#
|
74
|
-
# @see http://developer.dnsimple.com/contacts/#delete
|
74
|
+
# @see http://developer.dnsimple.com/v1/contacts/#delete
|
75
75
|
#
|
76
76
|
# @param [Fixnum] contact The contact id.
|
77
77
|
# @return [void]
|
@@ -79,7 +79,7 @@ module Dnsimple
|
|
79
79
|
# @raise [NotFoundError]
|
80
80
|
# @raise [RequestError] When the request fails.
|
81
81
|
def delete_contact(contact, options = {})
|
82
|
-
client.delete("
|
82
|
+
client.delete(Client.versioned("contacts/#{contact}"), options)
|
83
83
|
end
|
84
84
|
alias :delete :delete_contact
|
85
85
|
|
@@ -4,14 +4,14 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the domains in the account.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/#list
|
8
8
|
#
|
9
9
|
# @param [Hash] options the filtering and sorting option
|
10
10
|
# @return [Array<Struct::Domain>]
|
11
11
|
#
|
12
12
|
# @raise [RequestError] When the request fails.
|
13
13
|
def domains(options = {})
|
14
|
-
response = client.get("
|
14
|
+
response = client.get(Client.versioned("/domains"), options)
|
15
15
|
|
16
16
|
response.map { |r| Struct::Domain.new(r["domain"]) }
|
17
17
|
end
|
@@ -20,7 +20,7 @@ module Dnsimple
|
|
20
20
|
|
21
21
|
# Creates a domain in the account.
|
22
22
|
#
|
23
|
-
# @see http://developer.dnsimple.com/domains/#create
|
23
|
+
# @see http://developer.dnsimple.com/v1/domains/#create
|
24
24
|
#
|
25
25
|
# @param [Hash] attributes
|
26
26
|
# @return [Struct::Domain]
|
@@ -29,7 +29,7 @@ module Dnsimple
|
|
29
29
|
def create_domain(attributes = {}, options = {})
|
30
30
|
Extra.validate_mandatory_attributes(attributes, [:name])
|
31
31
|
options = options.merge({ domain: attributes })
|
32
|
-
response = client.post("
|
32
|
+
response = client.post(Client.versioned("/domains"), options)
|
33
33
|
|
34
34
|
Struct::Domain.new(response["domain"])
|
35
35
|
end
|
@@ -37,7 +37,7 @@ module Dnsimple
|
|
37
37
|
|
38
38
|
# Gets a domain from the account.
|
39
39
|
#
|
40
|
-
# @see http://developer.dnsimple.com/domains/#get
|
40
|
+
# @see http://developer.dnsimple.com/v1/domains/#get
|
41
41
|
#
|
42
42
|
# @param [#to_s] domain The domain id or domain name.
|
43
43
|
# @return [Struct::Domain]
|
@@ -45,7 +45,7 @@ module Dnsimple
|
|
45
45
|
# @raise [NotFoundError]
|
46
46
|
# @raise [RequestError] When the request fails.
|
47
47
|
def domain(domain, options = {})
|
48
|
-
response = client.get("
|
48
|
+
response = client.get(Client.versioned("/domains/#{domain}"), options)
|
49
49
|
|
50
50
|
Struct::Domain.new(response["domain"])
|
51
51
|
end
|
@@ -54,7 +54,7 @@ module Dnsimple
|
|
54
54
|
#
|
55
55
|
# WARNING: this cannot be undone.
|
56
56
|
#
|
57
|
-
# @see http://developer.dnsimple.com/domains/#delete
|
57
|
+
# @see http://developer.dnsimple.com/v1/domains/#delete
|
58
58
|
#
|
59
59
|
# @param [#to_s] domain The domain id or domain name.
|
60
60
|
# @return [void]
|
@@ -62,7 +62,7 @@ module Dnsimple
|
|
62
62
|
# @raise [NotFoundError]
|
63
63
|
# @raise [RequestError] When the request fails.
|
64
64
|
def delete_domain(domain, options = {})
|
65
|
-
client.delete("
|
65
|
+
client.delete(Client.versioned("/domains/#{domain}"), options)
|
66
66
|
end
|
67
67
|
alias :delete :delete_domain
|
68
68
|
|
@@ -4,28 +4,28 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Enables auto-renewal for a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/
|
7
|
+
# @see http://developer.dnsimple.com/v1/registrar/auto-renewal/#enable
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [Struct::Domain]
|
11
11
|
#
|
12
12
|
# @raise [RequestError] When the request fails.
|
13
13
|
def enable_auto_renewal(domain, options = {})
|
14
|
-
response = client.post("
|
14
|
+
response = client.post(Client.versioned("/domains/#{domain}/auto_renewal"), options)
|
15
15
|
|
16
16
|
Struct::Domain.new(response["domain"])
|
17
17
|
end
|
18
18
|
|
19
19
|
# Disables auto-renewal for a domain.
|
20
20
|
#
|
21
|
-
# @see http://developer.dnsimple.com/
|
21
|
+
# @see http://developer.dnsimple.com/v1/registrar/auto-renewal/#disable
|
22
22
|
#
|
23
23
|
# @param [#to_s] domain The domain id or domain name.
|
24
24
|
# @return [Struct::Domain]
|
25
25
|
#
|
26
26
|
# @raise [RequestError] When the request fails.
|
27
27
|
def disable_auto_renewal(domain, options = {})
|
28
|
-
response = client.delete("
|
28
|
+
response = client.delete(Client.versioned("/domains/#{domain}/auto_renewal"), options)
|
29
29
|
|
30
30
|
Struct::Domain.new(response["domain"])
|
31
31
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the email forwards for a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/forwards/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/forwards/#list
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [Array<Struct::EmailForward>]
|
@@ -12,7 +12,7 @@ module Dnsimple
|
|
12
12
|
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def email_forwards(domain, options = {})
|
15
|
-
response = client.get("
|
15
|
+
response = client.get(Client.versioned("/domains/#{domain}/email_forwards"), options)
|
16
16
|
|
17
17
|
response.map { |r| Struct::EmailForward.new(r["email_forward"]) }
|
18
18
|
end
|
@@ -20,7 +20,7 @@ module Dnsimple
|
|
20
20
|
|
21
21
|
# Creates an email forward for a domain.
|
22
22
|
#
|
23
|
-
# @see http://developer.dnsimple.com/domains/forwards/#create
|
23
|
+
# @see http://developer.dnsimple.com/v1/domains/forwards/#create
|
24
24
|
#
|
25
25
|
# @param [#to_s] domain The domain id or domain name.
|
26
26
|
# @param [Hash] attributes
|
@@ -31,14 +31,14 @@ module Dnsimple
|
|
31
31
|
def create_email_forward(domain, attributes = {}, options = {})
|
32
32
|
Extra.validate_mandatory_attributes(attributes, [:from, :to])
|
33
33
|
options = options.merge({ email_forward: attributes })
|
34
|
-
response = client.post("
|
34
|
+
response = client.post(Client.versioned("/domains/#{domain}/email_forwards"), options)
|
35
35
|
|
36
36
|
Struct::EmailForward.new(response["email_forward"])
|
37
37
|
end
|
38
38
|
|
39
39
|
# Gets an email forward for a domain.
|
40
40
|
#
|
41
|
-
# @see http://developer.dnsimple.com/domains/forwards/#get
|
41
|
+
# @see http://developer.dnsimple.com/v1/domains/forwards/#get
|
42
42
|
#
|
43
43
|
# @param [#to_s] domain The domain id or domain name.
|
44
44
|
# @param [Fixnum] forward The forward id.
|
@@ -47,14 +47,14 @@ module Dnsimple
|
|
47
47
|
# @raise [NotFoundError]
|
48
48
|
# @raise [RequestError] When the request fails.
|
49
49
|
def email_forward(domain, forward, options = {})
|
50
|
-
response = client.get("
|
50
|
+
response = client.get(Client.versioned("/domains/#{domain}/email_forwards/#{forward}"), options)
|
51
51
|
|
52
52
|
Struct::EmailForward.new(response["email_forward"])
|
53
53
|
end
|
54
54
|
|
55
55
|
# Deletes an email forward for a domain.
|
56
56
|
#
|
57
|
-
# @see http://developer.dnsimple.com/domains/forwards/#delete
|
57
|
+
# @see http://developer.dnsimple.com/v1/domains/forwards/#delete
|
58
58
|
#
|
59
59
|
# @param [#to_s] domain The domain id or domain name.
|
60
60
|
# @param [Fixnum] forward The forward id.
|
@@ -63,7 +63,7 @@ module Dnsimple
|
|
63
63
|
# @raise [NotFoundError]
|
64
64
|
# @raise [RequestError] When the request fails.
|
65
65
|
def delete_email_forward(domain, forward, options = {})
|
66
|
-
client.delete("
|
66
|
+
client.delete(Client.versioned("/domains/#{domain}/email_forwards/#{forward}"), options)
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -4,28 +4,28 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Enables WHOIS privacy for a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/
|
7
|
+
# @see http://developer.dnsimple.com/v1/registrar/privacy/#enable
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [Struct::WhoisPrivacy]
|
11
11
|
#
|
12
12
|
# @raise [RequestError] When the request fails.
|
13
13
|
def enable_whois_privacy(domain, options = {})
|
14
|
-
response = client.post("
|
14
|
+
response = client.post(Client.versioned("domains/#{domain}/whois_privacy"), options)
|
15
15
|
|
16
16
|
Struct::WhoisPrivacy.new(response["whois_privacy"])
|
17
17
|
end
|
18
18
|
|
19
19
|
# Disables WHOIS privacy for a domain.
|
20
20
|
#
|
21
|
-
# @see http://developer.dnsimple.com/
|
21
|
+
# @see http://developer.dnsimple.com/v1/registrar/privacy/#disable
|
22
22
|
#
|
23
23
|
# @param [#to_s] domain The domain id or domain name.
|
24
24
|
# @return [Struct::WhoisPrivacy]
|
25
25
|
#
|
26
26
|
# @raise [RequestError] When the request fails.
|
27
27
|
def disable_whois_privacy(domain, options = {})
|
28
|
-
response = client.delete("
|
28
|
+
response = client.delete(Client.versioned("domains/#{domain}/whois_privacy"), options)
|
29
29
|
|
30
30
|
Struct::WhoisPrivacy.new(response["whois_privacy"])
|
31
31
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the records for a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/records/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/records/#list
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @param [Hash] options
|
@@ -13,7 +13,7 @@ module Dnsimple
|
|
13
13
|
# @raise [NotFoundError]
|
14
14
|
# @raise [RequestError] When the request fails.
|
15
15
|
def records(domain, options = {})
|
16
|
-
response = client.get("
|
16
|
+
response = client.get(Client.versioned("domains/#{domain}/records"), options)
|
17
17
|
|
18
18
|
response.map { |r| Struct::Record.new(r["record"]) }
|
19
19
|
end
|
@@ -21,7 +21,7 @@ module Dnsimple
|
|
21
21
|
|
22
22
|
# Creates a record for a domain.
|
23
23
|
#
|
24
|
-
# @see http://developer.dnsimple.com/domains/records/#create
|
24
|
+
# @see http://developer.dnsimple.com/v1/domains/records/#create
|
25
25
|
#
|
26
26
|
# @param [#to_s] domain The domain id or domain name.
|
27
27
|
# @param [Hash] attributes
|
@@ -32,14 +32,14 @@ module Dnsimple
|
|
32
32
|
def create_record(domain, attributes = {}, options = {})
|
33
33
|
Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
|
34
34
|
options = options.merge({ record: attributes })
|
35
|
-
response = client.post("
|
35
|
+
response = client.post(Client.versioned("domains/#{domain}/records"), options)
|
36
36
|
|
37
37
|
Struct::Record.new(response["record"])
|
38
38
|
end
|
39
39
|
|
40
40
|
# Gets a record for a domain.
|
41
41
|
#
|
42
|
-
# @see http://developer.dnsimple.com/domains/records/#get
|
42
|
+
# @see http://developer.dnsimple.com/v1/domains/records/#get
|
43
43
|
#
|
44
44
|
# @param [#to_s] domain The domain id or domain name.
|
45
45
|
# @param [Fixnum] record The record id.
|
@@ -48,14 +48,14 @@ module Dnsimple
|
|
48
48
|
# @raise [NotFoundError]
|
49
49
|
# @raise [RequestError] When the request fails.
|
50
50
|
def record(domain, record, options = {})
|
51
|
-
response = client.get("
|
51
|
+
response = client.get(Client.versioned("domains/#{domain}/records/#{record}"), options)
|
52
52
|
|
53
53
|
Struct::Record.new(response["record"])
|
54
54
|
end
|
55
55
|
|
56
56
|
# Updates a record for a domain.
|
57
57
|
#
|
58
|
-
# @see http://developer.dnsimple.com/domains/records/#update
|
58
|
+
# @see http://developer.dnsimple.com/v1/domains/records/#update
|
59
59
|
#
|
60
60
|
# @param [#to_s] domain The domain id or domain name.
|
61
61
|
# @param [Fixnum] record The record id.
|
@@ -66,14 +66,14 @@ module Dnsimple
|
|
66
66
|
# @raise [RequestError] When the request fails.
|
67
67
|
def update_record(domain, record, attributes = {}, options = {})
|
68
68
|
options = options.merge({ record: attributes })
|
69
|
-
response = client.put("
|
69
|
+
response = client.put(Client.versioned("domains/#{domain}/records/#{record}"), options)
|
70
70
|
|
71
71
|
Struct::Record.new(response["record"])
|
72
72
|
end
|
73
73
|
|
74
74
|
# Deletes a record for a domain.
|
75
75
|
#
|
76
|
-
# @see http://developer.dnsimple.com/domains/records/#delete
|
76
|
+
# @see http://developer.dnsimple.com/v1/domains/records/#delete
|
77
77
|
#
|
78
78
|
# @param [#to_s] domain The domain id or domain name.
|
79
79
|
# @param [Fixnum] record The record id.
|
@@ -82,7 +82,7 @@ module Dnsimple
|
|
82
82
|
# @raise [NotFoundError]
|
83
83
|
# @raise [RequestError] When the request fails.
|
84
84
|
def delete_record(domain, record, options = {})
|
85
|
-
client.delete("
|
85
|
+
client.delete(Client.versioned("domains/#{domain}/records/#{record}"), options)
|
86
86
|
end
|
87
87
|
|
88
88
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the memberships.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/sharing/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/sharing/#list
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [Array<Struct::Membership>]
|
@@ -12,7 +12,7 @@ module Dnsimple
|
|
12
12
|
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def memberships(domain, options = {})
|
15
|
-
response = client.get("
|
15
|
+
response = client.get(Client.versioned("/domains/#{domain}/memberships"), options)
|
16
16
|
|
17
17
|
response.map { |r| Struct::Membership.new(r["membership"]) }
|
18
18
|
end
|
@@ -20,7 +20,7 @@ module Dnsimple
|
|
20
20
|
|
21
21
|
# Shares a domain.
|
22
22
|
#
|
23
|
-
# @see http://developer.dnsimple.com/domains/sharing/#create
|
23
|
+
# @see http://developer.dnsimple.com/v1/domains/sharing/#create
|
24
24
|
#
|
25
25
|
# @param [#to_s] domain The domain id or domain name.
|
26
26
|
# @param [String] email
|
@@ -30,14 +30,14 @@ module Dnsimple
|
|
30
30
|
# @raise [RequestError] When the request fails.
|
31
31
|
def create_membership(domain, email, options = {})
|
32
32
|
options = options.merge({ membership: { email: email }})
|
33
|
-
response = client.post("
|
33
|
+
response = client.post(Client.versioned("/domains/#{domain}/memberships"), options)
|
34
34
|
|
35
35
|
Struct::Membership.new(response["membership"])
|
36
36
|
end
|
37
37
|
|
38
38
|
# Un-shares a domain.
|
39
39
|
#
|
40
|
-
# @see http://developer.dnsimple.com/domains/sharing/#delete
|
40
|
+
# @see http://developer.dnsimple.com/v1/domains/sharing/#delete
|
41
41
|
#
|
42
42
|
# @param [#to_s] domain The domain id or domain name.
|
43
43
|
# @param [Fixnum] membership The membership id.
|
@@ -46,7 +46,7 @@ module Dnsimple
|
|
46
46
|
# @raise [NotFoundError]
|
47
47
|
# @raise [RequestError] When the request fails.
|
48
48
|
def delete_membership(domain, membership, options = {})
|
49
|
-
client.delete("
|
49
|
+
client.delete(Client.versioned("/domains/#{domain}/memberships/#{membership}"), options)
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Gets a domain zone as zone file.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/zones/#get
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/zones/#get
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [String]
|
@@ -12,7 +12,7 @@ module Dnsimple
|
|
12
12
|
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def zone(domain, options = {})
|
15
|
-
response = client.get("
|
15
|
+
response = client.get(Client.versioned("/domains/#{domain}/zone"), options)
|
16
16
|
|
17
17
|
response["zone"]
|
18
18
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the name servers for a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/nameservers/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/nameservers/#list
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [Array<String>] The delegates name servers.
|
@@ -12,7 +12,7 @@ module Dnsimple
|
|
12
12
|
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def name_servers(domain, options = {})
|
15
|
-
response = client.get("
|
15
|
+
response = client.get(Client.versioned("/domains/#{domain}/name_servers"), options)
|
16
16
|
|
17
17
|
response.parsed_response
|
18
18
|
end
|
@@ -21,7 +21,7 @@ module Dnsimple
|
|
21
21
|
|
22
22
|
# Changes the name servers for a domain.
|
23
23
|
#
|
24
|
-
# @see http://developer.dnsimple.com/domains/nameservers/#change
|
24
|
+
# @see http://developer.dnsimple.com/v1/domains/nameservers/#change
|
25
25
|
#
|
26
26
|
# @param [#to_s] domain The domain id or domain name.
|
27
27
|
# @param [Array<String>] servers The name server list.
|
@@ -32,7 +32,7 @@ module Dnsimple
|
|
32
32
|
def change(domain, servers, options = {})
|
33
33
|
servers = servers.inject({}) { |hash, server| hash.merge("ns#{hash.length + 1}" => server) }
|
34
34
|
options = options.merge({ name_servers: servers })
|
35
|
-
response = client.post("
|
35
|
+
response = client.post(Client.versioned("/domains/#{domain}/name_servers"), options)
|
36
36
|
|
37
37
|
response.parsed_response
|
38
38
|
end
|
@@ -40,7 +40,7 @@ module Dnsimple
|
|
40
40
|
|
41
41
|
# Registers a name server at the registry.
|
42
42
|
#
|
43
|
-
# @see http://developer.dnsimple.com/nameservers/#register
|
43
|
+
# @see http://developer.dnsimple.com/v1/nameservers/#register
|
44
44
|
#
|
45
45
|
# @param [#to_s] domain The domain id or domain name.
|
46
46
|
# @param [String] name The hostname to register.
|
@@ -50,12 +50,12 @@ module Dnsimple
|
|
50
50
|
# @raise [RequestError] When the request fails.
|
51
51
|
def register(domain, name, ip, options = {})
|
52
52
|
options = options.merge({ name_server: { name: name, ip: ip } })
|
53
|
-
client.post("
|
53
|
+
client.post(Client.versioned("/domains/#{domain}/registry_name_servers"), options)
|
54
54
|
end
|
55
55
|
|
56
56
|
# De-registers a name server at the registry.
|
57
57
|
#
|
58
|
-
# @see http://developer.dnsimple.com/nameservers/#deregister
|
58
|
+
# @see http://developer.dnsimple.com/v1/nameservers/#deregister
|
59
59
|
#
|
60
60
|
# @param [#to_s] domain The domain id or domain name.
|
61
61
|
# @param [String] name The hostname to register.
|
@@ -63,7 +63,7 @@ module Dnsimple
|
|
63
63
|
#
|
64
64
|
# @raise [RequestError] When the request fails.
|
65
65
|
def deregister(domain, name, options = {})
|
66
|
-
client.delete("
|
66
|
+
client.delete(Client.versioned("/domains/#{domain}/registry_name_servers/#{name}"), options)
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Checks the availability of a domain name.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/domains/registry/#check
|
7
|
+
# @see http://developer.dnsimple.com/v1/domains/registry/#check
|
8
8
|
#
|
9
9
|
# @param [#to_s] name The domain name to check.
|
10
10
|
# @return [Hash] The response containing the status, price, and more details.
|
@@ -12,7 +12,7 @@ module Dnsimple
|
|
12
12
|
# @raise [RequestError] When the request fails.
|
13
13
|
def check(name, options = {})
|
14
14
|
response = begin
|
15
|
-
client.get("
|
15
|
+
client.get(Client.versioned("/domains/#{name}/check"), options)
|
16
16
|
rescue NotFoundError => e
|
17
17
|
e.response
|
18
18
|
end
|
@@ -22,7 +22,7 @@ module Dnsimple
|
|
22
22
|
|
23
23
|
# Checks the availability of a domain name.
|
24
24
|
#
|
25
|
-
# @see http://developer.dnsimple.com/domains/registry/#check
|
25
|
+
# @see http://developer.dnsimple.com/v1/domains/registry/#check
|
26
26
|
#
|
27
27
|
# @param [#to_s] name The domain name to check.
|
28
28
|
# @return [Boolean] true if the domain is available
|
@@ -34,7 +34,7 @@ module Dnsimple
|
|
34
34
|
|
35
35
|
# Registers a domain.
|
36
36
|
#
|
37
|
-
# @see http://developer.dnsimple.com/domains/registry/#register
|
37
|
+
# @see http://developer.dnsimple.com/v1/domains/registry/#register
|
38
38
|
#
|
39
39
|
# @param [#to_s] name The domain name to register.
|
40
40
|
# @param [Fixnum] registrant_id The id of the contact to use as registrant.
|
@@ -45,14 +45,14 @@ module Dnsimple
|
|
45
45
|
# @raise [RequestError] When the request fails.
|
46
46
|
def register(name, registrant_id, extended_attributes = {}, options = {})
|
47
47
|
options = Extra.deep_merge(options, { domain: { name: name, registrant_id: registrant_id }, extended_attribute: extended_attributes })
|
48
|
-
response = client.post("
|
48
|
+
response = client.post(Client.versioned("/domain_registrations"), options)
|
49
49
|
|
50
50
|
Struct::Domain.new(response["domain"])
|
51
51
|
end
|
52
52
|
|
53
53
|
# Transfers a domain.
|
54
54
|
#
|
55
|
-
# @see http://developer.dnsimple.com/domains/registry/#transfer
|
55
|
+
# @see http://developer.dnsimple.com/v1/domains/registry/#transfer
|
56
56
|
#
|
57
57
|
# @param [#to_s] name The domain name to register.
|
58
58
|
# @param [String] auth_code
|
@@ -64,14 +64,14 @@ module Dnsimple
|
|
64
64
|
# @raise [RequestError] When the request fails.
|
65
65
|
def transfer(name, auth_code, registrant_id, extended_attributes = {}, options = {})
|
66
66
|
options = Extra.deep_merge(options, { domain: { name: name, registrant_id: registrant_id }, extended_attribute: extended_attributes, transfer_order: { authinfo: auth_code }})
|
67
|
-
response = client.post("
|
67
|
+
response = client.post(Client.versioned("/domain_transfers"), options)
|
68
68
|
|
69
69
|
Struct::TransferOrder.new(response["transfer_order"])
|
70
70
|
end
|
71
71
|
|
72
72
|
# Renew a domain.
|
73
73
|
#
|
74
|
-
# @see http://developer.dnsimple.com/domains/registry/#renew
|
74
|
+
# @see http://developer.dnsimple.com/v1/domains/registry/#renew
|
75
75
|
#
|
76
76
|
# @param [#to_s] name The domain name to renew.
|
77
77
|
# @param [Hash] options
|
@@ -80,7 +80,7 @@ module Dnsimple
|
|
80
80
|
# @raise [RequestError] When the request fails.
|
81
81
|
def renew(name, options = {})
|
82
82
|
options = Extra.deep_merge(options, { domain: { name: name }})
|
83
|
-
response = client.post("
|
83
|
+
response = client.post(Client.versioned("/domain_renewals"), options)
|
84
84
|
|
85
85
|
Struct::Domain.new(response["domain"])
|
86
86
|
end
|
@@ -88,14 +88,14 @@ module Dnsimple
|
|
88
88
|
|
89
89
|
# List the extended attributes for a TLD.
|
90
90
|
#
|
91
|
-
# @see http://developer.dnsimple.com/registrar/extended-attributes/#list
|
91
|
+
# @see http://developer.dnsimple.com/v1/registrar/extended-attributes/#list
|
92
92
|
#
|
93
93
|
# @param [#to_s] tld The TLD name.
|
94
94
|
# @return [Array<Struct::ExtendedAttribute>]
|
95
95
|
#
|
96
96
|
# @raise [RequestError] When the request fails.
|
97
97
|
def extended_attributes(tld, options = {})
|
98
|
-
response = client.get("
|
98
|
+
response = client.get(Client.versioned("/extended_attributes/#{tld}"), options)
|
99
99
|
|
100
100
|
response.map { |r| Struct::ExtendedAttribute.new(r) }
|
101
101
|
end
|
@@ -103,13 +103,13 @@ module Dnsimple
|
|
103
103
|
|
104
104
|
# List all the TLD prices.
|
105
105
|
#
|
106
|
-
# @see http://developer.dnsimple.com/registrar/prices/#list
|
106
|
+
# @see http://developer.dnsimple.com/v1/registrar/prices/#list
|
107
107
|
#
|
108
108
|
# @return [Array<Struct::Price>]
|
109
109
|
#
|
110
110
|
# @raise [RequestError] When the request fails.
|
111
111
|
def prices(options = {})
|
112
|
-
response = client.get("
|
112
|
+
response = client.get(Client.versioned("/prices"), options)
|
113
113
|
|
114
114
|
response.map { |r| Struct::Price.new(r["price"]) }
|
115
115
|
end
|
@@ -4,13 +4,13 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the supported services.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/services/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/services/#list
|
8
8
|
#
|
9
9
|
# @return [Array<Struct::Service>]
|
10
10
|
#
|
11
11
|
# @raise [RequestError] When the request fails.
|
12
12
|
def services(options = {})
|
13
|
-
response = client.get("
|
13
|
+
response = client.get(Client.versioned("services"), options)
|
14
14
|
|
15
15
|
response.map { |r| Struct::Service.new(r["service"]) }
|
16
16
|
end
|
@@ -19,7 +19,7 @@ module Dnsimple
|
|
19
19
|
|
20
20
|
# Gets a service.
|
21
21
|
#
|
22
|
-
# @see http://developer.dnsimple.com/services/#get
|
22
|
+
# @see http://developer.dnsimple.com/v1/services/#get
|
23
23
|
#
|
24
24
|
# @param [Fixnum] service The service id.
|
25
25
|
# @return [Struct::Service]
|
@@ -27,7 +27,7 @@ module Dnsimple
|
|
27
27
|
# @raise [NotFoundError]
|
28
28
|
# @raise [RequestError] When the request fails.
|
29
29
|
def service(service, options = {})
|
30
|
-
response = client.get("
|
30
|
+
response = client.get(Client.versioned("services/#{service}"), options)
|
31
31
|
|
32
32
|
Struct::Service.new(response["service"])
|
33
33
|
end
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the services applied to a domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/services/#applied
|
7
|
+
# @see http://developer.dnsimple.com/v1/services/#applied
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @return [Array<Struct::Service>]
|
@@ -12,14 +12,14 @@ module Dnsimple
|
|
12
12
|
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def applied(domain, options = {})
|
15
|
-
response = client.get("
|
15
|
+
response = client.get(Client.versioned("domains/#{domain}/applied_services"), options)
|
16
16
|
|
17
17
|
response.map { |r| Struct::Service.new(r["service"]) }
|
18
18
|
end
|
19
19
|
|
20
20
|
# Lists the services not applied to a domain.
|
21
21
|
#
|
22
|
-
# @see http://developer.dnsimple.com/services/#available
|
22
|
+
# @see http://developer.dnsimple.com/v1/services/#available
|
23
23
|
#
|
24
24
|
# @param [#to_s] domain The domain id or domain name.
|
25
25
|
# @return [Array<Struct::Service>]
|
@@ -27,14 +27,14 @@ module Dnsimple
|
|
27
27
|
# @raise [NotFoundError]
|
28
28
|
# @raise [RequestError] When the request fails.
|
29
29
|
def available(domain, options = {})
|
30
|
-
response = client.get("
|
30
|
+
response = client.get(Client.versioned("domains/#{domain}/available_services"), options)
|
31
31
|
|
32
32
|
response.map { |r| Struct::Service.new(r["service"]) }
|
33
33
|
end
|
34
34
|
|
35
35
|
# Applies a service to a domain.
|
36
36
|
#
|
37
|
-
# @see http://developer.dnsimple.com/services/#apply
|
37
|
+
# @see http://developer.dnsimple.com/v1/services/#apply
|
38
38
|
#
|
39
39
|
# @param [#to_s] domain The domain id or domain name.
|
40
40
|
# @param [Fixnum] service The service id.
|
@@ -44,13 +44,13 @@ module Dnsimple
|
|
44
44
|
# @raise [RequestError] When the request fails.
|
45
45
|
def apply(domain, service, options = {})
|
46
46
|
options = Extra.deep_merge(options, { service: { id: service }})
|
47
|
-
response = client.post("
|
47
|
+
response = client.post(Client.versioned("domains/#{domain}/applied_services"), options)
|
48
48
|
response.code == 200
|
49
49
|
end
|
50
50
|
|
51
51
|
# Un-applies a service from a domain.
|
52
52
|
#
|
53
|
-
# @see http://developer.dnsimple.com/services/#unapply
|
53
|
+
# @see http://developer.dnsimple.com/v1/services/#unapply
|
54
54
|
#
|
55
55
|
# @param [#to_s] domain The domain id or domain name.
|
56
56
|
# @param [Fixnum] service The service id.
|
@@ -59,7 +59,7 @@ module Dnsimple
|
|
59
59
|
# @raise [NotFoundError]
|
60
60
|
# @raise [RequestError] When the request fails.
|
61
61
|
def unapply(domain, service, options = {})
|
62
|
-
response = client.delete("
|
62
|
+
response = client.delete(Client.versioned("domains/#{domain}/applied_services/#{service}"), options)
|
63
63
|
response.code == 200
|
64
64
|
end
|
65
65
|
|
@@ -4,13 +4,13 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the templates in the account.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/templates/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/templates/#list
|
8
8
|
#
|
9
9
|
# @return [Array<Struct::Template>]
|
10
10
|
#
|
11
11
|
# @raise [RequestError] When the request fails.
|
12
12
|
def templates(options = {})
|
13
|
-
response = client.get("
|
13
|
+
response = client.get(Client.versioned("templates"), options)
|
14
14
|
|
15
15
|
response.map { |r| Struct::Template.new(r["dns_template"]) }
|
16
16
|
end
|
@@ -19,7 +19,7 @@ module Dnsimple
|
|
19
19
|
|
20
20
|
# Creates a template in the account.
|
21
21
|
#
|
22
|
-
# @see http://developer.dnsimple.com/templates/#create
|
22
|
+
# @see http://developer.dnsimple.com/v1/templates/#create
|
23
23
|
#
|
24
24
|
# @param [Hash] attributes
|
25
25
|
# @return [Struct::Template]
|
@@ -28,7 +28,7 @@ module Dnsimple
|
|
28
28
|
def create_template(attributes = {}, options = {})
|
29
29
|
Extra.validate_mandatory_attributes(attributes, [:name, :short_name])
|
30
30
|
options = options.merge({ dns_template: attributes })
|
31
|
-
response = client.post("
|
31
|
+
response = client.post(Client.versioned("templates"), options)
|
32
32
|
|
33
33
|
Struct::Template.new(response["dns_template"])
|
34
34
|
end
|
@@ -36,7 +36,7 @@ module Dnsimple
|
|
36
36
|
|
37
37
|
# Gets a template from the account.
|
38
38
|
#
|
39
|
-
# @see http://developer.dnsimple.com/templates/#get
|
39
|
+
# @see http://developer.dnsimple.com/v1/templates/#get
|
40
40
|
#
|
41
41
|
# @param [#to_s] template The template id or short-name.
|
42
42
|
# @return [Struct::Template]
|
@@ -44,14 +44,14 @@ module Dnsimple
|
|
44
44
|
# @raise [NotFoundError]
|
45
45
|
# @raise [RequestError] When the request fails.
|
46
46
|
def template(template, options = {})
|
47
|
-
response = client.get("
|
47
|
+
response = client.get(Client.versioned("templates/#{template}"), options)
|
48
48
|
|
49
49
|
Struct::Template.new(response["dns_template"])
|
50
50
|
end
|
51
51
|
|
52
52
|
# Updates a template in the account.
|
53
53
|
#
|
54
|
-
# @see http://developer.dnsimple.com/templates/#update
|
54
|
+
# @see http://developer.dnsimple.com/v1/templates/#update
|
55
55
|
#
|
56
56
|
# @param [#to_s] template The template id or short-name.
|
57
57
|
# @param [Hash] attributes
|
@@ -61,7 +61,7 @@ module Dnsimple
|
|
61
61
|
# @raise [RequestError] When the request fails.
|
62
62
|
def update_template(template, attributes = {}, options = {})
|
63
63
|
options = options.merge({ dns_template: attributes })
|
64
|
-
response = client.put("
|
64
|
+
response = client.put(Client.versioned("templates/#{template}"), options)
|
65
65
|
|
66
66
|
Struct::Template.new(response["dns_template"])
|
67
67
|
end
|
@@ -71,7 +71,7 @@ module Dnsimple
|
|
71
71
|
#
|
72
72
|
# WARNING: this cannot be undone.
|
73
73
|
#
|
74
|
-
# @see http://developer.dnsimple.com/templates/#delete
|
74
|
+
# @see http://developer.dnsimple.com/v1/templates/#delete
|
75
75
|
#
|
76
76
|
# @param [#to_s] template The template id or short-name.
|
77
77
|
# @return [void]
|
@@ -79,7 +79,7 @@ module Dnsimple
|
|
79
79
|
# @raise [NotFoundError]
|
80
80
|
# @raise [RequestError] When the request fails.
|
81
81
|
def delete_template(template, options = {})
|
82
|
-
client.delete("
|
82
|
+
client.delete(Client.versioned("templates/#{template}"), options)
|
83
83
|
end
|
84
84
|
alias :delete :delete_template
|
85
85
|
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Applies the template to the domain.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/templates/#apply
|
7
|
+
# @see http://developer.dnsimple.com/v1/templates/#apply
|
8
8
|
#
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
# @param [#to_s] template The template id or short-name.
|
@@ -13,7 +13,7 @@ module Dnsimple
|
|
13
13
|
# @raise [NotFoundError]
|
14
14
|
# @raise [RequestError] When the request fails.
|
15
15
|
def apply_template(domain, template, options = {})
|
16
|
-
response = client.post("
|
16
|
+
response = client.post(Client.versioned("/domains/#{domain}/templates/#{template}/apply"), options)
|
17
17
|
response.code == 200
|
18
18
|
end
|
19
19
|
alias :apply :apply_template
|
@@ -4,7 +4,7 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the records for a template.
|
6
6
|
#
|
7
|
-
# @see http://developer.dnsimple.com/templates/records/#list
|
7
|
+
# @see http://developer.dnsimple.com/v1/templates/records/#list
|
8
8
|
#
|
9
9
|
# @param [#to_s] template The template id or short-name.
|
10
10
|
# @return [Array<Struct::TemplateRecord>]
|
@@ -12,14 +12,14 @@ module Dnsimple
|
|
12
12
|
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def records(template, options = {})
|
15
|
-
response = client.get("
|
15
|
+
response = client.get(Client.versioned("/templates/#{template}/records"), options)
|
16
16
|
|
17
17
|
response.map { |r| Struct::TemplateRecord.new(r["dns_template_record"]) }
|
18
18
|
end
|
19
19
|
|
20
20
|
# Creates a record for a template.
|
21
21
|
#
|
22
|
-
# @see http://developer.dnsimple.com/templates/records/#create
|
22
|
+
# @see http://developer.dnsimple.com/v1/templates/records/#create
|
23
23
|
#
|
24
24
|
# @param [#to_s] template The template id or short-name.
|
25
25
|
# @param [Hash] attributes
|
@@ -30,14 +30,14 @@ module Dnsimple
|
|
30
30
|
def create_record(template, attributes = {}, options = {})
|
31
31
|
Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
|
32
32
|
options = options.merge({ dns_template_record: attributes })
|
33
|
-
response = client.post("
|
33
|
+
response = client.post(Client.versioned("/templates/#{template}/records"), options)
|
34
34
|
|
35
35
|
Struct::TemplateRecord.new(response["dns_template_record"])
|
36
36
|
end
|
37
37
|
|
38
38
|
# Gets a record for a template.
|
39
39
|
#
|
40
|
-
# @see http://developer.dnsimple.com/templates/records/#delete
|
40
|
+
# @see http://developer.dnsimple.com/v1/templates/records/#delete
|
41
41
|
#
|
42
42
|
# @param [#to_s] template The template id or short-name.
|
43
43
|
# @param [Fixnum] record The record id.
|
@@ -46,14 +46,14 @@ module Dnsimple
|
|
46
46
|
# @raise [NotFoundError]
|
47
47
|
# @raise [RequestError] When the request fails.
|
48
48
|
def record(template, record, options = {})
|
49
|
-
response = client.get("
|
49
|
+
response = client.get(Client.versioned("/templates/#{template}/records/#{record}"), options)
|
50
50
|
|
51
51
|
Struct::TemplateRecord.new(response["dns_template_record"])
|
52
52
|
end
|
53
53
|
|
54
54
|
# Updates a record for a template.
|
55
55
|
#
|
56
|
-
# @see http://developer.dnsimple.com/templates/#update
|
56
|
+
# @see http://developer.dnsimple.com/v1/templates/#update
|
57
57
|
#
|
58
58
|
# @param [#to_s] template The template id or short-name.
|
59
59
|
# @param [Fixnum] record The record id.
|
@@ -64,14 +64,14 @@ module Dnsimple
|
|
64
64
|
# @raise [RequestError] When the request fails.
|
65
65
|
def update_record(template, record, attributes = {}, options = {})
|
66
66
|
options = options.merge({ dns_template_record: attributes })
|
67
|
-
response = client.put("
|
67
|
+
response = client.put(Client.versioned("/templates/#{template}/records/#{record}"), options)
|
68
68
|
|
69
69
|
Struct::TemplateRecord.new(response["dns_template_record"])
|
70
70
|
end
|
71
71
|
|
72
72
|
# Deletes a record for a template.
|
73
73
|
#
|
74
|
-
# @see http://developer.dnsimple.com/templates/records/#get
|
74
|
+
# @see http://developer.dnsimple.com/v1/templates/records/#get
|
75
75
|
#
|
76
76
|
# @param [#to_s] template The template id or short-name.
|
77
77
|
# @param [Fixnum] record The record id.
|
@@ -80,7 +80,7 @@ module Dnsimple
|
|
80
80
|
# @raise [NotFoundError]
|
81
81
|
# @raise [RequestError] When the request fails.
|
82
82
|
def delete_record(template, record, options = {})
|
83
|
-
client.delete("
|
83
|
+
client.delete(Client.versioned("/templates/#{template}/records/#{record}"), options)
|
84
84
|
end
|
85
85
|
|
86
86
|
end
|
@@ -8,7 +8,7 @@ module Dnsimple
|
|
8
8
|
#
|
9
9
|
# @raise [RequestError] When the request fails.
|
10
10
|
def user(options = {})
|
11
|
-
response = client.get("
|
11
|
+
response = client.get(Client.versioned("/user"), options)
|
12
12
|
|
13
13
|
Struct::User.new(response["user"])
|
14
14
|
end
|
@@ -18,7 +18,7 @@ module Dnsimple
|
|
18
18
|
# The exchange-token is required to validate API requests
|
19
19
|
# using HTTP Basic Authentication when the account has two-factor authentication enabled.
|
20
20
|
#
|
21
|
-
# @see http://developer.dnsimple.com/authentication/#twofa
|
21
|
+
# @see http://developer.dnsimple.com/v1/authentication/#twofa
|
22
22
|
#
|
23
23
|
# @example Request an Exchange Token
|
24
24
|
# Dnsimple::User.two_factor_exchange_token('0000000')
|
@@ -30,7 +30,7 @@ module Dnsimple
|
|
30
30
|
# @raise [AuthenticationFailed] if the provided OTP token is invalid.
|
31
31
|
def exchange_token(otp_token, options = {})
|
32
32
|
options = Extra.deep_merge(options, headers: { Client::HEADER_2FA_STRICT => "1", Client::HEADER_OTP_TOKEN => otp_token })
|
33
|
-
response = client.get("
|
33
|
+
response = client.get(Client.versioned("/user"), options)
|
34
34
|
response.headers[Client::HEADER_EXCHANGE_TOKEN]
|
35
35
|
end
|
36
36
|
|
data/lib/dnsimple/extra.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module Dnsimple
|
2
2
|
module Extra
|
3
3
|
|
4
|
+
# Joins two pieces of URI with a /.
|
5
|
+
#
|
6
|
+
# @return [String] The joined string.
|
7
|
+
def self.join_uri(*parts)
|
8
|
+
parts.map { |part| part.chomp("/") }.join("/")
|
9
|
+
end
|
10
|
+
|
4
11
|
# Returns a new hash with +self+ and +other+ merged recursively.
|
5
12
|
#
|
6
13
|
# h1 = { a: true, b: { c: [1, 2, 3] } }
|
data/lib/dnsimple/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Extra do
|
4
|
+
|
5
|
+
describe ".join_uri" do
|
6
|
+
it "joins two or more strings" do
|
7
|
+
expect(described_class.join_uri("foo")).to eq("foo")
|
8
|
+
expect(described_class.join_uri("foo", "bar")).to eq("foo/bar")
|
9
|
+
expect(described_class.join_uri("foo", "bar", "baz")).to eq("foo/bar/baz")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "removes multiple trailing /" do
|
13
|
+
expect(described_class.join_uri("foo", "bar")).to eq("foo/bar")
|
14
|
+
expect(described_class.join_uri("foo", "bar/")).to eq("foo/bar")
|
15
|
+
expect(described_class.join_uri("foo/", "bar")).to eq("foo/bar")
|
16
|
+
expect(described_class.join_uri("foo/", "bar/")).to eq("foo/bar")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does not strip protocols" do
|
20
|
+
expect(described_class.join_uri("https://dnsimple.com", "path")).to eq("https://dnsimple.com/path")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsimple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Eden
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
-
description:
|
84
|
+
description: The DNSimple API client for Ruby.
|
85
85
|
email:
|
86
86
|
- anthony.eden@dnsimple.com
|
87
87
|
- simone.carletti@dnsimple.com
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- spec/dnsimple/client/users_spec.rb
|
164
164
|
- spec/dnsimple/client_spec.rb
|
165
165
|
- spec/dnsimple/compatibility_spec.rb
|
166
|
+
- spec/dnsimple/extra_spec.rb
|
166
167
|
- spec/files/2fa/error-badtoken.http
|
167
168
|
- spec/files/2fa/error-required.http
|
168
169
|
- spec/files/2fa/exchange-token.http
|
@@ -274,7 +275,7 @@ rubyforge_project:
|
|
274
275
|
rubygems_version: 2.4.7
|
275
276
|
signing_key:
|
276
277
|
specification_version: 4
|
277
|
-
summary:
|
278
|
+
summary: The DNSimple API client for Ruby
|
278
279
|
test_files:
|
279
280
|
- spec/dnsimple/client/certificates_spec.rb
|
280
281
|
- spec/dnsimple/client/contacts_spec.rb
|
@@ -295,6 +296,7 @@ test_files:
|
|
295
296
|
- spec/dnsimple/client/users_spec.rb
|
296
297
|
- spec/dnsimple/client_spec.rb
|
297
298
|
- spec/dnsimple/compatibility_spec.rb
|
299
|
+
- spec/dnsimple/extra_spec.rb
|
298
300
|
- spec/files/2fa/error-badtoken.http
|
299
301
|
- spec/files/2fa/error-required.http
|
300
302
|
- spec/files/2fa/exchange-token.http
|