dnsimple 4.1.0 → 4.2.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
  SHA1:
3
- metadata.gz: e0f3e109fc2b3c88b76f2f569764e32792a626f7
4
- data.tar.gz: e092631aa456c81f5a77076fab26334f2c9f93a0
3
+ metadata.gz: af0c0df379377bed93734974abb9af0f682cd75e
4
+ data.tar.gz: 250b4394bf6b35d7ea80276ee6b92cc6d90b2d50
5
5
  SHA512:
6
- metadata.gz: f6393c8b54b069a15bd4cdce2e259586f7dde2c979b50bcddbeae5aa40015b08e6c6429851eba324daabbb7e27d05aa42f333bc09244032bb22790967762b9a6
7
- data.tar.gz: 6f403fdb0107e7f8e50bee41ce24244ee5a1ae398835670bbdf19b369b0116f8d70788dd72f07bf1fd61e82821b277acb798807ea605b00f2593391f060693ad
6
+ metadata.gz: 075b9ffc70204575a94aec17e36f2bf11c1ba57384162abcbcb6d3daafb3a14a09e429d7a5ee6d87ce5e3800a6bdb72c37fff33c10891b7c335012a8989aa9fd
7
+ data.tar.gz: 489c8662934bdb41307a69ca9c972d8534125b707cb51bbe35e13d8b29dc3159062a970400a4dafbf3ea456bd0d07f6709777fd383054eb318f68a58855da13a
@@ -14,7 +14,7 @@ AllCops:
14
14
  # end
15
15
  #
16
16
  Lint/EndAlignment:
17
- AlignWith: variable
17
+ EnforcedStyleAlignWith: variable
18
18
 
19
19
  # [codesmell]
20
20
  Metrics/AbcSize:
@@ -23,6 +23,17 @@ Metrics/AbcSize:
23
23
  - 'spec/**/*_spec.rb'
24
24
  - 'test/**/*_test.rb'
25
25
 
26
+ # [codesmell]
27
+ Metrics/BlockLength:
28
+ Enabled: false
29
+
30
+ # [codesmell]
31
+ Metrics/CyclomaticComplexity:
32
+ Enabled: false
33
+ Exclude:
34
+ - 'spec/**/*_spec.rb'
35
+ - 'test/**/*_test.rb'
36
+
26
37
  # [codesmell]
27
38
  Metrics/ClassLength:
28
39
  Enabled: false
@@ -53,6 +64,15 @@ Metrics/ModuleLength:
53
64
  - 'spec/**/*_spec.rb'
54
65
  - 'test/**/*_test.rb'
55
66
 
67
+ # [codesmell]
68
+ Metrics/ParameterLists:
69
+ Enabled: false
70
+ Max: 5
71
+
72
+ # [codesmell]
73
+ Metrics/PerceivedComplexity:
74
+ Enabled: false
75
+
56
76
  # [codesmell]
57
77
  # I don't really get the point of this cop.
58
78
  Performance/RedundantMerge:
@@ -88,7 +108,7 @@ Style/BracesAroundHashParameters:
88
108
  # end
89
109
  #
90
110
  Style/CaseIndentation:
91
- IndentWhenRelativeTo: end
111
+ EnforcedStyle: end
92
112
 
93
113
  # I was a big fan of leading, but trailing seems to be more commonly adopted.
94
114
  # At least at the time being.
@@ -121,6 +141,11 @@ Style/EmptyLinesAroundClassBody:
121
141
  Style/EmptyLinesAroundModuleBody:
122
142
  Enabled: false
123
143
 
144
+ # There is no specific preference for empty methods.
145
+ # One-line methods are not exceptionally nice in Ruby. Just ignore this cop for now.
146
+ Style/EmptyMethod:
147
+ Enabled: false
148
+
124
149
  # I personally don't care about the format style.
125
150
  # In most cases I like to use %, but not at the point I want to enforce it
126
151
  # as a convention in the entire code.
@@ -164,6 +189,16 @@ Style/IndentHash:
164
189
  Style/IfInsideElse:
165
190
  Enabled: false
166
191
 
192
+ # module_function doesn't respect the visibility of the methods,
193
+ # and doesn't work well when the module contain both public/private methods.
194
+ Style/ModuleFunction:
195
+ Enabled: false
196
+
197
+ Style/MultilineBlockChain:
198
+ Exclude:
199
+ # RSpec uses multi-line blocks for certain features
200
+ - 'spec/**/*_spec.rb'
201
+
167
202
  # Multi-line differs from standard indentation, they are indented twice.
