dnsmadeeasy-api 0.9.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  = Changelog
2
2
 
3
+ == Release 1.0.0 - Jul 08, 2011
4
+
5
+ * CHANGE: The hashes returned by api methods now have symbols as keys, as opposed to string. This makes them consistent with the hashes used for creating and updating records.
6
+ * CHANGE: The update_record! method does not require the entire record to be re-specified. Only the parameters to be changed need to be specified.
7
+ * NEW: Command level help in the command line utility
8
+
3
9
  == Release 0.9.7 - Jul 08, 2011
4
10
 
5
11
  * FIX: API Documentation
data/Rakefile CHANGED
@@ -2,9 +2,9 @@ require "rubygems"
2
2
  require "rake"
3
3
  require "echoe"
4
4
 
5
- Echoe.new("dnsmadeeasy-api", "0.9.7") do |p|
6
- p.description = "Ruby client for DNSMadeEasy API."
7
- p.summary = "Ruby client for DNSMadeEasy API."
5
+ Echoe.new("dnsmadeeasy-api", "1.0.0") do |p|
6
+ p.description = "Ruby client and commandline utility for the DNSMadeEasy API."
7
+ p.summary = "Ruby client and commandline utility for the DNSMadeEasy API."
8
8
  p.url = "http://rubygems.org/gems/dnsmadeeasy-api"
9
9
  p.author = "Nitesh Goel"
10
10
  p.email = "nitesh@sigfig.com"
data/bin/dme CHANGED
@@ -30,16 +30,99 @@ module DnsMadeEasy
30
30
  "delete-records" => "Delete multiple dns records",
31
31
  "delete-record" => "Delete a dns record",
32
32
  "update-record" => "Update an existing dns record",
33
- "describe-record" => "Describe an existing dns record"
33
+ "describe-record" => "Describe an existing dns record",
34
+ "help" => "Print help message"
34
35
  }
35
36
  help = "Usage: dme command [options]"
36
37
  help << "\nValid commands\n"
37
38
  valid_commands.each do |name, description|
38
39
  help << "\t#{name.ljust(18)}=> #{description}\n"
39
40
  end
41
+ help << %Q[To know more about a command, use "dme help <command name>"]
40
42
  return help
41
43
  end
42
44
 
