dnsimple 8.1.0 → 8.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 926c26b50cdc2958b19e86a45cd6eb0394f5d884bcc12e45e8fda88b194c8fac
4
- data.tar.gz: 930e5d25b213d496faa3268b3af1a0a1a407e0b632ad9a4a7f16fc8cb2a72256
3
+ metadata.gz: 34867970ac25f062a88e64df5c8ffc1a4cebb69612aea702cf6075ca79a9f9e7
4
+ data.tar.gz: 79ffa15c0875466c11c175feeda98df3467ddeb0b2229c16aa6c92aecf1e0a39
5
5
  SHA512:
6
- metadata.gz: 94cb5d1a3c141069d239d26a95e097b016b008acca7dcb2c14ff7040ed325a896e0ceaea4139344e22de6fb72360c7709df016de5aba668eab5b9afba17db8fc
7
- data.tar.gz: 0c975b2a65075d1df91923e26d1604600d6fa595634fd3b1ec85aa31fedef28627774340cca6b2d63b09bae96731d4895745a4a040943a835cab4387cb94acb4
6
+ metadata.gz: d7d71422305173c73b5dc948ffaf006d76b651697afc072b90e494dd9051c90424409ad7f16366bbec4ea5992fadcad6463c133c7b0ef522bbabe03c6b78f766
7
+ data.tar.gz: 980c1e8c59db95933ab3d6e95eea871fcaaf9234b4866efbfc105c7da2fb841097a8e9aec2deb467d3ca1a6a7e9db79bcaed9b3851c6da4429c5799e3ded2a92
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @dnsimple/client-ruby
1
+ * @dnsimple/external-integrations
@@ -4,19 +4,18 @@ updates:
4
4
  - package-ecosystem: bundler
5
5
  directory: /
6
6
  schedule:
7
- interval: daily
8
- time: '12:00'
7
+ interval: monthly
9
8
  open-pull-requests-limit: 10
10
9
  labels:
11
10
  - task
12
11
  - dependencies
13
-
14
12
  - package-ecosystem: "github-actions"
15
13
  directory: "/"
16
14
  schedule:
17
- interval: "daily"
15
+ interval: monthly
18
16
  time: '12:00'
19
17
  open-pull-requests-limit: 10
20
18
  labels:
21
19
  - task
22
20
  - dependencies
21
+ - automerge
@@ -0,0 +1,32 @@
1
+ name: Auto-merge
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - labeled
7
+ - synchronize
8
+ - opened
9
+
10
+ jobs:
11
+ auto-merge:
12
+ name: 'Auto-merge'
13
+ runs-on: ubuntu-latest
14
+ permissions: write-all
15
+
16
+ if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'automerge')
17
+ steps:
18
+ - name: Wait for tests to succeed
19
+ uses: lewagon/wait-on-check-action@v1.3.1
20
+ timeout-minutes: 15
21
+ with:
22
+ ref: ${{ github.ref }}
23
+ running-workflow-name: 'Auto-merge'
24
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
25
+ wait-interval: 10
26
+ allowed-conclusions: success
27
+ - uses: juliangruber/merge-pull-request-action@v1
28
+ with:
29
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
30
+ number: ${{ github.event.number }}
31
+ method: squash
32
+ repo: dnsimple/dnsimple-ruby
@@ -18,22 +18,13 @@ jobs:
18
18
  - name: Checkout Code
19
19
  uses: actions/checkout@v3
20
20
  - name: Run markdownlint-cli
21
- uses: nosborn/github-action-markdown-cli@v3.1.0
21
+ uses: nosborn/github-action-markdown-cli@v3.3.0
22
22
  with:
23
23
  files: .
24
24
  config_file: ".markdownlint.yaml"
25
25
 
26
- yamllint:
27
- name: Lint YAML
28
- runs-on: ubuntu-latest
29
- steps:
30
- - name: Checkout Code
31
- uses: actions/checkout@v3
32
- - name: Run YAML Lint
33
- uses: actionshub/yamllint@main
34
-
35
26
  test:
36
- needs: [markdownlint-cli, yamllint]
27
+ needs: [markdownlint-cli]
37
28
  runs-on: ubuntu-latest
38
29
  name: Ruby ${{ matrix.ruby-version }}
39
30
  strategy:
