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
Instance Method Details
#all_pages(paginated) ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/cfoundry/v2/base.rb', line 72
def all_pages(paginated)
payload = paginated[:resources]
while next_page = paginated[:next_url]
paginated = get(next_page, :accept => :json)
payload += paginated[:resources]
end
payload
end
|
#crashes(guid) ⇒ Object
56
57
58
|
# File 'lib/cfoundry/v2/base.rb', line 56
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
|
#instances(guid) ⇒ Object
52
53
54
|
# File 'lib/cfoundry/v2/base.rb', line 52
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
60
61
62
|
# File 'lib/cfoundry/v2/base.rb', line 60
def stats(guid)
get("v2", "apps", guid, "stats", :accept => :json)
end
|
#stream_file(guid, instance, *path, &blk) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/cfoundry/v2/base.rb', line 41
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, async = false) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/cfoundry/v2/base.rb', line 64
def update_app(guid, diff, async = false)
put("v2", "apps", guid,
:content => :json,
:payload => diff,
:return_response => true,
:params => { :stage_async => !!async })
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
|