fog-dnsimple 2.0.0 → 2.1.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/.travis.yml +8 -4
- data/CHANGELOG.md +11 -2
- data/LICENSE.txt +22 -0
- data/README.md +11 -7
- data/Rakefile +8 -4
- data/fog-dnsimple.gemspec +6 -4
- data/lib/fog/dnsimple/dns.rb +28 -0
- data/lib/fog/dnsimple/requests/dns/delete_domain.rb +1 -1
- data/lib/fog/dnsimple/requests/dns/get_domain.rb +10 -5
- data/lib/fog/dnsimple/requests/dns/get_record.rb +12 -11
- 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 +18 -13
- data/lib/fog/dnsimple/requests/dns/list_records.rb +19 -14
- data/lib/fog/dnsimple/version.rb +1 -1
- metadata +30 -22
- data/LICENSE.md +0 -20
- 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: defee94be0120a11aa2630d61ed1227bc9095f37b236affe30765cb81571d288
|
|
4
|
+
data.tar.gz: a88b4351865f5eec85595951256b3ffa0e21f579d5888b4c7edc345b45d4e93e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46070f3cecb487c6de446c6c4d15e1bf724305578a73bdded4e118dc97e657730f1bbf8a1ec832c2a024c32c77644c10bc50cff3be900e4c736626cd4fadf138
|
|
7
|
+
data.tar.gz: 12c751977800d34408a0a5554a030e1d95fa6f64167bc8690c84c7268840354b0085089439935e5dc736d20bb50324aa2bcef624aefdf9a40147de1855cd7804
|
data/.travis.yml
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
|
|
3
3
|
rvm:
|
|
4
|
-
- 2.0
|
|
5
4
|
- 2.1
|
|
6
5
|
- 2.2
|
|
7
|
-
- 2.3
|
|
6
|
+
- 2.3
|
|
7
|
+
- 2.4
|
|
8
|
+
- 2.5
|
|
8
9
|
- ruby-head
|
|
9
|
-
- jruby9k
|
|
10
10
|
- jruby-head
|
|
11
11
|
|
|
12
12
|
before_install:
|
|
13
|
+
- rvm get latest
|
|
13
14
|
- gem install bundler
|
|
14
15
|
|
|
15
16
|
matrix:
|
|
16
17
|
allow_failures:
|
|
17
18
|
- rvm: jruby-head
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
notifications:
|
|
21
|
+
slack:
|
|
22
|
+
secure: "iqBpU3PYNS+7GiZAJ0jjVTJoLyyeG1Aub7gXQxRhLAQVUWTgnQdgbFXkAG4YpUn4PGDveky4So6GpumG8sLb+7D2HEqCfGwZ0u/UuVSglm+ain0iX18rwGGnLMoyAti7Gln8uQmGE6hT8eN6Bjkr05RKMUnQtIrGPO4vokJQh2gRcbesgRlWiIX+pn6xIVk7gVX5fGo6UgCSZDIq0mgOc4Sodubalu7BE0zTx+N0eOjE/58FkqWYvJUX+njcdphFoLC+RAsIAedjh7ZJTwuKItGuVhxhJqiXBc8lVDK0e+1Ipff2nNJvBxriniCXJTpAzDBamJG1cn47ecdan0DiKtUrHFbKYzODDPwDTOJsh/AO2dLZwi65PAxvmit/VhTaQj5394JLtxrCTMOic04GGkrXez+d360kAQAQmxsbJR2vRe/3vLTj8WBzabh4zq3R1dPXiAhSYSY7CfKfCY5zMEeAPsr4C/NSKTdk77Ddoq8GoguLZOc3ew5VJe5FyRJMEGnWPDMbCF4XIc6vd3LSRvQXyAgpF3Zvo8JkIGeiQhhTNT3yxvo08hPR2sWcC8cidRMwulCIsWIebCwIebYUd9XfJKzng4GJP8gvdbxbNnaHfsip98mTPYZqiQbuvZsxD99o5ovJp8meaXsTkXOK1Sbw4wWTNeYZQ0gnjb5+P6Y="
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#### Release 2.0
|
|
4
|
+
#### Release 2.1.0
|
|
5
|
+
|
|
6
|
+
- NEW: Added ability to fetch all (non-paginated) domains and records (GH-4, GH-6)
|
|
7
|
+
|
|
8
|
+
- FIXED: Added missing "minimum Ruby version" in Gemspec
|
|
9
|
+
|
|
10
|
+
- CHANGED: Replaced Shindo with Minitest (GH-5)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#### Release 2.0.0
|
|
5
14
|
|
|
6
15
|
Upgrade to DNSimple API v2.
|
|
7
16
|
https://developer.dnsimple.com/v2/
|
|
@@ -12,6 +21,6 @@ In order to use API v2 you need an API v2 Oauth token, and the accound ID. The a
|
|
|
12
21
|
-> 1234
|
|
13
22
|
|
|
14
23
|
|
|
15
|
-
#### Release 1.0
|
|
24
|
+
#### Release 1.0.0
|
|
16
25
|
|
|
17
26
|
Initial version, extracted from `fog`.
|
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-2018 Aetrion LLC.
|
|
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
|
@@ -5,11 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
## API Version
|
|
7
7
|
|
|
8
|
-
This library currently uses the [DNSimple API
|
|
9
|
-
and it is
|
|
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.
|
|
8
|
+
This library currently uses the [DNSimple API v2](https://developer.dnsimple.com/v2/)
|
|
9
|
+
and it is compatible with the legacy implementation bundled with the `fog` gem.
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
## Installation
|
|
@@ -22,11 +19,15 @@ gem 'fog-dnsimple'
|
|
|
22
19
|
|
|
23
20
|
And then execute:
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
```
|
|
23
|
+
bundle
|
|
24
|
+
```
|
|
26
25
|
|
|
27
26
|
Or install it yourself as:
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
```
|
|
29
|
+
gem install fog-dnsimple
|
|
30
|
+
```
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
## Usage
|
|
@@ -41,6 +42,9 @@ dns = Fog::DNS.new({
|
|
|
41
42
|
})
|
|
42
43
|
```
|
|
43
44
|
|
|
45
|
+
- `YOUR_API_TOKEN`: This is the API v2 access token. You can create it from your account page: Account > Access Tokens > Account access tokens.
|
|
46
|
+
- `YOUR_ACCOUNT_ID`: This is the account ID. We currently support only the numeric ID (account string identifiers will be supported in the future). The account ID is the numeric ID after the `/a` in the path prefix. For instance, if the account page is `https://dnsimple.com/a/1234/domains`, the account ID is `1234`.
|
|
47
|
+
|
|
44
48
|
This can then be used like other [Fog DNS](http://fog.io/dns/) providers.
|
|
45
49
|
|
|
46
50
|
```ruby
|
data/Rakefile
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
-
require "rake/testtask"
|
|
3
2
|
|
|
4
3
|
task :default => :test
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
|
|
6
|
+
require "rake/testtask"
|
|
7
|
+
|
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
|
9
|
+
t.libs = %w( lib test )
|
|
10
|
+
t.pattern = "test/**/*_test.rb"
|
|
11
|
+
t.verbose = !ENV["VERBOSE"].nil?
|
|
12
|
+
t.warning = !ENV["WARNING"].nil?
|
|
9
13
|
end
|
data/fog-dnsimple.gemspec
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'fog/dnsimple/version'
|
|
@@ -20,10 +19,13 @@ Gem::Specification.new do |spec|
|
|
|
20
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
20
|
spec.require_paths = ["lib"]
|
|
22
21
|
|
|
22
|
+
spec.required_ruby_version = ">= 2.1"
|
|
23
|
+
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.12"
|
|
24
25
|
spec.add_development_dependency "rake", "~> 12.0"
|
|
25
|
-
spec.add_development_dependency "
|
|
26
|
+
spec.add_development_dependency "minitest"
|
|
27
|
+
spec.add_development_dependency "minitest-reporters"
|
|
26
28
|
|
|
27
|
-
spec.add_dependency
|
|
28
|
-
spec.add_dependency
|
|
29
|
+
spec.add_dependency "fog-core", ">= 1.38", "< 3"
|
|
30
|
+
spec.add_dependency "fog-json"
|
|
29
31
|
end
|
data/lib/fog/dnsimple/dns.rb
CHANGED
|
@@ -14,11 +14,13 @@ module Fog
|
|
|
14
14
|
|
|
15
15
|
request_path 'fog/dnsimple/requests/dns'
|
|
16
16
|
request :list_domains
|
|
17
|
+
request :list_all_domains
|
|
17
18
|
request :create_domain
|
|
18
19
|
request :get_domain
|
|
19
20
|
request :delete_domain
|
|
20
21
|
request :create_record
|
|
21
22
|
request :list_records
|
|
23
|
+
request :list_all_records
|
|
22
24
|
request :update_record
|
|
23
25
|
request :delete_record
|
|
24
26
|
request :get_record
|
|
@@ -100,6 +102,32 @@ module Fog
|
|
|
100
102
|
end
|
|
101
103
|
response
|
|
102
104
|
end
|
|
105
|
+
|
|
106
|
+
private
|
|
107
|
+
|
|
108
|
+
def paginate(query: {})
|
|
109
|
+
current_page = 0
|
|
110
|
+
total_pages = nil
|
|
111
|
+
total_entries = nil
|
|
112
|
+
collection = []
|
|
113
|
+
response = nil
|
|
114
|
+
|
|
115
|
+
begin
|
|
116
|
+
current_page += 1
|
|
117
|
+
current_query = query.merge({ page: current_page, per_page: 100 })
|
|
118
|
+
|
|
119
|
+
response = yield(current_query)
|
|
120
|
+
total_entries ||= response.body.dig("pagination", "total_entries")
|
|
121
|
+
total_pages ||= response.body.dig("pagination", "total_pages")
|
|
122
|
+
collection.concat(response.body["data"])
|
|
123
|
+
end while current_page < total_pages
|
|
124
|
+
|
|
125
|
+
total_entries == collection.size or
|
|
126
|
+
raise(Fog::Errors::Error, "Expected `#{total_entries}`, fetched only `#{collection.size}`")
|
|
127
|
+
|
|
128
|
+
response.body["data"] = collection
|
|
129
|
+
response
|
|
130
|
+
end
|
|
103
131
|
end
|
|
104
132
|
end
|
|
105
133
|
end
|
|
@@ -24,7 +24,7 @@ module Fog
|
|
|
24
24
|
class Mock
|
|
25
25
|
def delete_domain(zone_name)
|
|
26
26
|
self.data[:records].delete(zone_name)
|
|
27
|
-
self.data[:domains].reject! { |domain| domain["name"] == zone_name }
|
|
27
|
+
self.data[:domains].reject! { |domain| domain["id"] == zone_name || domain["name"] == zone_name }
|
|
28
28
|
|
|
29
29
|
response = Excon::Response.new
|
|
30
30
|
response.status = 204
|
|
@@ -24,13 +24,18 @@ module Fog
|
|
|
24
24
|
|
|
25
25
|
class Mock
|
|
26
26
|
def get_domain(zone_name)
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
response = Excon::Response.new
|
|
28
|
+
|
|
29
|
+
payload = self.data[:domains].find { |domain| domain["id"] == zone_name || domain["name"] == zone_name }
|
|
30
|
+
if payload
|
|
31
|
+
response.status = 200
|
|
32
|
+
response.body = { "data" => payload }
|
|
33
|
+
else
|
|
34
|
+
# response.status = 404
|
|
35
|
+
# response.body = { "message" => "Domain `#{zone_name}` not found" }
|
|
36
|
+
raise Excon::Errors::NotFound, "Domain `#{zone_name}` not found"
|
|
29
37
|
end
|
|
30
38
|
|
|
31
|
-
response = Excon::Response.new
|
|
32
|
-
response.status = 200
|
|
33
|
-
response.body = { "data" => domain }
|
|
34
39
|
response
|
|
35
40
|
end
|
|
36
41
|
end
|
|
@@ -26,21 +26,22 @@ module Fog
|
|
|
26
26
|
response = Excon::Response.new
|
|
27
27
|
|
|
28
28
|
if self.data[:records].key?(zone_name)
|
|
29
|
-
|
|
30
|
-
response.body = { "data" => self.data[:records][zone_name].find { |record| record["id"] == record_id }}
|
|
29
|
+
payload = self.data[:records][zone_name].find { |record| record["id"] == record_id }
|
|
31
30
|
|
|
32
|
-
if
|
|
33
|
-
response.status =
|
|
34
|
-
response.body = {
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
if payload
|
|
32
|
+
response.status = 200
|
|
33
|
+
response.body = { "data" => payload }
|
|
34
|
+
else
|
|
35
|
+
# response.status = 404
|
|
36
|
+
# response.body = { "message" => "Record `#{record_id}` not found" }
|
|
37
|
+
raise Excon::Errors::NotFound, "Record `#{record_id}` not found"
|
|
37
38
|
end
|
|
38
39
|
else
|
|
39
|
-
response.status = 404
|
|
40
|
-
response.body = {
|
|
41
|
-
|
|
42
|
-
}
|
|
40
|
+
# response.status = 404
|
|
41
|
+
# response.body = { "message" => "Domain `#{zone_name}` not found" }
|
|
42
|
+
raise Excon::Errors::NotFound, "Domain `#{zone_name}` not found"
|
|
43
43
|
end
|
|
44
|
+
|
|
44
45
|
response
|
|
45
46
|
end
|
|
46
47
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module DNS
|
|
3
|
+
class Dnsimple
|
|
4
|
+
class Real
|
|
5
|
+
# Get the list of ALL domains in the account.
|
|
6
|
+
#
|
|
7
|
+
# This method is similar to #list_domains, but instead of returning the results
|
|
8
|
+
# of a specific page it iterates all the pages and returns the entire collection.
|
|
9
|
+
#
|
|
10
|
+
# Please use this method carefully, as fetching the entire collection will increase
|
|
11
|
+
# the number of requests you send to the API server and you may eventually be rate-limited.
|
|
12
|
+
#
|
|
13
|
+
# @see https://developer.dnsimple.com/v2/domains/#list
|
|
14
|
+
# @see https://github.com/dnsimple/dnsimple-developer/tree/master/fixtures/v2/listDomains
|
|
15
|
+
#
|
|
16
|
+
# @param query [Hash]
|
|
17
|
+
# @return [Excon::Response]
|
|
18
|
+
def list_all_domains(query: {})
|
|
19
|
+
paginate(query: query) do |current_query|
|
|
20
|
+
list_domains(query: current_query)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Mock
|
|
26
|
+
def list_all_domains(_query: {})
|
|
27
|
+
response = Excon::Response.new
|
|
28
|
+
response.status = 200
|
|
29
|
+
response.body = {
|
|
30
|
+
"data" => self.data[:domains],
|
|
31
|
+
"pagination" => { "current_page" => nil, "per_page" => nil, "total_entries" => 60, "total_pages" => 2 }
|
|
32
|
+
}
|
|
33
|
+
response
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module DNS
|
|
3
|
+
class Dnsimple
|
|
4
|
+
class Real
|
|
5
|
+
# Get the list of ALL records for the specific zone.
|
|
6
|
+
#
|
|
7
|
+
# This method is similar to #list_domains, but instead of returning the results
|
|
8
|
+
# of a specific page it iterates all the pages and returns the entire collection.
|
|
9
|
+
#
|
|
10
|
+
# Please use this method carefully, as fetching the entire collection will increase
|
|
11
|
+
# the number of requests you send to the API server and you may eventually be rate-limited.
|
|
12
|
+
#
|
|
13
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#list
|
|
14
|
+
# @see https://github.com/dnsimple/dnsimple-developer/tree/master/fixtures/v2/listZoneRecords
|
|
15
|
+
#
|
|
16
|
+
# @param zone_name [String]
|
|
17
|
+
# @param query [Hash]
|
|
18
|
+
# @return [Excon::Response]
|
|
19
|
+
def list_all_records(zone_name, query: {})
|
|
20
|
+
paginate(query: query) do |current_query|
|
|
21
|
+
list_records(zone_name, query: current_query)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Mock
|
|
27
|
+
def list_all_records(zone_name, _query: {})
|
|
28
|
+
response = Excon::Response.new
|
|
29
|
+
response.status = 200
|
|
30
|
+
response.body = {
|
|
31
|
+
"data" => Array(self.data[:records][zone_name]),
|
|
32
|
+
"pagination" => { "current_page" => nil, "per_page" => nil, "total_entries" => 60, "total_pages" => 2 }
|
|
33
|
+
}
|
|
34
|
+
response
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -2,29 +2,34 @@ module Fog
|
|
|
2
2
|
module DNS
|
|
3
3
|
class Dnsimple
|
|
4
4
|
class Real
|
|
5
|
-
# Get the list of domains in the account.
|
|
5
|
+
# Get the paginated list of domains in the account.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
7
|
+
# @see https://developer.dnsimple.com/v2/domains/#list
|
|
8
|
+
# @see https://github.com/dnsimple/dnsimple-developer/tree/master/fixtures/v2/listDomains
|
|
8
9
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
# * "data"<~Array>:
|
|
13
|
-
# * <~Hash> The representation of the domain.
|
|
14
|
-
def list_domains
|
|
10
|
+
# @param query [Hash]
|
|
11
|
+
# @return [Excon::Response]
|
|
12
|
+
def list_domains(query: {})
|
|
15
13
|
request(
|
|
16
|
-
expects:
|
|
17
|
-
method:
|
|
18
|
-
path:
|
|
14
|
+
expects: 200,
|
|
15
|
+
method: "GET",
|
|
16
|
+
path: "/#{@dnsimple_account}/domains",
|
|
17
|
+
query: query
|
|
19
18
|
)
|
|
20
19
|
end
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
class Mock
|
|
24
|
-
def list_domains
|
|
23
|
+
def list_domains(query: {})
|
|
24
|
+
page = query[:page] || 1
|
|
25
|
+
per_page = query[:per_page] || 30
|
|
26
|
+
|
|
25
27
|
response = Excon::Response.new
|
|
26
28
|
response.status = 200
|
|
27
|
-
response.body = {
|
|
29
|
+
response.body = {
|
|
30
|
+
"data" => self.data[:domains],
|
|
31
|
+
"pagination" => { "current_page" => page, "per_page" => per_page, "total_entries" => 60, "total_pages" => 2 }
|
|
32
|
+
}
|
|
28
33
|
response
|
|
29
34
|
end
|
|
30
35
|
end
|
|
@@ -2,30 +2,35 @@ module Fog
|
|
|
2
2
|
module DNS
|
|
3
3
|
class Dnsimple
|
|
4
4
|
class Real
|
|
5
|
-
# Get the list of records for the specific
|
|
5
|
+
# Get the paginated list of records for the specific zone.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
7
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#list
|
|
8
|
+
# @see https://github.com/dnsimple/dnsimple-developer/tree/master/fixtures/v2/listZoneRecords
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
# * <~Hash> The representation of the record.
|
|
15
|
-
def list_records(zone_name)
|
|
10
|
+
# @param zone_name [String]
|
|
11
|
+
# @param query [Hash]
|
|
12
|
+
# @return [Excon::Response]
|
|
13
|
+
def list_records(zone_name, query: {})
|
|
16
14
|
request(
|
|
17
|
-
expects:
|
|
18
|
-
method:
|
|
19
|
-
path:
|
|
15
|
+
expects: 200,
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/#{@dnsimple_account}/zones/#{zone_name}/records",
|
|
18
|
+
query: query
|
|
20
19
|
)
|
|
21
20
|
end
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
class Mock
|
|
25
|
-
def list_records(zone_name)
|
|
24
|
+
def list_records(zone_name, query: {})
|
|
25
|
+
page = query[:page] || 1
|
|
26
|
+
per_page = query[:per_page] || 30
|
|
27
|
+
|
|
26
28
|
response = Excon::Response.new
|
|
27
29
|
response.status = 200
|
|
28
|
-
response.body = {
|
|
30
|
+
response.body = {
|
|
31
|
+
"data" => Array(self.data[:records][zone_name]),
|
|
32
|
+
"pagination" => { "current_page" => page, "per_page" => per_page, "total_entries" => 60, "total_pages" => 2 }
|
|
33
|
+
}
|
|
29
34
|
response
|
|
30
35
|
end
|
|
31
36
|
end
|
data/lib/fog/dnsimple/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fog-dnsimple
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simone Carletti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -39,19 +39,33 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '12.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: minitest
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0
|
|
47
|
+
version: '0'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: minitest-reporters
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0
|
|
68
|
+
version: '0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: fog-core
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -76,16 +90,16 @@ dependencies:
|
|
|
76
90
|
name: fog-json
|
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
|
78
92
|
requirements:
|
|
79
|
-
- - "
|
|
93
|
+
- - ">="
|
|
80
94
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
95
|
+
version: '0'
|
|
82
96
|
type: :runtime
|
|
83
97
|
prerelease: false
|
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
99
|
requirements:
|
|
86
|
-
- - "
|
|
100
|
+
- - ">="
|
|
87
101
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
102
|
+
version: '0'
|
|
89
103
|
description: |-
|
|
90
104
|
This library can be used as a module for `fog` or as standalone provider
|
|
91
105
|
to use the DNSimple in applications.
|
|
@@ -100,7 +114,7 @@ files:
|
|
|
100
114
|
- ".travis.yml"
|
|
101
115
|
- CHANGELOG.md
|
|
102
116
|
- Gemfile
|
|
103
|
-
- LICENSE.
|
|
117
|
+
- LICENSE.txt
|
|
104
118
|
- README.md
|
|
105
119
|
- Rakefile
|
|
106
120
|
- bin/console
|
|
@@ -119,18 +133,12 @@ files:
|
|
|
119
133
|
- lib/fog/dnsimple/requests/dns/delete_record.rb
|
|
120
134
|
- lib/fog/dnsimple/requests/dns/get_domain.rb
|
|
121
135
|
- lib/fog/dnsimple/requests/dns/get_record.rb
|
|
136
|
+
- lib/fog/dnsimple/requests/dns/list_all_domains.rb
|
|
137
|
+
- lib/fog/dnsimple/requests/dns/list_all_records.rb
|
|
122
138
|
- lib/fog/dnsimple/requests/dns/list_domains.rb
|
|
123
139
|
- lib/fog/dnsimple/requests/dns/list_records.rb
|
|
124
140
|
- lib/fog/dnsimple/requests/dns/update_record.rb
|
|
125
141
|
- lib/fog/dnsimple/version.rb
|
|
126
|
-
- tests/dns/helper.rb
|
|
127
|
-
- tests/dns/models/record_tests.rb
|
|
128
|
-
- tests/dns/models/records_tests.rb
|
|
129
|
-
- tests/dns/models/zone_tests.rb
|
|
130
|
-
- tests/dns/models/zones_tests.rb
|
|
131
|
-
- tests/helper.rb
|
|
132
|
-
- tests/helpers/mock_helper.rb
|
|
133
|
-
- tests/requests/dns/dns_tests.rb
|
|
134
142
|
homepage: https://github.com/fog/fog-dnsimple
|
|
135
143
|
licenses:
|
|
136
144
|
- MIT
|
|
@@ -143,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
143
151
|
requirements:
|
|
144
152
|
- - ">="
|
|
145
153
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: '
|
|
154
|
+
version: '2.1'
|
|
147
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
156
|
requirements:
|
|
149
157
|
- - ">="
|
|
@@ -151,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
159
|
version: '0'
|
|
152
160
|
requirements: []
|
|
153
161
|
rubyforge_project:
|
|
154
|
-
rubygems_version: 2.
|
|
162
|
+
rubygems_version: 2.7.3
|
|
155
163
|
signing_key:
|
|
156
164
|
specification_version: 4
|
|
157
165
|
summary: Module for the 'fog' gem to support DNSimple.
|
data/LICENSE.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016-2016 Aetrion LLC.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/tests/dns/helper.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
def dns_providers
|
|
2
|
-
{
|
|
3
|
-
:dnsimple => {
|
|
4
|
-
:mocked => false
|
|
5
|
-
},
|
|
6
|
-
}
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def generate_unique_domain( with_trailing_dot = false)
|
|
10
|
-
#get time (with 1/100th of sec accuracy)
|
|
11
|
-
#want unique domain name and if provider is fast, this can be called more than once per second
|
|
12
|
-
time= (Time.now.to_f * 100).to_i
|
|
13
|
-
domain = 'test-' + time.to_s + '.com'
|
|
14
|
-
if with_trailing_dot
|
|
15
|
-
domain+= '.'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
domain
|
|
19
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
for provider, config in dns_providers
|
|
2
|
-
|
|
3
|
-
domain_name = uniq_id + '.com'
|
|
4
|
-
|
|
5
|
-
Shindo.tests("Fog::DNS[:#{provider}] | record", [provider.to_s]) do
|
|
6
|
-
|
|
7
|
-
a_record_attributes = {
|
|
8
|
-
:name => 'a.' + domain_name,
|
|
9
|
-
:type => 'A',
|
|
10
|
-
:value => '1.2.3.4'
|
|
11
|
-
}.merge!(config[:record_attributes] || {})
|
|
12
|
-
|
|
13
|
-
aaaa_record_attributes = {
|
|
14
|
-
:name => 'aaaa.' + domain_name,
|
|
15
|
-
:type => 'AAAA',
|
|
16
|
-
:value => '2001:0db8:0000:0000:0000:ff00:0042:8329'
|
|
17
|
-
}.merge!(config[:record_attributes] || {})
|
|
18
|
-
|
|
19
|
-
cname_record_attributes = {
|
|
20
|
-
:name => 'cname.' + domain_name,
|
|
21
|
-
:type => 'CNAME',
|
|
22
|
-
:value => 'real.' + domain_name
|
|
23
|
-
}.merge!(config[:record_attributes] || {})
|
|
24
|
-
|
|
25
|
-
if !Fog.mocking? || config[:mocked]
|
|
26
|
-
zone_attributes = {
|
|
27
|
-
:domain => domain_name
|
|
28
|
-
}.merge(config[:zone_attributes] || {})
|
|
29
|
-
|
|
30
|
-
@zone = Fog::DNS[provider].zones.create(zone_attributes)
|
|
31
|
-
|
|
32
|
-
model_tests(@zone.records, a_record_attributes, config[:mocked])
|
|
33
|
-
model_tests(@zone.records, aaaa_record_attributes, config[:mocked])
|
|
34
|
-
model_tests(@zone.records, cname_record_attributes, config[:mocked])
|
|
35
|
-
|
|
36
|
-
@zone.destroy
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
for provider, config in dns_providers
|
|
2
|
-
|
|
3
|
-
domain_name = uniq_id + '.com'
|
|
4
|
-
|
|
5
|
-
Shindo.tests("Fog::DNS[:#{provider}] | records", [provider.to_s]) do
|
|
6
|
-
|
|
7
|
-
record_attributes = {
|
|
8
|
-
:name => 'www.' + domain_name,
|
|
9
|
-
:type => 'A',
|
|
10
|
-
:value => '1.2.3.4'
|
|
11
|
-
}.merge!(config[:record_attributes] || {})
|
|
12
|
-
|
|
13
|
-
if !Fog.mocking? || config[:mocked]
|
|
14
|
-
zone_attributes = {
|
|
15
|
-
:domain => domain_name
|
|
16
|
-
}.merge(config[:zone_attributes] || {})
|
|
17
|
-
|
|
18
|
-
@zone = Fog::DNS[provider].zones.create(zone_attributes)
|
|
19
|
-
|
|
20
|
-
collection_tests(@zone.records, record_attributes, config[:mocked])
|
|
21
|
-
|
|
22
|
-
@zone.destroy
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
for provider, config in dns_providers
|
|
2
|
-
|
|
3
|
-
domain_name = uniq_id + '.com'
|
|
4
|
-
|
|
5
|
-
Shindo.tests("Fog::DNS[:#{provider}] | zone", [provider.to_s]) do
|
|
6
|
-
|
|
7
|
-
zone_attributes = {
|
|
8
|
-
:domain => domain_name
|
|
9
|
-
}.merge!(config[:zone_attributes] || {})
|
|
10
|
-
|
|
11
|
-
model_tests(Fog::DNS[provider].zones, zone_attributes, config[:mocked])
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
for provider, config in dns_providers
|
|
2
|
-
|
|
3
|
-
domain_name = uniq_id + '.com'
|
|
4
|
-
|
|
5
|
-
Shindo.tests("Fog::DNS[:#{provider}] | zones", [provider.to_s]) do
|
|
6
|
-
|
|
7
|
-
zone_attributes = {
|
|
8
|
-
:domain => domain_name
|
|
9
|
-
}.merge!(config[:zone_attributes] || {})
|
|
10
|
-
|
|
11
|
-
collection_tests(Fog::DNS[provider].zones, zone_attributes, config[:mocked])
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
end
|
data/tests/helper.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'codeclimate-test-reporter'
|
|
3
|
-
CodeClimate::TestReporter.start
|
|
4
|
-
rescue LoadError => e
|
|
5
|
-
$stderr.puts "not recording test coverage: #{e.inspect}"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
require 'fog/test_helpers'
|
|
9
|
-
require File.expand_path('../../lib/fog/dnsimple', __FILE__)
|
|
10
|
-
|
|
11
|
-
Excon.defaults.merge!(:debug_request => true, :debug_response => true)
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
|
|
2
|
-
|
|
3
|
-
@domain = nil
|
|
4
|
-
@domain_count = 0
|
|
5
|
-
|
|
6
|
-
tests("success") do
|
|
7
|
-
|
|
8
|
-
test("get current domain count") do
|
|
9
|
-
response = Fog::DNS[:dnsimple].list_domains
|
|
10
|
-
if response.status == 200
|
|
11
|
-
@domain_count = response.body["data"].size
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
response.status == 200
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
test("create domain") do
|
|
18
|
-
domain = generate_unique_domain
|
|
19
|
-
response = Fog::DNS[:dnsimple].create_domain(domain)
|
|
20
|
-
if response.status == 201
|
|
21
|
-
@domain = response.body["data"]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
response.status == 201
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
test("get domain by id") do
|
|
28
|
-
response = Fog::DNS[:dnsimple].get_domain(@domain["id"])
|
|
29
|
-
response.status == 200
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
test("create an A resource record") do
|
|
33
|
-
domain = @domain["name"]
|
|
34
|
-
name = "www"
|
|
35
|
-
type = "A"
|
|
36
|
-
content = "1.2.3.4"
|
|
37
|
-
response = Fog::DNS[:dnsimple].create_record(domain, name, type, content)
|
|
38
|
-
|
|
39
|
-
if response.status == 201
|
|
40
|
-
@record = response.body["data"]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
response.status == 201
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
test("create a MX record") do
|
|
48
|
-
domain = @domain["name"]
|
|
49
|
-
name = ""
|
|
50
|
-
type = "MX"
|
|
51
|
-
content = "mail.#{domain}"
|
|
52
|
-
options = { "ttl" => 60, "priority" => 10 }
|
|
53
|
-
response = Fog::DNS[:dnsimple].create_record(domain, name, type, content, options)
|
|
54
|
-
|
|
55
|
-
test "MX record creation returns 201" do
|
|
56
|
-
response.status == 201
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
options.each do |key, value|
|
|
60
|
-
test("MX record has option #{key}") { value == response.body["data"][key.to_s] }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
test "MX record is correct type" do
|
|
64
|
-
response.body["data"]["type"] == "MX"
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
test("get a record") do
|
|
69
|
-
domain = @domain["name"]
|
|
70
|
-
record_id = @record["id"]
|
|
71
|
-
|
|
72
|
-
response = Fog::DNS[:dnsimple].get_record(domain, record_id)
|
|
73
|
-
|
|
74
|
-
(response.status == 200) and (@record == response.body["data"])
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
test("update a record") do
|
|
78
|
-
domain = @domain["name"]
|
|
79
|
-
record_id = @record["id"]
|
|
80
|
-
options = { "content" => "2.3.4.5", "ttl" => 600 }
|
|
81
|
-
response = Fog::DNS[:dnsimple].update_record(domain, record_id, options)
|
|
82
|
-
response.status == 200
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
test("list records") do
|
|
86
|
-
response = Fog::DNS[:dnsimple].list_records(@domain["name"])
|
|
87
|
-
|
|
88
|
-
if response.status == 200
|
|
89
|
-
@records = response.body["data"]
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
test "list records returns all records for domain" do
|
|
93
|
-
@records.reject { |record| record["system_record"] }.size == 2
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
response.status == 200
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
test("delete records") do
|
|
100
|
-
domain = @domain["name"]
|
|
101
|
-
|
|
102
|
-
result = true
|
|
103
|
-
@records.each do |record|
|
|
104
|
-
next if record["system_record"]
|
|
105
|
-
response = Fog::DNS[:dnsimple].delete_record(domain, record["id"])
|
|
106
|
-
if response.status != 204
|
|
107
|
-
result = false
|
|
108
|
-
break
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
result
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
test("delete domain") do
|
|
116
|
-
response = Fog::DNS[:dnsimple].delete_domain(@domain["name"])
|
|
117
|
-
response.status == 204
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
end
|