cfoundry 0.6.1.rc4 → 0.7.0.rc1

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.
@@ -2,14 +2,6 @@ require "cfoundry/baseclient"
2
2
  require "cfoundry/rest_client"
3
3
  require "cfoundry/auth_token"
4
4
 
5
- require "cfoundry/v1/app"
6
- require "cfoundry/v1/framework"
7
- require "cfoundry/v1/runtime"
8
- require "cfoundry/v1/service"
9
- require "cfoundry/v1/service_plan"
10
- require "cfoundry/v1/service_instance"
11
- require "cfoundry/v1/user"
12
-
13
5
  require "cfoundry/v2/app"
14
6
  require "cfoundry/v2/service"
15
7
  require "cfoundry/v2/service_binding"
@@ -24,24 +16,13 @@ require "cfoundry/v2/route"
24
16
  require "cfoundry/v2/stack"
25
17
  require "cfoundry/v2/quota_definition"
26
18
 
27
- require "cfoundry/v1/base"
28
- require "cfoundry/v1/client"
29
19
  require "cfoundry/v2/base"
30
20
  require "cfoundry/v2/client"
31
21
 
32
22
  module CFoundry
33
23
  class Client < BaseClient
34
24
  def self.new(*args)
35
- target, _ = args
36
-
37
- base = super(target)
38
-
39
- case base.info[:version]
40
- when 2
41
- CFoundry::V2::Client.new(*args)
42
- else
43
- CFoundry::V1::Client.new(*args)
44
- end
25
+ CFoundry::V2::Client.new(*args)
45
26
  end
46
27
  end
47
28
  end
@@ -76,11 +76,14 @@ module CFoundry
76
76
  original_options = options.dup
77
77
  payload = options[:payload]
78
78
 
79
- if params = options[:params]
80
- if uri.query
81
- uri.query += "&" + encode_params(params)
82
- else
83
- uri.query = encode_params(params)
79
+ if options[:params]
80
+ encoded_params = encode_params(options[:params])
81
+ if encoded_params.respond_to?(:empty?) ? !encoded_params.empty? : encoded_params
82
+ if uri.query
83
+ uri.query += "&" + encoded_params
84
+ else
85
+ uri.query = encoded_params
86
+ end
84
87
  end
85
88
  end
86
89
 
@@ -93,7 +93,11 @@ module CFoundry::V2
93
93
  end
94
94
  end
95
95
 
96
- @manifest = @client.base.send(:"create_#{object_name}", payload)
96
+ @manifest = @client.base.post("v2", plural_object_name,
97
+ :content => :json,
98
+ :accept => :json,
99
+ :payload => payload
100
+ )
97
101
 
98
102
  @guid = @manifest[:metadata][:guid]
99
103
 
@@ -103,7 +107,11 @@ module CFoundry::V2
103
107
  end
104
108
 
105
109
  def update!
106
- @manifest = @client.base.send(:"update_#{object_name}", @guid, @diff)
110
+ @client.base.put("v2", plural_object_name, guid,
111
+ :content => :json,
112
+ :accept => :json,
113
+ :payload => @diff
114
+ )
107
115
 
108
116
  @diff.clear
109
117
 
@@ -111,7 +119,7 @@ module CFoundry::V2
111
119
  end
112
120
 
113
121
  def delete!(options = {})
114
- @client.base.send(:"delete_#{object_name}", @guid, options)
122
+ @client.base.delete("v2", plural_object_name, guid, :params => options)
115
123
 
116
124
  @guid = nil
117
125
 
@@ -72,27 +72,6 @@ module CFoundry::V2
72
72
  )
73
73
  )
74
74
  end
75
-
76
- define_method(:"create_#{singular}") do |payload|
77
- post("v2", plural,
78
- :content => :json,
79
- :accept => :json,
80
- :payload => payload
81
- )
82
- end
83
-
84
- define_method(:"delete_#{singular}") do |guid, params|
85
- delete("v2", plural, guid, :params => params)
86
- true
87
- end
88
-
89
- define_method(:"update_#{singular}") do |guid, payload|
90
- put("v2", plural, guid,
91
- :content => :json,
92
- :accept => :json,
93
- :payload => payload
94
- )
95
- end
96
75
  end
97
76
 
