lib/cfoundry/v2/base.rb in cfoundry-0.5.1.rc2 vs lib/cfoundry/v2/base.rb in cfoundry-0.5.1.rc3

- old
+ new

@@ -36,25 +36,16 @@ def files(guid, instance, *path) get("v2", "apps", guid, "instances", instance, "files", *path) end alias :file :files - def stream_file(guid, instance, *path) + 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"] - uri = URI.parse(location + "&tail") - - Net::HTTP.start(uri.host, uri.port) do |http| - req = Net::HTTP::Get.new(uri.request_uri) - req["Authorization"] = token.auth_header if token - - http.request(req) do |response| - response.read_body { |chunk| yield chunk } - end - end + stream_url(location + "&tail", &blk) else yield redirect[:body] end end @@ -66,9 +57,17 @@ get("v2", "apps", guid, "crashes", :accept => :json) end def stats(guid) get("v2", "apps", guid, "stats", :accept => :json) + end + + def update_app(guid, diff, async = false) + put("v2", "apps", guid, + :content => :json, + :payload => diff, + :return_response => true, + :params => { :stage_async => !!async }) end def all_pages(paginated) payload = paginated[:resources]