fog-dnsimple 2.0.0 → 3.0.0
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 +5 -5
- data/CHANGELOG.md +17 -3
- data/Gemfile +9 -2
- data/LICENSE.txt +22 -0
- data/README.md +29 -26
- data/lib/fog/bin/dnsimple.rb +42 -21
- data/lib/fog/dnsimple/dns.rb +70 -35
- data/lib/fog/dnsimple/models/dns/record.rb +5 -5
- data/lib/fog/dnsimple/models/dns/records.rb +5 -5
- data/lib/fog/dnsimple/models/dns/zone.rb +3 -3
- data/lib/fog/dnsimple/models/dns/zones.rb +3 -3
- data/lib/fog/dnsimple/requests/dns/create_domain.rb +3 -12
- data/lib/fog/dnsimple/requests/dns/create_record.rb +4 -14
- data/lib/fog/dnsimple/requests/dns/delete_domain.rb +4 -9
- data/lib/fog/dnsimple/requests/dns/delete_record.rb +3 -7
- data/lib/fog/dnsimple/requests/dns/get_domain.rb +13 -12
- data/lib/fog/dnsimple/requests/dns/get_record.rb +15 -18
- data/lib/fog/dnsimple/requests/dns/list_all_domains.rb +38 -0
- data/lib/fog/dnsimple/requests/dns/list_all_records.rb +39 -0
- data/lib/fog/dnsimple/requests/dns/list_domains.rb +17 -17
- data/lib/fog/dnsimple/requests/dns/list_records.rb +18 -18
- data/lib/fog/dnsimple/requests/dns/update_record.rb +3 -10
- data/lib/fog/dnsimple/version.rb +1 -1
- data/lib/fog/dnsimple.rb +2 -0
- metadata +25 -85
- data/.gitignore +0 -9
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -18
- data/LICENSE.md +0 -20
- data/Rakefile +0 -9
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/fog-dnsimple.gemspec +0 -29
- data/tests/dns/helper.rb +0 -19
- data/tests/dns/models/record_tests.rb +0 -41
- data/tests/dns/models/records_tests.rb +0 -27
- data/tests/dns/models/zone_tests.rb +0 -15
- data/tests/dns/models/zones_tests.rb +0 -15
- data/tests/helper.rb +0 -11
- data/tests/helpers/mock_helper.rb +0 -6
- data/tests/requests/dns/dns_tests.rb +0 -122
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 823036363818ab3ec842ea8ccefa3e07af9491587275c388897a00393fa3d4af
|
|
4
|
+
data.tar.gz: 9feb86908b986414ac18650a56435eae0cc6327824494eac901b523a0f59886c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fec9f2a935a5ceb6867c0ecffb49be3fedd46704ee0864b30ba0d96f9589eb04e35a9603c30008e8310aacd186f31a3bfa3cd813bdcac891a1d8bf83981e851
|
|
7
|
+
data.tar.gz: 44f31c656c473ae7ad26fcb62dcb0850a5c69a42f4ce3f4323d966150a696d7b47af2d5e1191429c92a9b20429fa429ffbb539bd3d8ab3c2abeb10b51da6381d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
#### Release 3.0.0
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
- FIXED: Record requests use the zone name instead of the zone ID (#7, #11)
|
|
6
|
+
- CHANGED: Minimum Ruby version is now 3.2 (#9)
|
|
7
|
+
- CHANGED: Moved CI from Travis to GitHub Actions (#9)
|
|
8
|
+
- CHANGED: Minimum fog-core version is now 2.5 (#10)
|
|
9
|
+
- CHANGED: The service class is now `Fog::Dnsimple::DNS`. `Fog::DNS::Dnsimple` remains as an alias (#10)
|
|
10
|
+
- CHANGED: Requests use the dnsimple-ruby client instead of a custom HTTP connection (#11)
|
|
11
|
+
- CHANGED: Removed `Real#reload` and the public `Real#request`. From `connection_options`, only the proxy is used (#11)
|
|
12
|
+
|
|
13
|
+
#### Release 2.1.0
|
|
14
|
+
|
|
15
|
+
- NEW: Added ability to fetch all (non-paginated) domains and records (#4, #6)
|
|
16
|
+
- FIXED: Added missing "minimum Ruby version" in Gemspec
|
|
17
|
+
- CHANGED: Replaced Shindo with Minitest (#5)
|
|
18
|
+
|
|
19
|
+
#### Release 2.0.0
|
|
5
20
|
|
|
6
21
|
Upgrade to DNSimple API v2.
|
|
7
22
|
https://developer.dnsimple.com/v2/
|
|
@@ -11,7 +26,6 @@ In order to use API v2 you need an API v2 Oauth token, and the accound ID. The a
|
|
|
11
26
|
https://dnsimple.com/a/1234/domains/example.com
|
|
12
27
|
-> 1234
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
#### Release 1.0
|
|
29
|
+
#### Release 1.0.0
|
|
16
30
|
|
|
17
31
|
Initial version, extracted from `fog`.
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2009-2016 https://github.com/fog/fog/blob/master/CONTRIBUTORS.md
|
|
4
|
+
Copyright (c) 2016-2026 DNSimple Corporation
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
1
|
# Fog::Dnsimple
|
|
2
2
|
|
|
3
|
-
[
|
|
9
|
-
and it is fully compatible with the legacy implementation bundled with the `fog` gem.
|
|
10
|
-
|
|
11
|
-
In other words, this is a drop-in replacement. Please note that the `dnsimple` provider
|
|
12
|
-
will eventually be removed from the `fog` gem in favor of this fog-specific module.
|
|
3
|
+
[](https://github.com/fog/fog-dnsimple/actions/workflows/ci.yml)
|
|
13
4
|
|
|
5
|
+
This library is the [DNSimple](https://dnsimple.com/) provider for [fog](https://github.com/fog/fog). It uses the [DNSimple API](https://developer.dnsimple.com/) through the [dnsimple-ruby](https://github.com/dnsimple/dnsimple-ruby) client.
|
|
14
6
|
|
|
15
7
|
## Installation
|
|
16
8
|
|
|
17
9
|
Add this line to your application's Gemfile:
|
|
18
10
|
|
|
19
11
|
```ruby
|
|
20
|
-
gem
|
|
12
|
+
gem "fog-dnsimple"
|
|
21
13
|
```
|
|
22
14
|
|
|
23
15
|
And then execute:
|
|
24
16
|
|
|
25
|
-
|
|
17
|
+
```bash
|
|
18
|
+
bundle install
|
|
19
|
+
```
|
|
26
20
|
|
|
27
21
|
Or install it yourself as:
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
```bash
|
|
24
|
+
gem install fog-dnsimple
|
|
25
|
+
```
|
|
31
26
|
|
|
32
27
|
## Usage
|
|
33
28
|
|
|
34
29
|
Initialize a `Fog::DNS` object using the DNSimple provider.
|
|
35
30
|
|
|
36
31
|
```ruby
|
|
37
|
-
dns = Fog::DNS.new(
|
|
32
|
+
dns = Fog::DNS.new(
|
|
38
33
|
provider: "DNSimple",
|
|
39
34
|
dnsimple_token: "YOUR_API_TOKEN",
|
|
40
35
|
dnsimple_account: "YOUR_ACCOUNT_ID",
|
|
41
|
-
|
|
36
|
+
)
|
|
42
37
|
```
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
- `YOUR_API_TOKEN`: the API access token. You can create it from your account page: Account > Access Tokens > Account access tokens.
|
|
40
|
+
- `YOUR_ACCOUNT_ID`: the numeric account ID. It is the number after `/a` in the account URL. For instance, if the account page is `https://dnsimple.com/a/1234/domains`, the account ID is `1234`.
|
|
41
|
+
|
|
42
|
+
You can then use it like other fog DNS providers.
|
|
45
43
|
|
|
46
44
|
```ruby
|
|
47
45
|
zone = dns.zones.create(
|
|
@@ -54,19 +52,24 @@ record = zone.records.create(
|
|
|
54
52
|
)
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
The following
|
|
55
|
+
The following options are also supported:
|
|
58
56
|
|
|
59
57
|
```ruby
|
|
60
|
-
dns = Fog::DNS.new(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
dns = Fog::DNS.new(
|
|
59
|
+
provider: "DNSimple",
|
|
60
|
+
dnsimple_token: "YOUR_API_TOKEN",
|
|
61
|
+
dnsimple_account: "YOUR_ACCOUNT_ID",
|
|
62
|
+
# A different base URL, for example the Sandbox URL
|
|
63
|
+
dnsimple_url: "https://api.sandbox.dnsimple.com",
|
|
64
|
+
# An HTTP proxy
|
|
65
|
+
connection_options: { proxy: "http://proxy.example.com:8080" },
|
|
66
|
+
)
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
## Contributing
|
|
67
70
|
|
|
68
|
-
1. Fork it (
|
|
69
|
-
2. Create your feature branch (`git
|
|
70
|
-
3. Commit your changes (`git commit -am
|
|
71
|
+
1. Fork it (https://github.com/fog/fog-dnsimple/fork)
|
|
72
|
+
2. Create your feature branch (`git switch -c my-new-feature`)
|
|
73
|
+
3. Commit your changes (`git commit -am "Add some feature"`)
|
|
71
74
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
72
|
-
5. Create new Pull Request
|
|
75
|
+
5. Create a new Pull Request
|
data/lib/fog/bin/dnsimple.rb
CHANGED
|
@@ -1,28 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
module Fog
|
|
2
|
+
module Dnsimple
|
|
3
|
+
class Bin < Fog::Bin
|
|
4
|
+
class << self
|
|
5
|
+
def class_for(key)
|
|
6
|
+
case key
|
|
7
|
+
when :dns
|
|
8
|
+
Fog::Dnsimple::DNS
|
|
9
|
+
else
|
|
10
|
+
raise ArgumentError, "Unrecognized service: #{key}"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
def [](service)
|
|
15
|
+
@@connections ||= Hash.new do |hash, key|
|
|
16
|
+
hash[key] = case key
|
|
17
|
+
when :dns
|
|
18
|
+
Fog::DNS.new(provider: "Dnsimple")
|
|
19
|
+
else
|
|
20
|
+
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
@@connections[service]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def services
|
|
27
|
+
Fog::Dnsimple.services
|
|
19
28
|
end
|
|
20
29
|
end
|
|
21
|
-
@@connections[service]
|
|
22
30
|
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
# fog finds the provider bin at the top-level Dnsimple constant, but the dnsimple gem owns that module.
|
|
35
|
+
# Thus the module sends the bin methods to Fog::Dnsimple::Bin.
|
|
36
|
+
module Dnsimple
|
|
37
|
+
def self.method_missing(name, *args, &block)
|
|
38
|
+
bin_method?(name) ? Fog::Dnsimple::Bin.public_send(name, *args, &block) : super
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.respond_to_missing?(name, include_private = false)
|
|
42
|
+
bin_method?(name) || super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.bin_method?(name)
|
|
46
|
+
Fog::Dnsimple::Bin.singleton_methods.include?(name.to_sym)
|
|
27
47
|
end
|
|
48
|
+
private_class_method :bin_method?
|
|
28
49
|
end
|
data/lib/fog/dnsimple/dns.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
require "fog/core"
|
|
2
|
-
require
|
|
2
|
+
# dnsimple-ruby uses JSON but does not require it.
|
|
3
|
+
require "json"
|
|
4
|
+
require "dnsimple"
|
|
3
5
|
|
|
4
6
|
module Fog
|
|
5
|
-
module
|
|
6
|
-
class
|
|
7
|
+
module Dnsimple
|
|
8
|
+
class DNS < Fog::Service
|
|
7
9
|
recognizes :dnsimple_token, :dnsimple_account, :dnsimple_url
|
|
8
10
|
|
|
9
11
|
model_path 'fog/dnsimple/models/dns'
|
|
@@ -14,11 +16,13 @@ module Fog
|
|
|
14
16
|
|
|
15
17
|
request_path 'fog/dnsimple/requests/dns'
|
|
16
18
|
request :list_domains
|
|
19
|
+
request :list_all_domains
|
|
17
20
|
request :create_domain
|
|
18
21
|
request :get_domain
|
|
19
22
|
request :delete_domain
|
|
20
23
|
request :create_record
|
|
21
24
|
request :list_records
|
|
25
|
+
request :list_all_records
|
|
22
26
|
request :update_record
|
|
23
27
|
request :delete_record
|
|
24
28
|
request :get_record
|
|
@@ -55,52 +59,83 @@ module Fog
|
|
|
55
59
|
@dnsimple_token = options[:dnsimple_token]
|
|
56
60
|
@dnsimple_account = options[:dnsimple_account]
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
options[:
|
|
61
|
-
options
|
|
62
|
-
|
|
62
|
+
@client = ::Dnsimple::Client.new(
|
|
63
|
+
access_token: @dnsimple_token,
|
|
64
|
+
base_url: options[:dnsimple_url],
|
|
65
|
+
proxy: proxy_address(options.dig(:connection_options, :proxy)),
|
|
66
|
+
user_agent: "#{Fog::Core::Connection.user_agents} fog-dnsimple/#{Fog::Dnsimple::VERSION}"
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
# Converts the dnsimple-ruby result and errors to Excon types.
|
|
73
|
+
def request
|
|
74
|
+
unless @dnsimple_token && @dnsimple_account
|
|
75
|
+
raise ArgumentError.new("Insufficient credentials to properly authenticate!")
|
|
63
76
|
end
|
|
64
77
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
http_response = yield(@client).http_response
|
|
79
|
+
excon_response(http_response, http_response.parsed_response || "")
|
|
80
|
+
rescue ::Dnsimple::RequestError => e
|
|
81
|
+
raise Excon::Error.status_error({}, excon_response(e.http_response, e.http_response.body.to_s))
|
|
82
|
+
rescue ::Dnsimple::AuthenticationFailed => e
|
|
83
|
+
raise Excon::Error.status_error({}, Excon::Response.new(status: 401, body: JSON.dump("message" => e.message)))
|
|
84
|
+
rescue Timeout::Error => e
|
|
85
|
+
raise Excon::Error::Timeout, e.message
|
|
86
|
+
rescue SocketError, SystemCallError, IOError, OpenSSL::SSL::SSLError => e
|
|
87
|
+
raise Excon::Error::Socket.new(e)
|
|
88
|
+
rescue JSON::ParserError => e
|
|
89
|
+
raise Excon::Error::ResponseParse, e.message
|
|
90
|
+
end
|
|
68
91
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
92
|
+
# Converts an Excon proxy (URL or Hash) to the "host:port" form of dnsimple-ruby.
|
|
93
|
+
def proxy_address(proxy)
|
|
94
|
+
case proxy
|
|
95
|
+
when String
|
|
96
|
+
uri = URI.parse(proxy)
|
|
97
|
+
"#{uri.host}:#{uri.port}"
|
|
98
|
+
when Hash
|
|
99
|
+
"#{proxy[:host]}:#{proxy[:port]}"
|
|
100
|
+
end
|
|
74
101
|
end
|
|
75
102
|
|
|
76
|
-
|
|
77
|
-
|
|
103
|
+
# Excon errors carry the raw body, and successful responses carry the parsed JSON.
|
|
104
|
+
def excon_response(http_response, body)
|
|
105
|
+
Excon::Response.new(
|
|
106
|
+
status: http_response.code,
|
|
107
|
+
headers: http_response.response.each_header.to_h,
|
|
108
|
+
body: body
|
|
109
|
+
)
|
|
78
110
|
end
|
|
79
111
|
|
|
80
|
-
def
|
|
81
|
-
|
|
112
|
+
def paginate(query: {})
|
|
113
|
+
current_page = 0
|
|
114
|
+
total_pages = nil
|
|
115
|
+
total_entries = nil
|
|
116
|
+
collection = []
|
|
117
|
+
response = nil
|
|
82
118
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
raise ArgumentError.new("Insufficient credentials to properly authenticate!")
|
|
87
|
-
end
|
|
88
|
-
params[:headers].merge!(
|
|
89
|
-
"Accept" => "application/json",
|
|
90
|
-
"Content-Type" => "application/json"
|
|
91
|
-
)
|
|
119
|
+
begin
|
|
120
|
+
current_page += 1
|
|
121
|
+
current_query = query.merge({ page: current_page, per_page: 100 })
|
|
92
122
|
|
|
93
|
-
|
|
94
|
-
|
|
123
|
+
response = yield(current_query)
|
|
124
|
+
total_entries ||= response.body.dig("pagination", "total_entries")
|
|
125
|
+
total_pages ||= response.body.dig("pagination", "total_pages")
|
|
126
|
+
collection.concat(response.body["data"])
|
|
127
|
+
end while current_page < total_pages
|
|
95
128
|
|
|
96
|
-
|
|
129
|
+
total_entries == collection.size or
|
|
130
|
+
raise(Fog::Errors::Error, "Expected `#{total_entries}`, fetched only `#{collection.size}`")
|
|
97
131
|
|
|
98
|
-
|
|
99
|
-
response.body = Fog::JSON.decode(response.body)
|
|
100
|
-
end
|
|
132
|
+
response.body["data"] = collection
|
|
101
133
|
response
|
|
102
134
|
end
|
|
103
135
|
end
|
|
104
136
|
end
|
|
105
137
|
end
|
|
138
|
+
|
|
139
|
+
# Keeps the constant from the service::provider format for compatibility.
|
|
140
|
+
DNS::Dnsimple = Dnsimple::DNS
|
|
106
141
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'fog/core/model'
|
|
2
2
|
|
|
3
3
|
module Fog
|
|
4
|
-
module
|
|
5
|
-
class
|
|
4
|
+
module Dnsimple
|
|
5
|
+
class DNS
|
|
6
6
|
class Record < Fog::Model
|
|
7
7
|
identity :id
|
|
8
8
|
|
|
@@ -20,7 +20,7 @@ module Fog
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def destroy
|
|
23
|
-
service.delete_record(zone.
|
|
23
|
+
service.delete_record(zone.domain, identity)
|
|
24
24
|
true
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -35,12 +35,12 @@ module Fog
|
|
|
35
35
|
|
|
36
36
|
# decide whether its a new record or update of an existing
|
|
37
37
|
if id.nil?
|
|
38
|
-
data = service.create_record(zone.
|
|
38
|
+
data = service.create_record(zone.domain, name, type, value, options)
|
|
39
39
|
else
|
|
40
40
|
options[:name] = name if name
|
|
41
41
|
options[:content] = value if value
|
|
42
42
|
options[:type] = type if type
|
|
43
|
-
data = service.update_record(zone.
|
|
43
|
+
data = service.update_record(zone.domain, id, options)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
merge_attributes(data.body["data"])
|
|
@@ -2,23 +2,23 @@ require 'fog/core/collection'
|
|
|
2
2
|
require 'fog/dnsimple/models/dns/record'
|
|
3
3
|
|
|
4
4
|
module Fog
|
|
5
|
-
module
|
|
6
|
-
class
|
|
5
|
+
module Dnsimple
|
|
6
|
+
class DNS
|
|
7
7
|
class Records < Fog::Collection
|
|
8
8
|
attribute :zone
|
|
9
9
|
|
|
10
|
-
model Fog::DNS::
|
|
10
|
+
model Fog::Dnsimple::DNS::Record
|
|
11
11
|
|
|
12
12
|
def all
|
|
13
13
|
requires :zone
|
|
14
14
|
clear
|
|
15
|
-
data = service.list_records(zone.
|
|
15
|
+
data = service.list_records(zone.domain).body["data"]
|
|
16
16
|
load(data)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def get(record_id)
|
|
20
20
|
requires :zone
|
|
21
|
-
data = service.get_record(zone.
|
|
21
|
+
data = service.get_record(zone.domain, record_id).body["data"]
|
|
22
22
|
new(data)
|
|
23
23
|
rescue Excon::Errors::NotFound
|
|
24
24
|
nil
|
|
@@ -2,8 +2,8 @@ require 'fog/core/model'
|
|
|
2
2
|
require 'fog/dnsimple/models/dns/records'
|
|
3
3
|
|
|
4
4
|
module Fog
|
|
5
|
-
module
|
|
6
|
-
class
|
|
5
|
+
module Dnsimple
|
|
6
|
+
class DNS
|
|
7
7
|
class Zone < Fog::Model
|
|
8
8
|
identity :id
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ module Fog
|
|
|
18
18
|
|
|
19
19
|
def records
|
|
20
20
|
@records ||= begin
|
|
21
|
-
Fog::DNS::
|
|
21
|
+
Fog::Dnsimple::DNS::Records.new(
|
|
22
22
|
:zone => self,
|
|
23
23
|
:service => service
|
|
24
24
|
)
|
|
@@ -2,10 +2,10 @@ require 'fog/core/collection'
|
|
|
2
2
|
require 'fog/dnsimple/models/dns/zone'
|
|
3
3
|
|
|
4
4
|
module Fog
|
|
5
|
-
module
|
|
6
|
-
class
|
|
5
|
+
module Dnsimple
|
|
6
|
+
class DNS
|
|
7
7
|
class Zones < Fog::Collection
|
|
8
|
-
model Fog::DNS::
|
|
8
|
+
model Fog::Dnsimple::DNS::Zone
|
|
9
9
|
|
|
10
10
|
def all
|
|
11
11
|
clear
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Fog
|
|
2
|
-
module
|
|
3
|
-
class
|
|
2
|
+
module Dnsimple
|
|
3
|
+
class DNS
|
|
4
4
|
class Real
|
|
5
5
|
# Create a single domain in DNSimple in your account.
|
|
6
6
|
#
|
|
@@ -12,16 +12,7 @@ module Fog
|
|
|
12
12
|
# * body<~Hash>:
|
|
13
13
|
# * "data"<~Hash> The representation of the domain.
|
|
14
14
|
def create_domain(zone_name)
|
|
15
|
-
|
|
16
|
-
"name" => zone_name
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
request(
|
|
20
|
-
body: Fog::JSON.encode(body),
|
|
21
|
-
expects: 201,
|
|
22
|
-
method: "POST",
|
|
23
|
-
path: "/#{@dnsimple_account}/domains"
|
|
24
|
-
)
|
|
15
|
+
request { |client| client.domains.create_domain(@dnsimple_account, name: zone_name) }
|
|
25
16
|
end
|
|
26
17
|
end
|
|
27
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Fog
|
|
2
|
-
module
|
|
3
|
-
class
|
|
2
|
+
module Dnsimple
|
|
3
|
+
class DNS
|
|
4
4
|
class Real
|
|
5
5
|
# Create a new host in the specified zone
|
|
6
6
|
#
|
|
@@ -18,19 +18,9 @@ module Fog
|
|
|
18
18
|
# * body<~Hash>:
|
|
19
19
|
# * 'record'<~Hash> The representation of the record.
|
|
20
20
|
def create_record(zone_name, name, type, content, options = {})
|
|
21
|
-
|
|
22
|
-
"name" => name,
|
|
23
|
-
"type" => type,
|
|
24
|
-
"content" => content
|
|
25
|
-
}
|
|
26
|
-
body.merge!(options)
|
|
21
|
+
attributes = { name: name, type: type, content: content }.merge(options)
|
|
27
22
|
|
|
28
|
-
request(
|
|
29
|
-
body: Fog::JSON.encode(body),
|
|
30
|
-
expects: 201,
|
|
31
|
-
method: "POST",
|
|
32
|
-
path: "/#{@dnsimple_account}/zones/#{zone_name}/records"
|
|
33
|
-
)
|
|
23
|
+
request { |client| client.zones.create_zone_record(@dnsimple_account, zone_name, attributes) }
|
|
34
24
|
end
|
|
35
25
|
end
|
|
36
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Fog
|
|
2
|
-
module
|
|
3
|
-
class
|
|
2
|
+
module Dnsimple
|
|
3
|
+
class DNS
|
|
4
4
|
class Real
|
|
5
5
|
# Delete the given domain from your account. You may use
|
|
6
6
|
# either the domain ID or the domain name.
|
|
@@ -9,22 +9,17 @@ module Fog
|
|
|
9
9
|
# DNSimple this will not delete the domain from the registry.
|
|
10
10
|
#
|
|
11
11
|
# ==== Parameters
|
|
12
|
-
# * account_id<~String> - the account the domain belong to
|
|
13
12
|
# * zone_name<~String> - zone name
|
|
14
13
|
#
|
|
15
14
|
def delete_domain(zone_name)
|
|
16
|
-
request(
|
|
17
|
-
expects: 204,
|
|
18
|
-
method: "DELETE",
|
|
19
|
-
path: "/#{@dnsimple_account}/domains/#{zone_name}"
|
|
20
|
-
)
|
|
15
|
+
request { |client| client.domains.delete_domain(@dnsimple_account, zone_name) }
|
|
21
16
|
end
|
|
22
17
|
end
|
|
23
18
|
|
|
24
19
|
class Mock
|
|
25
20
|
def delete_domain(zone_name)
|
|
26
21
|
self.data[:records].delete(zone_name)
|
|
27
|
-
self.data[:domains].reject! { |domain| domain["name"] == zone_name }
|
|
22
|
+
self.data[:domains].reject! { |domain| domain["id"] == zone_name || domain["name"] == zone_name }
|
|
28
23
|
|
|
29
24
|
response = Excon::Response.new
|
|
30
25
|
response.status = 204
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Fog
|
|
2
|
-
module
|
|
3
|
-
class
|
|
2
|
+
module Dnsimple
|
|
3
|
+
class DNS
|
|
4
4
|
class Real
|
|
5
5
|
# Delete the record with the given ID for the given domain.
|
|
6
6
|
#
|
|
@@ -8,11 +8,7 @@ module Fog
|
|
|
8
8
|
# * zone_name<~String> - zone name
|
|
9
9
|
# * record_id<~String>
|
|
10
10
|
def delete_record(zone_name, record_id)
|
|
11
|
-
request(
|
|
12
|
-
expects: 204,
|
|
13
|
-
method: "DELETE",
|
|
14
|
-
path: "/#{@dnsimple_account}/zones/#{zone_name}/records/#{record_id}"
|
|
15
|
-
)
|
|
11
|
+
request { |client| client.zones.delete_zone_record(@dnsimple_account, zone_name, record_id) }
|
|
16
12
|
end
|
|
17
13
|
end
|
|
18
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Fog
|
|
2
|
-
module
|
|
3
|
-
class
|
|
2
|
+
module Dnsimple
|
|
3
|
+
class DNS
|
|
4
4
|
class Real
|
|
5
5
|
# Get the details for a specific domain in your account. You
|
|
6
6
|
# may pass either the domain numeric ID or the domain name
|
|
@@ -14,23 +14,24 @@ module Fog
|
|
|
14
14
|
# * body<~Hash>:
|
|
15
15
|
# * "data"<~Hash> The representation of the domain.
|
|
16
16
|
def get_domain(zone_name)
|
|
17
|
-
request(
|
|
18
|
-
expects: 200,
|
|
19
|
-
method: "GET",
|
|
20
|
-
path: "/#{@dnsimple_account}/domains/#{zone_name}"
|
|
21
|
-
)
|
|
17
|
+
request { |client| client.domains.domain(@dnsimple_account, zone_name) }
|
|
22
18
|
end
|
|
23
19
|
end
|
|
24
20
|
|
|
25
21
|
class Mock
|
|
26
22
|
def get_domain(zone_name)
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
response = Excon::Response.new
|
|
24
|
+
|
|
25
|
+
payload = self.data[:domains].find { |domain| domain["id"] == zone_name || domain["name"] == zone_name }
|
|
26
|
+
if payload
|
|
27
|
+
response.status = 200
|
|
28
|
+
response.body = { "data" => payload }
|
|
29
|
+
else
|
|
30
|
+
# response.status = 404
|
|
31
|
+
# response.body = { "message" => "Domain `#{zone_name}` not found" }
|
|
32
|
+
raise Excon::Errors::NotFound, "Domain `#{zone_name}` not found"
|
|
29
33
|
end
|
|
30
34
|
|
|
31
|
-
response = Excon::Response.new
|
|
32
|
-
response.status = 200
|
|
33
|
-
response.body = { "data" => domain }
|
|
34
35
|
response
|
|
35
36
|
end
|
|
36
37
|
end
|