98
77
  define_client_methods do
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.6.1.rc4".freeze
3
+ VERSION = "0.7.0.rc1".freeze
4
4
  end
@@ -3,13 +3,7 @@ require 'spec_helper'
3
3
  describe CFoundry::Client do
4
4
  subject { CFoundry::Client.new('http://example.com') }
5
5
 
6
- it "returns a v1 client when used on a v1 target" do
7
- stub_request(:get, "http://example.com/info").to_return(:status => 200, :body => '{"version":1}')
8
- subject.should be_a(CFoundry::V1::Client)
9
- end
10
-
11
- it "returns a v2 client when used on a v2 target" do
12
- stub_request(:get, "http://example.com/info").to_return(:status => 200, :body => '{"version":2}')
6
+ it "returns a v2 client" do
13
7
  subject.should be_a(CFoundry::V2::Client)
14
8
  end
15
9
  end
@@ -76,6 +76,28 @@ describe CFoundry::RestClient do
76
76
  end
77
77
  end
78
78
 
79
+ context "when params are passed" do
80
+ context "when params is an empty hash" do
81
+ let(:options) { { :params => {} } }
82
+
83
+ it "does not add a query string delimiter (the question mark)" do
84
+ request_stub = stub_request(:get, "https://api.cloudfoundry.com/some-path")
85
+ subject
86
+ expect(request_stub).to have_been_requested
87
+ end
88
+ end
89
+
90
+ context "when params has values" do
91
+ let(:options) { { :params => { "key" => "value" } } }
92
+
93
+ it "appends a query string and delimiter" do
94
+ request_stub = stub_request(:get, "https://api.cloudfoundry.com/some-path?key=value")
95
+ subject
96
+ expect(request_stub).to have_been_requested
97
+ end
98
+ end
99
+ end
100
+
79
101
  context 'and the token is set' do
80
102
  let(:token_header) { "bearer something" }
81
103
  let(:token) { CFoundry::AuthToken.new(token_header) }
@@ -138,10 +160,6 @@ describe CFoundry::RestClient do
138
160
  end
139
161
  end
140
162
 
141
- describe 'payload' do
142
-
143
- end
144
-
145
163
  describe 'errors' do
146
164
  context "when the target refuses the connection" do
147
165
  let(:target) { "http://localhost:2358974958" }
@@ -93,20 +93,19 @@ describe CFoundry::V2::ModelMagic do
93
93
 
94
94
  subject { myobject }
95
95
 
96
- it "stores it in the diff under the json key" do
97
- mock(client.base).update_my_fake_model(subject.guid, :not_foo => 123)
96
+ it "uses the 'at' value in the update payload" do
97
+ mock(client.base).put("v2", :my_fake_models, subject.guid, hash_including(:payload => {:not_foo => 123}))
98
98
  subject.foo = 123
99
99
  subject.update!
100
100
  end
101
101
 
102
- it "stores it in the manifest under the json key" do
102
+ it "uses the 'at' value in the create payload" do
103
103
  subject.foo = 123
104
104
 
105
- mock(client.base).create_my_fake_model(:not_foo => 123) do
106
- { :metadata => { :guid => guid },
107
- :entity => { :not_foo => 123 }
108
- }
109
- end
105
+ mock(client.base).post(
106
+ "v2", :my_fake_models,
107
+ hash_including(:payload => {:not_foo => 123})
108
+ ) { {:metadata => {}} }
110
109
 
111
110
  subject.create!
112
111
  end
@@ -3,15 +3,77 @@ require "spec_helper"
3
3
  describe CFoundry::V2::Model do
4
4
  let(:client) { fake_client }
5
5
  let(:guid) { random_string("my-object-guid") }
