Method: Fog::Compute::Linode::Real#request

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

#request(params) ⇒ Object

[View source]

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/fog/linode/compute.rb', line 94

def request(params)
  params[:query] ||= {}
  params[:query].merge!(:api_key => @linode_api_key)

  response = @connection.request(params.merge!({:host => @host}))

  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body)
    if data = response.body['ERRORARRAY'].first
      error = case data['ERRORCODE']
      when 5
        Fog::Compute::Linode::NotFound
      else
        Fog::Compute::Linode::Error
      end
      raise error.new(data['ERRORMESSAGE'])
    end
  end
  response
end