Class: CFoundry::V2::Base
Instance Attribute Summary
Attributes inherited from BaseClient
#rest_client
Instance Method Summary
collapse
Methods inherited from BaseClient
#delete, #get, #info, #initialize, #password_score, #post, #put, #refresh_token!, #request, #request_raw, #stream_url, #token=, #trace=, #uaa
#proxy_options_for
Instance Method Details
#all_pages(paginated) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/cfoundry/v2/base.rb', line 81
def all_pages(paginated)
payload = []
for_each(paginated) do |resource|
payload << resource
end
payload
end
|
#crashes(guid) ⇒ Object
57
58
59
|
# File 'lib/cfoundry/v2/base.rb', line 57
def crashes(guid)
get("v2", "apps", guid, "crashes", :accept => :json)
end
|
#files(guid, instance, *path) ⇒ Object
Also known as:
file
36
37
38
|
# File 'lib/cfoundry/v2/base.rb', line 36
def files(guid, instance, *path)
get("v2", "apps", guid, "instances", instance, "files", *path)
end
|
#for_each(paginated, &block) ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/cfoundry/v2/base.rb', line 72
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) ⇒ Object
53
54
55
|
# File 'lib/cfoundry/v2/base.rb', line 53
def instances(guid)
get("v2", "apps", guid, "instances", :accept => :json)
end
|
#resource_match(fingerprints) ⇒ Object
12
13
14
|
# 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) ⇒ Object
61
62
63
|
# File 'lib/cfoundry/v2/base.rb', line 61
def stats(guid)
get("v2", "apps", guid, "stats", :accept => :json)
end
|
#stream_file(guid, instance, *path, &blk) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/cfoundry/v2/base.rb', line 42
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) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/cfoundry/v2/base.rb', line 65
def update_app(guid, diff)
put("v2", "apps", guid,
:content => :json,
:payload => diff,
:return_response => true)
end
|
#upload_app(guid, zipfile = nil, resources = []) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# 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
put("v2", "apps", guid, "bits", :payload => payload)
rescue EOFError
retry
end
|