168
203
  Style/MultilineMethodCallIndentation:
169
204
  EnforcedStyle: indented
@@ -195,6 +230,17 @@ Style/RegexpLiteral:
195
230
  Style/RescueModifier:
196
231
  Enabled: false
197
232
 
233
+ # Sorry, but using trailing spaces helps readability.
234
+ #
235
+ # %w( foo bar )
236
+ #
237
+ # looks better to me than
238
+ #
239
+ # %w( foo bar )
240
+ #
241
+ Style/SpaceInsidePercentLiteralDelimiters:
242
+ Enabled: false
243
+
198
244
  # We don't have a preference.
199
245
  Style/SpecialGlobalVars:
200
246
  Enabled: false
@@ -220,3 +266,7 @@ Style/TrivialAccessors:
220
266
  # end
221
267
  #
222
268
  IgnoreClassMethods: true
269
+
270
+ Style/WordArray:
271
+ EnforcedStyle: percent
272
+ MinSize: 3
@@ -4,8 +4,10 @@ rvm:
4
4
  - 2.0
5
5
  - 2.1
6
6
  - 2.2
7
- - 2.3.0
7
+ - 2.3.3
8
+ - 2.4.0
8
9
  env: COVERALL=1
9
10
 
10
11
  before_install:
11
- - gem install bundler
12
+ - gem update --system
13
+ - gem install bundler
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project uses [Semantic Versioning 2.0.0](http://semver.org/).
4
4
 
5
+ #### 4.2.0
6
+
7
+ - NEW: Added DNSSEC support support (dnsimple/dnsimple-ruby#152)
8
+
5
9
  #### 4.1.0
6
10
 
7
11
  - NEW: Added domain premium price support (dnsimple/dnsimple-ruby#143)
@@ -35,7 +39,7 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).
35
39
 
36
40
  - CHANGED: Pagination params must be passed as top level options. Previously they were passed inside `:query` options (GH-116).
37
41
  - CHANGED: Authentication credentials presence is no longer validated on the client as it was causing an error getting the access token (GH-74 and GH-102).
38
- - CHANGED: Setting a custom user-agent no longer overrides the origina user-agent (GH-105).
42
+ - CHANGED: Setting a custom user-agent no longer overrides the original user-agent (GH-105).
39
43
  - CHANGED: Updated client to use Contact#email (GH-108).
40
44
 
41
45
  - REMOVED: Removed support for wildcard accounts (GH-107).
data/README.md CHANGED
@@ -61,18 +61,31 @@ puts response.data
61
61
 
62
62
  For the full library documentation visit http://rubydoc.info/gems/dnsimple
63
63
 
64
- ## Sandbox Usage
65
64
 
66
- If you would like to test the [DNSimple sandbox environment](https://developer.dnsimple.com/sandbox/) then pass the `base_url` named argument when you construct the client. For example:
65
+ ## Sandbox Environment
67
66
 
68
- ```ruby
69
- require 'dnsimple'
67
+ We highly recommend testing against our [sandbox environment](https://developer.dnsimple.com/sandbox/) before using our production environment. This will allow you to avoid real purchases, live charges on your credit card, and reduce the chance of your running up against rate limits.
68
+
69
+ The client supports both the production and sandbox environment. To switch to sandbox pass the sandbox API host using the `base_url` option when you construct the client:
70
70
 
71
+ ```ruby
71
72
  client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "a1b2c3")
72
73
  ```
73
74
 
74
75
  You will need to ensure that you are using an access token created in the sandbox environment. Production tokens will *not* work in the sandbox environment.
75
76
 
77
+
78
+ ## Setting a custom `User-Agent` header
79
+
80
+ You customize the `User-Agent` header for the calls made to the DNSimple API:
81
+
82
+ ```ruby
83
+ client = Dnsimple::Client.new(user_agent: "my-app")
84
+ ```
85
+
86
+ The value you provide will be appended to the default `User-Agent` the client uses. For example, if you use `my-app`, the final header value will be `dnsimple-ruby/4.1.0 my-app` (note that it will vary depending on the client version).
87
+
88
+
76
89
  ## License
77
90
 
78
91
  Copyright (c) 2010-2016 Aetrion LLC. This is Free Software distributed under the MIT license.
@@ -9,6 +9,18 @@ module Dnsimple
9
9
  # Client for the DNSimple API
10
10
  #
11
11
  # @see https://developer.dnsimple.com/
12
+ # @see https://developer.dnsimple.com/sandbox/
13
+ # @see #base_url
14
+ #
15
+ # @example Default (Production)
16
+ # require "dnsimple"
17
+ #
18
+ # client = Dnsimple::Client.new(access_token: "abc")
19
+ #
20
+ # @example Custom Base URL (Sandbox)
21
+ # require 'dnsimple'
22
+ #
23
+ # client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "abc")
12
24
  class Client
13
25
 
14
26
  HEADER_AUTHORIZATION = "Authorization".freeze
@@ -37,15 +49,13 @@ module Dnsimple
37
49
  # @!attribute access_token
38
50
  # @see https://developer.dnsimple.com/v2/#authentication
39
51
  # @return [String] Domain API access token for authentication
40
- # @!attribute base_url
41
- # @return [String] Base URL for API requests. (default: https://api.dnsimple.com/)
42
52
  # @!attribute user_agent
43
53
  # @return [String] Configure User-Agent header for requests.
44
54
  # @!attribute proxy
45
55
  # @return [String,nil] Configure address:port values for proxy server
46
56
 
47
57
  attr_accessor :username, :password, :domain_api_token, :access_token,
48
- :base_url, :user_agent, :proxy
58
+ :user_agent, :proxy
49
59
 
50
60
 
51
61
  def initialize(options = {})
@@ -59,7 +69,24 @@ module Dnsimple
59
69
  end
60
70
 
61
71
 
62
- # @return [String] Base URL for API requests.
72
+ # Base URL for API requests.
73
+ #
74
+ # It defaults to <tt>"https://api.dnsimple.com"</tt>.
75
+ # For testing purposes use <tt>"https://api.sandbox.dnsimple.com"</tt>.
76
+ #
77
+ # @return [String] Base URL
78
+ #
79
+ # @see https://developer.dnsimple.com/sandbox/
80
+ #
81
+ # @example Default (Production)
82
+ # require "dnsimple"
83
+ #
84
+ # client = Dnsimple::Client.new(access_token: "abc")
85
+ #
86
+ # @example Custom Base URL (Sandbox)
87
+ # require 'dnsimple'
88
+ #
89
+ # client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "abc")
63
90
  def base_url
64
91
  Extra.join_uri(@base_url, "")
65
92
  end
@@ -133,12 +133,16 @@ module Dnsimple
133
133
 
134
134
 
135
135
  require_relative 'domains'
136
+ require_relative 'domains_delegation_signer_records'
137
+ require_relative 'domains_dnssec'
136
138
  require_relative 'domains_email_forwards'
137
139
  require_relative 'domains_pushes'
138
140
  require_relative 'collaborators'
139
141
 
140
142
  class DomainsService < ClientService
141
143
  include Client::Domains
144
+ include Client::DomainsDelegationSignerRecords
145
+ include Client::DomainsDnssec
142
146
  include Client::DomainsEmailForwards
143
147
  include Client::DomainsPushes
144
148
  include Client::Collaborators
@@ -14,7 +14,7 @@ module Dnsimple
14
14
  #
15
15
  # @param [Integer] account_id the account ID
16
16
  # @param [#to_s] domain_id the domain ID or name
17
- # @param [Hash] request options
17
+ # @param [Hash] options request options
18
18
  # @option options [Integer] :page current page (pagination)
19
19
  # @option options [Integer] :per_page number of entries to return (pagination)
20
20
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Collaborator>]
@@ -35,9 +35,9 @@ module Dnsimple
35
35
  #
36
36
  # @param [Integer] account_id the account ID
37
37
  # @param [#to_s] domain_id the domain ID or name
38
- # @param [Hash] user attributes
39
- # @param attributes [String] :email user email (mandatory)
40
- # @param [Hash] request options
38
+ # @param [Hash] attributes user attributes
39
+ # @option attributes [String] :email user email (mandatory)
40
+ # @param [Hash] options request options
41
41
  # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::Collaborator>]
42
42
  #
43
43
  # @raise [Dnsimple::RequestError]
@@ -60,7 +60,7 @@ module Dnsimple
60
60
  # @param [Integer] account_id the account ID
61
61
  # @param [#to_s] domain_id the domain ID or name
62
62
  # @param [#to_s] contact_id the contact ID
63
- # @param [Hash] request options
63
+ # @param [Hash] options request options
64
64
  # @return [Dnsimple::Response<nil>]
65
65
  #
66
66
  # @raise [Dnsimple::NotFoundError]
@@ -0,0 +1,122 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsDelegationSignerRecords
4
+
5
+ # Lists the delegation signer records for the domain.
6
+ #
7
+ # @see https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-list
8
+ #
9
+ # @example List delegation signer records in the first page
10
+ # client.domains.delegation_signer_records(1010, "example.com")
11
+ #
12
+ # @example List delegation signer records, provide a specific page
13
+ # client.domains.email_forwards(1010, "example.com", page: 2)
14
+ #
15
+ # @example List delegation signer records, provide a sorting policy
16
+ # client.domains.delegation_signer_records(1010, "example.com", sort: "from:asc")
17
+ #
18
+ # @param [Integer] account_id the account ID
19
+ # @param [#to_s] domain_id The domain ID or domain name
20
+ # @param [Hash] options the filtering and sorting options
21
+ # @option options [Integer] :page current page (pagination)
22
+ # @option options [Integer] :per_page number of entries to return (pagination)
23
+ # @option options [String] :sort sorting policy
24
+ # @return [Dnsimple::PaginatedResponse<Dnsimple::Struct::DelegationSignerRecord>]
25
+ #
26
+ # @raise [Dnsimple::NotFoundError]
27
+ # @raise [Dnsimple::RequestError]
28
+ def delegation_signer_records(account_id, domain_id, options = {})
29
+ response = client.get(Client.versioned("/%s/domains/%s/ds_records" % [account_id, domain_id]), Options::ListOptions.new(options))
30
+
31
+ Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::DelegationSignerRecord.new(r) })
32
+ end
33
+
34
+ # Lists ALL the delegation signer records for the domain.
35
+ #
36
+ # This method is similar to {#delegation_signer_records}, but instead of returning the results of a specific page
37
+ # it iterates all the pages and returns the entire collection.
38
+ #
39
+ # Please use this method carefully, as fetching the entire collection will increase the number of requests
40
+ # you send to the API server and you may eventually risk to hit the throttle limit.
41
+ #
42
+ # @see https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-list
43
+ # @see #email_forwards
44
+ #
45
+ # @param [Integer] account_id the account ID
46
+ # @param [#to_s] domain_id The domain ID or domain name
47
+ # @param [Hash] options the filtering and sorting option
48
+ # @option options [Integer] :page current page (pagination)
49
+ # @option options [Integer] :per_page number of entries to return (pagination)
50
+ # @option options [String] :sort sorting policy
51
+ # @return [Dnsimple::CollectionResponse<Dnsimple::Struct::DelegationSignerRecord>]
52
+ #
53
+ # @raise [Dnsimple::RequestError]
54
+ def all_delegation_signer_records(account_id, domain_id, options = {})
55
+ paginate(:delegation_signer_records, account_id, domain_id, options)
56
+ end
57
+
58
+ # Creates a delegation signer record for the domain.
59
+ #
60
+ # @see https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-create
61
+ # @see http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
62
+ # @see http://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml
63
+ #
64
+ # @param [Integer] account_id the account ID
65
+ # @param [#to_s] domain_id The domain ID or domain name
66
+ # @param [Hash] attributes
67
+ # @option attributes [Integer] :algorithm DNSSEC algorithm as number (required)
68
+ # @option attributes [String] :digest The hexidecimal representation of the digest of the corresponding DNSKEY record (required)
69
+ # @option attributes [Integer] :digest_type DNSSEC digest type (required)
70
+ # @option attributes [String] :keytag A keytag that references the corresponding DNSKEY record (required)
71
+ # @param [Hash] options
72
+ # @return [Dnsimple::Response<Dnsimple::Struct::DelegationSignerRecord>]
73
+ #
74
+ # @raise [Dnsimple::RequestError]
75
+ def create_delegation_signer_record(account_id, domain_id, attributes, options = {})
76
+ Extra.validate_mandatory_attributes(attributes, [:algorithm, :digest, :digest_type, :keytag])
77
+ response = client.post(Client.versioned("/%s/domains/%s/ds_records" % [account_id, domain_id]), attributes, options)
78
+
79
+ Dnsimple::Response.new(response, Struct::DelegationSignerRecord.new(response["data"]))
80
+ end
81
+
82
+ # Gets a delegation signer record for the domain.
83
+ #
84
+ # @see https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-get
85
+ #
86
+ # @param [Integer] account_id the account ID
87
+ # @param [#to_s] domain_id The domain ID or domain name
88
+ # @param [#to_s] ds_record_id The delegation signer record ID
89
+ # @param [Hash] options
90
+ # @return [Dnsimple::Response<Dnsimple::Struct::DelegationSignerRecord>]
91
+ #
92
+ # @raise [Dnsimple::NotFoundError]
93
+ # @raise [Dnsimple::RequestError]
94
+ def delegation_signer_record(account_id, domain_id, ds_record_id, options = {})
95
+ response = client.get(Client.versioned("/%s/domains/%s/ds_records/%s" % [account_id, domain_id, ds_record_id]), options)
96
+
97
+ Dnsimple::Response.new(response, Struct::DelegationSignerRecord.new(response["data"]))
98
+ end
99
+
100
+ # Deletes a delegation signer record for the domain.
101
+ #
102
+ # WARNING: this cannot be undone.
103
+ #
104
+ # @see https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-delete
105
+ #
106
+ # @param [Integer] account_id the account ID
107
+ # @param [#to_s] domain_id The domain ID or domain name
108
+ # @param [#to_s] ds_record_id The delegation signer record ID
109
+ # @param [Hash] options
110
+ # @return [Dnsimple::Response<nil>]
111
+ #
112
+ # @raise [Dnsimple::NotFoundError]
113
+ # @raise [Dnsimple::RequestError]
114
+ def delete_delegation_signer_record(account_id, domain_id, ds_record_id, options = {})
115
+ response = client.delete(Client.versioned("/%s/domains/%s/ds_records/%s" % [account_id, domain_id, ds_record_id]), nil, options)
116
+
117
+ Dnsimple::Response.new(response, nil)
118
+ end
119
+
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,57 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsDnssec
4
+
5
+ # Enable DNSSEC for the domain in the account.
6
+ #
7
+ # @see https://developer.dnsimple.com/v2/dnssec/#enable
8
+ #
9
+ # @param [Integer] account_id the account ID
10
+ # @param [#to_s] domain_name the domain name
11
+ # @param [Hash] options
12
+ # @return [Dnsimple::Response<Dnsimple::Struct::Dnssec>]
13
+ #
14
+ # @raise [Dnsimple::NotFoundError]
15
+ # @raise [Dnsimple::RequestError]
16
+ def enable_dnssec(account_id, domain_name, options = {})
17
+ response = client.post(Client.versioned("/%s/domains/%s/dnssec" % [account_id, domain_name]), nil, options)
18
+
19
+ Dnsimple::Response.new(response, Struct::Dnssec.new(response["data"]))
20
+ end
21
+
22
+ # Disable DNSSEC for the domain in the account.
23
+ #
24
+ # @see https://developer.dnsimple.com/v2/dnssec/#disable
25
+ #
26
+ # @param [Integer] account_id the account ID
27
+ # @param [#to_s] domain_name the domain name
28
+ # @param [Hash] options
29
+ # @return [Dnsimple::Response<nil>]
30
+ #
31
+ # @raise [Dnsimple::NotFoundError]
32
+ # @raise [Dnsimple::RequestError]
33
+ def disable_dnssec(account_id, domain_name, options = {})
34
+ response = client.delete(Client.versioned("/%s/domains/%s/dnssec" % [account_id, domain_name]), nil, options)
35
+
36
+ Dnsimple::Response.new(response, nil)
37
+ end
38
+
39
+ # Get the DNSSEC status for the domain in the account.
40
+ #
41
+ # @see https://developer.dnsimple.com/v2/dnssec/#get
42
+ #
43
+ # @param [Integer] account_id the account ID
44
+ # @param [#to_s] domain_name the domain name
45
+ # @param [Hash] options
46
+ # @return [Dnsimple::Response<Dnsimple::Struct::Dnssec>]
47
+ #
48
+ # @raise [Dnsimple::NotFoundError]
49
+ # @raise [Dnsimple::RequestError]
50
+ def get_dnssec(account_id, domain_name, options = {})
51
+ response = client.get(Client.versioned("/%s/domains/%s/dnssec" % [account_id, domain_name]), options)
52
+
53
+ Dnsimple::Response.new(response, Struct::Dnssec.new(response["data"]))
54
+ end
55
+ end
56
+ end
57
+ end