class CFoundry::V2::Base
Public Instance Methods
all_pages(paginated)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 104 def all_pages(paginated) payload = [] for_each(paginated) do |resource| payload << resource end payload end
crashes(guid)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 76 def crashes(guid) get("v2", "apps", guid, "crashes", :accept => :json) end
env(guid)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 84 def env(guid) get("v2", "apps", guid, "env", :accept => :json) end
files(guid, instance, *path)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 55 def files(guid, instance, *path) get("v2", "apps", guid, "instances", instance, "files", *path) end
Also aliased as: file
for_each(paginated, &block)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 95 def for_each(paginated, &block) paginated[:resources].each &block while (next_page = paginated[:next_url]) paginated = get(next_page, :accept => :json) paginated[:resources].each &block end end
instances(guid)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 72 def instances(guid) get("v2", "apps", guid, "instances", :accept => :json) end
poll_upload_until_finished(guid)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 43 def poll_upload_until_finished(guid) while true response = get("v2", "jobs", guid, :accept => :json) break if response[:entity][:status] == "finished" if response[:entity][:status] == "failed" raise CFoundry::BadResponse end sleep 0.2 end end
resource_match(fingerprints)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 12 def resource_match(fingerprints) put("v2", "resource_match", :content => :json, :accept => :json, :payload => fingerprints) end
stats(guid)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 80 def stats(guid) get("v2", "apps", guid, "stats", :accept => :json) end
stream_file(guid, instance, *path) { |redirect| ... }
click to toggle source
# File lib/cfoundry/v2/base.rb, line 61 def stream_file(guid, instance, *path, &blk) path_and_options = path + [{:return_response => true, :follow_redirects => false}] redirect = get("v2", "apps", guid, "instances", instance, "files", *path_and_options) if location = redirect[:headers]["location"] stream_url(location + "&tail", &blk) else yield redirect[:body] end end
update_app(guid, diff)
click to toggle source
# File lib/cfoundry/v2/base.rb, line 88 def update_app(guid, diff) put("v2", "apps", guid, :content => :json, :payload => diff, :return_response => true) end
upload_app(guid, zipfile = nil, resources = [])
click to toggle source
# File lib/cfoundry/v2/base.rb, line 16 def upload_app(guid, zipfile = nil, resources = []) payload = {} payload[:resources] = MultiJson.dump(resources) if zipfile payload[:application] = UploadIO.new( if zipfile.is_a? File zipfile elsif zipfile.is_a? String File.new(zipfile, "rb") end, "application/zip") end response = put("v2", "apps", guid, "bits", :payload => payload, :params => {"async" => "true"}) if response.present? response_json = JSON.parse(response) poll_upload_until_finished(response_json['metadata']['guid']) end rescue EOFError retry end