6
+ let(:manifest) { {:metadata => {:foo => "bar"}} }
7
+ let(:klass) {
8
+ fake_model do
9
+ attribute :foo, :string, :read => :x, :write => [:y, :z]
10
+ end
11
+ }
12
+
13
+ subject { klass.new(guid, client, manifest) }
14
+
15
+ describe "#create!" do
16
+ before do
17
+ stub(client.base).post {
18
+ {:metadata => {:guid => "123"}}
19
+ }
20
+ subject.foo = "bar"
21
+ end
22
+
23
+ it "posts to the model's create url with appropriate arguments" do
24
+ mock(client.base).post("v2", :my_fake_models,
25
+ :content => :json,
26
+ :accept => :json,
27
+ :payload => {:foo => "bar"}
28
+ ) { {:metadata => {}} }
29
+ subject.create!
30
+ end
31
+
32
+ it "clears diff" do
33
+ subject.diff.should be_present
34
+ subject.create!
35
+ subject.diff.should_not be_present
36
+ end
37
+
38
+ it "sets manifest from the response" do
39
+ subject.create!
40
+ subject.manifest.should == {:metadata => {:guid => "123"}}
41
+ end
42
+
43
+ it "sets guid from the response metadata" do
44
+ subject.create!
45
+ subject.guid.should == "123"
46
+ end
47
+ end
48
+
49
+ describe "#update!" do
50
+ before do
51
+ stub(client.base).put
52
+ subject.foo = "bar"
53
+ end
6
54
 
7
- subject { described_class.new(guid, client) }
55
+ it "updates using the client with the v2 api, its plural model name, object guid, and diff object" do
56
+ mock(client.base).put("v2", :my_fake_models, guid,
57
+ :content => :json,
58
+ :accept => :json,
59
+ :payload => {:foo => "bar"}
60
+ )
61
+ subject.update!
62
+ end
63
+
64
+ it "clears diff" do
65
+ subject.diff.should be_present
66
+ subject.update!
67
+ subject.diff.should_not be_present
68
+ end
69
+ end
8
70
 
9
71
  describe "#delete!" do
10
- before { stub(client.base).delete_model }
72
+ before { stub(client.base).delete }
11
73
 
12
74
  context "without options" do
13
- it "sends delete with the object guid and an empty hash" do
14
- mock(client.base).delete_model(guid, {})
75
+ it "deletes using the client with the v2 api, its plural model name, object guid, and empty params hash" do
76
+ mock(client.base).delete("v2", :my_fake_models, guid, :params => {})
15
77
  subject.delete!
16
78
  end
17
79
  end
@@ -19,7 +81,7 @@ describe CFoundry::V2::Model do
19
81
  context "with options" do
20
82
  it "sends delete with the object guid and options" do
21
83
  options = {:excellent => "billandted"}
22
- mock(client.base).delete_model(guid, options)
84
+ mock(client.base).delete("v2", :my_fake_models, guid, :params => options)
23
85
 
24
86
  subject.delete!(options)
25
87
  end
@@ -30,5 +92,27 @@ describe CFoundry::V2::Model do
30
92
  subject.delete!
31
93
  subject.guid.should_not be_present
32
94
  end
95
+
96
+ it "clears its manifest metadata" do
97
+ subject.manifest.should have_key(:metadata)
98
+ subject.delete!
99
+ subject.manifest.should_not have_key(:metadata)
100
+ end
101
+
102
+ it "clears the diff" do
103
+ subject.foo = "bar"
104
+ subject.diff.should be_present
105
+ subject.delete!
106
+ subject.diff.should_not be_present
107
+ end
108
+
109
+ it "delete me" do
110
+ begin
111
+ subject.delete!
112
+ rescue => ex
113
+ ex.message.should_not =~ /\?/
114
+ end
115
+ end
116
+
33
117
  end
34
118
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,5 @@ end
15
15
 
16
16
  RSpec.configure do |c|
17
17
  c.include Fake::FakeMethods
18
- c.include V1Fake::FakeMethods
19
18
  c.mock_with :rr
20
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.rc4
4
+ version: 0.7.0.rc1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-11 00:00:00.000000000 Z
13
+ date: 2013-04-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multipart-post
@@ -207,17 +207,6 @@ files:
207
207
  - lib/cfoundry/trace_helpers.rb
208
208
  - lib/cfoundry/uaaclient.rb
209
209
  - lib/cfoundry/upload_helpers.rb
210
- - lib/cfoundry/v1/app.rb
211
- - lib/cfoundry/v1/base.rb
212
- - lib/cfoundry/v1/client.rb
213
- - lib/cfoundry/v1/framework.rb
214
- - lib/cfoundry/v1/model.rb
215
- - lib/cfoundry/v1/model_magic.rb
216
- - lib/cfoundry/v1/runtime.rb
217
- - lib/cfoundry/v1/service.rb
218
- - lib/cfoundry/v1/service_instance.rb
219
- - lib/cfoundry/v1/service_plan.rb
220
- - lib/cfoundry/v1/user.rb
221
210
  - lib/cfoundry/v2/app.rb
