right-scale-api 0.0.0 → 0.0.1

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/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  *.iml
3
3
  *~
4
4
  .DS_Store
5
+ pkg/*
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -6,11 +6,12 @@ module RightScaleAPI
6
6
  #attributes that directly correspond to the api's
7
7
  def self.attributes attrs=nil
8
8
  if attrs
9
+ @attributes ||= Base.attributes
9
10
  @attributes ||= []
10
- @attributes += attrs
11
+ @attributes += attrs.map {|attr|attr.to_sym}
11
12
  attr_accessor *attrs
12
13
 
13
- @attributes.each do |attr|
14
+ attrs.each do |attr|
14
15
  if attr =~ /(.+)_href$/
15
16
  relation = $1
16
17
  attr_accessor relation
@@ -21,7 +22,7 @@ module RightScaleAPI
21
22
  @attributes
22
23
  end
23
24
 
24
- attributes [:tags, :created_at, :updated_at,:errors]
25
+ attributes [:tags, :created_at, :updated_at,:errors, :nickname]
25
26
 
26
27
  def self.get id
27
28
  new :id => id
@@ -68,13 +69,29 @@ module RightScaleAPI
68
69
  delete ''
69
70
  end
70
71
 
71
- def method_missing method,*args
72
- if %w(get head post put delete).include? method.to_s
73
- args[0] = "#{path}#{args[0]}"
74
- RightScaleAPI::Client.send method, *args
75
- else
76
- super method, *args
77
- end
72
+ def send_request method, *args
73
+ args[0] = "#{path}#{args[0]}"
74
+ RightScaleAPI::Client.send method, *args
75
+ end
76
+
77
+ def get *args
78
+ send_request :get, *args
79
+ end
80
+
81
+ def head *args
82
+ send_request :head, *args
83
+ end
84
+
85
+ def post *args
86
+ send_request :post, *args
87
+ end
88
+
89
+ def put *args
90
+ send_request :put, *args
91
+ end
92
+
93
+ def delete *args
94
+ send_request :delete, *args
78
95
  end
79
96
 
80
97
  def uri
@@ -108,16 +125,16 @@ module RightScaleAPI
108
125
  def self.opts_to_query_opts opts
109
126
  query_opts = opts.dup
110
127
 
111
- relations = attributes.select {|a|a.include? '_href'}
128
+ relations = attributes.select {|a|a.to_s.include? '_href'}
112
129
  relations.each do |r|
113
- r_name = r.sub('_href','').to_sym
130
+ r_name = r.to_s.sub('_href','').to_sym
114
131
  if query_opts[r_name]
115
132
  query_opts[r] = query_opts.delete(r_name).href
116
133
  end
117
134
  end
118
- query_opts.delete_if {|k,v| ! attributes.include? k.to_s }
135
+ query_opts.delete_if {|k,v| ! attributes.include? k.to_sym }
119
136
 
120
137
  query_opts
121
138
  end
122
139
  end
123
- end
140
+ end
@@ -11,6 +11,10 @@ module RightScaleAPI
11
11
  created_at
12
12
  )
13
13
 
14
+ def servers= list
15
+ @servers = list.map {|params| Server.new params.merge(:account => self.account, :deployment => self) }
16
+ end
17
+
14
18
  def start_all
15
19
  post '/start_all'
16
20
  end
@@ -15,7 +15,7 @@ class Ec2EbsVolume < Account::SubResource
15
15
 
16
16
  def attach_to_server server, device, mount
17
17
  account.post '/component_ec2_ebs_volumes', :body => {
18
- :component_ec2_ebs_volumes => {
18
+ :component_ec2_ebs_volume => {
19
19
  :ec2_ebs_volume_href => uri,
20
20
  :component_href => server.href,
21
21
  :device => device,
@@ -39,6 +39,10 @@ module RightScaleAPI
39
39
  get('/settings')['settings']
40
40
  end
41
41
 
42
+ def running?
43
+ state == 'operational'
44
+ end
45
+
42
46
  def attach_volume volume, device
43
47
  if running?
44
48
  post '/attach_volume', :query => {
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{right-scale-api}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nick Howard"]
12
- s.date = %q{2010-05-01}
12
+ s.date = %q{2010-05-06}
13
13
  s.description = %q{A client for the RightScale API that hides some of the complexity of the API
14
14
  (It doesn't require passing around hrefs as much). Based on HTTParty
15
15
  }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 0
9
- version: 0.0.0
8
+ - 1
9
+ version: 0.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nick Howard
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-01 00:00:00 -06:00
17
+ date: 2010-05-06 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency