Module: VagrantPlugins::Openstack::HttpUtils
Defined Under Namespace
Modules: RequestLogger
Instance Method Summary
collapse
#log_request, #log_response
Instance Method Details
#delete(env, url, headers = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/vagrant-openstack-illuin-provider/client/http_utils.rb', line 43
def delete(env, url, = {})
calling_method = caller[0][/`.*'/][1..-2]
@logger.debug("#{calling_method} - start")
.merge!('X-Auth-Token' => @session.token, :accept => :json, :content_type => :json)
log_request(:DELETE, url, )
authenticated(env) do
RestUtils.delete(env, url, ) { |res| handle_response(res) }.tap do
@logger.debug("#{calling_method} - end")
end
end
end
|
#get(env, url, headers = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/vagrant-openstack-illuin-provider/client/http_utils.rb', line 13
def get(env, url, = {})
calling_method = caller[0][/`.*'/][1..-2]
@logger.debug("#{calling_method} - start")
.merge!('X-Auth-Token' => @session.token, :accept => :json)
log_request(:GET, url, )
authenticated(env) do
RestUtils.get(env, url, ) { |res| handle_response(res) }.tap do
@logger.debug("#{calling_method} - end")
end
end
end
|
#get_api_version_list(env, service_type) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/vagrant-openstack-illuin-provider/client/http_utils.rb', line 58
def get_api_version_list(env, service_type)
url = @session.endpoints[service_type]
= { 'X-Auth-Token' => @session.token, :accept => :json }
log_request(:GET, url, )
json = RestUtils.get(env, url, ) do |response|
log_response(response)
case response.code
when 200, 300
response
when 401
fail Errors::AuthenticationFailed
else
fail Errors::VagrantOpenstackError, message: response.to_s
end
end
JSON.parse(json)['versions']
end
|
#post(env, url, body = nil, headers = {}) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/vagrant-openstack-illuin-provider/client/http_utils.rb', line 28
def post(env, url, body = nil, = {})
calling_method = caller[0][/`.*'/][1..-2]
@logger.debug("#{calling_method} - start")
.merge!('X-Auth-Token' => @session.token, :accept => :json, :content_type => :json)
log_request(:POST, url, body, )
authenticated(env) do
RestUtils.post(env, url, body, ) { |res| handle_response(res) }.tap do
@logger.debug("#{calling_method} - end")
end
end
end
|