222
211
  - lib/cfoundry/v2/base.rb
223
212
  - lib/cfoundry/v2/client.rb
@@ -263,9 +252,6 @@ files:
263
252
  - spec/cfoundry/trace_helpers_spec.rb
264
253
  - spec/cfoundry/uaaclient_spec.rb
265
254
  - spec/cfoundry/upload_helpers_spec.rb
266
- - spec/cfoundry/v1/base_spec.rb
267
- - spec/cfoundry/v1/client_spec.rb
268
- - spec/cfoundry/v1/model_magic_spec.rb
269
255
  - spec/cfoundry/v2/app_spec.rb
270
256
  - spec/cfoundry/v2/base_spec.rb
271
257
  - spec/cfoundry/v2/client_spec.rb
@@ -337,7 +323,6 @@ files:
337
323
  - spec/support/shared_examples/cc_api_stub_request_examples.rb
338
324
  - spec/support/shared_examples/client_login_examples.rb
339
325
  - spec/support/shared_examples/model_summary_examples.rb
340
- - spec/support/v1_fake_helper.rb
341
326
  homepage: http://github.com/cloudfoundry/vmc-lib
342
327
  licenses: []
343
328
  post_install_message:
@@ -352,7 +337,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
352
337
  version: '0'
353
338
  segments:
354
339
  - 0
355
- hash: 163727160375400133
340
+ hash: 3268215508581398236
356
341
  required_rubygems_version: !ruby/object:Gem::Requirement
357
342
  none: false
358
343
  requirements:
@@ -387,9 +372,6 @@ test_files:
387
372
  - spec/cfoundry/trace_helpers_spec.rb
388
373
  - spec/cfoundry/uaaclient_spec.rb
389
374
  - spec/cfoundry/upload_helpers_spec.rb
390
- - spec/cfoundry/v1/base_spec.rb
391
- - spec/cfoundry/v1/client_spec.rb
392
- - spec/cfoundry/v1/model_magic_spec.rb
393
375
  - spec/cfoundry/v2/app_spec.rb
394
376
  - spec/cfoundry/v2/base_spec.rb
395
377
  - spec/cfoundry/v2/client_spec.rb
@@ -461,4 +443,3 @@ test_files:
461
443
  - spec/support/shared_examples/cc_api_stub_request_examples.rb
462
444
  - spec/support/shared_examples/client_login_examples.rb
463
445
  - spec/support/shared_examples/model_summary_examples.rb
