Module: VagrantPlugins::Openstack::HttpUtils

Includes:
RequestLogger
Included in:
CinderClient, NeutronClient, NovaClient
Defined in:
lib/vagrant-openstack-provider/client/http_utils.rb,
lib/vagrant-openstack-provider/client/request_logger.rb

Defined Under Namespace

Modules: RequestLogger

Instance Method Summary collapse

Methods included from RequestLogger

#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-provider/client/http_utils.rb', line 43

def delete(env, url, headers = {})
  calling_method = caller[0][/`.*'/][1..-2]
  @logger.debug("#{calling_method} - start")

  headers.merge!('X-Auth-Token' => @session.token, :accept => :json, :content_type => :json)

  log_request(:DELETE, url, headers)

  authenticated(env) do
    RestClient.delete(url, headers) { |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-provider/client/http_utils.rb', line 13

def get(env, url, headers = {})
  calling_method = caller[0][/`.*'/][1..-2]
  @logger.debug("#{calling_method} - start")

  headers.merge!('X-Auth-Token' => @session.token, :accept => :json)

  log_request(:GET, url, headers)

  authenticated(env) do
    RestClient.get(url, headers) { |res| handle_response(res) }.tap do
      @logger.debug("#{calling_method} - end")
    end
  end
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-provider/client/http_utils.rb', line 28

def post(env, url, body = nil, headers = {})
  calling_method = caller[0][/`.*'/][1..-2]
  @logger.debug("#{calling_method} - start")

  headers.merge!('X-Auth-Token' => @session.token, :accept => :json, :content_type => :json)

  log_request(:POST, url, body, headers)

  authenticated(env) do
    RestClient.post(url, body, headers) { |res| handle_response(res) }.tap do
      @logger.debug("#{calling_method} - end")
    end
  end
end