45
+ def show_help(command)
46
+ options = ""
47
+ footnote = ""
48
+
49
+ case command
50
+ when "list-domains", "delete-domains"
51
+ options = ""
52
+ when "create-domain", "delete-domain", "describe-domain"
53
+ options = "--doman <domain name>"
54
+ when "list-records"
55
+ options = "--domain <domain name> [--name <name>] [--type <type>] [--gtd <gtd location>]"
56
+ footnote = "* Without any of --name, --type, and --gtd, all records are listed.
57
+ * Valid --type values are A, CNAME, MX, TXT, SRV, NS, AAAA, HTTPRED, PTR.
58
+ * Valid --gtd values are DEFAULT, US_EAST, US_WEST, EUROPE"
59
+ when "create-record"
60
+ options = "--domain <domain name> --name <name> --type <type> --value <value> --ttl <ttl> [--gtd <gtd location>]"
61
+ footnote = %Q[* Valid --type values are A, CNAME, MX, TXT, SRV, NS, AAAA, HTTPRED, PTR.
62
+ * Valid --gtd values are DEFAULT, US_EAST, US_WEST, EUROPE. DEFAULT is used when none is provided.
63
+
64
+ * Here's a list of possible --value values, with the record type they are used with:
65
+ - A: [host IP]
66
+ - AAAA: [IPv6 host IP]
67
+ - CNAME: [target name]
68
+ - HTTPRED: [redirection URL]
69
+ - MX: [priority] [target name]
70
+ - NS: [name server]
71
+ - PTR: [target name]
72
+ - SRV: [priority] [weight] [port] [target name]
73
+ - TXT: [text value]
74
+
75
+ * For CNAME, MX, NS, PTR, and SRV records, the domain name of the dns record is automatically
76
+ appended to the given data unless the data ends with a "." So, to map, say mail to mail.google.com,
77
+ use "mail.google.com." as the data value. By the same logic, to map "www.sigfig.com" to, say, "server1.sigfig.com",
78
+ just use "server1" as the data value or "server1.sigfig.com."; don't give "server1.sigfig.com" because that'll
79
+ essentially resolve to server1.sigfig.com.sigfig.com.
80
+ ]
81
+ when "update-record"
82
+ options = "--domain <domain name> --record <record id> [--name <name>] [--type <type>] [--value <value>] [--ttl <ttl>] [--gtd <gtd location>]"
83
+ footnote = %Q[* Valid --type values are A, CNAME, MX, TXT, SRV, NS, AAAA, HTTPRED, PTR.
84
+ * Valid --gtd values are DEFAULT, US_EAST, US_WEST, EUROPE. DEFAULT is used when none is provided.
85
+
86
+ * Here's a list of possible --value values, with the record type they are used with:
87
+ - A: [host IP]
88
+ - AAAA: [IPv6 host IP]
89
+ - CNAME: [target name]
90
+ - HTTPRED: [redirection URL]
91
+ - MX: [priority] [target name]
92
+ - NS: [name server]
93
+ - PTR: [target name]
94
+ - SRV: [priority] [weight] [port] [target name]
95
+ - TXT: [text value]
96
+
97
+ * For CNAME, MX, NS, PTR, and SRV records, the domain name of the dns record is automatically
98
+ appended to the given data unless the data ends with a "." So, to map, say mail to mail.google.com,
99
+ use "mail.google.com." as the data value. By the same logic, to map "www.sigfig.com" to, say, "server1.sigfig.com",
100
+ just use "server1" as the data value or "server1.sigfig.com."; don't give "server1.sigfig.com" because that'll
101
+ essentially resolve to server1.sigfig.com.sigfig.com.
102
+
103
+ * The params not specified in the command remain unchanged.]
104
+ when "delete-record", "describe-record"
105
+ options = "--domain <domain name> --record <record id>"
106
+ when "delete-records"
107
+ options = "--domain <domain name> [--name <name>] [--type <type>] [--gtd <gtd location>]"
108
+ footnote = "* Unless a --force param is given, confirmation is seeked before any deletions.
109
+ * Without any of --name, --type, and --gtd, all records are deleted.
110
+ * Valid --type values are A, CNAME, MX, TXT, SRV, NS, AAAA, HTTPRED, PTR.
111
+ * Valid --gtd values are DEFAULT, US_EAST, US_WEST, EUROPE"
112
+ else
113
+ show_error "Please enter a valid command"
114
+ end
115
+
116
+ footnote << "\n" unless footnote.empty?
117
+ footnote << %Q[* Use --sandbox option to run the command in sandbox mode
118
+ * Use --json to get output in json format]
119
+
120
+ puts "Usage: dme #{command} #{options}"
121
+ puts "\nNotes:\n"
122
+ puts footnote.split("\n").map { |x| x.strip }.join("\n") unless footnote.empty?
123
+ exit 0
124
+ end
125
+
43
126
  def show_error(message)
44
127
  if @json
45
128
  output = { "error" => message }
@@ -124,9 +207,10 @@ options = {}
124
207
  force = false
125
208
  record_id = nil
126
209
  sandbox = false
210
+ help = false
127
211
  optparse = OptionParser.new do |opts|
128
212
  opts.banner = printer.help_text + "\nOptions\n"
129
- opts.on("-f", "--force", "Force operation") do
213
+ opts.on("-f", "--force", "Force operation. No confirmation is requested when a command runs with this parameter. Use prudentially!") do
130
214
  force = true
131
215
  end
132
216
  opts.on("-j", "--json", "Format output as json") do
@@ -144,11 +228,14 @@ optparse = OptionParser.new do |opts|
144
228
  opts.on("-v", "--value VALUE", "The destination of the entry (IP/relative hostname/hostname)") do |v|
