dnsimple 4.4.0 → 4.5.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/.rubocop_dnsimple.yml +34 -2
- data/.travis.yml +5 -1
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +12 -7
- data/README.md +1 -2
- data/dnsimple.gemspec +1 -1
- data/lib/dnsimple/client.rb +1 -1
- data/lib/dnsimple/client/accounts.rb +0 -1
- data/lib/dnsimple/client/certificates.rb +1 -0
- data/lib/dnsimple/client/clients.rb +4 -2
- data/lib/dnsimple/client/contacts.rb +0 -5
- data/lib/dnsimple/client/domains.rb +0 -4
- data/lib/dnsimple/client/{collaborators.rb → domains_collaborators.rb} +1 -1
- data/lib/dnsimple/client/registrar_delegation.rb +4 -4
- data/lib/dnsimple/client/services.rb +0 -2
- data/lib/dnsimple/client/tlds.rb +14 -17
- data/lib/dnsimple/client/webhooks.rb +0 -3
- data/lib/dnsimple/client/zones.rb +0 -1
- data/lib/dnsimple/client/zones_distributions.rb +47 -0
- data/lib/dnsimple/client/zones_records.rb +23 -28
- data/lib/dnsimple/struct.rb +2 -0
- data/lib/dnsimple/struct/vanity_name_server.rb +25 -0
- data/lib/dnsimple/struct/zone_distribution.rb +11 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/{collaborators_spec.rb → domains_collaborators_spec.rb} +0 -0
- data/spec/dnsimple/client/registrar_delegation_spec.rb +3 -2
- data/spec/dnsimple/client/tlds_spec.rb +13 -12
- data/spec/dnsimple/client/zones_distributions_spec.rb +135 -0
- data/spec/dnsimple/client/zones_records_spec.rb +33 -33
- data/spec/dnsimple/client_spec.rb +5 -5
- data/spec/fixtures.http/checkZoneDistribution/error.http +21 -0
- data/spec/fixtures.http/checkZoneDistribution/failure.http +21 -0
- data/spec/fixtures.http/checkZoneDistribution/success.http +21 -0
- data/spec/fixtures.http/checkZoneRecordDistribution/error.http +21 -0
- data/spec/fixtures.http/checkZoneRecordDistribution/failure.http +21 -0
- data/spec/fixtures.http/checkZoneRecordDistribution/success.http +21 -0
- data/spec/spec_helper.rb +1 -1
- metadata +24 -7
@@ -28,7 +28,6 @@ module Dnsimple
|
|
28
28
|
|
29
29
|
Dnsimple::CollectionResponse.new(response, response["data"].map { |r| Struct::Webhook.new(r) })
|
30
30
|
end
|
31
|
-
alias list webhooks
|
32
31
|
alias list_webhooks webhooks
|
33
32
|
|
34
33
|
# Creates a webhook in the account.
|
@@ -47,7 +46,6 @@ module Dnsimple
|
|
47
46
|
|
48
47
|
Dnsimple::Response.new(response, Struct::Webhook.new(response["data"]))
|
49
48
|
end
|
50
|
-
alias create create_webhook
|
51
49
|
|
52
50
|
# Gets a webhook from the account.
|
53
51
|
#
|
@@ -84,7 +82,6 @@ module Dnsimple
|
|
84
82
|
|
85
83
|
Dnsimple::Response.new(response, nil)
|
86
84
|
end
|
87
|
-
alias delete delete_webhook
|
88
85
|
|
89
86
|
end
|
90
87
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class Client
|
3
|
+
module ZonesDistributions
|
4
|
+
|
5
|
+
# Checks if a zone change is fully distributed to all DNSimple name
|
6
|
+
# servers across the globe.
|
7
|
+
#
|
8
|
+
# @see https://developer.dnsimple.com/v2/zones/#checkZoneDistribution
|
9
|
+
#
|
10
|
+
# @param account_id [Integer] the account ID
|
11
|
+
# @param zone_id [#to_s] the zone name
|
12
|
+
# @param options [Hash]
|
13
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::ZoneDistribution>]
|
14
|
+
#
|
15
|
+
# @raise [Dnsimple::NotFoundError]
|
16
|
+
# @raise [Dnsimple::RequestError]
|
17
|
+
def zone_distribution(account_id, zone_id, options = {})
|
18
|
+
response = client.get(Client.versioned("/%s/zones/%s/distribution" % [account_id, zone_id]), options)
|
19
|
+
|
20
|
+
Dnsimple::Response.new(response, Struct::ZoneDistribution.new(response["data"]))
|
21
|
+
end
|
22
|
+
|
23
|
+
# Checks if a zone record is fully distributed to all DNSimple name
|
24
|
+
# servers across the globe.
|
25
|
+
#
|
26
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#checkZoneRecordDistribution
|
27
|
+
#
|
28
|
+
# @example Get record 123 in zone "example.com"
|
29
|
+
# client.zones.zone_record_distribution(1010, "example.com", 123)
|
30
|
+
#
|
31
|
+
# @param [Integer] account_id the account ID
|
32
|
+
# @param [String] zone_id the zone name
|
33
|
+
# @param [Integer] record_id the record ID
|
34
|
+
# @param [Hash] options
|
35
|
+
# @return [Dnsimple::Response<Dnsimple::Struct::ZoneDistribution>]
|
36
|
+
#
|
37
|
+
# @raise [Dnsimple::NotFoundError]
|
38
|
+
# @raise [Dnsimple::RequestError]
|
39
|
+
def zone_record_distribution(account_id, zone_id, record_id, options = {})
|
40
|
+
response = client.get(Client.versioned("/%s/zones/%s/records/%s/distribution" % [account_id, zone_id, record_id]), options)
|
41
|
+
|
42
|
+
Dnsimple::Response.new(response, Struct::ZoneDistribution.new(response["data"]))
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -4,20 +4,20 @@ module Dnsimple
|
|
4
4
|
|
5
5
|
# Lists the zone records in the account.
|
6
6
|
#
|
7
|
-
# @see https://developer.dnsimple.com/v2/zones/records/#
|
7
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#listZoneRecords
|
8
8
|
# @see #all_records
|
9
9
|
#
|
10
10
|
# @example List records for the zone "example.com" in the first page
|
11
|
-
# client.zones.
|
11
|
+
# client.zones.list_zone_records(1010, "example.com")
|
12
12
|
#
|
13
13
|
# @example List records for the zone "example.com", provide a specific page
|
14
|
-
# client.zones.
|
14
|
+
# client.zones.list_zone_records(1010, "example.com", page: 2)
|
15
15
|
#
|
16
16
|
# @example List records for the zone "example.com", sorting in ascending order
|
17
|
-
# client.zones.
|
17
|
+
# client.zones.list_zone_records(1010, "example.com", sort: "type:asc")
|
18
18
|
#
|
19
19
|
# @example List records for the zone "example.com", filtering by 'A' record type
|
20
|
-
# client.zones.
|
20
|
+
# client.zones.list_zone_records(1010, "example.com", filter: { type: 'A' })
|
21
21
|
#
|
22
22
|
# @param [Integer] account_id the account ID
|
23
23
|
# @param [String] zone_id the zone name
|
@@ -30,13 +30,12 @@ module Dnsimple
|
|
30
30
|
#
|
31
31
|
# @raise [Dnsimple::NotFoundError]
|
32
32
|
# @raise [Dnsimple::RequestError]
|
33
|
-
def
|
33
|
+
def zone_records(account_id, zone_id, options = {})
|
34
34
|
response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), Options::ListOptions.new(options))
|
35
35
|
|
36
36
|
Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::ZoneRecord.new(r) })
|
37
37
|
end
|
38
|
-
alias
|
39
|
-
alias list_records records
|
38
|
+
alias list_zone_records zone_records
|
40
39
|
|
41
40
|
# Lists ALL the zone records in the account.
|
42
41
|
#
|
@@ -46,11 +45,11 @@ module Dnsimple
|
|
46
45
|
# Please use this method carefully, as fetching the entire collection will increase the number of requests
|
47
46
|
# you send to the API server and you may eventually risk to hit the throttle limit.
|
48
47
|
#
|
49
|
-
# @see https://developer.dnsimple.com/v2/zones/records/#
|
48
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#listZoneRecords
|
50
49
|
# @see #records
|
51
50
|
#
|
52
51
|
# @example List all records for the zone "example.com"
|
53
|
-
# client.zones.
|
52
|
+
# client.zones.all_zone_records(1010, "example.com")
|
54
53
|
#
|
55
54
|
# @param [Integer] account_id the account ID
|
56
55
|
# @param [String] zone_id the zone name
|
@@ -63,17 +62,16 @@ module Dnsimple
|
|
63
62
|
#
|
64
63
|
# @raise [Dnsimple::NotFoundError]
|
65
64
|
# @raise [Dnsimple::RequestError]
|
66
|
-
def
|
67
|
-
paginate(:
|
65
|
+
def all_zone_records(account_id, zone_id, options = {})
|
66
|
+
paginate(:list_zone_records, account_id, zone_id, options)
|
68
67
|
end
|
69
|
-
alias all all_records
|
70
68
|
|
71
69
|
# Creates a zone record in the account.
|
72
70
|
#
|
73
|
-
# @see https://developer.dnsimple.com/v2/zones/records/#
|
71
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#createZoneRecord
|
74
72
|
#
|
75
73
|
# @example Create a URL record in zone "example.com"
|
76
|
-
# client.zones.
|
74
|
+
# client.zones.create_zone_record(1010, "example.com", name: "www", type: "url", content: "example.com")
|
77
75
|
#
|
78
76
|
# @param [Integer] account_id the account ID
|
79
77
|
# @param [String] zone_id the zone name
|
@@ -83,20 +81,19 @@ module Dnsimple
|
|
83
81
|
#
|
84
82
|
# @raise [Dnsimple::NotFoundError]
|
85
83
|
# @raise [Dnsimple::RequestError]
|
86
|
-
def
|
84
|
+
def create_zone_record(account_id, zone_id, attributes, options = {})
|
87
85
|
Extra.validate_mandatory_attributes(attributes, [:type, :name, :content])
|
88
86
|
response = client.post(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), attributes, options)
|
89
87
|
|
90
88
|
Dnsimple::Response.new(response, Struct::ZoneRecord.new(response["data"]))
|
91
89
|
end
|
92
|
-
alias create create_record
|
93
90
|
|
94
91
|
# Gets a zone record from the account.
|
95
92
|
#
|
96
|
-
# @see https://developer.dnsimple.com/v2/zones/records/#
|
93
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#getZoneRecord
|
97
94
|
#
|
98
95
|
# @example Get record 123 in zone "example.com"
|
99
|
-
# client.zones.
|
96
|
+
# client.zones.zone_record(1010, "example.com", 123)
|
100
97
|
#
|
101
98
|
# @param [Integer] account_id the account ID
|
102
99
|
# @param [String] zone_id the zone name
|
@@ -106,7 +103,7 @@ module Dnsimple
|
|
106
103
|
#
|
107
104
|
# @raise [Dnsimple::NotFoundError]
|
108
105
|
# @raise [Dnsimple::RequestError]
|
109
|
-
def
|
106
|
+
def zone_record(account_id, zone_id, record_id, options = {})
|
110
107
|
response = client.get(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), options)
|
111
108
|
|
112
109
|
Dnsimple::Response.new(response, Struct::ZoneRecord.new(response["data"]))
|
@@ -114,10 +111,10 @@ module Dnsimple
|
|
114
111
|
|
115
112
|
# Updates a zone record in the account.
|
116
113
|
#
|
117
|
-
# @see https://developer.dnsimple.com/v2/zones/records/#
|
114
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#updateZoneRecord
|
118
115
|
#
|
119
116
|
# @example Update the TTL to 600 of record 123 in zone "example.com"
|
120
|
-
# client.zones.
|
117
|
+
# client.zones.update_zone_record(1010, "example.com", 123, ttl: 600)
|
121
118
|
#
|
122
119
|
# @param [Integer] account_id the account ID
|
123
120
|
# @param [String] zone_id the zone name
|
@@ -128,21 +125,20 @@ module Dnsimple
|
|
128
125
|
#
|
129
126
|
# @raise [Dnsimple::NotFoundError]
|
130
127
|
# @raise [Dnsimple::RequestError]
|
131
|
-
def
|
128
|
+
def update_zone_record(account_id, zone_id, record_id, attributes, options = {})
|
132
129
|
response = client.patch(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), attributes, options)
|
133
130
|
|
134
131
|
Dnsimple::Response.new(response, Struct::ZoneRecord.new(response["data"]))
|
135
132
|
end
|
136
|
-
alias update update_record
|
137
133
|
|
138
134
|
# Deletes a zone record from the account.
|
139
135
|
#
|
140
136
|
# WARNING: this cannot be undone.
|
141
137
|
#
|
142
|
-
# @see https://developer.dnsimple.com/v2/zones/records/#
|
138
|
+
# @see https://developer.dnsimple.com/v2/zones/records/#deleteZoneRecord
|
143
139
|
#
|
144
140
|
# @example Delete record 123 in zone "example.com"
|
145
|
-
# client.zones.
|
141
|
+
# client.zones.delete_zone_record(1010, "example.com", 123)
|
146
142
|
#
|
147
143
|
# @param [Integer] account_id the account ID
|
148
144
|
# @param [String] zone_id the zone name
|
@@ -152,12 +148,11 @@ module Dnsimple
|
|
152
148
|
#
|
153
149
|
# @raise [Dnsimple::NotFoundError]
|
154
150
|
# @raise [Dnsimple::RequestError]
|
155
|
-
def
|
151
|
+
def delete_zone_record(account_id, zone_id, record_id, options = {})
|
156
152
|
response = client.delete(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), nil, options)
|
157
153
|
|
158
154
|
Dnsimple::Response.new(response, nil)
|
159
155
|
end
|
160
|
-
alias delete delete_record
|
161
156
|
|
162
157
|
end
|
163
158
|
end
|
data/lib/dnsimple/struct.rb
CHANGED
@@ -38,8 +38,10 @@ require_relative 'struct/template'
|
|
38
38
|
require_relative 'struct/template_record'
|
39
39
|
require_relative 'struct/tld'
|
40
40
|
require_relative 'struct/user'
|
41
|
+
require_relative 'struct/vanity_name_server'
|
41
42
|
require_relative 'struct/whois_privacy'
|
42
43
|
require_relative 'struct/zone'
|
43
44
|
require_relative 'struct/zone_file'
|
45
|
+
require_relative 'struct/zone_distribution'
|
44
46
|
require_relative 'struct/webhook'
|
45
47
|
require_relative 'struct/whoami'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
module Struct
|
3
|
+
|
4
|
+
class VanityNameServer < Base
|
5
|
+
# @return [Integer] The vanity name server ID in DNSimple.
|
6
|
+
attr_accessor :id
|
7
|
+
|
8
|
+
# @return [String] The vanity name server name.
|
9
|
+
attr_accessor :name
|
10
|
+
|
11
|
+
# @return [String] The vanity name server IPv4.
|
12
|
+
attr_accessor :ipv4
|
13
|
+
|
14
|
+
# @return [String] The vanity name server IPv6.
|
15
|
+
attr_accessor :ipv6
|
16
|
+
|
17
|
+
# @return [String] When the vanity name server was created in DNSimple.
|
18
|
+
attr_accessor :created_at
|
19
|
+
|
20
|
+
# @return [String] When the vanity name server was last updated in DNSimple.
|
21
|
+
attr_accessor :updated_at
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/dnsimple/version.rb
CHANGED
File without changes
|
@@ -75,8 +75,9 @@ describe Dnsimple::Client, ".registrar" do
|
|
75
75
|
response = subject.change_domain_delegation_to_vanity(account_id, "example.com", attributes)
|
76
76
|
expect(response).to be_a(Dnsimple::Response)
|
77
77
|
|
78
|
-
|
79
|
-
expect(
|
78
|
+
vanity_name_server = response.data.first
|
79
|
+
expect(vanity_name_server).to be_a(Dnsimple::Struct::VanityNameServer)
|
80
|
+
expect(vanity_name_server.name).to eq("ns1.example.com")
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -3,39 +3,39 @@ require 'spec_helper'
|
|
3
3
|
describe Dnsimple::Client, ".tlds" do
|
4
4
|
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").tlds }
|
5
5
|
|
6
|
-
describe "#
|
6
|
+
describe "#list_tlds" do
|
7
7
|
before do
|
8
8
|
stub_request(:get, %r{/v2/tlds})
|
9
9
|
.to_return(read_http_fixture("listTlds/success.http"))
|
10
10
|
end
|
11
11
|
|
12
12
|
it "builds the correct request" do
|
13
|
-
subject.
|
13
|
+
subject.list_tlds
|
14
14
|
|
15
15
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds")
|
16
16
|
.with(headers: { 'Accept' => 'application/json' })
|
17
17
|
end
|
18
18
|
|
19
19
|
it "supports pagination" do
|
20
|
-
subject.
|
20
|
+
subject.list_tlds(page: 2)
|
21
21
|
|
22
22
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds?page=2")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "supports additional options" do
|
26
|
-
subject.
|
26
|
+
subject.list_tlds(query: { foo: "bar" })
|
27
27
|
|
28
28
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds?foo=bar")
|
29
29
|
end
|
30
30
|
|
31
31
|
it "supports sorting" do
|
32
|
-
subject.
|
32
|
+
subject.list_tlds(sort: "tld:asc")
|
33
33
|
|
34
34
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds?sort=tld:asc")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "returns the tlds" do
|
38
|
-
response = subject.
|
38
|
+
response = subject.list_tlds
|
39
39
|
|
40
40
|
expect(response).to be_a(Dnsimple::PaginatedResponse)
|
41
41
|
expect(response.data).to be_an(Array)
|
@@ -49,7 +49,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "exposes the pagination information" do
|
52
|
-
response = subject.
|
52
|
+
response = subject.list_tlds
|
53
53
|
|
54
54
|
expect(response.respond_to?(:page)).to be(true)
|
55
55
|
expect(response.page).to eq(1)
|
@@ -66,7 +66,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "delegates to client.paginate" do
|
69
|
-
expect(subject).to receive(:paginate).with(:
|
69
|
+
expect(subject).to receive(:paginate).with(:list_tlds, foo: "bar")
|
70
70
|
subject.all_tlds(foo: "bar")
|
71
71
|
end
|
72
72
|
|
@@ -108,21 +108,21 @@ describe Dnsimple::Client, ".tlds" do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
describe "#
|
111
|
+
describe "#tld_extended_attributes" do
|
112
112
|
before do
|
113
113
|
stub_request(:get, %r{/v2/tlds/uk/extended_attributes$})
|
114
114
|
.to_return(read_http_fixture("getTldExtendedAttributes/success.http"))
|
115
115
|
end
|
116
116
|
|
117
117
|
it "builds the correct request" do
|
118
|
-
subject.
|
118
|
+
subject.tld_extended_attributes(tld = "uk")
|
119
119
|
|
120
120
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/tlds/#{tld}/extended_attributes")
|
121
121
|
.with(headers: { 'Accept' => 'application/json' })
|
122
122
|
end
|
123
123
|
|
124
124
|
it "returns the extended attributes" do
|
125
|
-
response = subject.
|
125
|
+
response = subject.tld_extended_attributes("uk")
|
126
126
|
expect(response).to be_a(Dnsimple::CollectionResponse)
|
127
127
|
|
128
128
|
response.data.each do |result|
|
@@ -132,6 +132,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
132
132
|
expect(result).to respond_to(:required)
|
133
133
|
|
134
134
|
next if result.options.empty?
|
135
|
+
|
135
136
|
result.options.each do |option|
|
136
137
|
expect(option).to be_a(Dnsimple::Struct::ExtendedAttribute::Option)
|
137
138
|
expect(option.title).to be_a(String)
|
@@ -148,7 +149,7 @@ describe Dnsimple::Client, ".tlds" do
|
|
148
149
|
end
|
149
150
|
|
150
151
|
it "returns an empty CollectionResponse" do
|
151
|
-
response = subject.
|
152
|
+
response = subject.tld_extended_attributes("com")
|
152
153
|
expect(response).to be_a(Dnsimple::CollectionResponse)
|
153
154
|
|
154
155
|
result = response.data
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Client, ".zones" do
|
4
|
+
|
5
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").zones }
|
6
|
+
|
7
|
+
describe "#zone_distribution" do
|
8
|
+
let(:account_id) { 1010 }
|
9
|
+
|
10
|
+
before do
|
11
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$})
|
12
|
+
.to_return(read_http_fixture("checkZoneDistribution/success.http"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "builds the correct request" do
|
16
|
+
subject.zone_distribution(account_id, zone = "example.com")
|
17
|
+
|
18
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/distribution")
|
19
|
+
.with(headers: { 'Accept' => 'application/json' })
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns the zone distribution check with true when the zone is fully distributed" do
|
23
|
+
response = subject.zone_distribution(account_id, "example.com")
|
24
|
+
expect(response).to be_a(Dnsimple::Response)
|
25
|
+
|
26
|
+
result = response.data
|
27
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
28
|
+
expect(result.distributed).to be(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns the zone distribution check with false when the zone isn't fully distributed" do
|
32
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$})
|
33
|
+
.to_return(read_http_fixture("checkZoneDistribution/failure.http"))
|
34
|
+
|
35
|
+
response = subject.zone_distribution(account_id, "example.com")
|
36
|
+
expect(response).to be_a(Dnsimple::Response)
|
37
|
+
|
38
|
+
result = response.data
|
39
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
40
|
+
expect(result.distributed).to be(false)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises an error when the server wasn't able to complete the check" do
|
44
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/.+$})
|
45
|
+
.to_return(read_http_fixture("checkZoneDistribution/error.http"))
|
46
|
+
|
47
|
+
expect {
|
48
|
+
subject.zone_distribution(account_id, "example.com")
|
49
|
+
}.to raise_error(Dnsimple::RequestError, "Could not query zone, connection timed out")
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when the zone does not exist" do
|
53
|
+
it "raises NotFoundError" do
|
54
|
+
stub_request(:get, %r{/v2})
|
55
|
+
.to_return(read_http_fixture("notfound-zone.http"))
|
56
|
+
|
57
|
+
expect {
|
58
|
+
subject.zone_distribution(account_id, "example.com")
|
59
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
describe "#zone_record_distribution" do
|
66
|
+
let(:account_id) { 1010 }
|
67
|
+
let(:zone_id) { "example.com" }
|
68
|
+
let(:record_id) { 5 }
|
69
|
+
|
70
|
+
before do
|
71
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution$})
|
72
|
+
.to_return(read_http_fixture("checkZoneRecordDistribution/success.http"))
|
73
|
+
end
|
74
|
+
|
75
|
+
it "builds the correct request" do
|
76
|
+
subject.zone_record_distribution(account_id, zone_id, record_id)
|
77
|
+
|
78
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution")
|
79
|
+
.with(headers: { 'Accept' => 'application/json' })
|
80
|
+
end
|
81
|
+
|
82
|
+
it "returns the zone record distribution check with true when the zone is fully distributed" do
|
83
|
+
response = subject.zone_record_distribution(account_id, zone_id, record_id)
|
84
|
+
expect(response).to be_a(Dnsimple::Response)
|
85
|
+
|
86
|
+
result = response.data
|
87
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
88
|
+
expect(result.distributed).to be(true)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns the zone distribution check with false when the zone isn't fully distributed" do
|
92
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution$})
|
93
|
+
.to_return(read_http_fixture("checkZoneRecordDistribution/failure.http"))
|
94
|
+
|
95
|
+
response = subject.zone_record_distribution(account_id, zone_id, record_id)
|
96
|
+
expect(response).to be_a(Dnsimple::Response)
|
97
|
+
|
98
|
+
result = response.data
|
99
|
+
expect(result).to be_a(Dnsimple::Struct::ZoneDistribution)
|
100
|
+
expect(result.distributed).to be(false)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "raises an error when the server wasn't able to complete the check" do
|
104
|
+
stub_request(:get, %r{/v2/#{account_id}/zones/#{zone_id}/records/#{record_id}/distribution$})
|
105
|
+
.to_return(read_http_fixture("checkZoneRecordDistribution/error.http"))
|
106
|
+
|
107
|
+
expect {
|
108
|
+
subject.zone_record_distribution(account_id, zone_id, record_id)
|
109
|
+
}.to raise_error(Dnsimple::RequestError, "Could not query zone, connection timed out")
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when the zone does not exist" do
|
113
|
+
it "raises NotFoundError" do
|
114
|
+
stub_request(:get, %r{/v2})
|
115
|
+
.to_return(read_http_fixture("notfound-zone.http"))
|
116
|
+
|
117
|
+
expect {
|
118
|
+
subject.zone_record_distribution(account_id, zone_id, "0")
|
119
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "when the record does not exist" do
|
124
|
+
it "raises NotFoundError" do
|
125
|
+
stub_request(:get, %r{/v2})
|
126
|
+
.to_return(read_http_fixture("notfound-record.http"))
|
127
|
+
|
128
|
+
expect {
|
129
|
+
subject.zone_record_distribution(account_id, zone_id, "0")
|
130
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|