@@ -42,6 +33,7 @@ jobs:
42
33
  - '2.7'
43
34
  - '3.0'
44
35
  - '3.1'
36
+ - '3.2'
45
37
  - 'ruby-head'
46
38
  - 'truffleruby-head'
47
39
  steps:
@@ -7,11 +7,11 @@ on:
7
7
  jobs:
8
8
  publish:
9
9
  name: Release to RubyGems
10
- runs-on: ubuntu-latest
10
+ runs-on: ubuntu-20.04
11
11
 
12
12
  steps:
13
13
  - name: Wait for tests to succeed
14
- uses: lewagon/wait-on-check-action@v1.1.2
14
+ uses: lewagon/wait-on-check-action@v1.3.1
15
15
  with:
16
16
  ref: 'refs/heads/main'
17
17
  running-workflow-name: 'Release to RubyGems'
@@ -22,7 +22,8 @@ jobs:
22
22
  - uses: actions/checkout@v3
23
23
 
24
24
  - name: Release Gem
25
- uses: cadwallion/publish-rubygems-action@8f9e0538302643309e4e43bf48cd34173ca48cfc # yamllint disable-line
25
+ uses: simplyqio/publish-rubygems-action@2.0.0
26
26
  env:
27
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27
28
  RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
28
- RELEASE_COMMAND: rake release
29
+ RELEASE_COMMAND: "rake build && gem push pkg/*.gem"
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-09-01 12:27:48 UTC using RuboCop version 1.36.0.
3
+ # on 2023-01-26 12:48:02 UTC using RuboCop version 1.44.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 70
9
+ # Offense count: 74
10
10
  # Configuration parameters: CountAsOne.
11
11
  RSpec/ExampleLength:
12
12
  Max: 17
@@ -16,18 +16,19 @@ RSpec/LeakyConstantDeclaration:
16
16
  Exclude:
17
17
  - 'spec/dnsimple/client/client_service_spec.rb'
18
18
 
19
- # Offense count: 11
19
+ # Offense count: 12
20
20
  # Configuration parameters: .
21
21
  # SupportedStyles: have_received, receive
22
22
  RSpec/MessageSpies:
23
23
  EnforcedStyle: receive
24
24
 
25
- # Offense count: 111
25
+ # Offense count: 115
26
26
  RSpec/MultipleExpectations:
27
27
  Max: 15
28
28
 
29
- # Offense count: 371
30
- # Configuration parameters: IgnoreSharedExamples.
29
+ # Offense count: 372
30
+ # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
31
+ # SupportedStyles: always, named_only
31
32
  RSpec/NamedSubject:
32
33
  Enabled: false
33
34
 
@@ -47,7 +48,7 @@ RSpec/SubjectStub:
47
48
  - 'spec/dnsimple/client/zones_spec.rb'
48
49
  - 'spec/dnsimple/client_spec.rb'
49
50
 
50
- # Offense count: 37
51
+ # Offense count: 69
51
52
  # Configuration parameters: AllowedConstants.
52
53
  Style/Documentation:
53
54
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).
4
4
 
5
5
  ## main
6
6
 
