shanesveller-webbynode-api 0.0.7 → 0.1.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.
- data/.document +1 -1
- data/README.markdown +77 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/webbynode-api/data.rb +60 -29
- data/lib/webbynode-api.rb +13 -12
- data/test/webbynode-api_test.rb +39 -39
- data/webbynode-api.gemspec +7 -4
- metadata +6 -4
data/.document
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#webbynode-api
|
2
|
+
|
3
|
+
This gem wraps the API available for the VPS hosting company
|
4
|
+
[WebbyNode](http://www.webbynode.com). Details and a preliminary
|
5
|
+
design document for the API itself are available
|
6
|
+
[here](http://howto.webbynode.com/topic.php?id=25). Functionality
|
7
|
+
is currently based on the API guide version 2.
|
8
|
+
|
9
|
+
##Notice
|
10
|
+
**All previous methods/initializers used named/ordered arguments. New API
|
11
|
+
interactions are designed to use hashes of arguments instead. Older API
|
12
|
+
models will be converted to this new design pattern soon.**
|
13
|
+
|
14
|
+
**Also, any new/improved documentation will instead be visible in the
|
15
|
+
[YARD documentation](http://rdoc.info/projects/shanesveller/webbynode-api)
|
16
|
+
hosted at [rdoc.info](http://rdoc.info).**
|
17
|
+
|
18
|
+
##Currently Supported API functionality
|
19
|
+
* Client information such as account status, contact/address info, credit
|
20
|
+
* Webby information (status) and simple actions (start, shutdown, reboot)
|
21
|
+
* List all webbies
|
22
|
+
* DNS zone information such as domain name, TTL, and status
|
23
|
+
* Creation/deletion of DNS zones
|
24
|
+
|
25
|
+
##In Development
|
26
|
+
* DNS record information such as type, data, name, id, and TTL
|
27
|
+
|
28
|
+
##Planned Features
|
29
|
+
* DNS zone/record creation, editing and deletion
|
30
|
+
* Whatever else WebbyNode gives us in the API :)
|
31
|
+
|
32
|
+
##Example Usage
|
33
|
+
###Account
|
34
|
+
require 'webbynode-api'
|
35
|
+
email = "example@email.com"
|
36
|
+
api_key = "1234567890abcdef"
|
37
|
+
@client = WebbyNode::Client.new(email, api_key)
|
38
|
+
puts @client.firstname
|
39
|
+
|
40
|
+
###Webby
|
41
|
+
require 'webbynode-api'
|
42
|
+
email = "example@email.com"
|
43
|
+
api_key = "1234567890abcdef"
|
44
|
+
hostname = "webby1"
|
45
|
+
# Get a single Webby's info
|
46
|
+
@webby = WebbyNode::Webby.new(email, api_key, hostname)
|
47
|
+
@webby.status
|
48
|
+
@webby.shutdown
|
49
|
+
@webby.status
|
50
|
+
# Get a list of all Webbies
|
51
|
+
@webbies = WebbyNode::Webby.new(email, api_key)
|
52
|
+
puts @webbies.list
|
53
|
+
|
54
|
+
###DNS
|
55
|
+
require 'webbynode-api'
|
56
|
+
email = "example@email.com"
|
57
|
+
api_key = "1234567890abcdef"
|
58
|
+
zone_id = 123
|
59
|
+
@dns = WebbyNode::DNS.new(email, api_key)
|
60
|
+
pp @dns.zones
|
61
|
+
@dns = WebbyNode::DNS.new(email, api_key, zone_id)
|
62
|
+
pp @dns.domain
|
63
|
+
pp @dns.records
|
64
|
+
|
65
|
+
###DNS Zone Creation/Deletion
|
66
|
+
require 'webbynode-api'
|
67
|
+
email = "example@email.com"
|
68
|
+
api_key = "1234567890abcdef"
|
69
|
+
@new_zone = WebbyNode::DNS.new_zone(:email => email, :token => api_key, :domain => "mynewdomain.com.", :ttl => 86400)
|
70
|
+
pp @new_zone["id"]
|
71
|
+
# => 171
|
72
|
+
WebbyNode::DNS.delete_zone(:email => email, :token => api_key, :id => 171)
|
73
|
+
# => true
|
74
|
+
|
75
|
+
##Copyright
|
76
|
+
|
77
|
+
Copyright (c) 2009 Shane Sveller. See LICENSE for details.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/webbynode-api/data.rb
CHANGED
@@ -3,43 +3,40 @@ class WebbyNode
|
|
3
3
|
#
|
4
4
|
# @author Shane Sveller
|
5
5
|
# @since 0.0.1
|
6
|
+
# @version 0.1.0
|
6
7
|
class Client < WebbyNode::APIObject
|
7
|
-
def initialize(
|
8
|
-
super(
|
8
|
+
def initialize(options = {})
|
9
|
+
super(options)
|
9
10
|
@data = auth_get("/api/xml/client")["hash"]["client"]
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
# Represents an individual webby with status, reboot/shutdown/start functionality
|
14
15
|
# via +method_missing+
|
15
|
-
#
|
16
|
+
#
|
16
17
|
# @author Shane Sveller
|
17
18
|
# @since 0.0.1
|
19
|
+
# @version 0.1.0
|
18
20
|
class Webby < WebbyNode::APIObject
|
19
21
|
attr_accessor :hostname
|
20
22
|
|
21
|
-
# Fetches
|
23
|
+
# Fetches an individual Webby's data.
|
22
24
|
#
|
23
|
-
# @
|
24
|
-
# @
|
25
|
-
# @
|
25
|
+
# @option options [String] :email E-mail address used for API access
|
26
|
+
# @option options [String] :token API token used for API access
|
27
|
+
# @option options [String] :hostname Hostname used to look up an individual
|
26
28
|
# Webby. When absent or nil, the newly instantiated object instead
|
27
29
|
# represents an Array of Webbies.
|
28
30
|
# @example Fetch data for a Webby named "webby1"
|
29
|
-
# WebbyNode::Webby.new(email,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
if hostname
|
35
|
-
@hostname = hostname
|
36
|
-
else
|
37
|
-
@data = auth_get("/api/xml/webbies")["hash"]["webbies"]
|
38
|
-
end
|
31
|
+
# @webby = WebbyNode::Webby.new(:email => email, :token => token, "webby1")
|
32
|
+
def initialize(options = {})
|
33
|
+
raise ArgumentError, ":hostname is a required argument" unless options[:hostname]
|
34
|
+
super(options)
|
35
|
+
@hostname = options[:hostname]
|
39
36
|
end
|
40
37
|
|
41
38
|
# Provides status, start/shutdown/reboot functionality for an individual
|
42
|
-
# Webby.
|
39
|
+
# Webby.
|
43
40
|
def method_missing(method)
|
44
41
|
if method.to_s == "status"
|
45
42
|
return auth_get("/api/xml/webby/#{@hostname}/status")["hash"]["status"]
|
@@ -53,10 +50,29 @@ class WebbyNode
|
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
53
|
+
# Represents a list of all Webbies on an account
|
54
|
+
#
|
55
|
+
# @author Shane Sveller
|
56
|
+
# @since 0.1.0
|
57
|
+
# @version 0.1.0
|
58
|
+
class WebbyList < WebbyNode::APIObject
|
59
|
+
# Fetches an array of Webbies' data.
|
60
|
+
#
|
61
|
+
# @option options [String] :email E-mail address used for API access
|
62
|
+
# @option options [String] :token API token used for API access
|
63
|
+
# @example Fetch an Array of Webbies
|
64
|
+
# WebbyNode::Webby.new(:email => email, :token => token)
|
65
|
+
def initialize(options = {})
|
66
|
+
super(options)
|
67
|
+
@data = auth_get("/api/xml/webbies")["hash"]["webbies"]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
56
71
|
# Represents the DNS zones present on the API account
|
57
72
|
#
|
58
73
|
# @author Shane Sveller
|
59
74
|
# @since 0.0.2
|
75
|
+
# @version 0.1.0
|
60
76
|
class DNS < WebbyNode::APIObject
|
61
77
|
# Holds the ID used internally at WebbyNode that represents a given zone.
|
62
78
|
attr_accessor :id
|
@@ -64,17 +80,16 @@ class WebbyNode
|
|
64
80
|
# Fetches either a single zone or an Array of all zones based on the presence
|
65
81
|
# of the id parameter.
|
66
82
|
#
|
67
|
-
# @
|
68
|
-
# @
|
69
|
-
# @
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
83
|
+
# @option options [String] :email E-mail address used for API access
|
84
|
+
# @option options [String] :token API token used for API access
|
85
|
+
# @option options [Integer] :id ID that represents an individual zone
|
86
|
+
# @raise [ArgumentError] Raises ArgumentError if the :id option is missing
|
87
|
+
# from the optins parameter.
|
88
|
+
def initialize(options = {})
|
89
|
+
raise ArgumentError, ":id is a required argument" unless options[:id]
|
90
|
+
super(options)
|
91
|
+
@id = options[:id]
|
92
|
+
@data = auth_get("/api/xml/dns/#{@id}")["hash"]["zone"]
|
78
93
|
end
|
79
94
|
|
80
95
|
# @since 0.0.3
|
@@ -122,4 +137,20 @@ class WebbyNode
|
|
122
137
|
return auth_post("/api/xml/dns/#{options[:id]}/delete", :query => options)["hash"]["success"]
|
123
138
|
end
|
124
139
|
end
|
140
|
+
|
141
|
+
# Represents an Array of all DNS zones present on the API account
|
142
|
+
#
|
143
|
+
# @author Shane Sveller
|
144
|
+
# @since 0.1.0
|
145
|
+
# @version 0.1.0
|
146
|
+
class DNSList < WebbyNode::APIObject
|
147
|
+
# Fetches an Array of all zones into @data.
|
148
|
+
#
|
149
|
+
# @option options [String] :email E-mail address used for API access
|
150
|
+
# @option options [String] :token API token used for API access
|
151
|
+
def initialize(options = {})
|
152
|
+
super(options)
|
153
|
+
@data = auth_get("/api/xml/dns")["hash"]["zones"]
|
154
|
+
end
|
155
|
+
end
|
125
156
|
end
|
data/lib/webbynode-api.rb
CHANGED
@@ -2,11 +2,11 @@ require 'rubygems'
|
|
2
2
|
gem 'httparty'
|
3
3
|
require 'httparty'
|
4
4
|
|
5
|
-
# @author Shane Sveller
|
6
5
|
class WebbyNode
|
7
6
|
|
8
7
|
# @author Shane Sveller
|
9
8
|
# @since 0.0.1
|
9
|
+
# @version 0.1.0
|
10
10
|
class APIObject
|
11
11
|
include HTTParty
|
12
12
|
base_uri "https://manager.webbynode.com"
|
@@ -15,19 +15,20 @@ class WebbyNode
|
|
15
15
|
# E-mail address used to access the WebbyNode API
|
16
16
|
attr_accessor :email
|
17
17
|
# API token used to access the WebbyNode API, visible at https://manager.webbynode.com/account
|
18
|
-
attr_accessor :
|
18
|
+
attr_accessor :token
|
19
19
|
# Stores the results of the HTTParty API interactions
|
20
20
|
attr_accessor :data
|
21
21
|
|
22
22
|
# Creates a new API object secured by e-mail address and API token
|
23
23
|
#
|
24
|
-
# @
|
25
|
-
# @
|
24
|
+
# @option options [String] :email e-mail address with API access
|
25
|
+
# @option options [String] :token API token that matches the included e-mail address
|
26
26
|
# @example Instantiates a new API access object
|
27
|
-
# WebbyNode::APIObject.new("example@email.com", "123456abcdef")
|
28
|
-
def initialize(
|
29
|
-
|
30
|
-
@
|
27
|
+
# WebbyNode::APIObject.new(:email => "example@email.com", :token => "123456abcdef")
|
28
|
+
def initialize(options = {})
|
29
|
+
raise ArgumentError, ":email and :token are required arguments" unless options[:email] && options[:token]
|
30
|
+
@email = options[:email]
|
31
|
+
@token = options[:token]
|
31
32
|
end
|
32
33
|
|
33
34
|
# Uses HTTParty to submit a secure API request via email address and token
|
@@ -35,9 +36,9 @@ class WebbyNode
|
|
35
36
|
# @param [Hash] options Hash of additional HTTParty parameters
|
36
37
|
# @option options [Hash] :query query hash used to build the final URL
|
37
38
|
def auth_get(url, options = {})
|
38
|
-
raise ArgumentError, "API information is missing or incomplete" unless @email && @
|
39
|
+
raise ArgumentError, "API information is missing or incomplete" unless @email && @token
|
39
40
|
options[:query] ||= {}
|
40
|
-
options[:query].merge!(:email => @email, :token => @
|
41
|
+
options[:query].merge!(:email => @email, :token => @token)
|
41
42
|
results = self.class.get(url, options)
|
42
43
|
raise ArgumentError, "Probable bad API information given" if results == {}
|
43
44
|
return results
|
@@ -72,8 +73,8 @@ class WebbyNode
|
|
72
73
|
#
|
73
74
|
# @return [Object, nil] If the @data instance variable is set, and contains a hash
|
74
75
|
# with a key matching the missing method, return the value from that hash key.
|
75
|
-
# Said value may be typecast into a Ruby object if the XML is formatted
|
76
|
-
# Otherwise returns nil.
|
76
|
+
# Said value may be typecast into a Ruby object if the source XML is formatted
|
77
|
+
# properly. Otherwise returns nil.
|
77
78
|
def method_missing(method)
|
78
79
|
key = @data[method.to_s] if @data
|
79
80
|
key
|
data/test/webbynode-api_test.rb
CHANGED
@@ -4,7 +4,7 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
4
4
|
context "with bad API token or email" do
|
5
5
|
setup do
|
6
6
|
@email ="example@email.com"
|
7
|
-
@
|
7
|
+
@token = "123456"
|
8
8
|
data_path = File.join(File.dirname(__FILE__), "data")
|
9
9
|
FakeWeb.clean_registry
|
10
10
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/client\?\w+/i, :body => File.read("#{data_path}/bad-auth.xml"))
|
@@ -12,28 +12,28 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
should "raise ArgumentError if no API data given" do
|
14
14
|
# for auth_get
|
15
|
-
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::Client.new(nil, nil) }
|
16
|
-
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::Client.new(@email, nil) }
|
17
|
-
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::Client.new(nil, @
|
15
|
+
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::Client.new(:email => nil, :token => nil) }
|
16
|
+
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::Client.new(:email => @email, :token => nil) }
|
17
|
+
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::Client.new(:email => nil, :token => @token) }
|
18
18
|
# for auth_post
|
19
|
-
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::APIObject.new(nil, nil).auth_post("",{}) }
|
20
|
-
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::APIObject.new(@email, nil).auth_post("",{}) }
|
21
|
-
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::APIObject.new(nil, @
|
19
|
+
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::APIObject.new(:email => nil, :token => nil).auth_post("",{}) }
|
20
|
+
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::APIObject.new(:email => @email, :token => nil).auth_post("",{}) }
|
21
|
+
assert_raise(ArgumentError, "API information is missing or incomplete"){ WebbyNode::APIObject.new(:email => nil, :token => @token).auth_post("",{}) }
|
22
22
|
end
|
23
23
|
should "raise ArgumentError if bad API data given" do
|
24
|
-
assert_raise(ArgumentError, "Probable bad API information given"){ WebbyNode::Client.new(@email, @
|
24
|
+
assert_raise(ArgumentError, "Probable bad API information given"){ WebbyNode::Client.new(@email, @token) }
|
25
25
|
# TODO: Need XML fixture file for this
|
26
|
-
# assert_raise(ArgumentError, "Probable bad API information given"){ WebbyNode::APIObject.new(@email, @
|
26
|
+
# assert_raise(ArgumentError, "Probable bad API information given"){ WebbyNode::APIObject.new(@email, @token).auth_post("",{}) }
|
27
27
|
end
|
28
28
|
end
|
29
29
|
context "fetching client data from API" do
|
30
30
|
setup do
|
31
31
|
email = "example@email.com"
|
32
|
-
|
32
|
+
token = "123456"
|
33
33
|
data_path = File.join(File.dirname(__FILE__), "data")
|
34
34
|
FakeWeb.clean_registry
|
35
35
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/client\?.+/i, :body => File.read("#{data_path}/client.xml"))
|
36
|
-
@api = WebbyNode::Client.new(email,
|
36
|
+
@api = WebbyNode::Client.new(:email => email, :token => token)
|
37
37
|
end
|
38
38
|
|
39
39
|
should "use method missing to get values for present keys" do
|
@@ -68,17 +68,17 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
context "fetching
|
71
|
+
context "fetching webby data from API" do
|
72
72
|
setup do
|
73
73
|
email = "example@email.com"
|
74
|
-
|
74
|
+
token = "123456"
|
75
75
|
hostname = "webby1"
|
76
76
|
data_path = File.join(File.dirname(__FILE__), "data")
|
77
77
|
FakeWeb.clean_registry
|
78
78
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/webby\/\w+\/start\?.+/i, :body => File.read("#{data_path}/webby-start.xml"))
|
79
79
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/webby\/\w+\/shutdown\?.+/i, :body => File.read("#{data_path}/webby-shutdown.xml"))
|
80
80
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/webby\/\w+\/reboot\?.+/i, :body => File.read("#{data_path}/webby-reboot.xml"))
|
81
|
-
@webby = WebbyNode::Webby.new(email,
|
81
|
+
@webby = WebbyNode::Webby.new(:email => email, :token => token, :hostname => hostname)
|
82
82
|
end
|
83
83
|
should "return a job ID when starting, shutting down, or rebooting" do
|
84
84
|
@webby.start.should == 2562
|
@@ -97,18 +97,18 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
97
97
|
@webby.status.should == "Rebooting"
|
98
98
|
end
|
99
99
|
end
|
100
|
-
context "fetching webbies data from API
|
100
|
+
context "fetching webbies data from API" do
|
101
101
|
setup do
|
102
102
|
email = "example@email.com"
|
103
|
-
|
103
|
+
token = "123456"
|
104
104
|
data_path = File.join(File.dirname(__FILE__), "data")
|
105
105
|
FakeWeb.clean_registry
|
106
106
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/webbies\?.+/i, :body => File.read("#{data_path}/webbies.xml"))
|
107
|
-
@webbies = WebbyNode::
|
107
|
+
@webbies = WebbyNode::WebbyList.new(:email => email, :token => token)
|
108
108
|
end
|
109
109
|
should "return a array of webbies" do
|
110
|
-
@webbies.
|
111
|
-
webby = @webbies.
|
110
|
+
@webbies.data.is_a?(Array).should be(true)
|
111
|
+
webby = @webbies.data.first
|
112
112
|
webby["status"].should == "on"
|
113
113
|
webby["ip"].should == "222.111.222.111"
|
114
114
|
webby["node"].should == "location-a01"
|
@@ -118,25 +118,25 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
context "fetching DNS data from API
|
121
|
+
context "fetching all DNS data from API" do
|
122
122
|
setup do
|
123
123
|
email = "example@email.com"
|
124
|
-
|
124
|
+
token = "123456"
|
125
125
|
data_path = File.join(File.dirname(__FILE__), "data")
|
126
126
|
FakeWeb.clean_registry
|
127
127
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\?.+/i, :body => File.read("#{data_path}/dns.xml"))
|
128
128
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\/\d+\?.+/i, :body => File.read("#{data_path}/dns-1.xml"))
|
129
|
-
@
|
129
|
+
@zones = WebbyNode::DNSList.new(:email => email, :token => token)
|
130
130
|
end
|
131
131
|
should "return an array of zones with domain, status, id, and TTL" do
|
132
|
-
@
|
133
|
-
@
|
134
|
-
zone = @
|
132
|
+
@zones.data.is_a?(Array).should be(true)
|
133
|
+
@zones.data.size.should == 3
|
134
|
+
zone = @zones.data.first
|
135
135
|
zone["id"].should == 1
|
136
136
|
zone["status"].should == "Active"
|
137
137
|
zone["domain"].should == "example.com."
|
138
138
|
zone["ttl"].should == 86400
|
139
|
-
zone = @
|
139
|
+
zone = @zones.data.last
|
140
140
|
zone["id"].should == 132
|
141
141
|
zone["status"].should == "Inactive"
|
142
142
|
zone["domain"].should == "inactive.com."
|
@@ -146,14 +146,14 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
146
146
|
context "fetching DNS data from API with id" do
|
147
147
|
setup do
|
148
148
|
email = "example@email.com"
|
149
|
-
|
149
|
+
token = "123456"
|
150
150
|
id = 1
|
151
151
|
data_path = File.join(File.dirname(__FILE__), "data")
|
152
152
|
FakeWeb.clean_registry
|
153
153
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\?.+/i, :body => File.read("#{data_path}/dns.xml"))
|
154
154
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\/\d+\?.+/i, :body => File.read("#{data_path}/dns-1.xml"))
|
155
155
|
FakeWeb.register_uri(:get, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\/\d+\/records\?.+/i, :body => File.read("#{data_path}/dns-records.xml"))
|
156
|
-
@dns = WebbyNode::DNS.new(email,
|
156
|
+
@dns = WebbyNode::DNS.new(:email => email, :token => token, :id => id)
|
157
157
|
end
|
158
158
|
should "return domain name, status, id and TTL" do
|
159
159
|
@dns.domain.should == "example.com."
|
@@ -175,7 +175,7 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
175
175
|
context "creating a new DNS zone" do
|
176
176
|
setup do
|
177
177
|
@email = "example@email.com"
|
178
|
-
@
|
178
|
+
@token = "123456"
|
179
179
|
@domain = "example.com."
|
180
180
|
@ttl = 86400
|
181
181
|
data_path = File.join(File.dirname(__FILE__), "data")
|
@@ -183,21 +183,21 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
183
183
|
FakeWeb.register_uri(:post, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\/new\?.+/i, :body => File.read("#{data_path}/new-zone.xml"))
|
184
184
|
end
|
185
185
|
should "raise ArgumentError if API information isn't present" do
|
186
|
-
assert_raise(ArgumentError,"API access information via :email and :token are required arguments"){ WebbyNode::DNS.new_zone(:token => @
|
186
|
+
assert_raise(ArgumentError,"API access information via :email and :token are required arguments"){ WebbyNode::DNS.new_zone(:token => @token, :domain => @domain, :ttl => @ttl) }
|
187
187
|
assert_raise(ArgumentError,"API access information via :email and :token are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :domain => @domain, :ttl => @ttl) }
|
188
188
|
end
|
189
189
|
should "raise ArgumentError if :domain or :ttl aren't included in method call" do
|
190
|
-
assert_raise(ArgumentError, ":domain and :ttl are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :token => @
|
191
|
-
assert_raise(ArgumentError, ":domain and :ttl are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :token => @
|
190
|
+
assert_raise(ArgumentError, ":domain and :ttl are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :token => @token, :ttl => @ttl) }
|
191
|
+
assert_raise(ArgumentError, ":domain and :ttl are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :token => @token, :domain => @domain) }
|
192
192
|
end
|
193
193
|
should "raise ArgumentError if :status is not a valid option" do
|
194
|
-
assert_raise(ArgumentError, ":domain and :ttl are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :token => @
|
195
|
-
assert_nothing_raised(ArgumentError){ WebbyNode::DNS.new_zone(:email => @email, :token => @
|
196
|
-
assert_nothing_raised(ArgumentError){ WebbyNode::DNS.new_zone(:email => @email, :token => @
|
197
|
-
assert_nothing_raised(ArgumentError){ WebbyNode::DNS.new_zone(:email => @email, :token => @
|
194
|
+
assert_raise(ArgumentError, ":domain and :ttl are required arguments"){ WebbyNode::DNS.new_zone(:email => @email, :token => @token, :ttl => @ttl, :status => "Not active") }
|
195
|
+
assert_nothing_raised(ArgumentError){ WebbyNode::DNS.new_zone(:email => @email, :token => @token, :domain => @domain, :ttl => @ttl, :status => "Active") }
|
196
|
+
assert_nothing_raised(ArgumentError){ WebbyNode::DNS.new_zone(:email => @email, :token => @token, :domain => @domain, :ttl => @ttl, :status => "Inactive") }
|
197
|
+
assert_nothing_raised(ArgumentError){ WebbyNode::DNS.new_zone(:email => @email, :token => @token, :domain => @domain, :ttl => @ttl, :status => nil) }
|
198
198
|
end
|
199
199
|
should "return a Hash containing the new zone's information" do
|
200
|
-
@new_zone = WebbyNode::DNS.new_zone(:email => @email, :token => @
|
200
|
+
@new_zone = WebbyNode::DNS.new_zone(:email => @email, :token => @token, :domain => @domain, :ttl => @ttl, :status => "Inactive")
|
201
201
|
@new_zone["id"].should == 171
|
202
202
|
@new_zone["domain"].should == "example.com."
|
203
203
|
@new_zone["ttl"].should == 86400
|
@@ -206,14 +206,14 @@ class WebbynodeApiTest < Test::Unit::TestCase
|
|
206
206
|
context "deleting a DNS zone" do
|
207
207
|
setup do
|
208
208
|
@email = "example@email.com"
|
209
|
-
@
|
209
|
+
@token = "123456"
|
210
210
|
@id = 171
|
211
211
|
data_path = File.join(File.dirname(__FILE__), "data")
|
212
212
|
FakeWeb.clean_registry
|
213
213
|
FakeWeb.register_uri(:post, /^https:\/\/manager\.webbynode\.com\/api\/xml\/dns\/\d+\/delete\?.+/i, :body => File.read("#{data_path}/delete-zone.xml"))
|
214
214
|
end
|
215
215
|
should "return a boolean true for succesful deletion" do
|
216
|
-
WebbyNode::DNS.delete_zone(:email => @email, :token => @
|
216
|
+
WebbyNode::DNS.delete_zone(:email => @email, :token => @token, :id => @id)
|
217
217
|
end
|
218
218
|
end
|
219
219
|
end
|
data/webbynode-api.gemspec
CHANGED
@@ -2,20 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{webbynode-api}
|
5
|
-
s.version = "0.0
|
5
|
+
s.version = "0.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Shane Sveller"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-13}
|
10
10
|
s.email = %q{shanesveller@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
13
|
+
"README.markdown",
|
13
14
|
"README.rdoc"
|
14
15
|
]
|
15
16
|
s.files = [
|
16
17
|
".document",
|
17
18
|
".gitignore",
|
18
19
|
"LICENSE",
|
20
|
+
"README.markdown",
|
19
21
|
"README.rdoc",
|
20
22
|
"Rakefile",
|
21
23
|
"VERSION",
|
@@ -40,10 +42,11 @@ Gem::Specification.new do |s|
|
|
40
42
|
"test/webbynode-api_test.rb",
|
41
43
|
"webbynode-api.gemspec"
|
42
44
|
]
|
45
|
+
s.has_rdoc = true
|
43
46
|
s.homepage = %q{http://github.com/shanesveller/webbynode-api}
|
44
47
|
s.rdoc_options = ["--charset=UTF-8"]
|
45
48
|
s.require_paths = ["lib"]
|
46
|
-
s.rubygems_version = %q{1.3.
|
49
|
+
s.rubygems_version = %q{1.3.1}
|
47
50
|
s.summary = %q{wraps the WebbyNode API into nice Ruby objects}
|
48
51
|
s.test_files = [
|
49
52
|
"test/test_helper.rb",
|
@@ -52,7 +55,7 @@ Gem::Specification.new do |s|
|
|
52
55
|
|
53
56
|
if s.respond_to? :specification_version then
|
54
57
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
|
-
s.specification_version =
|
58
|
+
s.specification_version = 2
|
56
59
|
|
57
60
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
58
61
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shanesveller-webbynode-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Sveller
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -21,11 +21,13 @@ extensions: []
|
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- LICENSE
|
24
|
+
- README.markdown
|
24
25
|
- README.rdoc
|
25
26
|
files:
|
26
27
|
- .document
|
27
28
|
- .gitignore
|
28
29
|
- LICENSE
|
30
|
+
- README.markdown
|
29
31
|
- README.rdoc
|
30
32
|
- Rakefile
|
31
33
|
- VERSION
|
@@ -49,7 +51,7 @@ files:
|
|
49
51
|
- test/test_helper.rb
|
50
52
|
- test/webbynode-api_test.rb
|
51
53
|
- webbynode-api.gemspec
|
52
|
-
has_rdoc:
|
54
|
+
has_rdoc: true
|
53
55
|
homepage: http://github.com/shanesveller/webbynode-api
|
54
56
|
post_install_message:
|
55
57
|
rdoc_options:
|
@@ -73,7 +75,7 @@ requirements: []
|
|
73
75
|
rubyforge_project:
|
74
76
|
rubygems_version: 1.2.0
|
75
77
|
signing_key:
|
76
|
-
specification_version:
|
78
|
+
specification_version: 2
|
77
79
|
summary: wraps the WebbyNode API into nice Ruby objects
|
78
80
|
test_files:
|
79
81
|
- test/test_helper.rb
|