145
229
  options[:data] = v
146
230
  end
231
+ opts.on("-D", "--data VALUE", "Alias for --value") do |v|
232
+ options[:data] = v
233
+ end
147
234
  opts.on("-g", "--gtd GTD", "GTD Location") do |g|
148
235
  options[:gtdLocation] = g
149
236
  end
150
237
  opts.on("-t", "--type TYPE", "The type of dns record") do |t|
151
- options[:type] = t.upcase.to_sym
238
+ options[:type] = t.upcase
152
239
  end
153
240
  opts.on("-l", "--ttl TTL", "Time to live") do |l|
154
241
  options[:ttl] = l
@@ -159,6 +246,7 @@ optparse = OptionParser.new do |opts|
159
246
  end
160
247
 
161
248
  optparse.parse!
249
+ command = ARGV.shift
162
250
 
163
251
  auth_file = sandbox ? "/etc/dnsmadeeasy/api_sandbox.keys" : "/etc/dnsmadeeasy/api.keys"
164
252
  begin
@@ -176,8 +264,6 @@ end
176
264
 
177
265
  api = DnsMadeEasy::Api.new(api_key, secret_key, sandbox)
178
266
 
179
- command = ARGV.shift
180
-
181
267
  begin
182
268
  case command
183
269
  when "list-domains"
@@ -256,7 +342,13 @@ begin
256
342
  puts "Done"
257
343
  end
258
344
  when "help"
259
- help_for_command = ARGV.shift
345
+ if ARGV.empty?
346
+ puts optparse.help
347
+ exit 0
348
+ else
349
+ command = ARGV.shift
350
+ printer.show_help command
351
+ end
260
352
  else
261
353
  printer.show_error "Please enter a valid command"
262
354
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dnsmadeeasy-api}
5
- s.version = "0.9.7"
5
+ s.version = "1.0.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Nitesh Goel}]
9
- s.date = %q{2011-07-07}
10
- s.description = %q{Ruby client for DNSMadeEasy API.}
9
+ s.date = %q{2011-07-08}
10
+ s.description = %q{Ruby client and commandline utility for the DNSMadeEasy API.}
11
11
  s.email = %q{nitesh@sigfig.com}
12
12
  s.executables = [%q{dme}]
13
13
  s.extra_rdoc_files = [%q{CHANGELOG.rdoc}, %q{README.rdoc}, %q{bin/dme}, %q{lib/dnsmadeeasy/api.rb}, %q{lib/dnsmadeeasy/exceptions.rb}]
@@ -21,7 +21,7 @@ to use the dme binary.}
21
21
  s.require_paths = [%q{lib}]
22
22
  s.rubyforge_project = %q{dnsmadeeasy-api}
23
23
  s.rubygems_version = %q{1.8.5}
24
- s.summary = %q{Ruby client for DNSMadeEasy API.}
24
+ s.summary = %q{Ruby client and commandline utility for the DNSMadeEasy API.}
25
25
 
26
26
  if s.respond_to? :specification_version then
27
27
  s.specification_version = 3
@@ -12,7 +12,7 @@ Ruby client for DNSMadeEasy API.
12
12
 
13
13
  == Installation
14
14
 
15
- # gem install environment
15
+ gem install environment
16
16
 
17
17
  == Usage
18
18
 
@@ -31,10 +31,10 @@ This is a great way to test your application without changing your production DN
31
31
  api.list_records "sigfig.com"
32
32
 
33
33
  The api calls throw the following exceptions:
34
- * BadRequestError: For cases when there is missing information or the api limits have been exceeded
35
- * ResourceNotFoundError: For cases when a request is made for an unknown domain or record
36
- * AuthorizationFailedError: For cases when the request cannot be authorized
37
- * InvalidRecordError: When a record to be created or updated is not well formed
34
+ * <b>BadRequestError</b>: For cases when there is missing information or the api limits have been exceeded
35
+ * <b>ResourceNotFoundError</b>: For cases when a request is made for an unknown domain or record
36
+ * <b>AuthorizationFailedError</b>: For cases when the request cannot be authorized
37
+ * <b>InvalidRecordError</b>: When a record to be created or updated is not well formed
38
38
 
