RightScaleAPIHelper 0.4.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/RightScaleAPIHelper.gemspec +5 -3
- data/VERSION +1 -1
- data/lib/RightScaleAPIHelper.rb +21 -14
- data/lib/rs_api_helper/connection.rb +7 -0
- data/lib/rs_api_helper.rb +12 -0
- metadata +6 -4
data/README.rdoc
CHANGED
@@ -10,6 +10,11 @@ Example
|
|
10
10
|
api_conn = RightScaleAPIHelper::Helper.new(123456, 'email@email.com', 'password')
|
11
11
|
|
12
12
|
resp = api_conn.get("/deployments")
|
13
|
+
|
14
|
+
'or you can use the full api path'
|
15
|
+
|
16
|
+
resp = api_conn.get("https://my.rightscale.com/api/acct/######/deployments")
|
17
|
+
|
13
18
|
puts resp.code # Response code from RightScale
|
14
19
|
puts resp.body # xml or json response
|
15
20
|
|
data/RightScaleAPIHelper.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "RightScaleAPIHelper"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Eric VanWieren"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-09-04"
|
13
13
|
s.description = "Simple wrapper for connecting and using the RightScale API. Eases the use of connecting with a username and password, and then provides an object to do GET, PUT, POST, DELETE requests. Returns an HTTP response."
|
14
14
|
s.email = "eric@codex.org"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,13 +25,15 @@ Gem::Specification.new do |s|
|
|
25
25
|
"RightScaleAPIHelper.gemspec",
|
26
26
|
"VERSION",
|
27
27
|
"lib/RightScaleAPIHelper.rb",
|
28
|
+
"lib/rs_api_helper.rb",
|
29
|
+
"lib/rs_api_helper/connection.rb",
|
28
30
|
"test/helper.rb",
|
29
31
|
"test/test_RightScaleAPIHelper.rb"
|
30
32
|
]
|
31
33
|
s.homepage = "http://github.com/evanwieren/RightScaleAPIHelper"
|
32
34
|
s.licenses = ["MIT"]
|
33
35
|
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = "1.8.
|
36
|
+
s.rubygems_version = "1.8.25"
|
35
37
|
s.summary = "Simple wrapper for connecting to RightScale API and make Calls"
|
36
38
|
|
37
39
|
if s.respond_to? :specification_version then
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.7
|
data/lib/RightScaleAPIHelper.rb
CHANGED
@@ -70,20 +70,22 @@ module RightScaleAPIHelper
|
|
70
70
|
def get(query, values = {})
|
71
71
|
begin
|
72
72
|
#puts "#{@api_call}#{query}#{@formatting}"
|
73
|
+
request_value = api_request(query)
|
73
74
|
|
74
|
-
req = Net::HTTP::Get.new("#{
|
75
|
+
req = Net::HTTP::Get.new("#{request_value}#{@formatting}", @headers)
|
75
76
|
req.set_form_data(values)
|
76
77
|
|
77
78
|
resp = @conn.request(req)
|
78
79
|
|
79
80
|
rescue
|
80
|
-
raise("Get query failed.\
|
81
|
+
raise("Get query failed.\n Query string is #{request_value}#{@formatting}")
|
81
82
|
end
|
82
83
|
return resp
|
83
84
|
end
|
84
85
|
|
85
86
|
def post(query, values)
|
86
|
-
|
87
|
+
request_value = api_request(query)
|
88
|
+
req = Net::HTTP::Post.new(request_value, @headers)
|
87
89
|
|
88
90
|
req.set_form_data(values)
|
89
91
|
resp = @conn.request(req)
|
@@ -92,24 +94,29 @@ module RightScaleAPIHelper
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def delete(query)
|
95
|
-
|
97
|
+
request_value = api_request(query)
|
98
|
+
req = Net::HTTP::Delete.new(request_value, @headers)
|
96
99
|
resp = @conn.request(req)
|
97
100
|
end
|
98
101
|
|
99
102
|
def put(query, values)
|
100
|
-
|
103
|
+
request_value = api_request(query)
|
104
|
+
req = Net::HTTP::Put.new(request_value, @headers)
|
101
105
|
req.set_form_data(values)
|
102
106
|
resp = @conn.request(req)
|
103
107
|
end
|
104
108
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
#
|
109
|
+
def api_request(submitted_query)
|
110
|
+
if is_full_path?(submitted_query)
|
111
|
+
return submitted_query
|
112
|
+
else
|
113
|
+
return "#{@full_api_call}#{submitted_query}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Function just to check if the path that is being passed is a full url or just the extension.
|
118
|
+
def is_full_path?(queryString)
|
119
|
+
(queryString =~ /^http/i) != nil
|
120
|
+
end
|
114
121
|
end
|
115
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RightScaleAPIHelper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
@@ -93,6 +93,8 @@ files:
|
|
93
93
|
- RightScaleAPIHelper.gemspec
|
94
94
|
- VERSION
|
95
95
|
- lib/RightScaleAPIHelper.rb
|
96
|
+
- lib/rs_api_helper.rb
|
97
|
+
- lib/rs_api_helper/connection.rb
|
96
98
|
- test/helper.rb
|
97
99
|
- test/test_RightScaleAPIHelper.rb
|
98
100
|
homepage: http://github.com/evanwieren/RightScaleAPIHelper
|
@@ -110,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
112
|
version: '0'
|
111
113
|
segments:
|
112
114
|
- 0
|
113
|
-
hash:
|
115
|
+
hash: 1901197611965626758
|
114
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
117
|
none: false
|
116
118
|
requirements:
|
@@ -119,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
121
|
version: '0'
|
120
122
|
requirements: []
|
121
123
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.25
|
123
125
|
signing_key:
|
124
126
|
specification_version: 3
|
125
127
|
summary: Simple wrapper for connecting to RightScale API and make Calls
|