dnsimple 8.7.1 → 8.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/auto-merge.yml +1 -1
  3. data/.github/workflows/ci.yml +1 -13
  4. data/.github/workflows/release.yml +2 -2
  5. data/.rubocop_dnsimple.yml +19 -76
  6. data/CHANGELOG.md +4 -0
  7. data/Gemfile +5 -2
  8. data/lib/dnsimple/client/billing.rb +2 -0
  9. data/lib/dnsimple/client/clients.rb +45 -0
  10. data/lib/dnsimple/client/dns_analytics.rb +30 -0
  11. data/lib/dnsimple/client/domains.rb +1 -0
  12. data/lib/dnsimple/client/domains_dnssec.rb +1 -0
  13. data/lib/dnsimple/client/domains_pushes.rb +0 -1
  14. data/lib/dnsimple/client/identity.rb +2 -0
  15. data/lib/dnsimple/client/registrar.rb +1 -0
  16. data/lib/dnsimple/client/registrar_registrant_changes.rb +1 -0
  17. data/lib/dnsimple/client/services.rb +1 -0
  18. data/lib/dnsimple/client/templates_records.rb +1 -0
  19. data/lib/dnsimple/client/tlds.rb +2 -0
  20. data/lib/dnsimple/client.rb +0 -1
  21. data/lib/dnsimple/default.rb +1 -2
  22. data/lib/dnsimple/error.rb +8 -2
  23. data/lib/dnsimple/options.rb +10 -0
  24. data/lib/dnsimple/response.rb +12 -0
  25. data/lib/dnsimple/struct/account.rb +2 -2
  26. data/lib/dnsimple/struct/certificate.rb +2 -2
  27. data/lib/dnsimple/struct/certificate_bundle.rb +0 -2
  28. data/lib/dnsimple/struct/certificate_purchase.rb +2 -2
  29. data/lib/dnsimple/struct/certificate_renewal.rb +2 -2
  30. data/lib/dnsimple/struct/charge.rb +3 -1
  31. data/lib/dnsimple/struct/collaborator.rb +2 -2
  32. data/lib/dnsimple/struct/contact.rb +2 -2
  33. data/lib/dnsimple/struct/delegation_signer_record.rb +2 -2
  34. data/lib/dnsimple/struct/dns_analytics.rb +18 -0
  35. data/lib/dnsimple/struct/dnssec.rb +2 -2
  36. data/lib/dnsimple/struct/domain.rb +2 -1
  37. data/lib/dnsimple/struct/domain_check.rb +2 -2
  38. data/lib/dnsimple/struct/domain_premium_price.rb +2 -2
  39. data/lib/dnsimple/struct/domain_price.rb +2 -2
  40. data/lib/dnsimple/struct/domain_push.rb +2 -2
  41. data/lib/dnsimple/struct/domain_registration.rb +2 -2
  42. data/lib/dnsimple/struct/domain_renewal.rb +2 -2
  43. data/lib/dnsimple/struct/domain_transfer.rb +2 -2
  44. data/lib/dnsimple/struct/email_forward.rb +2 -1
  45. data/lib/dnsimple/struct/extended_attribute.rb +2 -2
  46. data/lib/dnsimple/struct/oauth_token.rb +2 -2
  47. data/lib/dnsimple/struct/registrant_change.rb +2 -1
  48. data/lib/dnsimple/struct/registrant_change_check.rb +2 -1
  49. data/lib/dnsimple/struct/service.rb +2 -2
  50. data/lib/dnsimple/struct/template.rb +2 -2
  51. data/lib/dnsimple/struct/template_record.rb +2 -2
  52. data/lib/dnsimple/struct/tld.rb +2 -2
  53. data/lib/dnsimple/struct/transfer_lock.rb +2 -2
  54. data/lib/dnsimple/struct/user.rb +2 -2
  55. data/lib/dnsimple/struct/vanity_name_server.rb +2 -2
  56. data/lib/dnsimple/struct/webhook.rb +2 -2
  57. data/lib/dnsimple/struct/whoami.rb +2 -2
  58. data/lib/dnsimple/struct/whois_privacy.rb +2 -2
  59. data/lib/dnsimple/struct/whois_privacy_renewal.rb +2 -2
  60. data/lib/dnsimple/struct/zone.rb +2 -2
  61. data/lib/dnsimple/struct/zone_distribution.rb +2 -2
  62. data/lib/dnsimple/struct/zone_file.rb +2 -2
  63. data/lib/dnsimple/struct/zone_record.rb +2 -2
  64. data/lib/dnsimple/struct.rb +4 -3
  65. data/lib/dnsimple/version.rb +3 -1
  66. data/spec/dnsimple/client/dns_analytics_spec.rb +84 -0
  67. data/spec/dnsimple/client/registrar_delegation_spec.rb +4 -4
  68. data/spec/dnsimple/client/vanity_name_servers_spec.rb +1 -1
  69. data/spec/dnsimple/client/zones_records_spec.rb +2 -2
  70. data/spec/dnsimple/client_spec.rb +2 -2
  71. data/spec/dnsimple/extra_spec.rb +1 -1
  72. data/spec/fixtures.http/dnsAnalytics/success.http +20 -0
  73. metadata +7 -3
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class Whoami < Base
6
+
7
7
  # @return [Account] The account, if present.