39
39
  == Command line tool
40
40
 
@@ -72,8 +72,8 @@ module DnsMadeEasy
72
72
  def list_domains
73
73
  execute_with_caution do
74
74
  response = RestClient.get request_url, headers
75
- response_hash = JSON.parse(response)
76
- return response_hash.has_key?("list") ? response_hash["list"] : []
75
+ response_hash = JSON.parse(response, :symbolize_names => true)
76
+ return response_hash.has_key?(:list) ? response_hash[:list] : []
77
77
  end
78
78
  end
79
79
 
@@ -92,18 +92,18 @@ module DnsMadeEasy
92
92
  # Create a new domain entry.
93
93
  #
94
94
  # Returns a hash of the newly created domain entry, e.g.
95
- # { "name" => "sigfig.com", "nameServer" => ["ns66.dnsmadeeasy.com", "ns99.dnsmadeeasy.com"], "gtdEnabled" => true }
95
+ # { :name => "sigfig.com", :nameServer => ["ns66.dnsmadeeasy.com", "ns99.dnsmadeeasy.com"], :gtdEnabled => true }
96
96
  def create_domain!(domain)
97
97
  execute_with_caution :domain => domain do
98
98
  response = RestClient.put request_url(:path => "#{domain}"), {}, headers
99
- return JSON.parse(response)
99
+ return JSON.parse(response, :symbolize_names => true)
100
100
  end
101
101
  end
102
102
 
103
103
  # Delete a domain entry.
104
104
  #
105
105
  # Returns a hash of the deleted domain entry, e.g.
106
- # { "name" => "sigfig.com", "nameServer" => ["ns66.dnsmadeeasy.com", "ns99.dnsmadeeasy.com"], "gtdEnabled" => true }
106
+ # { :nameServer => "sigfig.com", :nameServer => ["ns66.dnsmadeeasy.com", "ns99.dnsmadeeasy.com"], :gtdEnabled => true }
107
107
  def delete_domain!(domain)
108
108
  execute_with_caution :domain => domain do
109
109
  description = describe_domain(domain)
@@ -115,11 +115,11 @@ module DnsMadeEasy
115
115
  # Describe a domain entry.
116
116
  #
117
117
  # Returns a hash of the domain entry, e.g.
118
- # { "name" => "sigfig.com", "nameServer" => ["ns66.dnsmadeeasy.com", "ns99.dnsmadeeasy.com"], "gtdEnabled" => true }
118
+ # { :name => "sigfig.com", :nameServer => ["ns66.dnsmadeeasy.com", "ns99.dnsmadeeasy.com"], :gtdEnabled => true }
119
119
  def describe_domain(domain)
120
120
  execute_with_caution :domain => domain do
121
121
  response = RestClient.get request_url(:path => "#{domain}"), headers
122
- return JSON.parse(response)
122
+ return JSON.parse(response, :symbolize_names => true)
123
123
  end
124
124
  end
125
125
 
@@ -132,13 +132,13 @@ module DnsMadeEasy
132
132
  #
133
133
  # Returns an array of hashes, each hash representing a dns entry, e.g.
134
134
  # [
135
- # { "name" => "", "type" => "A", "data" => "127.0.0.1", "ttl" => 7200, "id" => 12345, "gtdLocation" => "DEFAULT" },
136
- # { "name" => "www", "type" => "CNAME", data => "sigfig.com.", "ttl" => 7200, id => 23456, "gtdLocation" => "DEFAULT" }
135
+ # { :name => "", :type => "A", "data" => "127.0.0.1", :ttl => 7200, :id => 12345, :gtdLocation => "DEFAULT" },
136
+ # { :name => "www", :type => "CNAME", :data => "sigfig.com.", :ttl => 7200, id => 23456, :gtdLocation => "DEFAULT" }
137
137
  # ]
