cfoundry 0.3.25 → 0.3.26
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cfoundry/baseclient.rb +45 -24
- data/lib/cfoundry/v2/base.rb +2 -1
- data/lib/cfoundry/v2/client.rb +3 -2
- data/lib/cfoundry/v2/framework.rb +1 -7
- data/lib/cfoundry/version.rb +1 -1
- metadata +3 -3
data/lib/cfoundry/baseclient.rb
CHANGED
@@ -3,9 +3,13 @@ require "multi_json"
|
|
3
3
|
|
4
4
|
module CFoundry
|
5
5
|
class BaseClient # :nodoc:
|
6
|
+
attr_accessor :trace, :no_backtrace
|
7
|
+
|
6
8
|
def initialize(target, token = nil)
|
7
9
|
@target = target
|
8
10
|
@token = token
|
11
|
+
@trace = false
|
12
|
+
@no_backtrace = false
|
9
13
|
end
|
10
14
|
|
11
15
|
def request_path(method, path, types = {}, options = {})
|
@@ -78,29 +82,7 @@ module CFoundry
|
|
78
82
|
json = accept == :json
|
79
83
|
|
80
84
|
RestClient::Request.execute(req) do |response, request|
|
81
|
-
if @trace
|
82
|
-
$stderr.puts '>>>'
|
83
|
-
$stderr.puts "PROXY: #{RestClient.proxy}" if RestClient.proxy
|
84
|
-
$stderr.puts "REQUEST: #{req[:method]} #{req[:url]}"
|
85
|
-
$stderr.puts "RESPONSE_HEADERS:"
|
86
|
-
response.headers.each do |key, value|
|
87
|
-
$stderr.puts " #{key} : #{value}"
|
88
|
-
end
|
89
|
-
$stderr.puts "REQUEST_HEADERS:"
|
90
|
-
request.headers.each do |key, value|
|
91
|
-
$stderr.puts " #{key} : #{value}"
|
92
|
-
end
|
93
|
-
$stderr.puts "REQUEST_BODY: #{req[:payload]}" if req[:payload]
|
94
|
-
$stderr.puts "RESPONSE: [#{response.code}]"
|
95
|
-
begin
|
96
|
-
parsed_body = MultiJson.load(response.body)
|
97
|
-
$stderr.puts MultiJson.dump(parsed_body, :pretty => true)
|
98
|
-
rescue
|
99
|
-
$stderr.puts "#{response.body}"
|
100
|
-
end
|
101
|
-
$stderr.puts '<<<'
|
102
|
-
end
|
103
|
-
|
85
|
+
print_trace(req, request, response, caller) if @trace
|
104
86
|
handle_response(response, accept)
|
105
87
|
end
|
106
88
|
rescue SocketError, Errno::ECONNREFUSED => e
|
@@ -168,7 +150,46 @@ module CFoundry
|
|
168
150
|
}.join("/")
|
169
151
|
end
|
170
152
|
|
171
|
-
|
153
|
+
def print_trace(req, request, response, locs)
|
154
|
+
$stderr.puts ">>>"
|
155
|
+
$stderr.puts "PROXY: #{RestClient.proxy}" if RestClient.proxy
|
156
|
+
$stderr.puts "REQUEST: #{req[:method]} #{req[:url]}"
|
157
|
+
$stderr.puts "RESPONSE_HEADERS:"
|
158
|
+
response.headers.each do |key, value|
|
159
|
+
$stderr.puts " #{key} : #{value}"
|
160
|
+
end
|
161
|
+
$stderr.puts "REQUEST_HEADERS:"
|
162
|
+
request.headers.each do |key, value|
|
163
|
+
$stderr.puts " #{key} : #{value}"
|
164
|
+
end
|
165
|
+
$stderr.puts "REQUEST_BODY: #{req[:payload]}" if req[:payload]
|
166
|
+
$stderr.puts "RESPONSE: [#{response.code}]"
|
167
|
+
begin
|
168
|
+
parsed_body = MultiJson.load(response.body)
|
169
|
+
$stderr.puts MultiJson.dump(parsed_body, :pretty => true)
|
170
|
+
rescue
|
171
|
+
$stderr.puts "#{response.body}"
|
172
|
+
end
|
173
|
+
$stderr.puts "<<<"
|
174
|
+
|
175
|
+
return if @no_backtrace
|
176
|
+
|
177
|
+
interesting_locs = locs.drop_while { |loc|
|
178
|
+
loc =~ /\/(cfoundry\/|restclient\/|net\/http)/
|
179
|
+
}
|
180
|
+
|
181
|
+
$stderr.puts "--- backtrace:"
|
182
|
+
|
183
|
+
$stderr.puts "... (boring)" unless locs == interesting_locs
|
184
|
+
|
185
|
+
trimmed_locs = interesting_locs[0..5]
|
186
|
+
|
187
|
+
trimmed_locs.each do |loc|
|
188
|
+
$stderr.puts "=== #{loc}"
|
189
|
+
end
|
190
|
+
|
191
|
+
$stderr.puts "... (trimmed)" unless trimmed_locs == interesting_locs
|
192
|
+
end
|
172
193
|
|
173
194
|
def handle_response(response, accept)
|
174
195
|
json = accept == :json
|
data/lib/cfoundry/v2/base.rb
CHANGED
@@ -47,7 +47,8 @@ module CFoundry::V2
|
|
47
47
|
|
48
48
|
|
49
49
|
[ :app, :organization, :space, :user, :runtime, :framework, :service,
|
50
|
-
:service_plan, :service_binding, :service_instance,
|
50
|
+
:domain, :service_plan, :service_binding, :service_instance,
|
51
|
+
:service_auth_token
|
51
52
|
].each do |obj|
|
52
53
|
plural = "#{obj}s"
|
53
54
|
|
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -14,6 +14,7 @@ require "cfoundry/v2/service_plan"
|
|
14
14
|
require "cfoundry/v2/service_auth_token"
|
15
15
|
require "cfoundry/v2/space"
|
16
16
|
require "cfoundry/v2/user"
|
17
|
+
require "cfoundry/v2/domain"
|
17
18
|
|
18
19
|
module CFoundry::V2
|
19
20
|
# The primary API entrypoint. Wraps a BaseClient to provide nicer return
|
@@ -62,7 +63,6 @@ module CFoundry::V2
|
|
62
63
|
# printed out.
|
63
64
|
def trace=(bool)
|
64
65
|
@base.trace = bool
|
65
|
-
@base.uaa.trace = bool if @base.uaa
|
66
66
|
end
|
67
67
|
|
68
68
|
# The currently authenticated user.
|
@@ -123,7 +123,8 @@ module CFoundry::V2
|
|
123
123
|
|
124
124
|
|
125
125
|
[ :app, :organization, :space, :user, :runtime, :framework, :service,
|
126
|
-
:service_plan, :service_binding, :service_instance,
|
126
|
+
:domain, :service_plan, :service_binding, :service_instance,
|
127
|
+
:service_auth_token
|
127
128
|
].each do |singular|
|
128
129
|
plural = :"#{singular}s"
|
129
130
|
|
data/lib/cfoundry/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 26
|
10
|
+
version: 0.3.26
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|