8
8
  attr_reader :account
9
9
 
@@ -26,7 +26,7 @@ module Dnsimple
26
26
  def user=(user)
27
27
  @user = user ? Struct::User.new(user) : user
28
28
  end
29
- end
30
29
 
30
+ end
31
31
  end
32
32
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class WhoisPrivacy < Base
6
+
7
7
  # @return [Integer] The associated domain ID.
8
8
  attr_accessor :domain_id
9
9
 
@@ -18,7 +18,7 @@ module Dnsimple
18
18
 
19
19
  # @return [String] When the whois privacy was last updated in DNSimple.
20
20
  attr_accessor :updated_at
21
- end
22
21
 
22
+ end
23
23
  end
24
24
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class WhoisPrivacyRenewal < Base
6
+
7
7
  # @return [Integer] The associated domain ID.
8
8
  attr_accessor :domain_id
9
9
 
@@ -24,7 +24,7 @@ module Dnsimple
24
24
 
25
25
  # @return [String] When the WHOIS Privacy was last updated in DNSimple.
26
26
  attr_accessor :updated_at
27
- end
28
27
 
28
+ end
29
29
  end
30
30
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class Zone < Base
6
+
7
7
  # @return [Integer] The zone ID in DNSimple.
8
8
  attr_accessor :id
9
9
 
@@ -30,7 +30,7 @@ module Dnsimple
30
30
 
31
31
  # @return [String] When the zone was last updated in DNSimple.
32
32
  attr_accessor :updated_at
33
- end
34
33
 
34
+ end
35
35
  end
36
36
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class ZoneDistribution < Base
6
+
7
7
  # @return [Boolean] true if the zone is properly distributed across
8
8
  # all DNSimple name servers.
9
9
  attr_accessor :distributed
10
- end
11
10
 
11
+ end
12
12
  end
13
13
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class ZoneFile < Base
6
+
7
7
  # @return [String] The zone file contents.
8
8
  attr_accessor :zone
9
- end
10
9
 
10
+ end
11
11
  end
12
12
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class ZoneRecord < Base
6
+
7
7
  # @return [Integer] The record ID in DNSimple.
8
8
  attr_accessor :id
9
9
 
@@ -39,7 +39,7 @@ module Dnsimple
39
39
 
40
40
  # @return [String] When the record was last updated in DNSimple.
41
41
  attr_accessor :updated_at
42
- end
43
42
 
43
+ end
44
44
  end
45
45
  end
@@ -2,16 +2,16 @@
2
2
 
3
3
  module Dnsimple
4
4
  module Struct
5
-
6
5
  class Base
6
+
7
7
  def initialize(attributes = {})
8
8
  attributes.each do |key, value|
9
- m = "#{key}=".to_sym
9
+ m = :"#{key}="
10
10
  send(m, value) if respond_to?(m)
11
11
  end
12
12
  end
13
- end
14
13
 