138
138
  def list_records(domain, filter={})
139
139
  execute_with_caution :domain => domain do
140
140
  response = RestClient.get request_url(:path => "#{domain}/records", :query => filter), headers
141
- return JSON.parse(response)
141
+ return JSON.parse(response, :symbolize_names => true)
142
142
  end
143
143
  end
144
144
 
@@ -147,7 +147,7 @@ module DnsMadeEasy
147
147
  # Record should be a hash with the following values:
148
148
  #
149
149
  # :name => Hostname. E.g. www, or empty string for root domain
150
- # :type => Record type. E.g. :A, :CNAME, :MX, :TXT, :SRV, :NS, :AAAA, :HTTPRED, :PTR
150
+ # :type => Record type. E.g. A, CNAME, MX, TXT, SRV, NS, AAAA, HTTPRED, PTR
151
151
  # :data => Public name. E.g. "66.88.99.44" or "ec2-gibberish.amazonaws.com."
152
152
  # :gtdLocation => Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE (optional, defaults to DEFAULT)
153
153
  # :ttl => Time to live. The amount of time a record will be cached before being refreshed. E.g. 300
@@ -170,7 +170,7 @@ module DnsMadeEasy
170
170
  # essentially resolve to server1.sigfig.com.sigfig.com.
171
171
  #
172
172
  # Returns a hash of the newly created dns entry, e.g.
173
- # { "name" => "www", "type" => "CNAME", data => "sigfig.com.", "ttl" => 7200, id => 23456, "gtdLocation" => "DEFAULT" }
173
+ # { :name => "www", :type => "CNAME", :data => "sigfig.com.", :ttl => 7200, id => 23456, :gtdLocation => "DEFAULT" }
174
174
  def create_record!(domain, record)
175
175
  validate_record(record)
176
176
  request_data = {
@@ -178,14 +178,14 @@ module DnsMadeEasy
178
178
  }.merge(record)
179
179
  execute_with_caution :domain => domain do
180
180
  response = RestClient.post request_url(:path => "#{domain}/records"), request_data.to_json, headers(:content_type => "application/json")
181
- return JSON.parse(response)
181
+ return JSON.parse(response, :symbolize_names => true)
182
182
  end
183
183
  end
184
184
 
185
185
  # Delete a dns record.
186
186
  #
187
187
  # Returns a hash of the deleted dns entry, e.g.
188
- # { "name" => "", "type" => "A", "data" => "127.0.0.1", "ttl" => 7200, "id" => 12345, "gtdLocation" => "DEFAULT" }
188
+ # { :name => "", :type => "A", "data" => "127.0.0.1", :ttl => 7200, :id => 12345, :gtdLocation => "DEFAULT" }
189
189
  def delete_record!(domain, record_id)
190
190
  execute_with_caution :domain => domain, :record => record_id do
191
191
  record = describe_record(domain, record_id)
@@ -196,29 +196,25 @@ module DnsMadeEasy
196
196
 
197
197
  # Delete multiple records for a domain.
198
198
  #
199
- # The filter parameter allows you to list a list a subset of records filtered by a criteria. Available filters:
200
- # * { :name => "www" }: Lists all entries for host "www"
201
- # * { :type => :A }: Lists all A records
202
- # * { :gtdLocation => :EUROPE } List all entries for EUROPE Traffic Director
199
+ # Refer to list_records for available filters.
203
200
  #
204
- # N.B. Given that there are limits to the number of api requests, the amoticity of this action is not guaranteed.
201
+ # N.B. Given that there are limits to the number of api requests, the atomicity of this action is not guaranteed.
205
202
  # This means that it is possible under certain circumstances that not all records that match the given criteria
206
203
  # will be deleted.
207
204
  #
208
205
  # Returns an array of hashes, each hash representing a deleted dns entry, e.g.
209
206
  # [
