dynect4r 0.2.2 → 0.2.3

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.
Files changed (3) hide show
  1. data/bin/dynect4r-client +5 -5
  2. data/lib/dynect4r.rb +17 -19
  3. metadata +7 -9
@@ -96,14 +96,14 @@ end
96
96
  curr_rec_args = {}
97
97
  begin
98
98
  response = c.rest_call(:get, [Dynect::rtype_to_resource(options[:type]), options[:zone], options[:node]])
99
- response[:data].each do |url|
99
+ response['data'].each do |url|
100
100
  begin
101
- record = c.rest_call(:get, url)[:data]
102
- rdata = record[:rdata].inject({}) { |memo,(k,v)| memo[k.to_s] = v.to_s; memo }
101
+ record = c.rest_call(:get, url)['data']
102
+ rdata = record['rdata'].inject({}) { |memo,(k,v)| memo[k.to_s] = v.to_s; memo }
103
103
  log.info('Found record (Zone="%s", Node="%s" TTL="%s", Type="%s", RData="%s")' %
104
- [record[:zone], record[:fqdn], record[:ttl], record[:record_type], rdata.to_json])
104
+ [record['zone'], record['fqdn'], record['ttl'], record['record_type'], rdata.to_json])
105
105
  record_args = {
106
- 'ttl' => record[:ttl],
106
+ 'ttl' => record['ttl'],
107
107
  'rdata' => rdata
108
108
  }
109
109
  curr_rec_args[record_args] = url
@@ -1,6 +1,4 @@
1
1
  require 'rubygems'
2
- gem 'json', '>= 1.4.3'
3
-
4
2
  require 'json'
5
3
  require 'logger'
6
4
  require 'rest_client'
@@ -14,7 +12,7 @@ module Dynect
14
12
  @base_url = 'https://api2.dynect.net'
15
13
  @headers = { :content_type => :json, :accept => :json }
16
14
  response = rest_call(:post, 'Session', params)
17
- @headers['Auth-Token'] = response[:data][:token]
15
+ @headers['Auth-Token'] = response['data']['token']
18
16
  end
19
17
 
20
18
  # do a rest call
@@ -94,7 +92,7 @@ module Dynect
94
92
 
95
93
  # parse response
96
94
  begin
97
- @hash = JSON.parse(response, :symbolize_names => true)
95
+ @hash = JSON.parse(response)
98
96
  rescue JSON::ParserError
99
97
  if response =~ /REST\/Job\/[0-9]+/
100
98
  raise RedirectError, response
@@ -104,33 +102,33 @@ module Dynect
104
102
  end
105
103
 
106
104
  # raise error based on error code
107
- if @hash.has_key?(:msgs)
108
- @hash[:msgs].each do |msg|
109
- case msg[:ERR_CD]
105
+ if @hash.has_key?('msgs')
106
+ @hash['msgs'].each do |msg|
107
+ case msg['ERR_CD']
110
108
  when 'ILLEGAL_OPERATION'
111
- raise IllegalOperationError, msg[:INFO]
109
+ raise IllegalOperationError, msg['INFO']
112
110
  when 'INTERNAL_ERROR'
113
- raise InternalErrorError, msg[:INFO]
111
+ raise InternalErrorError, msg['INFO']
114
112
  when 'INVALID_DATA'
115
- raise InvalidDataError, msg[:INFO]
113
+ raise InvalidDataError, msg['INFO']
116
114
  when 'INVALID_REQUEST'
117
- raise InvalidRequestError, msg[:INFO]
115
+ raise InvalidRequestError, msg['INFO']
118
116
  when 'INVALID_VERSION'
119
- raise InvalidVersionError, msg[:INFO]
117
+ raise InvalidVersionError, msg['INFO']
120
118
  when 'MISSING_DATA'
121
- raise MissingDataError, msg[:INFO]
119
+ raise MissingDataError, msg['INFO']
122
120
  when 'NOT_FOUND'
123
- raise NotFoundError, msg[:INFO]
121
+ raise NotFoundError, msg['INFO']
124
122
  when 'OPERATION_FAILED'
125
- raise OperationFailedError, msg[:INFO]
123
+ raise OperationFailedError, msg['INFO']
126
124
  when 'PERMISSION_DENIED'
127
- raise PermissionDeniedError, msg[:INFO]
125
+ raise PermissionDeniedError, msg['INFO']
128
126
  when 'SERVICE_UNAVAILABLE'
129
- raise ServiceUnavailableError, msg[:INFO]
127
+ raise ServiceUnavailableError, msg['INFO']
130
128
  when 'TARGET_EXISTS'
131
- raise TargetExistsError, msg[:INFO]
129
+ raise TargetExistsError, msg['INFO']
132
130
  when 'UNKNOWN_ERROR'
133
- raise UnknownErrorError, msg[:INFO]
131
+ raise UnknownErrorError, msg['INFO']
134
132
  end
135
133
  end
136
134
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynect4r
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael T. Conigliaro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-09 00:00:00 -06:00
18
+ date: 2010-07-13 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,10 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 1
29
+ hash: 3
30
30
  segments:
31
- - 1
32
- - 4
33
- - 3
34
- version: 1.4.3
31
+ - 0
32
+ version: "0"
35
33
  type: :runtime
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency