Module: EyApi
- Included in:
- EY::ChefRecipes, EY::Stonith
- Defined in:
- lib/ey-api.rb
Instance Method Summary collapse
Instance Method Details
#call_api(path, opts = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ey-api.rb', line 2 def call_api(path, opts={}) JSON.parse(@rest["/api/#{path}"].post(@keys.merge(opts), {"Accept" => "application/json"})) rescue RestClient::RequestFailed => e case e.http_code when 503 sleep 10 # Nanite, save us... retry else raise "API call to Engine Yard failed. Are there any running instances for #{@env}?" end end |
#get_envs ⇒ Object
14 15 16 |
# File 'lib/ey-api.rb', line 14 def get_envs @_envs ||= call_api("environments") end |
#get_json(instance_id = nil) ⇒ Object
18 19 20 21 |
# File 'lib/ey-api.rb', line 18 def get_json(instance_id = nil) env = get_envs[@env] call_api("json_for_instance", :id => env['id'], :instance_id => instance_id) end |