210
- # { "name" => "", "type" => "A", "data" => "127.0.0.1", "ttl" => 7200, "id" => 12345, "gtdLocation" => "DEFAULT" },
211
- # { "name" => "www", "type" => "CNAME", data => "sigfig.com.", "ttl" => 7200, id => 23456, "gtdLocation" => "DEFAULT" }
207
+ # { :name => "", :type => "A", "data" => "127.0.0.1", :ttl => 7200, :id => 12345, :gtdLocation => "DEFAULT" },
208
+ # { :name => "www", :type => "CNAME", :data => "sigfig.com.", :ttl => 7200, :id => 23456, :gtdLocation => "DEFAULT" }
212
209
  # ]
213
- # An empty array is returned if no deletions are made.
214
210
  def delete_records!(domain, filter={})
215
211
  record_list = list_records(domain, filter)
216
212
  unless record_list.empty?
217
213
  if record_list.size == 1
218
- delete_record!(domain, record_list[0]["id"])
214
+ delete_record!(domain, record_list[0][:id])
219
215
  elsif requests_remaining >= record_list.size
220
216
  record_list.each do |record|
221
- delete_record!(domain, record["id"])
217
+ delete_record!(domain, record[:id])
222
218
  end
223
219
  else
224
220
  raise DnsMadeEasy::BadRequestError, "Not enough requests remaining to complete the operation"
@@ -229,35 +225,13 @@ module DnsMadeEasy
229
225
 
230
226
  # Update an existing dns record.
231
227
  #
232
- # Record should be a hash with the following values:
233
- #
234
- # :name => Hostname. E.g. www, or empty string for root domain
235
- # :type => Record type. E.g. :A, :CNAME, :MX, :TXT, :SRV, :NS, :AAAA, :HTTPRED, :PTR
236
- # :data => Public name. E.g. "66.88.99.44" or "ec2-gibberish.amazonaws.com."
237
- # :gtdLocation => Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE (optional, defaults to DEFAULT)
238
- # :ttl => Time to live. The amount of time a record will be cached before being refreshed. E.g. 300
239
- #
240
- # Here's a list of possible data values, with the record type they are used with:
241
- # * A: [host IP]
242
- # * AAAA: [IPv6 host IP]
243
- # * CNAME: [target name]
244
- # * HTTPRED: [redirection URL]
245
- # * MX: [priority] [target name]
246
- # * NS: [name server]
247
- # * PTR: [target name]
248
- # * SRV: [priority] [weight] [port] [target name]
249
- # * TXT: [text value]
250
- #
251
- # N.B. for CNAME, MX, NS, PTR, and SRV records, the domain name of the dns record is automatically
252
- # appended to the given data unless the data ends with a "." So, to map, say mail to mail.google.com,
253
- # use "mail.google.com." as the data value. By the same logic, to map "www.sigfig.com" to, say, "server1.sigfig.com",
254
- # just use "server1" as the data value or "server1.sigfig.com."; don't give "server1.sigfig.com" because that'll
255
- # essentially resolve to server1.sigfig.com.sigfig.com.
228
+ # Refer to create_record! documentation for record format. The params not specified remain unchanged
256
229
  #
257
230
  # Returns a hash of the newly updated dns entry, e.g.
258
- # { "name" => "www", "type" => "CNAME", data => "sigfig.com.", "ttl" => 7200, id => 23456, "gtdLocation" => "DEFAULT" }
231
+ # { :name => "www", :type => "CNAME", :data => "sigfig.com.", :ttl => 7200, :id => 23456, :gtdLocation => "DEFAULT" }
259
232
  def update_record!(domain, record_id, record)
260
- validate_record(record)
233
+ existing_record = describe_record(domain, record_id)
234
+ record = existing_record.merge(record)
261
235
  execute_with_caution :domain => domain, :record => record_id do
262
236
  response = RestClient.put request_url(:path => "#{domain}/records/#{record_id}"), record.to_json, headers(:content_type => "application/json")
263
237
  return describe_record(domain, record_id)
