RightScaleAPIHelper 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "RightScaleAPIHelper"
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
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 = "2012-04-19"
12
+ s.date = "2012-08-17"
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 = [
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
@@ -1,8 +1,22 @@
1
1
  module RightScaleAPIHelper
2
2
  class Helper
3
- # The aim of this class is to help access the RightScale API.
4
- # The goal is to include this in programs so that you can then use the api
5
- # without the need for all of the heavy lifting.
3
+ # Helper for connecting and using the RightScale API
4
+ #
5
+ # Example:
6
+ # >> rscon = RightScaleAPIHelper::Helper.new(99999, username, password)
7
+ # >> resp = rscon.get("/servers")
8
+ # >> puts resp.code
9
+ # => 200
10
+ # >> puts resp.body
11
+ # => output from body
12
+ #
13
+ # >>servers = JSON.parse(resp.body)
14
+ #
15
+ # Arguments:
16
+ #
17
+ # RightScaleAPIHelper::Helper.new(RightScaleAcctNum, RSusername, RSpasswd, format = 'js'|'xml', version = '1.0')
18
+ #
19
+
6
20
 
7
21
  # This currently only works with version 1.0 of the api. This is because it is all we currently
8
22
  # use. Will probably need to make it smarter at some point, but this is just for
@@ -14,14 +28,16 @@ module RightScaleAPIHelper
14
28
  # Initialize the connection with account information.
15
29
  # Return an object that can then later be used to make calls
16
30
  # against the RightScale API without authenticating again.
17
- # Inputs: format = xml or js
18
- # version = 1.0 # 1.5 to be supported soon
31
+ # Inputs:
32
+ # format = xml or js
33
+ # ersion = 1.0 # 1.5 to be supported soon
19
34
  def initialize(account, username, password, format = 'js', version = '1.0')
20
35
  # Set Default Variables
21
36
  rs_url = "https://my.rightscale.com"
22
37
  api_url = '/api/acct/'
23
38
  @api_call = "#{api_url}#{account}"
24
39
  @full_api_call = "#{rs_url}#{@api_call}"
40
+ @format=format
25
41
  @formatting = "?format=#{format}"
26
42
  @conn = Net::HTTP.new('my.rightscale.com', 443)
27
43
  @conn.use_ssl=true
@@ -47,10 +63,16 @@ module RightScaleAPIHelper
47
63
  }
48
64
  end
49
65
 
50
- def get(query)
66
+ # Do a GET request against RightScale API
67
+ def get(query, values = {})
51
68
  begin
52
69
  #puts "#{@api_call}#{query}#{@formatting}"
53
- resp = @conn.get("#{@api_call}#{query}#{@formatting}", @headers)
70
+
71
+ req = Net::HTTP::Get.new("#{@full_api_call}#{query}", @headers)
72
+ req.set_form_data(values)
73
+
74
+ resp = @conn.request(req)
75
+
54
76
  rescue
55
77
  raise("Get query failed.\nError: #")
56
78
  end
@@ -76,5 +98,15 @@ module RightScaleAPIHelper
76
98
  req.set_form_data(values)
77
99
  resp = @conn.request(req)
78
100
  end
101
+
102
+ # def self.parseInput(queryString)
103
+ # if queryString =~ m/\?/
104
+ #
105
+ # end
106
+ #
107
+ # if queryString =~ m/^http::/
108
+ # if
109
+ # end
110
+ # end
79
111
  end
80
112
  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.3
4
+ version: 0.4.4
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: 2012-04-19 00:00:00.000000000 Z
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: -3587793904631514069
113
+ hash: -2250818361753456587
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements: