Method: Fog::Compute::Bluebox::Real#request

Defined in:
lib/fog/bluebox/compute.rb

#request(params) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fog/bluebox/compute.rb', line 80

def request(params)
  params[:headers] ||= {}
  params[:headers].merge!({
    'Authorization' => "Basic #{Base64.encode64([@bluebox_customer_id, @bluebox_api_key].join(':')).delete("\r\n")}"
  })

  begin
    response = @connection.request(params.merge!({:host => @host}))
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
    when Excon::Errors::NotFound
      Fog::Compute::Bluebox::NotFound.slurp(error)
    else
      error
    end
  end
  unless response.body.empty?
    response.body = MultiJson.decode(response.body)
  end
  response
end