14
+ end
15
15
  end
16
16
  end
17
17
 
@@ -33,6 +33,7 @@ require_relative 'struct/domain_push'
33
33
  require_relative 'struct/domain_registration'
34
34
  require_relative 'struct/domain_transfer'
35
35
  require_relative 'struct/domain_renewal'
36
+ require_relative 'struct/dns_analytics'
36
37
  require_relative 'struct/email_forward'
37
38
  require_relative 'struct/extended_attribute'
38
39
  require_relative 'struct/oauth_token'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dnsimple
4
- VERSION = "8.7.1"
4
+
5
+ VERSION = "8.8.0"
6
+
5
7
  end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Dnsimple::Client, ".dns_analytics" do
6
+
7
+ subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").dns_analytics }
8
+
9
+ describe "#query" do
10
+ before do
11
+ stub_request(:get, %r{/v2/1/dns_analytics})
12
+ .to_return(read_http_fixture("dnsAnalytics/success.http"))
13
+ end
14
+
15
+ it "builds the correct request" do
16
+ subject.query(1)
17
+
18
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/1/dns_analytics")
19
+ .with(headers: { 'Accept' => 'application/json' })
20
+ end
21
+
22
+ it "supports pagination" do
23
+ subject.query(1, page: 2, per_page: 200)
24
+
25
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/1/dns_analytics?page=2&per_page=200")
26
+ end
27
+
28
+ it "supports sorting" do
29
+ subject.query(1, sort: "date:asc")
30
+
31
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/1/dns_analytics?sort=date:asc")
32
+ end
33
+
34
+ it "supports filtering" do
35
+ subject.query(1, filter: { start_date: '2024-08-01', end_date: '2024-09-01' })
36
+
37
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/1/dns_analytics?start_date=2024-08-01&end_date=2024-09-01")
38
+ end
39
+
40
+ it "supports groupings" do
41
+ subject.query(1, groupings: 'date,zone_name')
42
+
43
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/1/dns_analytics?groupings=date,zone_name")
44
+ end
45
+
46
+
47
+ it "returns a list of DNS Analytics entries" do
48
+ response = subject.query(1)
49
+
50
+ expect(response).to be_a(Dnsimple::PaginatedResponseWithQuery)
51
+ expect(response.data).to be_a(Array)
52
+ expect(response.data.size).to eq(12)
53
+
54
+ expect(response.data.all?(Dnsimple::Struct::DnsAnalytics)).to be(true)
55
+ expect(response.data[0].date).to eq('2023-12-08')
56
+ expect(response.data[0].zone_name).to eq('bar.com')
57
+ expect(response.data[0].volume).to eq(1200)
58
+ end
59
+
60
+ it "exposes the pagination information" do
61
+ response = subject.query(1)
62
+
63
+ expect(response.respond_to?(:page)).to be(true)
64
+ expect(response.page).to eq(0)
65
+ expect(response.per_page).to eq(100)
66
+ expect(response.total_entries).to eq(93)
67
+ expect(response.total_pages).to eq(1)
68
+ end
69
+
70
+ it "exposes the query parameters applied to produce the results" do
71
+ response = subject.query(1)
72
+
73
+ expect(response.respond_to?(:query)).to be(true)
74
+ query = response.query
75
+ expect(query["account_id"]).to eq("1")
76
+ expect(query["start_date"]).to eq('2023-12-08')
77
+ expect(query["end_date"]).to eq('2024-01-08')
78
+ expect(query["sort"]).to eq("zone_name:asc,date:asc")
79
+ expect(query["groupings"]).to eq("zone_name,date")
80
+ expect(query["page"]).to eq(0)
81
+ expect(query["per_page"]).to eq(100)
82
+ end
83
+ end
84
+ end
@@ -25,13 +25,13 @@ describe Dnsimple::Client, ".registrar" do
25
25
  response = subject.domain_delegation(account_id, "example.com")
26
26
  expect(response).to be_a(Dnsimple::Response)
27
27
 
28
- expect(response.data).to match_array(%w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com))
28
+ expect(response.data).to match_array(%w[ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com])
29
29
  end