@@ -267,15 +241,15 @@ module DnsMadeEasy
267
241
  # Describe an existing dns record.
268
242
  #
269
243
  # Returns a hash of the dns entry.
270
- # { "name" => "www", "type" => "CNAME", data => "sigfig.com.", "ttl" => 7200, id => 23456, "gtdLocation" => "DEFAULT" }
244
+ # { :name => "www", :type => "CNAME", :data => "sigfig.com.", :ttl => 7200, :id => 23456, :gtdLocation => "DEFAULT" }
271
245
  def describe_record(domain, record_id)
272
246
  execute_with_caution :domain => domain, :record => record_id do
273
247
  response = RestClient.get request_url(:path => "#{domain}/records/#{record_id}"), headers
274
- return JSON.parse(response)
248
+ return JSON.parse(response, :symbolize_names => true)
275
249
  end
276
250
  end
277
251
 
278
- # Return the umber of api requests remaining.
252
+ # Return the number of api requests remaining.
279
253
  def requests_remaining
280
254
  begin
281
255
  execute_with_caution do
@@ -298,12 +272,12 @@ module DnsMadeEasy
298
272
  end
299
273
 
300
274
  # check record types
301
- acceptable_types = [:A, :CNAME, :MX, :TXT, :SRV, :NS, :AAAA, :HTTPRED, :PTR]
302
- raise DnsMadeEasy::InvalidRecordError, "Invalid record type #{record[:type]}" unless acceptable_types.include?(record[:type].to_sym)
275
+ acceptable_types = ["A", "CNAME", "MX", "TXT", "SRV", "NS", "AAAA", "HTTPRED", "PTR"]
276
+ raise DnsMadeEasy::InvalidRecordError, "Invalid record type #{record[:type]}" unless acceptable_types.include?(record[:type])
303
277
 
304
278
  # check gtd location
305
- acceptable_location = [:DEFAULT, :US_EAST, :US_WEST, :EUROPE]
306
- if record.has_key?(:gtdLocation) && acceptable_location.include?(record[:gtdLocation].to_sym)
279
+ acceptable_location = ["DEFAULT", "US_EAST", "US_WEST", "EUROPE"]
280
+ if record.has_key?(:gtdLocation) && acceptable_location.include?(record[:gtdLocation])
307
281
  raise DnsMadeEasy::InvalidRecordError, "Invalid gtd location #{record[:gtdLocation]}"
308
282
  end
309
283
 
@@ -344,8 +318,8 @@ module DnsMadeEasy
344
318
  begin
345
319
  return yield
346
320
  rescue RestClient::BadRequest => e
347
- error = JSON.parse(e.http_body)
348
- raise DnsMadeEasy::BadRequestError, error["error"][0]
321
+ error = JSON.parse(e.http_body, :symbolize_names => true)
322
+ raise DnsMadeEasy::BadRequestError, error[:error][0]
349
323
  rescue RestClient::ResourceNotFound => e
350
324
  raise DnsMadeEasy::ResourceNotFoundError, namespace
351
325
  rescue RestClient::Forbidden => e
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsmadeeasy-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 9
9
- - 7
10
- version: 0.9.7
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nitesh Goel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-07 00:00:00 Z
18
+ date: 2011-07-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client
@@ -73,7 +73,7 @@ dependencies:
73
73
  version: "0"
74
74
  type: :development
75
75
  version_requirements: *id004
76
- description: Ruby client for DNSMadeEasy API.
76
+ description: Ruby client and commandline utility for the DNSMadeEasy API.
77
77
  email: nitesh@sigfig.com
78
78
  executables:
79
79
  - dme
@@ -136,6 +136,6 @@ rubyforge_project: dnsmadeeasy-api
136
136
  rubygems_version: 1.8.5
137
137
  signing_key:
138
138
  specification_version: 3
139
- summary: Ruby client for DNSMadeEasy API.
139
+ summary: Ruby client and commandline utility for the DNSMadeEasy API.
140
140
  test_files: []
141
141