Class: CFoundry::V2::App
Overview
Class for representing a user’s application on a given target (via Client).
Does not guarantee that the app exists; used for both app creation and retrieval, as the attributes are all lazily retrieved. Setting attributes does not perform any requests; use #update! to commit your changes.
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#bind(*service_names) ⇒ Object
Bind services to application.
-
#debug_mode ⇒ Object
(also: #console)
TODO v2.
- #env ⇒ Object
- #env=(hash) ⇒ Object
-
#health ⇒ Object
Determine application health.
-
#healthy? ⇒ Boolean
(also: #running?)
Check that all application instances are running.
-
#restart! ⇒ Object
Restart the application.
-
#start! ⇒ Object
Start the application.
-
#started? ⇒ Boolean
Is the application started?.
-
#stop! ⇒ Object
Stop the application.
-
#stopped? ⇒ Boolean
Is the application stopped?.
-
#unbind(*service_names) ⇒ Object
Unbind services from application.
- #uri ⇒ Object (also: #url)
-
#uris ⇒ Object
(also: #urls)
TODO v2.
- #uris=(x) ⇒ Object (also: #urls=)
Methods inherited from Model
#==, attribute, #create!, defaults, #delete!, #exists?, #initialize, #inspect, #manifest, #object_name, to_many, to_one, #update!
Constructor Details
This class inherits a constructor from CFoundry::V2::Model
Instance Method Details
#bind(*service_names) ⇒ Object
Bind services to application.
124 125 126 |
# File 'lib/cfoundry/v2/app.rb', line 124 def bind(*service_names) update!(:services => services + service_names) end |
#debug_mode ⇒ Object Also known as: console
TODO v2
56 57 58 |
# File 'lib/cfoundry/v2/app.rb', line 56 def debug_mode # TODO v2 nil end |
#env ⇒ Object
44 45 46 47 48 |
# File 'lib/cfoundry/v2/app.rb', line 44 def env @env ||= CFoundry::ChattyHash.new( method(:env=), JSON.parse(environment_json)) end |
#env=(hash) ⇒ Object
50 51 52 53 54 |
# File 'lib/cfoundry/v2/app.rb', line 50 def env=(hash) @env = hash @diff["environment_json"] = hash hash end |
#health ⇒ Object
Determine application health.
If all instances are running, returns “RUNNING”. If only some are started, returns the precentage of them that are healthy.
Otherwise, returns application’s status.
98 99 100 |
# File 'lib/cfoundry/v2/app.rb', line 98 def health state end |
#healthy? ⇒ Boolean Also known as: running?
Check that all application instances are running.
103 104 105 106 107 |
# File 'lib/cfoundry/v2/app.rb', line 103 def healthy? # invalidate cache so the check is fresh @manifest = nil health == "RUNNING" end |
#restart! ⇒ Object
Restart the application.
87 88 89 90 |
# File 'lib/cfoundry/v2/app.rb', line 87 def restart! stop! start! end |
#start! ⇒ Object
Start the application.
82 83 84 |
# File 'lib/cfoundry/v2/app.rb', line 82 def start! update! :state => "STARTED" end |
#started? ⇒ Boolean
Is the application started?
Note that this does not imply that all instances are running. See #healthy?
119 120 121 |
# File 'lib/cfoundry/v2/app.rb', line 119 def started? state == "STARTED" end |
#stop! ⇒ Object
Stop the application.
77 78 79 |
# File 'lib/cfoundry/v2/app.rb', line 77 def stop! update! :state => "STOPPED" end |
#stopped? ⇒ Boolean
Is the application stopped?
111 112 113 |
# File 'lib/cfoundry/v2/app.rb', line 111 def stopped? state == "STOPPED" end |
#unbind(*service_names) ⇒ Object
Unbind services from application.
129 130 131 132 133 134 |
# File 'lib/cfoundry/v2/app.rb', line 129 def unbind(*service_names) update!(:services => services.reject { |s| service_names.include?(s) }) end |
#uri ⇒ Object Also known as: url
71 72 73 |
# File 'lib/cfoundry/v2/app.rb', line 71 def uri uris[0] end |
#uris ⇒ Object Also known as: urls
TODO v2
61 62 63 |
# File 'lib/cfoundry/v2/app.rb', line 61 def uris # TODO v2 [] end |
#uris=(x) ⇒ Object Also known as: urls=
66 67 68 |
# File 'lib/cfoundry/v2/app.rb', line 66 def uris=(x) nil end |