30
30
  end
31
31
 
32
32
  describe "#change_domain_delegation" do
33
33
  let(:account_id) { 1010 }
34
- let(:attributes) { %w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com) }
34
+ let(:attributes) { %w[ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com] }
35
35
 
36
36
  before do
37
37
  stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation$})
@@ -51,13 +51,13 @@ describe Dnsimple::Client, ".registrar" do
51
51
  response = subject.change_domain_delegation(account_id, "example.com", attributes)
52
52
  expect(response).to be_a(Dnsimple::Response)
53
53
 
54
- expect(response.data).to match_array(%w(ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com))
54
+ expect(response.data).to match_array(%w[ns1.dnsimple.com ns2.dnsimple.com ns3.dnsimple.com ns4.dnsimple.com])
55
55
  end
56
56
  end
57
57
 
58
58
  describe "#change_domain_delegation_to_vanity" do
59
59
  let(:account_id) { 1010 }
60
- let(:attributes) { %w(ns1.example.com ns2.example.com) }
60
+ let(:attributes) { %w[ns1.example.com ns2.example.com] }
61
61
 
62
62
  before do
63
63
  stub_request(:put, %r{/v2/#{account_id}/registrar/domains/.+/delegation/vanity$})
@@ -26,7 +26,7 @@ describe Dnsimple::Client, ".vanity_name_servers" do
26
26
  expect(response).to be_a(Dnsimple::Response)
27
27
 
28
28
  vanity_name_servers = response.data.map { |ns| ns["name"] }
29
- expect(vanity_name_servers).to match_array(%w(ns1.example.com ns2.example.com ns3.example.com ns4.example.com))
29
+ expect(vanity_name_servers).to match_array(%w[ns1.example.com ns2.example.com ns3.example.com ns4.example.com])
30
30
  end
31
31
  end
32
32
 
@@ -112,7 +112,7 @@ describe Dnsimple::Client, ".zones" do
112
112
 
113
113
  describe "#create_zone_record" do
114
114
  let(:account_id) { 1010 }
115
- let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w(global) } }
115
+ let(:attributes) { { type: "A", name: "www", content: "127.0.0.1", regions: %w[global] } }
116
116
  let(:zone_id) { "example.com" }
117
117
 
118
118
  before do
@@ -186,7 +186,7 @@ describe Dnsimple::Client, ".zones" do
186
186
  expect(result.ttl).to eq(600)
187
187
  expect(result.priority).to eq(10)
188
188
  expect(result.system_record).to be(false)
189
- expect(result.regions).to eq(%w(SV1 IAD))
189
+ expect(result.regions).to eq(%w[SV1 IAD])
190
190
  expect(result.created_at).to eq("2016-10-05T09:51:35Z")
191
191
  expect(result.updated_at).to eq("2016-10-05T09:51:35Z")
192
192
  end
@@ -33,7 +33,7 @@ describe Dnsimple::Client do
33
33
  subject = described_class.new(username: "user", password: "pass")
34
34
  subject.execute(:get, "test", {})
35
35
 
36
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.com/test").with(basic_auth: %w(user pass))
36
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.com/test").with(basic_auth: %w[user pass])
37
37
  end
38
38
 
39
39
  it "uses access token if there's an access token provided" do
@@ -138,7 +138,7 @@ describe Dnsimple::Client do
138
138
  subject.request(:get, 'foo', {})
139
139
 
140
140
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.com/foo")
141
- .with(basic_auth: %w(user pass),
141
+ .with(basic_auth: %w[user pass],
142
142
  headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT })
143
143
  end
144
144
 
@@ -24,7 +24,7 @@ describe Dnsimple::Extra do
24
24
  end
25
25
 
26
26
  describe ".validate_mandatory_attributes" do
27
- let(:mandatory_attributes) { %i(name email) }
27
+ let(:mandatory_attributes) { %i[name email] }
28
28
 
29
29
  it "raises an error if a mandatory attribute is not present" do
