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.
- data/bin/dynect4r-client +5 -5
- data/lib/dynect4r.rb +17 -19
- metadata +7 -9
data/bin/dynect4r-client
CHANGED
@@ -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[
|
99
|
+
response['data'].each do |url|
|
100
100
|
begin
|
101
|
-
record = c.rest_call(:get, url)[
|
102
|
-
rdata = record[
|
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[
|
104
|
+
[record['zone'], record['fqdn'], record['ttl'], record['record_type'], rdata.to_json])
|
105
105
|
record_args = {
|
106
|
-
'ttl' => record[
|
106
|
+
'ttl' => record['ttl'],
|
107
107
|
'rdata' => rdata
|
108
108
|
}
|
109
109
|
curr_rec_args[record_args] = url
|
data/lib/dynect4r.rb
CHANGED
@@ -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[
|
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
|
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?(
|
108
|
-
@hash[
|
109
|
-
case msg[
|
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[
|
109
|
+
raise IllegalOperationError, msg['INFO']
|
112
110
|
when 'INTERNAL_ERROR'
|
113
|
-
raise InternalErrorError, msg[
|
111
|
+
raise InternalErrorError, msg['INFO']
|
114
112
|
when 'INVALID_DATA'
|
115
|
-
raise InvalidDataError, msg[
|
113
|
+
raise InvalidDataError, msg['INFO']
|
116
114
|
when 'INVALID_REQUEST'
|
117
|
-
raise InvalidRequestError, msg[
|
115
|
+
raise InvalidRequestError, msg['INFO']
|
118
116
|
when 'INVALID_VERSION'
|
119
|
-
raise InvalidVersionError, msg[
|
117
|
+
raise InvalidVersionError, msg['INFO']
|
120
118
|
when 'MISSING_DATA'
|
121
|
-
raise MissingDataError, msg[
|
119
|
+
raise MissingDataError, msg['INFO']
|
122
120
|
when 'NOT_FOUND'
|
123
|
-
raise NotFoundError, msg[
|
121
|
+
raise NotFoundError, msg['INFO']
|
124
122
|
when 'OPERATION_FAILED'
|
125
|
-
raise OperationFailedError, msg[
|
123
|
+
raise OperationFailedError, msg['INFO']
|
126
124
|
when 'PERMISSION_DENIED'
|
127
|
-
raise PermissionDeniedError, msg[
|
125
|
+
raise PermissionDeniedError, msg['INFO']
|
128
126
|
when 'SERVICE_UNAVAILABLE'
|
129
|
-
raise ServiceUnavailableError, msg[
|
127
|
+
raise ServiceUnavailableError, msg['INFO']
|
130
128
|
when 'TARGET_EXISTS'
|
131
|
-
raise TargetExistsError, msg[
|
129
|
+
raise TargetExistsError, msg['INFO']
|
132
130
|
when 'UNKNOWN_ERROR'
|
133
|
-
raise UnknownErrorError, msg[
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.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-
|
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:
|
29
|
+
hash: 3
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
|
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
|