fog-dnsimple 1.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0354086ffbb0b1f2866f487a18268ba11eb6be51
4
- data.tar.gz: ccfcba77bec25c5a529c1f0458fd324e7ada83dc
3
+ metadata.gz: 7ae36b9bfa292d8ec1b6f188e38f00c38250b6cb
4
+ data.tar.gz: 4a8d56b5b4a8c37113305ec80fa61283964c60b1
5
5
  SHA512:
6
- metadata.gz: 7ef2487be043841076620e863a78c8553f658710b315b1fed129cdf67b28460998fb0016d89a8def934f3727ceae2a8819aeb014ac02d9f242d1b7a37072be7c
7
- data.tar.gz: 48ff4ad4dc4d169df5d2527d98a0e1d85b8111cda50351c6e0a8ad3db7d93ca5c480ca9fbb4035f77787fd28ba66951ce5c1064784b6b79d500953a734a1bb16
6
+ metadata.gz: bd86df711ff013b7f711afb7edaf0897a5ccc4788ea13a52beb05b12d8f19e2c802de6c3cd611403fa03e949a7bbb257453297a9a5d136eaec8590ecbf254173
7
+ data.tar.gz: 50533cd840e2002326d4ce7c17251289a82dc1607bb0033ec5726ed2a504a2565d5d9e0bbdae0ae69144fa55b84a72aa685787707be4a1409d9940fcf0781ab5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+
4
+ #### Release 2.0
5
+
6
+ Upgrade to DNSimple API v2.
7
+ https://developer.dnsimple.com/v2/
8
+
9
+ In order to use API v2 you need an API v2 Oauth token, and the accound ID. The account ID is the ID visible in the URL of the page, after /a.
10
+
11
+ https://dnsimple.com/a/1234/domains/example.com
12
+ -> 1234
13
+
14
+
3
15
  #### Release 1.0
4
16
 
5
17
  Initial version, extracted from `fog`.
data/README.md CHANGED
@@ -35,9 +35,9 @@ Initialize a `Fog::DNS` object using the DNSimple provider.
35
35
 
36
36
  ```ruby
37
37
  dns = Fog::DNS.new({
38
- provider: "DNSimple",
39
- dnsimple_email: "YOUR_EMAIL",
40
- dnsimple_token: "YOUR_API_V1_TOKEN",
38
+ provider: "DNSimple",
39
+ dnsimple_token: "YOUR_API_TOKEN",
40
+ dnsimple_account: "YOUR_ACCOUNT_ID",
41
41
  })
42
42
  ```
43
43
 
@@ -45,11 +45,11 @@ This can then be used like other [Fog DNS](http://fog.io/dns/) providers.
45
45
 
46
46
  ```ruby
47
47
  zone = dns.zones.create(
48
- domain: "example.com
48
+ domain: "example.com"
49
49
  )
50
50
  record = zone.records.create(
51
- name: "example.com,
52
- value: "1.2.3.4,
51
+ name: "foo",
52
+ value: "1.2.3.4",
53
53
  type: "A"
54
54
  )
55
55
  ```
@@ -60,18 +60,6 @@ The following configurations are supported:
60
60
  dns = Fog::DNS.new({
61
61
  # Use dnsimple_url to provide a different base URL, e.g. the Sandbox URL
62
62
  dnsimple_url: "https://api.sandbox.dnsimple.com/",
63
-
64
- # API v1 token-based authentication
65
- dnsimple_email: "...",
66
- dnsimple_token: "...",
67
-
68
- # API v1 basic-auth
69
- dnsimple_email: "...",
70
- dnsimple_password: "...",
71
-
72
- # API v1 domain-token authentication
73
- dnsimple_domain: "example.com",
74
- dnsimple_token: "...",
75
63
  })
76
64
  ```
77
65
 
data/fog-dnsimple.gemspec CHANGED
@@ -16,13 +16,14 @@ Gem::Specification.new do |spec|
16
16
  spec.license = "MIT"
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
21
  spec.require_paths = ["lib"]
21
22
 
22
23
  spec.add_development_dependency "bundler", "~> 1.12"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake", "~> 12.0"
24
25
  spec.add_development_dependency "shindo", "~> 0.3"
25
26
 
26
- spec.add_dependency 'fog-core', '~> 1.38'
27
+ spec.add_dependency 'fog-core', '>= 1.38', '< 3'
27
28
  spec.add_dependency 'fog-json', '~> 1.0'
28
29
  end
@@ -13,7 +13,7 @@ class Dnsimple < Fog::Bin
13
13
  @@connections ||= Hash.new do |hash, key|
14
14
  hash[key] = case key
15
15
  when :dns
16
- Fog::DNS.new(:provider => 'Dnsimple')
16
+ Fog::DNS.new(provider: "Dnsimple")
17
17
  else
18
18
  raise ArgumentError, "Unrecognized service: #{key.inspect}"
19
19
  end
@@ -4,7 +4,7 @@ require "fog/json"
4
4
  module Fog
5
5
  module DNS
6
6
  class Dnsimple < Fog::Service
7
- recognizes :dnsimple_email, :dnsimple_password, :dnsimple_token, :dnsimple_domain, :dnsimple_url
7
+ recognizes :dnsimple_token, :dnsimple_account, :dnsimple_url
8
8
 
9
9
  model_path 'fog/dnsimple/models/dns'
10
10
  model :record
@@ -27,8 +27,8 @@ module Fog
27
27
  def self.data
28
28
  @data ||= Hash.new do |hash, key|
29
29
  hash[key] = {
30
- :domains => [],
31
- :records => {}
30
+ domains: [],
31
+ records: {}
32
32
  }
33
33
  end
34
34
  end
@@ -37,28 +37,23 @@ module Fog
37
37
  @data = nil
38
38
  end
39
39
 
40
- def initialize(options={})
41
- @dnsimple_email = options[:dnsimple_email]
42
- @dnsimple_password = options[:dnsimple_password]
40
+ def initialize(options = {})
43
41
  @dnsimple_token = options[:dnsimple_token]
44
- @dnsimple_domain = options[:dnsimple_domain]
45
42
  end
46
43
 
47
44
  def data
48
- self.class.data[@dnsimple_email]
45
+ self.class.data[@dnsimple_token]
49
46
  end
50
47
 
51
48
  def reset_data
52
- self.class.data.delete(@dnsimple_email)
49
+ self.class.data.delete(@dnsimple_token)
53
50
  end
54
51
  end
55
52
 
56
53
  class Real
57
- def initialize(options={})
58
- @dnsimple_email = options[:dnsimple_email]
59
- @dnsimple_password = options[:dnsimple_password]
54
+ def initialize(options = {})
60
55
  @dnsimple_token = options[:dnsimple_token]
61
- @dnsimple_domain = options[:dnsimple_domain]
56
+ @dnsimple_account = options[:dnsimple_account]
62
57
 
63
58
  if options[:dnsimple_url]
64
59
  uri = URI.parse(options[:dnsimple_url])
@@ -74,7 +69,7 @@ module Fog
74
69
  host = options[:host] || "api.dnsimple.com"
75
70
  persistent = options[:persistent] || false
76
71
  port = options[:port] || 443
77
- scheme = options[:scheme] || 'https'
72
+ scheme = options[:scheme] || "https"
78
73
  @connection = Fog::Core::Connection.new("#{scheme}://#{host}:#{port}", persistent, connection_options)
79
74
  end
80
75
 
@@ -85,15 +80,8 @@ module Fog
85
80
  def request(params)
86
81
  params[:headers] ||= {}
87
82
 
88
- if(@dnsimple_password)
89
- key = "#{@dnsimple_email}:#{@dnsimple_password}"
90
- params[:headers].merge!("Authorization" => "Basic " + Base64.encode64(key).gsub("\n",''))
91
- elsif(@dnsimple_token)
92
- if(@dnsimple_domain)
93
- params[:headers].merge!("X-DNSimple-Domain-Token" => @dnsimple_token)
94
- else
95
- params[:headers].merge!("X-DNSimple-Token" => "#{@dnsimple_email}:#{@dnsimple_token}")
96
- end
83
+ if @dnsimple_token && @dnsimple_account
84
+ params[:headers].merge!("Authorization" => "Bearer #{@dnsimple_token}")
97
85
  else
98
86
  raise ArgumentError.new("Insufficient credentials to properly authenticate!")
99
87
  end
@@ -102,8 +90,8 @@ module Fog
102
90
  "Content-Type" => "application/json"
103
91
  )
104
92
 
105
- version = params.delete(:version) || 'v1'
106
- params[:path] = File.join('/', version, params[:path])
93
+ version = params.delete(:version) || "v2"
94
+ params[:path] = File.join("/", version, params[:path])
107
95
 
108
96
  response = @connection.request(params)
109
97
 
@@ -6,16 +6,16 @@ module Fog
6
6
  class Record < Fog::Model
7
7
  identity :id
8
8
 
9
- attribute :zone_id, :aliases => "domain_id"
9
+ attribute :zone_id, aliases: "domain_id"
10
10
  attribute :name
11
- attribute :value, :aliases => "content"
11
+ attribute :value, aliases: "content"
12
12
  attribute :ttl
13
- attribute :priority, :aliases => "prio"
14
- attribute :type, :aliases => "record_type"
13
+ attribute :priority
14
+ attribute :type
15
15
  attribute :created_at
16
16
  attribute :updated_at
17
17
 
18
- def initialize(attributes={})
18
+ def initialize(attributes = {})
19
19
  super
20
20
  end
21
21
 
@@ -31,8 +31,7 @@ module Fog
31
31
  def save
32
32
  requires :name, :type, :value
33
33
  options = {}
34
- options[:prio] = priority if priority
35
- options[:ttl] = ttl if ttl
34
+ options[:ttl] = ttl if ttl
36
35
 
37
36
  # decide whether its a new record or update of an existing
38
37
  if id.nil?
@@ -44,7 +43,7 @@ module Fog
44
43
  data = service.update_record(zone.id, id, options)
45
44
  end
46
45
 
47
- merge_attributes(data.body["record"])
46
+ merge_attributes(data.body["data"])
48
47
  true
49
48
  end
50
49
 
@@ -12,13 +12,13 @@ module Fog
12
12
  def all
13
13
  requires :zone
14
14
  clear
15
- data = service.list_records(zone.id).body.map {|record| record['record']}
15
+ data = service.list_records(zone.id).body["data"]
16
16
  load(data)
17
17
  end
18
18
 
19
19
  def get(record_id)
20
20
  requires :zone
21
- data = service.get_record(zone.id, record_id).body["record"]
21
+ data = service.get_record(zone.id, record_id).body["data"]
22
22
  new(data)
23
23
  rescue Excon::Errors::NotFound
24
24
  nil
@@ -26,7 +26,7 @@ module Fog
26
26
 
27
27
  def new(attributes = {})
28
28
  requires :zone
29
- super({ :zone => zone }.merge!(attributes))
29
+ super({ zone: zone }.merge!(attributes))
30
30
  end
31
31
  end
32
32
  end
@@ -7,7 +7,7 @@ module Fog
7
7
  class Zone < Fog::Model
8
8
  identity :id
9
9
 
10
- attribute :domain, :aliases => 'name'
10
+ attribute :domain, aliases: "name"
11
11
  attribute :created_at
12
12
  attribute :updated_at
13
13
 
@@ -36,7 +36,7 @@ module Fog
36
36
 
37
37
  def save
38
38
  requires :domain
39
- data = service.create_domain(domain).body["domain"]
39
+ data = service.create_domain(domain).body["data"]
40
40
  merge_attributes(data)
41
41
  true
42
42
  end
@@ -9,12 +9,12 @@ module Fog
9
9
 
10
10
  def all
11
11
  clear
12
- data = service.list_domains.body.map {|zone| zone['domain']}
12
+ data = service.list_domains.body["data"]
13
13
  load(data)
14
14
  end
15
15
 
16
16
  def get(zone_id)
17
- data = service.get_domain(zone_id).body['domain']
17
+ data = service.get_domain(zone_id).body["data"]
18
18
  new(data)
19
19
  rescue Excon::Errors::NotFound
20
20
  nil
@@ -5,55 +5,47 @@ module Fog
5
5
  # Create a single domain in DNSimple in your account.
6
6
  #
7
7
  # ==== Parameters
8
- # * name<~String> - domain name to host (ie example.com)
8
+ # * zone_name<~String> - zone name to host (ie example.com)
9
9
  #
10
10
  # ==== Returns
11
11
  # * response<~Excon::Response>:
12
12
  # * body<~Hash>:
13
- # * 'domain'<~Hash> The representation of the domain.
14
- def create_domain(name)
13
+ # * "data"<~Hash> The representation of the domain.
14
+ def create_domain(zone_name)
15
15
  body = {
16
- "domain" => {
17
- "name" => name
18
- }
16
+ "name" => zone_name
19
17
  }
20
18
 
21
19
  request(
22
- :body => Fog::JSON.encode(body),
23
- :expects => 201,
24
- :method => 'POST',
25
- :path => "/domains"
20
+ body: Fog::JSON.encode(body),
21
+ expects: 201,
22
+ method: "POST",
23
+ path: "/#{@dnsimple_account}/domains"
26
24
  )
27
25
  end
28
26
  end
29
27
 
30
28
  class Mock
31
- def create_domain(name)
29
+ def create_domain(zone_name)
32
30
  body = {
33
- "domain" => {
34
- "id" => Fog::Mock.random_numbers(1).to_i,
35
- "user_id" => 1,
36
- "registrant_id" => nil,
37
- "name" => name,
38
- "unicode_name" => name,
39
- "token" => "4fIFYWYiJayvL2tkf_mkBkqC4L+4RtYqDA",
40
- "state" => "registered",
41
- "language" => nil,
42
- "lockable" => true,
43
- "auto_renew" => nil,
44
- "whois_protected" => false,
45
- "record_count" => 0,
46
- "service_count" => 0,
47
- "expires_on" => Date.today + 365,
48
- "created_at" => Time.now.iso8601,
49
- "updated_at" => Time.now.iso8601,
50
- }
31
+ "id" => Fog::Mock.random_numbers(1).to_i,
32
+ "account_id" => @dnsimple_account,
33
+ "registrant_id" => nil,
34
+ "name" => zone_name,
35
+ "unicode_name" => zone_name,
36
+ "token" => "4fIFYWYiJayvL2tkf_mkBkqC4L+4RtYqDA",
37
+ "state" => "registered",
38
+ "auto_renew" => nil,
39
+ "private_whois" => false,
40
+ "expires_on" => Date.today + 365,
41
+ "created_at" => Time.now.iso8601,
42
+ "updated_at" => Time.now.iso8601,
51
43
  }
52
44
  self.data[:domains] << body
53
45
 
54
46
  response = Excon::Response.new
55
47
  response.status = 201
56
- response.body = body
48
+ response.body = { "data" => body }
57
49
  response
58
50
  end
59
51
  end
@@ -5,7 +5,7 @@ module Fog
5
5
  # Create a new host in the specified zone
6
6
  #
7
7
  # ==== Parameters
8
- # * domain<~String> - domain name or numeric ID
8
+ # * zone_name<~String> - zone name
9
9
  # * name<~String>
10
10
  # * type<~String>
11
11
  # * content<~String>
@@ -17,48 +17,43 @@ module Fog
17
17
  # * response<~Excon::Response>:
18
18
  # * body<~Hash>:
19
19
  # * 'record'<~Hash> The representation of the record.
20
- def create_record(domain, name, type, content, options = {})
20
+ def create_record(zone_name, name, type, content, options = {})
21
21
  body = {
22
- "record" => {
23
- "name" => name,
24
- "record_type" => type,
25
- "content" => content
26
- }
22
+ "name" => name,
23
+ "type" => type,
24
+ "content" => content
27
25
  }
28
-
29
- body["record"].merge!(options)
26
+ body.merge!(options)
30
27
 
31
28
  request(
32
- :body => Fog::JSON.encode(body),
33
- :expects => 201,
34
- :method => 'POST',
35
- :path => "/domains/#{domain}/records"
29
+ body: Fog::JSON.encode(body),
30
+ expects: 201,
31
+ method: "POST",
32
+ path: "/#{@dnsimple_account}/zones/#{zone_name}/records"
36
33
  )
37
34
  end
38
35
  end
39
36
 
40
37
  class Mock
41
- def create_record(domain, name, type, content, options = {})
38
+ def create_record(zone_name, name, type, content, options = {})
42
39
  body = {
43
- "record" => {
44
- "id" => Fog::Mock.random_numbers(1).to_i,
45
- "domain_id" => domain,
46
- "name" => name,
47
- "content" => content,
48
- "ttl" => 3600,
49
- "prio" => nil,
50
- "record_type" => type,
51
- "system_record" => nil,
52
- "created_at" => Time.now.iso8601,
53
- "updated_at" => Time.now.iso8601,
54
- }.merge(options)
55
- }
56
- self.data[:records][domain] ||= []
57
- self.data[:records][domain] << body
40
+ "id" => Fog::Mock.random_numbers(1).to_i,
41
+ "domain_id" => 1,
42
+ "name" => name,
43
+ "content" => content,
44
+ "ttl" => 3600,
45
+ "priority" => 0,
46
+ "type" => type,
47
+ "system_record" => false,
48
+ "created_at" => Time.now.iso8601,
49
+ "updated_at" => Time.now.iso8601,
50
+ }.merge(options)
51
+ self.data[:records][zone_name] ||= []
52
+ self.data[:records][zone_name] << body
58
53
 
59
54
  response = Excon::Response.new
60
55
  response.status = 201
61
- response.body = body
56
+ response.body = { "data" => body }
62
57
  response
63
58
  end
64
59
  end
@@ -9,24 +9,25 @@ module Fog
9
9
  # DNSimple this will not delete the domain from the registry.
10
10
  #
11
11
  # ==== Parameters
12
- # * domain<~String> - domain name or numeric ID
12
+ # * account_id<~String> - the account the domain belong to
13
+ # * zone_name<~String> - zone name
13
14
  #
14
- def delete_domain(domain)
15
+ def delete_domain(zone_name)
15
16
  request(
16
- :expects => 200,
17
- :method => 'DELETE',
18
- :path => "/domains/#{domain}"
17
+ expects: 204,
18
+ method: "DELETE",
19
+ path: "/#{@dnsimple_account}/domains/#{zone_name}"
19
20
  )
20
21
  end
21
22
  end
22
23
 
23
24
  class Mock
24
- def delete_domain(name)
25
- self.data[:records].delete name
26
- self.data[:domains].reject! { |domain| domain["domain"]["name"] == name }
25
+ def delete_domain(zone_name)
26
+ self.data[:records].delete(zone_name)
27
+ self.data[:domains].reject! { |domain| domain["name"] == zone_name }
27
28
 
28
29
  response = Excon::Response.new
29
- response.status = 200
30
+ response.status = 204
30
31
  response
31
32
  end
32
33
  end
@@ -5,23 +5,23 @@ module Fog
5
5
  # Delete the record with the given ID for the given domain.
6
6
  #
7
7
  # ==== Parameters
8
- # * domain<~String> - domain name or numeric ID
8
+ # * zone_name<~String> - zone name
9
9
  # * record_id<~String>
10
- def delete_record(domain, record_id)
10
+ def delete_record(zone_name, record_id)
11
11
  request(
12
- :expects => 200,
13
- :method => "DELETE",
14
- :path => "/domains/#{domain}/records/#{record_id}"
12
+ expects: 204,
13
+ method: "DELETE",
14
+ path: "/#{@dnsimple_account}/zones/#{zone_name}/records/#{record_id}"
15
15
  )
16
16
  end
17
17
  end
18
18
 
19
19
  class Mock
20
- def delete_record(domain, record_id)
21
- self.data[:records][domain].reject! { |record| record["record"]["id"] == record_id }
20
+ def delete_record(zone_name, record_id)
21
+ self.data[:records][zone_name].reject! { |record| record["id"] == record_id }
22
22
 
23
23
  response = Excon::Response.new
24
- response.status = 200
24
+ response.status = 204
25
25
  response
26
26
  end
27
27
  end
@@ -7,30 +7,30 @@ module Fog
7
7
  # itself.
8
8
  #
9
9
  # ==== Parameters
10
- # * domain<~String> - domain name or numeric ID
10
+ # * zone_name<~String> - zone name
11
11
  #
12
12
  # ==== Returns
13
13
  # * response<~Excon::Response>:
14
14
  # * body<~Hash>:
15
- # * 'domain'<~Hash> The representation of the domain.
16
- def get_domain(domain)
15
+ # * "data"<~Hash> The representation of the domain.
16
+ def get_domain(zone_name)
17
17
  request(
18
- :expects => 200,
19
- :method => "GET",
20
- :path => "/domains/#{domain}"
18
+ expects: 200,
19
+ method: "GET",
20
+ path: "/#{@dnsimple_account}/domains/#{zone_name}"
21
21
  )
22
22
  end
23
23
  end
24
24
 
25
25
  class Mock
26
- def get_domain(id)
26
+ def get_domain(zone_name)
27
27
  domain = self.data[:domains].find do |domain|
28
- domain["domain"]["id"] == id || domain["domain"]["name"] == id
28
+ domain["id"] == zone_name || domain["name"] == zone_name
29
29
  end
30
30
 
31
31
  response = Excon::Response.new
32
32
  response.status = 200
33
- response.body = domain
33
+ response.body = { "data" => domain }
34
34
  response
35
35
  end
36
36
  end
@@ -5,29 +5,29 @@ module Fog
5
5
  # Gets record from given domain.
6
6
  #
7
7
  # ==== Parameters
8
- # * domain<~String> - domain name or numeric ID
8
+ # * zone_name<~String> - zone name
9
9
  # * record_id<~String>
10
10
  #
11
11
  # ==== Returns
12
12
  # * response<~Excon::Response>:
13
13
  # * body<~Hash>:
14
- # * 'record'<~Hash> The representation of the record.
15
- def get_record(domain, record_id)
14
+ # * "data"<~Hash> The representation of the record.
15
+ def get_record(zone_name, record_id)
16
16
  request(
17
- :expects => 200,
18
- :method => "GET",
19
- :path => "/domains/#{domain}/records/#{record_id}"
17
+ expects: 200,
18
+ method: "GET",
19
+ path: "/#{@dnsimple_account}/zones/#{zone_name}/records/#{record_id}"
20
20
  )
21
21
  end
22
22
  end
23
23
 
24
24
  class Mock
25
- def get_record(domain, record_id)
25
+ def get_record(zone_name, record_id)
26
26
  response = Excon::Response.new
27
27
 
28
- if self.data[:records].key?(domain)
28
+ if self.data[:records].key?(zone_name)
29
29
  response.status = 200
30
- response.body = self.data[:records][domain].find { |record| record["record"]["id"] == record_id }
30
+ response.body = { "data" => self.data[:records][zone_name].find { |record| record["id"] == record_id }}
31
31
 
32
32
  if response.body.nil?
33
33
  response.status = 404
@@ -38,7 +38,7 @@ module Fog
38
38
  else
39
39
  response.status = 404
40
40
  response.body = {
41
- "error" => "Couldn't find Domain with name = #{domain}"
41
+ "error" => "Couldn't find Domain with name = #{zone_name}"
42
42
  }
43
43
  end
44
44
  response
@@ -2,21 +2,20 @@ module Fog
2
2
  module DNS
3
3
  class Dnsimple
4
4
  class Real
5
- # Get the details for a specific domain in your account. You
6
- # may pass either the domain numeric ID or the domain name itself.
5
+ # Get the list of domains in the account.
7
6
  #
8
7
  # ==== Parameters
9
8
  #
10
9
  # ==== Returns
11
10
  # * response<~Excon::Response>:
12
11
  # * body<~Hash>:
13
- # * <~Array>:
14
- # * 'domain'<~Hash> The representation of the domain.
12
+ # * "data"<~Array>:
13
+ # * <~Hash> The representation of the domain.
15
14
  def list_domains
16
15
  request(
17
- :expects => 200,
18
- :method => 'GET',
19
- :path => '/domains'
16
+ expects: 200,
17
+ method: "GET",
18
+ path: "/#{@dnsimple_account}/domains"
20
19
  )
21
20
  end
22
21
  end
@@ -25,7 +24,7 @@ module Fog
25
24
  def list_domains
26
25
  response = Excon::Response.new
27
26
  response.status = 200
28
- response.body = self.data[:domains]
27
+ response.body = { "data" => self.data[:domains] }
29
28
  response
30
29
  end
31
30
  end
@@ -5,27 +5,27 @@ module Fog
5
5
  # Get the list of records for the specific domain.
6
6
  #
7
7
  # ==== Parameters
8
- # * domain<~String> - domain name or numeric ID
8
+ # * zone_name<~String> - zone name
9
9
  #
10
10
  # ==== Returns
11
11
  # * response<~Excon::Response>:
12
12
  # * body<~Hash>:
13
- # * <~Array>:
14
- # * 'record'<~Hash> The representation of the record.
15
- def list_records(domain)
13
+ # * "data"<~Array>:
14
+ # * <~Hash> The representation of the record.
15
+ def list_records(zone_name)
16
16
  request(
17
- :expects => 200,
18
- :method => "GET",
19
- :path => "/domains/#{domain}/records"
17
+ expects: 200,
18
+ method: "GET",
19
+ path: "/#{@dnsimple_account}/zones/#{zone_name}/records"
20
20
  )
21
21
  end
22
22
  end
23
23
 
24
24
  class Mock
25
- def list_records(domain)
25
+ def list_records(zone_name)
26
26
  response = Excon::Response.new
27
27
  response.status = 200
28
- response.body = self.data[:records][domain] || []
28
+ response.body = { "data" => self.data[:records][zone_name] || [] }
29
29
  response
30
30
  end
31
31
  end
@@ -5,7 +5,7 @@ module Fog
5
5
  # Update the given record for the given domain.
6
6
  #
7
7
  # ==== Parameters
8
- # * domain<~String> - domain name or numeric ID
8
+ # * zone_name<~String> - zone name
9
9
  # * record_id<~String>
10
10
  # * options<~Hash> - optional
11
11
  # * type<~String>
@@ -16,33 +16,31 @@ module Fog
16
16
  # ==== Returns
17
17
  # * response<~Excon::Response>:
18
18
  # * body<~Hash>:
19
- # * 'record'<~Hash> The representation of the record.
20
- def update_record(domain, record_id, options)
21
- body = {
22
- "record" => options
23
- }
19
+ # * "data"<~Hash> The representation of the record.
20
+ def update_record(zone_name, record_id, options)
21
+ body = options
24
22
 
25
23
  request(
26
- :body => Fog::JSON.encode(body),
27
- :expects => 200,
28
- :method => "PUT",
29
- :path => "/domains/#{domain}/records/#{record_id}"
24
+ body: Fog::JSON.encode(body),
25
+ expects: 200,
26
+ method: "PATCH",
27
+ path: "/#{@dnsimple_account}/zones/#{zone_name}/records/#{record_id}"
30
28
  )
31
29
  end
32
30
  end
33
31
 
34
32
  class Mock
35
- def update_record(domain, record_id, options)
36
- record = self.data[:records][domain].find { |record| record["record"]["id"] == record_id }
33
+ def update_record(zone_name, record_id, options)
34
+ record = self.data[:records][zone_name].find { |record| record["id"] == record_id }
37
35
  response = Excon::Response.new
38
36
 
39
37
  if record.nil?
40
38
  response.status = 400
41
39
  else
42
40
  response.status = 200
43
- record["record"].merge!(options)
44
- record["record"]["updated_at"] = Time.now.iso8601
45
- response.body = record
41
+ record.merge!(options)
42
+ record["updated_at"] = Time.now.iso8601
43
+ response.body = { "data" => record }
46
44
  end
47
45
 
48
46
  response
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Dnsimple
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -6,9 +6,9 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
6
6
  tests("success") do
7
7
 
8
8
  test("get current domain count") do
9
- response = Fog::DNS[:dnsimple].list_domains()
9
+ response = Fog::DNS[:dnsimple].list_domains
10
10
  if response.status == 200
11
- @domain_count = response.body.size
11
+ @domain_count = response.body["data"].size
12
12
  end
13
13
 
14
14
  response.status == 200
@@ -18,7 +18,7 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
18
18
  domain = generate_unique_domain
19
19
  response = Fog::DNS[:dnsimple].create_domain(domain)
20
20
  if response.status == 201
21
- @domain = response.body["domain"]
21
+ @domain = response.body["data"]
22
22
  end
23
23
 
24
24
  response.status == 201
@@ -37,7 +37,7 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
37
37
  response = Fog::DNS[:dnsimple].create_record(domain, name, type, content)
38
38
 
39
39
  if response.status == 201
40
- @record = response.body["record"]
40
+ @record = response.body["data"]
41
41
  end
42
42
 
43
43
  response.status == 201
@@ -49,7 +49,7 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
49
49
  name = ""
50
50
  type = "MX"
51
51
  content = "mail.#{domain}"
52
- options = { "ttl" => 60, "prio" => 10 }
52
+ options = { "ttl" => 60, "priority" => 10 }
53
53
  response = Fog::DNS[:dnsimple].create_record(domain, name, type, content, options)
54
54
 
55
55
  test "MX record creation returns 201" do
@@ -57,11 +57,11 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
57
57
  end
58
58
 
59
59
  options.each do |key, value|
60
- test("MX record has option #{key}") { value == response.body["record"][key.to_s] }
60
+ test("MX record has option #{key}") { value == response.body["data"][key.to_s] }
61
61
  end
62
62
 
63
63
  test "MX record is correct type" do
64
- response.body["record"]["record_type"] == "MX"
64
+ response.body["data"]["type"] == "MX"
65
65
  end
66
66
  end
67
67
 
@@ -71,7 +71,7 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
71
71
 
72
72
  response = Fog::DNS[:dnsimple].get_record(domain, record_id)
73
73
 
74
- (response.status == 200) and (@record == response.body["record"])
74
+ (response.status == 200) and (@record == response.body["data"])
75
75
  end
76
76
 
77
77
  test("update a record") do
@@ -86,11 +86,11 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
86
86
  response = Fog::DNS[:dnsimple].list_records(@domain["name"])
87
87
 
88
88
  if response.status == 200
89
- @records = response.body
89
+ @records = response.body["data"]
90
90
  end
91
91
 
92
92
  test "list records returns all records for domain" do
93
- @records.reject { |record| record["record"]["system_record"] }.size == 2
93
+ @records.reject { |record| record["system_record"] }.size == 2
94
94
  end
95
95
 
96
96
  response.status == 200
@@ -101,9 +101,9 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
101
101
 
102
102
  result = true
103
103
  @records.each do |record|
104
- next if record["record"]["system_record"]
105
- response = Fog::DNS[:dnsimple].delete_record(domain, record["record"]["id"])
106
- if response.status != 200
104
+ next if record["system_record"]
105
+ response = Fog::DNS[:dnsimple].delete_record(domain, record["id"])
106
+ if response.status != 204
107
107
  result = false
108
108
  break
109
109
  end
@@ -114,7 +114,7 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
114
114
 
115
115
  test("delete domain") do
116
116
  response = Fog::DNS[:dnsimple].delete_domain(@domain["name"])
117
- response.status == 200
117
+ response.status == 204
118
118
  end
119
119
 
120
120
  end
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: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: shindo
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,22 @@ dependencies:
56
56
  name: fog-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.38'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '3'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
67
70
  - !ruby/object:Gem::Version
68
71
  version: '1.38'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '3'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: fog-json
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -85,9 +91,7 @@ description: |-
85
91
  to use the DNSimple in applications.
86
92
  email:
87
93
  - weppos@weppos.net
88
- executables:
89
- - console
90
- - setup
94
+ executables: []
91
95
  extensions: []
92
96
  extra_rdoc_files: []
93
97
  files:
@@ -147,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
151
  version: '0'
148
152
  requirements: []
149
153
  rubyforge_project:
150
- rubygems_version: 2.5.1
154
+ rubygems_version: 2.6.13
151
155
  signing_key:
152
156
  specification_version: 4
153
157
  summary: Module for the 'fog' gem to support DNSimple.