30
30
  expect {
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Tue, 14 Jun 2016 12:02:58 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2391
8
+ X-RateLimit-Reset: 1465908577
9
+ ETag: W/"9ef3b4bf1f441a9b1cd6d7041bc181aa"
10
+ Cache-Control: max-age=0, private, must-revalidate
11
+ X-Request-Id: f705b65b-3589-43ad-97ca-3b2821d49d81
12
+ X-Runtime: 0.012661
13
+ X-Content-Type-Options: nosniff
14
+ X-Download-Options: noopen
15
+ X-Frame-Options: DENY
16
+ X-Permitted-Cross-Domain-Policies: none
17
+ X-XSS-Protection: 1; mode=block
18
+ Strict-Transport-Security: max-age=31536000
19
+
20
+ {"data": {"headers": ["zone_name", "date", "volume"], "rows": [["bar.com", "2023-12-08", 1200], ["bar.com", "2023-12-09", 1200], ["bar.com", "2024-01-07", 1200], ["bar.com", "2024-01-08", 1200], ["example.com", "2023-12-08", 1200], ["example.com", "2023-12-09", 1200], ["example.com", "2024-01-07", 1200], ["example.com", "2024-01-08", 1200], ["foo.com", "2023-12-08", 1200], ["foo.com", "2023-12-09", 1200], ["foo.com", "2024-01-07", 1200], ["foo.com", "2024-01-08", 1200]]}, "query": {"account_id": "1", "start_date": "2023-12-08", "end_date": "2024-01-08", "sort": "zone_name:asc,date:asc", "page": 0, "per_page": 100, "groupings": "zone_name,date"}, "pagination": {"current_page": 0, "per_page": 100, "total_entries": 93, "total_pages": 1}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.7.1
4
+ version: 8.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DNSimple
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-22 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -114,6 +114,7 @@ files:
114
114
  - lib/dnsimple/client/certificates.rb
115
115
  - lib/dnsimple/client/clients.rb
116
116
  - lib/dnsimple/client/contacts.rb
117
+ - lib/dnsimple/client/dns_analytics.rb
117
118
  - lib/dnsimple/client/domains.rb
118
119
  - lib/dnsimple/client/domains_collaborators.rb
119
120
  - lib/dnsimple/client/domains_delegation_signer_records.rb
@@ -154,6 +155,7 @@ files:
154
155
  - lib/dnsimple/struct/collaborator.rb
155
156
  - lib/dnsimple/struct/contact.rb
156
157
  - lib/dnsimple/struct/delegation_signer_record.rb
158
+ - lib/dnsimple/struct/dns_analytics.rb
157
159
  - lib/dnsimple/struct/dnssec.rb
158
160
  - lib/dnsimple/struct/domain.rb
159
161
  - lib/dnsimple/struct/domain_check.rb
@@ -189,6 +191,7 @@ files:
189
191
  - spec/dnsimple/client/certificates_spec.rb
190
192
  - spec/dnsimple/client/client_service_spec.rb
191
193
  - spec/dnsimple/client/contacts_spec.rb
194
+ - spec/dnsimple/client/dns_analytics_spec.rb
192
195
  - spec/dnsimple/client/domains_collaborators_spec.rb
193
196
  - spec/dnsimple/client/domains_delegation_signer_records_spec.rb
194
197
  - spec/dnsimple/client/domains_dnssec_spec.rb
@@ -275,6 +278,7 @@ files:
275
278
  - spec/fixtures.http/disableDomainTransferLock/success.http
276
279
  - spec/fixtures.http/disableVanityNameServers/success.http
277
280
  - spec/fixtures.http/disableWhoisPrivacy/success.http
281
+ - spec/fixtures.http/dnsAnalytics/success.http
278
282
  - spec/fixtures.http/downloadCertificate/success.http
279
283
  - spec/fixtures.http/enableDnssec/success.http
280
284
  - spec/fixtures.http/enableDomainAutoRenewal/success.http
@@ -401,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
405
  - !ruby/object:Gem::Version
402
406
  version: '0'
403
407
  requirements: []
404
- rubygems_version: 3.4.10
408
+ rubygems_version: 3.4.19
405
409
  signing_key:
406
410
  specification_version: 4
407
411
  summary: The DNSimple API client for Ruby