464
- - spec/support/v1_fake_helper.rb
@@ -1,363 +0,0 @@
1
- require "cfoundry/upload_helpers"
2
- require "cfoundry/chatty_hash"
3
-
4
- require "cfoundry/v1/model"
5
-
6
- module CFoundry::V1
7
- class App < Model
8
- include CFoundry::UploadHelpers
9
-
10
- attribute :name, :string, :guid => true
11
- attribute :instances, :integer
12
- attribute :state, :string
13
- attribute :created, :integer, :at => [:meta, :created], :read_only => true
14
- attribute :version, :integer, :at => [:meta, :version], :read_only => true
15
- attribute :framework, :string, :at => [:staging, :model]
16
- attribute :runtime, :string, :at => [:staging, :stack]
17
- attribute :command, :string, :at => [:staging, :command]
18
- attribute :memory, :integer, :at => [:resources, :memory]
19
- attribute :disk, :integer, :at => [:resources, :disk]
20
- attribute :fds, :integer, :at => [:resources, :fds]
21
- attribute :env, [:string], :default => []
22
- attribute :uris, [:string], :default => []
23
- attribute :services, [:string], :default => []
24
-
25
- attribute :console, :boolean, :default => false,
26
- :read => [:meta, :console], :write => :console
27
-
28
- attribute :debug, :string, :default => nil, :read => [:meta, :debug],
29
- :write => :debug
30
-
31
- attribute :running_instances, :integer, :read => :runningInstances,
32
- :read_only => true
33
-
34
-
35
- define_client_methods
36
-
37
-
38
- alias_method :total_instances, :instances
39
- alias_method :total_instances=, :instances=
40
-
41
- alias_method :debug_mode, :debug
42
- alias_method :debug_mode=, :debug=
43
-
44
- alias_method :framework_name, :framework
45
- alias_method :framework_name=, :framework=
46
-
47
- alias_method :runtime_name, :runtime
48
- alias_method :runtime_name=, :runtime=
49
-
50
- alias_method :service_names, :services
51
- alias_method :service_names=, :services=
52
-
53
- alias_method :status, :state
54
- alias_method :status=, :state=
55
-
56
- alias_method :urls, :uris
57
- alias_method :urls=, :uris=
58
-
59
- alias_method :env_array, :env
60
- alias_method :env_array=, :env=
61
-
62
- def framework
63
- @client.framework(framework_name)
64
- end
65
-
66
- def framework=(obj)
67
- set_named(:framework, obj)
68
- end
69
-
70
- def runtime
71
- @client.runtime(runtime_name)
72
- end
73
-
74
- def runtime=(obj)
75
- set_named(:runtime, obj)
76
- end
77
-
78
- def services
79
- service_names.collect { |name| @client.service_instance(name) }
80
- end
81
-
82
- def services=(objs)
83
- set_many_named(:service, objs)
84
- end
85
-
86
-
87
- # Retrieve all of the instances of the app, as Instance objects.
88
- def instances
89
- @client.base.instances(@guid).collect do |m|
90
- Instance.new(self, m[:index].to_s, @client, m)
91
- end
92
- end
93
-
94
- # Retrieve crashed instances
95
- def crashes
96
- @client.base.crashes(@guid).collect do |i|
97
- Instance.new(self, i[:instance].to_s, @client, i)
98
- end
99
- end
100
-
101
- # Retrieve application statistics, e.g. CPU load and memory usage.
102
- def stats
103
- stats = {}
104
-
105
- @client.base.stats(@guid).each do |idx, info|
106
- stats[idx.to_s] = info
107
- end
108
-
109
- stats
110
- end
111
-
112
- # Stop the application.
113
- def stop!
114
- self.state = "STOPPED"
115
- update!
116
- end
117
-
118
- # Start the application.
119
- def start!(async = false)
120
- self.state = "STARTED"
121
- update!
122
- end
123
-
124
- # Restart the application.
125
- def restart!(async = false)
126
- stop!
127
- start!
128
- end
129
-
130
- def update!(async = false)
131
- super()
132
- end
133
-
134
- # Determine application health.
135
- #
136
- # If all instances are running, returns "RUNNING". If only some are
137
- # started, returns the precentage of them that are healthy.
138
- #
139
- # Otherwise, returns application's status.
140
- def health
141
- s = state
142
- if s == "STARTED"
143
- healthy_count = running_instances
144
- expected = total_instances
145
-
146
- if healthy_count && expected > 0
147
- ratio = healthy_count / expected.to_f
148
- if ratio == 1.0
149
- "RUNNING"
150
- else
151
- "#{(ratio * 100).to_i}%"
152
- end
153
- else
154
- "N/A"
155
- end
156
- else
157
- s
158
- end
159
- end
160
-
161
- # Check that all application instances are running.
162
- def healthy?
163
- # invalidate cache so the check is fresh
164
- invalidate!
165
- health == "RUNNING"
166
- end
167
- alias_method :running?, :healthy?
168
-
169
- # Is the application stopped?
170
- def stopped?
171
- state == "STOPPED"
172
- end
173
-
174
- # Is the application started?
175
- #
176
- # Note that this does not imply that all instances are running. See
177
- # #healthy?
178
- def started?
179
- state == "STARTED"
180
- end
181
-
182
-
183
- # Shortcut for uris[0]
184
- def uri
185
- uris[0]
186
- end
187
-
188
- # Shortcut for uris = [x]
189
- def uri=(x)
190
- self.uris = [x]
191
- end
192
-
193
- alias_method :url, :uri
194
- alias_method :url=, :uri=
195
-
196
- def env
197
- e = env_array || []
198
-
199
- env = {}
200
- e.each do |pair|
201
- name, val = pair.split("=", 2)
202
- env[name] = val
203
- end
204
-
205
- CFoundry::ChattyHash.new(method(:env=), env)
206
- end
207
-
208
- def env=(hash)
209
- unless hash.is_a?(Array)
210
- hash = hash.collect { |k, v| "#{k}=#{v}" }
211
- end
212
-
213
- self.env_array = hash
214
- end
215
-
216
- def services
217
- service_names.collect do |name|
218
- @client.service_instance(name)
219
- end
220
- end
221
-
222
- def services=(instances)
223
- self.service_names = instances.collect(&:name)
224
- end
225
-
226
-
227
- # Bind services to application.
228
- def bind(*instances)
229
- self.services += instances
230
- update!
231
- end
232
-
233
- # Unbind services from application.
234
- def unbind(*instances)
235
- self.services -= instances
236
- update!
237
- end
238
-
239
- def binds?(instance)
240
- services.include? instance
241
- end
242
-
243
- # Retrieve file listing under path for the first instance of the application.
244
- #
245
- # [path]
246
- # A sequence of strings representing path segments.
247
- #
248
- # For example, <code>files("foo", "bar")</code> for +foo/bar+.
249
- def files(*path)
250
- Instance.new(self, "0", @client).files(*path)
251
- end
252
-
253
- # Retrieve file contents for the first instance of the application.
254
- #
255
- # [path]
256
- # A sequence of strings representing path segments.
257
- #
258
- # For example, <code>files("foo", "bar")</code> for +foo/bar+.
259
- def file(*path)
260
- Instance.new(self, "0", @client).file(*path)
261
- end
262
-
263
- private
264
-
265
- def set_named(attr, val)
266
- res = send(:"#{attr}_name=", val.name)
267
-
268
- if @changes.key?(attr)
269
- old, new = @changes[attr]
270
- @changes[attr] = [@client.send(attr, old), val]
271
- end
272
-
273
- res
274
- end
275
-
276
- def set_many_named(attr, vals)
277
- res = send(:"#{attr}_names=", val.collect(&:name))
278
-
279
- if @changes.key?(attr)
280
- old, new = @changes[attr]
281
- @changes[attr] = [old.collect { |o| @client.send(attr, o) }, vals]
282
- end
283
-
284
- vals
285
- end
286
-
287
- # Class represnting a running instance of an application.
288
- class Instance
289
- # The application this instance belongs to.
290
- attr_reader :app
291
-
292
- # Application instance number.
293
- attr_reader :id
294
-
295
- # Create an Instance object.
296
- #
297
- # You'll usually call App#instances instead
298
- def initialize(app, id, client, manifest = {})
299
- @app = app
300
- @id = id
301
- @client = client
302
- @manifest = manifest
303
- end
304
-
305
- # Show string representing the application instance.
306
- def inspect
307
- "#<App::Instance '#{@app.name}' \##@id>"
308
- end
309
-
310
- # Instance state.
311
- def state
312
- @manifest[:state]
313
- end
314
- alias_method :status, :state
315
-
316
- # Instance start time.
317
- def since
318
- Time.at(@manifest[:since])
319
- end
320
-
321
- # Instance debugger data. If instance is in debug mode, returns a hash
322
- # containing :ip and :port keys.
323
- def debugger
324
- return unless @manifest[:debug_ip] and @manifest[:debug_port]
325
-
326
- { :ip => @manifest[:debug_ip],
327
- :port => @manifest[:debug_port]
328
- }
329
- end
330
-
331
- # Instance console data. If instance has a console, returns a hash
332
- # containing :ip and :port keys.
333
- def console
334
- return unless @manifest[:console_ip] and @manifest[:console_port]
335
-
336
- { :ip => @manifest[:console_ip],
337
- :port => @manifest[:console_port]
338
- }
339
- end
340
-
341
- # True if instance is starting or running, false if it's down or
342
- # flapping.
343
- def healthy?
344
- case state
345
- when "STARTING", "RUNNING"
346
- true
347
- when "DOWN", "FLAPPING"
348
- false
349
- end
350
- end
351
-
352
- def files(*path)
353
- @client.base.files(@app.name, @id, *path).split("\n").collect do |entry|
354
- path + [entry.split(/\s+/, 2)[0]]
355
- end
356
- end
357
-
358
- def file(*path)
359
- @client.base.files(@app.name, @id, *path)
360
- end
361
- end
362
- end
363
- end