7
+ ## 8.4.0
8
+
9
+ FEATURES:
10
+
11
+ - NEW: Added `Dnsimple::Client::Zones#activate_dns` to activate DNS services (resolution) for a zone. (dnsimple/dnsimple-ruby#354)
12
+ - NEW: Added `Dnsimple::Client::Zones#deactivate_dns` to deactivate DNS services (resolution) for a zone. (dnsimple/dnsimple-ruby#354)
13
+
14
+ ## 8.3.1
15
+
16
+ - FIXED: Our release process had failed to push correctly `8.2.0` and `8.3.0` to RubyGems resulting in empty gem releases. This releases fixes the issue and contains the same changes of `8.2.0` and `8.3.0`.
17
+
18
+ ## 8.3.0
19
+
20
+ - CHANGED: Wrap 400 errors on the OAuth endpoint in `Dnsimple::OAuthInvalidRequestError` (dnsimple/dnsimple-ruby#336)
21
+
22
+ ## 8.2.0
23
+
24
+ - NEW: Added getDomainRenewal and getDomainRegistration endpoints (dnsimple/dnsimple-ruby#332)
25
+ - NEW: Documented the new `signature_algorithm` parameter for the Lets Encrypt certificate purchase endpoint (dnsimple/dnsimple-ruby#331)
26
+
7
27
  ## 8.1.0
8
28
 
9
29
  - CHANGED: Fixed and updated documentation for domain endpoints (dnsimple/dnsimple-ruby#300)
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  gem 'coveralls', require: false
8
- gem 'rubocop', '1.36.0', require: false
9
- gem 'rubocop-performance', '1.15.0', require: false
8
+ gem 'rubocop', '1.55.1', require: false
9
+ gem 'rubocop-performance', '1.18.0', require: false
10
10
  gem 'rubocop-rake', '0.6.0', require: false
11
- gem 'rubocop-rspec', '2.13.1', require: false
11
+ gem 'rubocop-rspec', '2.23.0', require: false
data/README.md CHANGED
@@ -23,7 +23,7 @@ gem install dnsimple
23
23
  Or use Bundler and define it as a dependency in your Gemfile:
24
24
 
25
25
  ```ruby
26
- gem 'dnsimple', '~> 6.0'
26
+ gem 'dnsimple', '~> 8.0'
27
27
  ```
28
28
 
29
29
  ## Documentation
@@ -110,4 +110,4 @@ puts response.data
110
110
 
111
111
  ## License
112
112
 
113
- Copyright (c) 2010-2022 DNSimple Corporation. This is Free Software distributed under the MIT license.
113
+ Copyright (c) 2010-2023 DNSimple Corporation. This is Free Software distributed under the MIT license.
@@ -124,6 +124,7 @@ module Dnsimple
124
124
  # @option attributes [String] :name the certificate name (optional)
125
125
  # @option attributes [Array<String>] :alternate_names the certificate alternate names (optional)
126
126
  # @option attributes [TrueClass,FalseClass] :auto_renew enable certificate auto renew (optional)
127
+ # @option attributes [String] :signature_algorithm the signature algorithm used to sign the certificate (optional)
127
128
  # @param options[Hash]
128
129
  #
129
130
  # @return [Dnsimple::Response<Dnsimple::Struct::CertificatPurchase>]
@@ -166,6 +167,15 @@ module Dnsimple
166
167
  # certificate.common_name # => "www.example.com"
167
168
  # certificate.alternate_names # => []
168
169
  # certificate.auto_renew # => true
170
+ #
171
+ # @example Signature Algorithm
172
+ # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", signature_algorithm: "RSA")
173
+ # certificate = response.data
174
+ #
175
+ # certificate.id # => 100
176
+ # certificate.common_name # => "www.example.com"
177
+ # certificate.alternate_names # => []
178
+ # certificate.auto_renew # => false
169
179
  def purchase_letsencrypt_certificate(account_id, domain_id, attributes = {}, options = {})
170
180
  response = client.post(Client.versioned("/%s/domains/%s/certificates/letsencrypt" % [account_id, domain_id]), attributes, options)
171
181
 
@@ -209,6 +219,7 @@ module Dnsimple
209
219
  # @param certificate_id [Integer] the certificate ID
210
220
  # @param attributes [Hash]
211
221
  # @option attributes [TrueClass,FalseClass] :auto_renew enable certificate auto renew (optional)
222
+ # @option attributes [String] :signature_algorithm the signature algorithm used to sign the certificate (optional)
212
223
  # @param options [Hash]
213
224
  #
214
225
  # @return [Dnsimple::Response<Dnsimple::Struct::CertificateRenewal>]
@@ -231,6 +242,14 @@ module Dnsimple
231
242
  # certificate_renewal.id # => 999
232
243
  # certificate_renewal.old_certificate_id # => 200
233
244
  # certificate_renewal.new_certificate_id # => 300
245
+ #
246
+ # @example Signature Algorithm
247
+ # response = client.certificates.purchase_letsencrypt_certificate_renewal(1010, "example.com", 200, signature_algorithm: "RSA")
248
+ # certificate_renewal = response.data
249
+ #
250
+ # certificate_renewal.id # => 999
251
+ # certificate_renewal.old_certificate_id # => 200
252
+ # certificate_renewal.new_certificate_id # => 300
234
253
  def purchase_letsencrypt_certificate_renewal(account_id, domain_id, certificate_id, attributes = {}, options = {})
235
254
  response = client.post(Client.versioned("/%s/domains/%s/certificates/letsencrypt/%s/renewals" % [account_id, domain_id, certificate_id]), attributes, options)
236
255
 
@@ -19,6 +19,11 @@ module Dnsimple
19
19
  attributes[:redirect_uri] = options.delete(:redirect_uri) if options.key?(:redirect_uri)
20
20
  response = client.post(Client.versioned("/oauth/access_token"), attributes, options)
21
21
  Struct::OauthToken.new(response)
22
+
23
+ rescue Dnsimple::RequestError => exception
24
+ raise exception unless exception.http_response.code == 400
25
+
26
+ raise Dnsimple::OAuthInvalidRequestError, exception.http_response
22
27
  end
23
28
 
24
29
  # Gets the URL to authorize an user for an application via the OAuth2 flow.
@@ -67,6 +67,28 @@ module Dnsimple
67
67
  Dnsimple::Response.new(response, Struct::DomainRegistration.new(response["data"]))
68
68
  end
69
69
 
70
+ # Retrieves the details of an existing domain registration.
71
+ #
72
+ # @see https://developer.dnsimple.com/v2/registrar/#getDomainRegistration
73
+ #
74
+ # @example Retrieve the registration 42 for example.com:
75
+ # client.registrar.get_domain_registration(1010, "example.com", 42)
76
+ #
77
+ # @param [Integer] account_id the account ID
78
+ # @param [#to_s] domain_name the domain name
79
+ # @param [Integer] domain_registration_id the domain registration ID
80
+ # @param [Hash] options
81
+ # @return [Struct::DomainRegistration]
82
+ #
83
+ # @raise [NotFoundError] When record is not found.
84
+ # @raise [RequestError] When the request fails.
85
+ def get_domain_registration(account_id, domain_name, domain_registration_id, options = {})
86
+ endpoint = Client.versioned("/%s/registrar/domains/%s/registrations/%s" % [account_id, domain_name, domain_registration_id])
87
+ response = client.get(endpoint, options)
88
+
89
+ Dnsimple::Response.new(response, Struct::DomainRegistration.new(response["data"]))
90
+ end
91
+
70
92
  # Renews a domain.
71
93
  #
72
94
  # @see https://developer.dnsimple.com/v2/registrar/#renew
@@ -88,6 +110,28 @@ module Dnsimple
88
110
  Dnsimple::Response.new(response, Struct::DomainRenewal.new(response["data"]))
89
111
  end
90
112
 
113
+ # Retrieve the details of an existing domain renewal.
114
+ #
115
+ # @see https://developer.dnsimple.com/v2/registrar/#getDomainRenewal
116
+ #
117
+ # @example Retrieve the renewal 42 for example.com:
118
+ # client.registrar.get_domain_renewal(1010, "example.com", 42)
119
+ #
120
+ # @param [Integer] account_id the account ID
121
+ # @param [#to_s] domain_name the domain name
122
+ # @param [Integer] domain_renewal_id the domain renewal ID
123
+ # @param [Hash] options
124
+ # @return [Struct::DomainRenewal]
125
+ #
126
+ # @raise [NotFoundError] When record is not found.
127
+ # @raise [RequestError] When the request fails.
128
+ def get_domain_renewal(account_id, domain_name, domain_renewal_id, options = {})
129
+ endpoint = Client.versioned("/%s/registrar/domains/%s/renewals/%s" % [account_id, domain_name, domain_renewal_id])
130
+ response = client.get(endpoint, options)
131
+
132
+ Dnsimple::Response.new(response, Struct::DomainRenewal.new(response["data"]))
133
+ end
134
+
91
135
  # Starts the transfer of a domain to DNSimple.
92
136
  #
93
137
  # @see https://developer.dnsimple.com/v2/registrar/#transfer
@@ -95,6 +95,40 @@ module Dnsimple
95
95
  Dnsimple::Response.new(response, Struct::ZoneFile.new(response["data"]))
96
96
  end
97
97
 
98
+ # Activate DNS resolution for the zone in the account.
99
+ #
100
+ # @see https://developer.dnsimple.com/v2/zones/#activateZoneService
101
+ #
102
+ # @param [#to_s] account_id the account ID
103
+ # @param [#to_s] zone_id the zone name
104
+ # @param [Hash] options
105
+ # @return [Dnsimple::Response<Dnsimple::Struct::Zone>]
106
+ #
107
+ # @raise [Dnsimple::NotFoundError]
108
+ # @raise [Dnsimple::RequestError]
109
+ def activate_dns(account_id, zone_id, options = {})
110
+ response = client.put(Client.versioned("/%s/zones/%s/activation" % [account_id, zone_id]), options)
111
+
112
+ Dnsimple::Response.new(response, Struct::Zone.new(response["data"]))
113
+ end
114
+
115
+ # Deactivate DNS resolution for the zone in the account.
116
+ #
117
+ # @see https://developer.dnsimple.com/v2/zones/#deactivateZoneService
118
+ #
119
+ # @param [#to_s] account_id the account ID
120
+ # @param [#to_s] zone_id the zone name
121
+ # @param [Hash] options
122
+ # @return [Dnsimple::Response<Dnsimple::Struct::Zone>]
123
+ #
124
+ # @raise [Dnsimple::NotFoundError]
125
+ # @raise [Dnsimple::RequestError]
126
+ def deactivate_dns(account_id, zone_id, options = {})
127
+ response = client.delete(Client.versioned("/%s/zones/%s/activation" % [account_id, zone_id]), options)
128
+
129
+ Dnsimple::Response.new(response, Struct::Zone.new(response["data"]))
130
+ end
131
+
98
132
  end
99
133
  end
100
134
  end
@@ -48,4 +48,21 @@ module Dnsimple
48
48
  class AuthenticationFailed < AuthenticationError
49
49
  end
50
50
 
51
+ class OAuthInvalidRequestError < Error
52
+ attr_reader :http_response, :error, :error_description
53
+
54
+ def initialize(http_response)
55
+ @http_response = http_response
56
+ @error = http_response.parsed_response["error"]
57
+ @error_description = http_response.parsed_response["error_description"]
58
+ super(message)
59
+ end
60
+
61
+ private
62
+
63
+ def message
64
+ "#{error}: #{error_description}"
65
+ end
66
+ end
67
+
51
68
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dnsimple
4
- VERSION = "8.1.0"
4
+ VERSION = "8.4.0"
5
5
  end
@@ -46,6 +46,25 @@ describe Dnsimple::Client, ".oauth" do
46
46
  .with(headers: { 'Accept' => 'application/json' })
47
47
  end
48
48
  end
49
+
50
+ context "when the request fails with 400" do
51
+ before do
52
+ stub_request(:post, %r{/v2/oauth/access_token$})
53
+ .to_return(read_http_fixture("oauthAccessToken/error-invalid-request.http"))
54
+ end
55
+
56
+ it "raises OAuthInvalidRequestError" do
57
+ expect {
58
+ subject.exchange_authorization_for_token(code, client_id, client_secret, state: state)
59
+ }.to raise_error(Dnsimple::OAuthInvalidRequestError) do |e|
60
+ error = "invalid_request"
61
+ error_description = "Invalid \"state\": value doesn't match the \"state\" in the authorization request"
62
+ expect(e.error).to eq(error)
63
+ expect(e.error_description).to eq(error_description)
64
+ expect(e.to_s).to eq("#{error}: #{error_description}")
65
+ end
66
+ end
67
+ end
49
68
  end
50
69
 
51
70
  describe "#authorize_url" do
@@ -112,6 +112,32 @@ describe Dnsimple::Client, ".registrar" do
112
112
  end
113
113
  end
114
114
 
115
+ describe "#get_domain_registration" do
116
+ let(:account_id) { 1010 }
117
+
118
+ before do
119
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/registrations/.+$})
120
+ .to_return(read_http_fixture("getDomainRegistration/success.http"))
121
+ end
122
+
123
+ it "builds the correct request" do
124
+ subject.get_domain_registration(account_id, domain_name = "example.com", registration_id = 361)
125
+
126
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/registrations/#{registration_id}")
127
+ .with(headers: { "Accept" => "application/json" })
128
+ end
129
+
130
+ it "returns the domain transfer" do
131
+ response = subject.get_domain_registration(account_id, "example.com", 361)
132
+ expect(response).to be_a(Dnsimple::Response)
133
+
134
+ result = response.data
135
+ expect(result).to be_a(Dnsimple::Struct::DomainRegistration)
136
+ expect(result.id).to be_a(Integer)
137
+ expect(result.domain_id).to be_a(Integer)
138
+ end
139
+ end
140
+
115
141
  describe "#renew_domain" do
116
142
  let(:account_id) { 1010 }
117
143
  let(:attributes) { { period: "3" } }
@@ -152,6 +178,32 @@ describe Dnsimple::Client, ".registrar" do
152
178
  end
153
179
  end
154
180
 
181
+ describe "#get_domain_renewal" do
182
+ let(:account_id) { 1010 }
183
+
184
+ before do
185
+ stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/renewals/.+$})
186
+ .to_return(read_http_fixture("getDomainRenewal/success.http"))
187
+ end
188
+
189
+ it "builds the correct request" do
190
+ subject.get_domain_renewal(account_id, domain_name = "example.com", renewal_id = 361)
191
+
192
+ expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/renewals/#{renewal_id}")
193
+ .with(headers: { "Accept" => "application/json" })
194
+ end
195
+
196
+ it "returns the domain renewal" do
197
+ response = subject.get_domain_renewal(account_id, "example.com", 361)
198
+ expect(response).to be_a(Dnsimple::Response)
199
+
200
+ result = response.data
201
+ expect(result).to be_a(Dnsimple::Struct::DomainRenewal)
202
+ expect(result.id).to be_a(Integer)
203
+ expect(result.domain_id).to be_a(Integer)
204
+ end
205
+ end
206
+
155
207
  describe "#transfer_domain" do
156
208
  let(:account_id) { 1010 }
157
209
  let(:attributes) { { registrant_id: "10", auth_code: "x1y2z3" } }
@@ -3,7 +3,6 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Dnsimple::Client, ".zones" do
6
-
7
6
  subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").zones }
8
7
 
9
8
 
@@ -173,4 +172,85 @@ describe Dnsimple::Client, ".zones" do
173
172
  end
174
173
  end
175
174
 
175
+ describe "#activate_dns" do
176
+ let(:account_id) { 1010 }
177
+
178
+ before do
179
+ stub_request(:put, %r{/v2/#{account_id}/zones/.+/activation})
180
+ .to_return(read_http_fixture("activateZoneService/success.http"))
181
+ end
182
+
183
+ it "builds the correct request" do
184
+ subject.activate_dns(account_id, zone = "example.com")
185
+
186
+ expect(WebMock).to have_requested(:put, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/activation")
187
+ .with(headers: { 'Accept' => 'application/json' })
188
+ end
189
+
190
+ it "returns the zone" do
191
+ response = subject.activate_dns(account_id, "example.com")
192
+ expect(response).to be_a(Dnsimple::Response)
193
+
194
+ result = response.data
195
+ expect(result).to be_a(Dnsimple::Struct::Zone)
196
+ expect(result.id).to eq(1)
197
+ expect(result.account_id).to eq(1010)
198
+ expect(result.name).to eq("example.com")
199
+ expect(result.reverse).to be(false)
200
+ expect(result.created_at).to eq("2022-09-28T04:45:24Z")
201
+ expect(result.updated_at).to eq("2023-07-06T11:19:48Z")
202
+ end
203
+
204
+ context "when the zone does not exist" do
205
+ it "raises NotFoundError" do
206
+ stub_request(:put, %r{/v2})
207
+ .to_return(read_http_fixture("notfound-zone.http"))
208
+
209
+ expect {
210
+ subject.activate_dns(account_id, "example.com")
211
+ }.to raise_error(Dnsimple::NotFoundError)
212
+ end
213
+ end
214
+ end
215
+
216
+ describe "#deactivate_dns" do
217
+ let(:account_id) { 1010 }
218
+
219
+ before do
220
+ stub_request(:delete, %r{/v2/#{account_id}/zones/.+/activation})
221
+ .to_return(read_http_fixture("deactivateZoneService/success.http"))
222
+ end
223
+
224
+ it "builds the correct request" do
225
+ subject.deactivate_dns(account_id, zone = "example.com")
226
+
227
+ expect(WebMock).to have_requested(:delete, "https://api.dnsimple.test/v2/#{account_id}/zones/#{zone}/activation")
228
+ .with(headers: { 'Accept' => 'application/json' })
229
+ end
230
+
231
+ it "returns the zone" do
232
+ response = subject.deactivate_dns(account_id, "example.com")
233
+ expect(response).to be_a(Dnsimple::Response)
234
+
235
+ result = response.data
236
+ expect(result).to be_a(Dnsimple::Struct::Zone)
237
+ expect(result.id).to eq(1)
238
+ expect(result.account_id).to eq(1010)
239
+ expect(result.name).to eq("example.com")
240
+ expect(result.reverse).to be(false)
241
+ expect(result.created_at).to eq("2022-09-28T04:45:24Z")
242
+ expect(result.updated_at).to eq("2023-08-08T04:19:52Z")
243
+ end
244
+
245
+ context "when the zone does not exist" do
246
+ it "raises NotFoundError" do
247
+ stub_request(:delete, %r{/v2})
248
+ .to_return(read_http_fixture("notfound-zone.http"))
249
+
250
+ expect {
251
+ subject.deactivate_dns(account_id, "example.com")
252
+ }.to raise_error(Dnsimple::NotFoundError)
253
+ end
254
+ end
255
+ end
176
256
  end
@@ -0,0 +1,16 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Tue, 08 Aug 2023 04:19:23 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2399
8
+ X-RateLimit-Reset: 1691471963
9
+ X-WORK-WITH-US: Love automation? So do we! https://dnsimple.com/jobs
10
+ ETag: W/"fe6afd982459be33146933235343d51d"
11
+ Cache-Control: max-age=0, private, must-revalidate
12
+ X-Request-Id: 8e8ac535-9f46-4304-8440-8c68c30427c3
13
+ X-Runtime: 0.176579
14
+ Strict-Transport-Security: max-age=63072000
15
+
16
+ {"data":{"id":1,"account_id":1010,"name":"example.com","reverse":false,"secondary":false,"last_transferred_at":null,"active":true,"created_at":"2022-09-28T04:45:24Z","updated_at":"2023-07-06T11:19:48Z"}}
@@ -0,0 +1,16 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Tue, 08 Aug 2023 04:19:52 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2398
8
+ X-RateLimit-Reset: 1691471962
9
+ X-WORK-WITH-US: Love automation? So do we! https://dnsimple.com/jobs
10
+ ETag: W/"5f30a37d01b99bb9e620ef1bbce9a014"
11
+ Cache-Control: max-age=0, private, must-revalidate
12
+ X-Request-Id: d2f7bba4-4c81-4818-81d2-c9bbe95f104e
13
+ X-Runtime: 0.133278
14
+ Strict-Transport-Security: max-age=63072000
15
+
16
+ {"data":{"id":1,"account_id":1010,"name":"example.com","reverse":false,"secondary":false,"last_transferred_at":null,"active":false,"created_at":"2022-09-28T04:45:24Z","updated_at":"2023-08-08T04:19:52Z"}}
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Fri, 05 Jun 2020 18:23:53 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2392
8
+ X-RateLimit-Reset: 1591384034
9
+ ETag: W/"80c5827934c13b1ca87a587d96e7d1e8"
10
+ Cache-Control: max-age=0, private, must-revalidate
11
+ X-Request-Id: 9f4959ee-06a9-488c-906e-27a570cafbbf
12
+ X-Runtime: 0.078429
13
+ X-Frame-Options: DENY
14
+ X-Content-Type-Options: nosniff
15
+ X-XSS-Protection: 1; mode=block
16
+ X-Download-Options: noopen
17
+ X-Permitted-Cross-Domain-Policies: none
18
+ Strict-Transport-Security: max-age=31536000
19
+
20
+ {"data":{"id":361,"domain_id":104040,"registrant_id":2715,"period":1,"state":"registering","auto_renew":false,"whois_privacy":false,"created_at":"2023-01-27T17:44:32Z","updated_at":"2023-01-27T17:44:40Z"}}
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 201 Created
2
+ Server: nginx
3
+ Date: Fri, 09 Dec 2016 19:46:57 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: keep-alive
6
+ X-RateLimit-Limit: 2400
7
+ X-RateLimit-Remaining: 2394
8
+ X-RateLimit-Reset: 1481315245
9
+ ETag: W/"179d85ea8a26a3d5dc76e42de2d7918e"
10
+ Cache-Control: max-age=0, private, must-revalidate
11
+ X-Request-Id: ba6f2707-5df0-4ffa-b91b-51d4460bab8e
12
+ X-Runtime: 13.571302
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":{"id":1,"domain_id":999,"period":1,"state":"renewed","created_at":"2016-12-09T19:46:45Z","updated_at":"2016-12-12T19:46:45Z"}}
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.1.0
4
+ version: 8.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DNSimple
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-19 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -90,6 +90,7 @@ extra_rdoc_files:
90
90
  files:
91
91
  - ".github/CODEOWNERS"
92
92
  - ".github/dependabot.yml"
93
+ - ".github/workflows/auto-merge.yml"
93
94
  - ".github/workflows/ci.yml"
94
95
  - ".github/workflows/release.yml"
95
96
  - ".gitignore"
@@ -98,7 +99,6 @@ files:
98
99
  - ".rubocop.yml"
99
100
  - ".rubocop_dnsimple.yml"
100
101
  - ".rubocop_todo.yml"
101
- - ".yamllint.yml"
102
102
  - CHANGELOG.md
103
103
  - CONTRIBUTING.md
104
104
  - Gemfile
@@ -211,6 +211,7 @@ files:
211
211
  - spec/fixtures.http/acceptPush/success.http
212
212
  - spec/fixtures.http/accounts/success-account.http
213
213
  - spec/fixtures.http/accounts/success-user.http
214
+ - spec/fixtures.http/activateZoneService/success.http
214
215
  - spec/fixtures.http/addCollaborator/invite-success.http
215
216
  - spec/fixtures.http/addCollaborator/success.http
216
217
  - spec/fixtures.http/appliedServices/success.http
@@ -244,6 +245,7 @@ files:
244
245
  - spec/fixtures.http/createWebhook/created.http
245
246
  - spec/fixtures.http/createZoneRecord/created-apex.http
246
247
  - spec/fixtures.http/createZoneRecord/created.http
248
+ - spec/fixtures.http/deactivateZoneService/success.http
247
249
  - spec/fixtures.http/deleteContact/error-contact-in-use.http
248
250
  - spec/fixtures.http/deleteContact/success.http
249
251
  - spec/fixtures.http/deleteDelegationSignerRecord/success.http
@@ -276,6 +278,8 @@ files:
276
278
  - spec/fixtures.http/getDomainPremiumPrice/success.http
277
279
  - spec/fixtures.http/getDomainPrices/failure.http
278
280
  - spec/fixtures.http/getDomainPrices/success.http
281
+ - spec/fixtures.http/getDomainRegistration/success.http
282
+ - spec/fixtures.http/getDomainRenewal/success.http
279
283
  - spec/fixtures.http/getDomainTransfer/success.http
280
284
  - spec/fixtures.http/getEmailForward/success.http
281
285
  - spec/fixtures.http/getPrimaryServer/success.http
@@ -360,7 +364,7 @@ files:
360
364
  homepage: https://github.com/dnsimple/dnsimple-ruby
361
365
  licenses: []
362
366
  metadata: {}
363
- post_install_message:
367
+ post_install_message:
364
368
  rdoc_options: []
365
369
  require_paths:
366
370
  - lib
@@ -375,8 +379,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
379
  - !ruby/object:Gem::Version
376
380
  version: '0'
377
381
  requirements: []
378
- rubygems_version: 3.3.7
379
- signing_key:
382
+ rubygems_version: 3.4.10
383
+ signing_key:
380
384
  specification_version: 4
381
385
  summary: The DNSimple API client for Ruby
382
386
  test_files: []
data/.yamllint.yml DELETED
@@ -1,29 +0,0 @@
1
- ---
2
-
3
- extends: default
4
-
5
- rules:
6
- braces:
7
- level: warning
8
- max-spaces-inside: 1
9
- brackets:
10
- level: warning
11
- max-spaces-inside: 1
12
- colons:
13
- level: warning
14
- commas:
15
- level: warning
16
- comments: disable
17
- comments-indentation: disable
18
- document-start: disable
19
- empty-lines:
20
- level: warning
21
- hyphens:
22
- level: warning
23
- indentation:
24
- level: warning
25
- indent-sequences: consistent
26
- line-length:
27
- level: warning
28
- allow-non-breakable-inline-mappings: true
29
- truthy: disable