dynect_rest 0.4.3 → 0.4.4.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +26 -0
- data/Rakefile +2 -21
- data/lib/dynect_rest.rb +23 -6
- data/lib/dynect_rest/exceptions.rb +11 -0
- data/lib/dynect_rest/gslb.rb +170 -0
- data/lib/dynect_rest/version.rb +21 -0
- data/spec/dynect_rest_spec.rb +38 -41
- data/spec/spec_helper.rb +0 -4
- metadata +42 -87
- data/.document +0 -5
- data/.rspec +0 -1
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -36
- data/VERSION +0 -1
- data/dynect_rest.gemspec +0 -80
- data/example.rb +0 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 07994682f1515d9cce892c91cf5eb92ce0334cc0
|
4
|
+
data.tar.gz: 49137e17b91cbd4ec29b708b077923bee6c91a33
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a29ce73f1dc63214d49d1abc15bd8c6a7a913de695534607595aff9c2c48b9e14e9ed5c47aedf664619b34c5af718aef7ba431413dbc35106aa3a85f7a5561df
|
7
|
+
data.tar.gz: 0aa2839499464941698332a55c5ec85a25ea368024356ff1e795022856432694ef38177fd10c770748bf7c8939d80ab28437e9fd479168f26c9e4bcfe161370a
|
data/README.rdoc
CHANGED
@@ -14,6 +14,32 @@ Since this is 90% of what you'll be doing, we make it easy.
|
|
14
14
|
|
15
15
|
Will add an A record and a CNAME. You can use the chained method syntax for every resource record - we map unknown methods to the resource data you make in the call. See link:"example.rb" for an executable example using environment variables.
|
16
16
|
|
17
|
+
== GSLB
|
18
|
+
|
19
|
+
Create a new GSLB:
|
20
|
+
|
21
|
+
require 'dynect_rest'
|
22
|
+
dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE")
|
23
|
+
gslb = dyn.gslb()
|
24
|
+
gslb.fqdn("sunshine.example.com").ttl(30).region_code("global")
|
25
|
+
gslb.min_healthy(1).serve_count(2)
|
26
|
+
gslb.monitor(:protocol => "HTTP", :interval => 1, :port => 8000, :path => "/healthcheck", :host => "sunshine.example.com")
|
27
|
+
gslb.add_host(:address => "1.1.1.1", :label => "friendly_name", :weight => 10, :serve_mode => "obey")
|
28
|
+
gslb.add_host(:address => "1.1.1.2", :label => "friendly_name2", :weight => 10, :serve_mode => "obey")
|
29
|
+
gslb.save
|
30
|
+
|
31
|
+
This will create a GSLB with hosts 1.1.1.1 and 1.1.1.2 in the global region. The parameters are self-explanatory.
|
32
|
+
|
33
|
+
Add a host to an existing GSLB:
|
34
|
+
|
35
|
+
require 'dynect_rest'
|
36
|
+
dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE")
|
37
|
+
gslb = dyn.gslb.get("sunshine.example.com")
|
38
|
+
gslb.add_host(:address => "1.1.1.3", :label => "friendly_name3", :weight => 10, :serve_mode => "obey")
|
39
|
+
gslb.save(:replace)
|
40
|
+
|
41
|
+
This will fetch the GSLB object for "sunshine.example.com", add the host 1.1.1.3, and save the updated configuration back to dynect.
|
42
|
+
|
17
43
|
== Everything else
|
18
44
|
|
19
45
|
We wrap up the lower-level functionality of the API, so you can focus on just making the calls. For example, to get a list of contacts:
|
data/Rakefile
CHANGED
@@ -1,27 +1,8 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "dynect_rest"
|
8
|
-
gem.summary = %Q{Dynect REST API library}
|
9
|
-
gem.description = %Q{Use the Dynect services REST API}
|
10
|
-
gem.email = "adam@opscode.com"
|
11
|
-
gem.homepage = "http://github.com/adamhjk/dynect-rest"
|
12
|
-
gem.authors = ["Adam Jacob"]
|
13
|
-
gem.add_development_dependency "rspec", ">= 2.0"
|
14
|
-
gem.add_development_dependency "yard", ">= 0"
|
15
|
-
gem.add_dependency('json')
|
16
|
-
gem.add_dependency('rest-client')
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
-
end
|
23
|
-
|
3
|
+
require "bundler/gem_tasks"
|
24
4
|
require 'rspec/core/rake_task'
|
5
|
+
|
25
6
|
RSpec::Core::RakeTask.new(:spec)
|
26
7
|
|
27
8
|
task :default => :spec
|
data/lib/dynect_rest.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
class DynectRest
|
20
20
|
|
21
21
|
require 'dynect_rest/exceptions'
|
22
|
+
require 'dynect_rest/gslb'
|
22
23
|
require 'dynect_rest/resource'
|
23
24
|
require 'rest_client'
|
24
25
|
require 'json'
|
@@ -33,11 +34,11 @@ class DynectRest
|
|
33
34
|
# @param [String] The zone you are going to be editing
|
34
35
|
# @param [Boolean] Whether to connect immediately or not - runs login for you
|
35
36
|
# @param [Boolean] Verbosity
|
36
|
-
def initialize(customer_name, user_name, password, zone=nil, connect=true, verbose=false)
|
37
|
+
def initialize(customer_name, user_name, password, zone=nil, connect=true, verbose=false, max_redirects=10)
|
37
38
|
@customer_name = customer_name
|
38
39
|
@user_name = user_name
|
39
40
|
@password = password
|
40
|
-
@rest = RestClient::Resource.new('https://api2.dynect.net/REST/', :headers => { :content_type => 'application/json' })
|
41
|
+
@rest = RestClient::Resource.new('https://api2.dynect.net/REST/', :headers => { :content_type => 'application/json' }, :max_redirects=>max_redirects)
|
41
42
|
@zone = zone
|
42
43
|
@verbose = verbose
|
43
44
|
login if connect
|
@@ -134,6 +135,13 @@ class DynectRest
|
|
134
135
|
end
|
135
136
|
end
|
136
137
|
|
138
|
+
##
|
139
|
+
# GSLB Service
|
140
|
+
##
|
141
|
+
def gslb
|
142
|
+
DynectRest::GSLB.new(:dynect => self, :zone => @zone)
|
143
|
+
end
|
144
|
+
|
137
145
|
# Raw GET request, formatted for Dyn. See list of endpoints at:
|
138
146
|
#
|
139
147
|
# https://manage.dynect.net/help/docs/api2/rest/resources/
|
@@ -190,18 +198,29 @@ class DynectRest
|
|
190
198
|
puts "I have #{e.inspect} with #{e.http_code}"
|
191
199
|
end
|
192
200
|
if e.http_code == 307
|
201
|
+
e.response.sub!('/REST/','') if e.response =~ /^\/REST\//
|
193
202
|
get(e.response)
|
194
203
|
end
|
195
204
|
e.response
|
196
205
|
end
|
197
|
-
|
206
|
+
|
207
|
+
parse_response(JSON.parse(response_body || '{}'))
|
198
208
|
end
|
199
209
|
|
200
210
|
def parse_response(response)
|
201
211
|
case response["status"]
|
202
212
|
when "success"
|
203
213
|
response["data"]
|
204
|
-
when "
|
214
|
+
when "incomplete"
|
215
|
+
# we get 'incomplete' when the API is running slow and claims the session has a previous job running
|
216
|
+
# raise an error and return the job ID in case we want to ask the API what the job's status is
|
217
|
+
error_messages = []
|
218
|
+
error_messages.push( "This session may have a job _still_ running (slowly). Call /REST/Job/#{response["job_id"]} to get its status." )
|
219
|
+
response["msgs"].each do |error_message|
|
220
|
+
error_messages << "#{error_message["LVL"]} #{error_message["ERR_CD"]} #{error_message["SOURCE"]} - #{error_message["INFO"]}"
|
221
|
+
end
|
222
|
+
raise DynectRest::Exceptions::IncompleteRequest.new( "#{error_messages.join("\n")}", response["job_id"] )
|
223
|
+
when "failure"
|
205
224
|
error_messages = []
|
206
225
|
response["msgs"].each do |error_message|
|
207
226
|
error_messages << "#{error_message["LVL"]} #{error_message["ERR_CD"]} #{error_message["SOURCE"]} - #{error_message["INFO"]}"
|
@@ -209,6 +228,4 @@ class DynectRest
|
|
209
228
|
raise DynectRest::Exceptions::RequestFailed, "Request failed: #{error_messages.join("\n")}"
|
210
229
|
end
|
211
230
|
end
|
212
|
-
|
213
|
-
|
214
231
|
end
|
@@ -19,5 +19,16 @@
|
|
19
19
|
class DynectRest
|
20
20
|
class Exceptions
|
21
21
|
class RequestFailed < RuntimeError; end
|
22
|
+
# we need to handle API calls that return a status of 'incomplete' and return the job_id
|
23
|
+
class IncompleteRequest < RuntimeError
|
24
|
+
|
25
|
+
attr_reader :job_id, :message
|
26
|
+
|
27
|
+
def initialize( message, job_id )
|
28
|
+
@message = message
|
29
|
+
@job_id = job_id
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Evan Gilman (<evan@pagerduty.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 PagerDuty, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class DynectRest
|
20
|
+
class GSLB
|
21
|
+
|
22
|
+
def initialize(init_hash={})
|
23
|
+
validate(init_hash, [:dynect, :zone])
|
24
|
+
|
25
|
+
@dynect = init_hash[:dynect]
|
26
|
+
@zone = init_hash[:zone]
|
27
|
+
@fqdn = init_hash[:fqdn]
|
28
|
+
@ttl = init_hash[:ttl] || 30
|
29
|
+
@host_list = init_hash[:host_list] || {}
|
30
|
+
@contact_nick = init_hash[:contact_nick] || 'owner'
|
31
|
+
|
32
|
+
@region_code = init_hash[:region_code] || 'global'
|
33
|
+
@monitor = init_hash[:monitor] || {}
|
34
|
+
@serve_count = init_hash[:serve_count] || 1
|
35
|
+
@min_healthy = init_hash[:min_healthy] || 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def [](host_list_key)
|
39
|
+
@host_list[host_list_key]
|
40
|
+
end
|
41
|
+
|
42
|
+
def fqdn(value=nil)
|
43
|
+
value ? (@fqdn = value; self) : @fqdn
|
44
|
+
end
|
45
|
+
|
46
|
+
def contact_nick(value=nil)
|
47
|
+
value ? (@contact_nick = value; self) : @contact_nick
|
48
|
+
end
|
49
|
+
|
50
|
+
def ttl(value=nil)
|
51
|
+
value ? (@ttl = value; self) : @ttl
|
52
|
+
end
|
53
|
+
|
54
|
+
def min_healthy(value=nil)
|
55
|
+
value ? (@min_healthy = value; self) : @min_healthy
|
56
|
+
end
|
57
|
+
|
58
|
+
def serve_count(value=nil)
|
59
|
+
value ? (@serve_count = value; self) : @serve_count
|
60
|
+
end
|
61
|
+
|
62
|
+
def region_code(value=nil)
|
63
|
+
# US West, US Central, US East, EU West, EU Central, EU East, Asia, global
|
64
|
+
value ? (@region_code = value; self) : @region_code
|
65
|
+
end
|
66
|
+
|
67
|
+
def host_list(value=nil)
|
68
|
+
value ? (@host_list = value; self) : @host_list
|
69
|
+
end
|
70
|
+
|
71
|
+
def monitor(value=nil)
|
72
|
+
# :protocol => 'HTTP', :interval => 1, :retries => 2, :timeout => 10, :port => 8000,
|
73
|
+
# :path => '/healthcheck', :host => 'example.com', :header => 'X-User-Agent: DynECT Health\n', :expected => 'passed'
|
74
|
+
value ? (@monitor = value; self) : @monitor
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_host(value)
|
78
|
+
# :address => 'x.x.x.x', :label => 'friendly-name', :weight => 10, :serve_mode => 'obey'
|
79
|
+
@host_list[value[:address]] = value
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def resource_path(full=false)
|
84
|
+
service_type = "GSLB"
|
85
|
+
if (full == true || full == :full)
|
86
|
+
"/REST/#{service_type}/#{@zone}"
|
87
|
+
else
|
88
|
+
"#{service_type}/#{@zone}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def get(fqdn=nil, region_code='global')
|
93
|
+
if fqdn
|
94
|
+
results = @dynect.get("#{resource_path}/#{fqdn}")
|
95
|
+
region = {}
|
96
|
+
results["region"].each {|r| region = r if r["region_code"] == region_code}
|
97
|
+
raise DynectRest::Exceptions::RequestFailed, "Cannot find #{region_code} GSLB pool for #{fqdn}" if region.empty?
|
98
|
+
|
99
|
+
# Default monitor timeout is 0, but specifying timeout 0 on a put or post results in an exception
|
100
|
+
results["monitor"].delete("timeout") if results["monitor"]["timeout"] == 0
|
101
|
+
|
102
|
+
host_list = {}
|
103
|
+
region["pool"].each do |h|
|
104
|
+
host_list[h["address"]] = {
|
105
|
+
:address => h["address"],
|
106
|
+
:label => h["label"],
|
107
|
+
:weight => h["weight"],
|
108
|
+
:serve_mode => h["serve_mode"]
|
109
|
+
}
|
110
|
+
end
|
111
|
+
DynectRest::GSLB.new(:dynect => @dynect,
|
112
|
+
:zone => results["zone"],
|
113
|
+
:fqdn => results["fqdn"],
|
114
|
+
:ttl => results["ttl"],
|
115
|
+
:host_list => host_list,
|
116
|
+
:contact_nick => results["contact_nickname"],
|
117
|
+
:region_code => region["region_code"],
|
118
|
+
:monitor => results["monitor"],
|
119
|
+
:serve_count => region["serve_count"],
|
120
|
+
:min_healthy => region["min_healthy"]
|
121
|
+
)
|
122
|
+
else
|
123
|
+
@dynect.get(resource_path)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def find(fqdn, query_hash)
|
128
|
+
results = []
|
129
|
+
get(fqdn).each do |rr|
|
130
|
+
query_hash.each do |key, value|
|
131
|
+
results << rr if rr[key.to_s] == value
|
132
|
+
end
|
133
|
+
end
|
134
|
+
results
|
135
|
+
end
|
136
|
+
|
137
|
+
def save(replace=false)
|
138
|
+
if replace == true || replace == :replace
|
139
|
+
@dynect.put("#{resource_path}/#{@fqdn}", self)
|
140
|
+
else
|
141
|
+
@dynect.post("#{resource_path}/#{@fqdn}", self)
|
142
|
+
end
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
def delete
|
147
|
+
@dynect.delete("#{resource_path}/#{fqdn}")
|
148
|
+
end
|
149
|
+
|
150
|
+
def validate(init_hash, required_keys)
|
151
|
+
required_keys.each do |k|
|
152
|
+
raise ArgumentError, "You must provide a value for #{k}" unless init_hash[k]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def to_json
|
157
|
+
{
|
158
|
+
"ttl" => @ttl,
|
159
|
+
"monitor" => @monitor,
|
160
|
+
"region" => {
|
161
|
+
"region_code" => @region_code,
|
162
|
+
"serve_count" => @serve_count,
|
163
|
+
"min_healthy" => @min_healthy,
|
164
|
+
"pool" => @host_list.values
|
165
|
+
},
|
166
|
+
"contact_nickname" => @contact_nick
|
167
|
+
}.to_json
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Ranjib Dey (dey.ranjib@gmail.com)
|
3
|
+
# Copyright:: Copyright (c) 2013 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class DynectRest
|
20
|
+
VERSION='0.4.4.beta'
|
21
|
+
end
|
data/spec/dynect_rest_spec.rb
CHANGED
@@ -1,77 +1,74 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe DynectRest do
|
4
|
-
|
4
|
+
|
5
|
+
let(:dynect) do
|
5
6
|
DynectRest.new("customer", "username", "password", "zone", false)
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
it "A Record" do
|
10
|
+
expect(dynect.a.resource_path).to eq('ARecord/zone')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "AAAA Record" do
|
14
|
+
expect(dynect.aaaa.resource_path).to eq('AAAARecord/zone')
|
11
15
|
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
its(:resource_path) { should == 'AAAARecord/zone' }
|
17
|
+
it "CNAME Record" do
|
18
|
+
expect(dynect.cname.resource_path).to eq('CNAMERecord/zone')
|
16
19
|
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
its(:resource_path) { should == 'CNAMERecord/zone' }
|
21
|
+
it "DNSKEY Record" do
|
22
|
+
expect(dynect.dnskey.resource_path).to eq('DNSKEYRecord/zone')
|
21
23
|
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
its(:resource_path) { should == 'DNSKEYRecord/zone' }
|
25
|
+
it "DS Record" do
|
26
|
+
expect(dynect.ds.resource_path).to eq('DSRecord/zone')
|
26
27
|
end
|
27
28
|
|
28
|
-
describe "
|
29
|
-
subject {
|
30
|
-
its(:resource_path) { should == '
|
29
|
+
describe "gslb" do
|
30
|
+
subject { dynect.gslb }
|
31
|
+
its(:resource_path) { should == 'GSLB/zone' }
|
31
32
|
end
|
32
33
|
|
33
34
|
describe "key" do
|
34
|
-
subject {
|
35
|
+
subject { dynect.key }
|
35
36
|
its(:resource_path) { should == 'KEYRecord/zone' }
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
it "KEY Record" do
|
40
|
+
expect(dynect.key.resource_path).to eq('KEYRecord/zone')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "LOC Record" do
|
44
|
+
expect(dynect.loc.resource_path).to eq('LOCRecord/zone')
|
41
45
|
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
its(:resource_path) { should == 'MXRecord/zone' }
|
47
|
+
it "MX Record" do
|
48
|
+
expect(dynect.mx.resource_path).to eq('MXRecord/zone')
|
46
49
|
end
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
its(:resource_path) { should == 'NSRecord/zone' }
|
51
|
+
it "NS Record" do
|
52
|
+
expect(dynect.ns.resource_path).to eq('NSRecord/zone')
|
51
53
|
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
its(:resource_path) { should == 'PTRRecord/zone' }
|
55
|
+
it "PTR Record" do
|
56
|
+
expect(dynect.ptr.resource_path).to eq('PTRRecord/zone')
|
56
57
|
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
its(:resource_path) { should == 'RPRecord/zone' }
|
59
|
+
it "RPR Record" do
|
60
|
+
expect(dynect.rp.resource_path).to eq('RPRecord/zone')
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
its(:resource_path) { should == 'SOARecord/zone' }
|
63
|
+
it "SOA Record" do
|
64
|
+
expect(dynect.soa.resource_path).to eq('SOARecord/zone')
|
66
65
|
end
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
its(:resource_path) { should == 'SRVRecord/zone' }
|
67
|
+
it "SRV Record" do
|
68
|
+
expect(dynect.srv.resource_path).to eq('SRVRecord/zone')
|
71
69
|
end
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
its(:resource_path) { should == 'TXTRecord/zone' }
|
71
|
+
it "TXT Record" do
|
72
|
+
expect(dynect.txt.resource_path).to eq('TXTRecord/zone')
|
76
73
|
end
|
77
74
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,126 +1,86 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynect_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.4.beta
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Jacob
|
8
|
+
- Ranjib Dey
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement:
|
17
|
-
none: false
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - '>='
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: '0'
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: json
|
27
|
-
requirement: &17351940 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
24
|
requirements:
|
30
|
-
- -
|
25
|
+
- - '>='
|
31
26
|
- !ruby/object:Gem::Version
|
32
27
|
version: '0'
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *17351940
|
36
28
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
39
|
-
none: false
|
29
|
+
name: json
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
40
31
|
requirements:
|
41
|
-
- -
|
32
|
+
- - '>='
|
42
33
|
- !ruby/object:Gem::Version
|
43
34
|
version: '0'
|
44
|
-
type: :
|
35
|
+
type: :runtime
|
45
36
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rspec
|
49
|
-
requirement: &17368800 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
38
|
requirements:
|
52
|
-
- -
|
39
|
+
- - '>='
|
53
40
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *17368800
|
41
|
+
version: '0'
|
58
42
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement:
|
61
|
-
none: false
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
62
45
|
requirements:
|
63
|
-
- -
|
46
|
+
- - '>='
|
64
47
|
- !ruby/object:Gem::Version
|
65
48
|
version: '0'
|
66
49
|
type: :development
|
67
50
|
prerelease: false
|
68
|
-
version_requirements:
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: jeweler
|
71
|
-
requirement: &17367600 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
52
|
requirements:
|
74
|
-
- -
|
53
|
+
- - '>='
|
75
54
|
- !ruby/object:Gem::Version
|
76
55
|
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: *17367600
|
80
56
|
- !ruby/object:Gem::Dependency
|
81
57
|
name: rspec
|
82
|
-
requirement:
|
83
|
-
none: false
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
84
59
|
requirements:
|
85
|
-
- -
|
60
|
+
- - '>='
|
86
61
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
62
|
+
version: 2.10.0
|
88
63
|
type: :development
|
89
64
|
prerelease: false
|
90
|
-
version_requirements:
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: yard
|
93
|
-
requirement: &17366360 !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
66
|
requirements:
|
96
|
-
- -
|
67
|
+
- - '>='
|
97
68
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: *17366360
|
69
|
+
version: 2.10.0
|
102
70
|
- !ruby/object:Gem::Dependency
|
103
|
-
name:
|
104
|
-
requirement:
|
105
|
-
none: false
|
71
|
+
name: yard
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
106
73
|
requirements:
|
107
|
-
- -
|
74
|
+
- - '>='
|
108
75
|
- !ruby/object:Gem::Version
|
109
76
|
version: '0'
|
110
|
-
type: :
|
77
|
+
type: :development
|
111
78
|
prerelease: false
|
112
|
-
version_requirements:
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: rest-client
|
115
|
-
requirement: &17364880 !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
117
80
|
requirements:
|
118
|
-
- -
|
81
|
+
- - '>='
|
119
82
|
- !ruby/object:Gem::Version
|
120
83
|
version: '0'
|
121
|
-
type: :runtime
|
122
|
-
prerelease: false
|
123
|
-
version_requirements: *17364880
|
124
84
|
description: Use the Dynect services REST API
|
125
85
|
email: adam@opscode.com
|
126
86
|
executables: []
|
@@ -129,43 +89,38 @@ extra_rdoc_files:
|
|
129
89
|
- LICENSE
|
130
90
|
- README.rdoc
|
131
91
|
files:
|
132
|
-
- .document
|
133
|
-
- .rspec
|
134
|
-
- Gemfile
|
135
|
-
- Gemfile.lock
|
136
|
-
- LICENSE
|
137
|
-
- README.rdoc
|
138
92
|
- Rakefile
|
139
|
-
-
|
140
|
-
- dynect_rest.gemspec
|
141
|
-
- example.rb
|
93
|
+
- LICENSE
|
142
94
|
- lib/dynect_rest.rb
|
95
|
+
- lib/dynect_rest/version.rb
|
143
96
|
- lib/dynect_rest/exceptions.rb
|
97
|
+
- lib/dynect_rest/gslb.rb
|
144
98
|
- lib/dynect_rest/resource.rb
|
145
|
-
- spec/dynect_rest_spec.rb
|
146
99
|
- spec/spec_helper.rb
|
100
|
+
- spec/dynect_rest_spec.rb
|
101
|
+
- README.rdoc
|
147
102
|
homepage: http://github.com/adamhjk/dynect-rest
|
148
103
|
licenses: []
|
104
|
+
metadata: {}
|
149
105
|
post_install_message:
|
150
106
|
rdoc_options: []
|
151
107
|
require_paths:
|
152
108
|
- lib
|
153
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
110
|
requirements:
|
156
|
-
- -
|
111
|
+
- - '>='
|
157
112
|
- !ruby/object:Gem::Version
|
158
113
|
version: '0'
|
159
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
-
none: false
|
161
115
|
requirements:
|
162
|
-
- -
|
116
|
+
- - '>='
|
163
117
|
- !ruby/object:Gem::Version
|
164
118
|
version: '0'
|
165
119
|
requirements: []
|
166
120
|
rubyforge_project:
|
167
|
-
rubygems_version:
|
121
|
+
rubygems_version: 2.0.3
|
168
122
|
signing_key:
|
169
|
-
specification_version:
|
123
|
+
specification_version: 4
|
170
124
|
summary: Dynect REST API library
|
171
125
|
test_files: []
|
126
|
+
has_rdoc:
|
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.2)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.6.2)
|
7
|
-
bundler (~> 1.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
|
-
json (1.5.1)
|
11
|
-
mime-types (1.16)
|
12
|
-
rake (0.9.1)
|
13
|
-
rest-client (1.6.3)
|
14
|
-
mime-types (>= 1.16)
|
15
|
-
rspec (2.0.1)
|
16
|
-
rspec-core (~> 2.0.1)
|
17
|
-
rspec-expectations (~> 2.0.1)
|
18
|
-
rspec-mocks (~> 2.0.1)
|
19
|
-
rspec-core (2.0.1)
|
20
|
-
rspec-expectations (2.0.1)
|
21
|
-
diff-lcs (>= 1.1.2)
|
22
|
-
rspec-mocks (2.0.1)
|
23
|
-
rspec-core (~> 2.0.1)
|
24
|
-
rspec-expectations (~> 2.0.1)
|
25
|
-
yard (0.7.1)
|
26
|
-
|
27
|
-
PLATFORMS
|
28
|
-
ruby
|
29
|
-
|
30
|
-
DEPENDENCIES
|
31
|
-
jeweler
|
32
|
-
json
|
33
|
-
rake
|
34
|
-
rest-client
|
35
|
-
rspec (~> 2.0.0)
|
36
|
-
yard
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.4.3
|
data/dynect_rest.gemspec
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "dynect_rest"
|
8
|
-
s.version = "0.4.3"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Adam Jacob"]
|
12
|
-
s.date = "2012-04-11"
|
13
|
-
s.description = "Use the Dynect services REST API"
|
14
|
-
s.email = "adam@opscode.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
"Gemfile",
|
23
|
-
"Gemfile.lock",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"dynect_rest.gemspec",
|
29
|
-
"example.rb",
|
30
|
-
"lib/dynect_rest.rb",
|
31
|
-
"lib/dynect_rest/exceptions.rb",
|
32
|
-
"lib/dynect_rest/resource.rb",
|
33
|
-
"spec/dynect_rest_spec.rb",
|
34
|
-
"spec/spec_helper.rb"
|
35
|
-
]
|
36
|
-
s.homepage = "http://github.com/adamhjk/dynect-rest"
|
37
|
-
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = "1.8.10"
|
39
|
-
s.summary = "Dynect REST API library"
|
40
|
-
|
41
|
-
if s.respond_to? :specification_version then
|
42
|
-
s.specification_version = 3
|
43
|
-
|
44
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
-
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
46
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
47
|
-
s.add_development_dependency(%q<rake>, [">= 0"])
|
48
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
|
49
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
50
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
51
|
-
s.add_development_dependency(%q<rspec>, [">= 2.0"])
|
52
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
53
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
54
|
-
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
55
|
-
else
|
56
|
-
s.add_dependency(%q<rest-client>, [">= 0"])
|
57
|
-
s.add_dependency(%q<json>, [">= 0"])
|
58
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
59
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
60
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
61
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
62
|
-
s.add_dependency(%q<rspec>, [">= 2.0"])
|
63
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
64
|
-
s.add_dependency(%q<json>, [">= 0"])
|
65
|
-
s.add_dependency(%q<rest-client>, [">= 0"])
|
66
|
-
end
|
67
|
-
else
|
68
|
-
s.add_dependency(%q<rest-client>, [">= 0"])
|
69
|
-
s.add_dependency(%q<json>, [">= 0"])
|
70
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
71
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
72
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
73
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
74
|
-
s.add_dependency(%q<rspec>, [">= 2.0"])
|
75
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
76
|
-
s.add_dependency(%q<json>, [">= 0"])
|
77
|
-
s.add_dependency(%q<rest-client>, [">= 0"])
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
data/example.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'dynect_rest'
|
2
|
-
|
3
|
-
DYNECT_CUST = ENV['DYNECT_CUST'] || 'customer'
|
4
|
-
DYNECT_USER = ENV['DYNECT_USER'] || 'user'
|
5
|
-
DYNECT_PASS = ENV['DYNECT_PASS'] || 'secretword'
|
6
|
-
DYNECT_ZONE = ENV['DYNECT_ZONE'] || 'example.com'
|
7
|
-
|
8
|
-
@dyn = DynectRest.new(DYNECT_CUST, DYNECT_USER, DYNECT_PASS, DYNECT_ZONE, true)
|
9
|
-
|
10
|
-
# Create or Update an A Record for the given host
|
11
|
-
host = "example.#{DYNECT_ZONE}"
|
12
|
-
@record = @dyn.a.fqdn(host)
|
13
|
-
if @record.get(host)
|
14
|
-
@dyn.a.fqdn(host).ttl(300).address("10.4.5.254").save(true)
|
15
|
-
# the true flag will use a put instead of a post. This is required if you want to be able to update, as welll as create
|
16
|
-
else
|
17
|
-
@dyn.a.fqdn(host).ttl(300).address("10.4.5.254").save(false)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Create a new cname record
|
21
|
-
@dyn.cname.fqdn("example-cname.#{DYNECT_ZONE}").cname("ec2-10-10-10-10.amazonaws.com").save
|
22
|
-
|
23
|
-
@dyn.publish
|
24
|
-
@dyn.logout
|
25
|
-
|
26
|
-
|
27
|
-
|