1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Whitespace.

This commit is contained in:
Sean Handley 2013-06-07 14:18:25 +01:00
parent a54632bc42
commit b5f3f064e4

View file

@ -1,15 +1,15 @@
module Fog module Fog
module Compute module Compute
class Serverlove < Fog::Service class Serverlove < Fog::Service
API_HOST = "api.z1-man.serverlove.com" API_HOST = "api.z1-man.serverlove.com"
requires :serverlove_uuid, :serverlove_api_key requires :serverlove_uuid, :serverlove_api_key
recognizes :serverlove_api_url recognizes :serverlove_api_url
request_path 'fog/serverlove/requests/compute' request_path 'fog/serverlove/requests/compute'
# Image # Image
request :get_image request :get_image
request :get_images request :get_images
@ -28,38 +28,38 @@ module Fog
request :stop_server request :stop_server
request :shutdown_server request :shutdown_server
request :reset_server request :reset_server
model_path 'fog/serverlove/models/compute' model_path 'fog/serverlove/models/compute'
model :image model :image
collection :images collection :images
model :server model :server
collection :servers collection :servers
class Mock class Mock
def initialize(options) def initialize(options)
@serverlove_uuid = options[:serverlove_uuid] || Fog.credentials[:serverlove_uuid] @serverlove_uuid = options[:serverlove_uuid] || Fog.credentials[:serverlove_uuid]
@serverlove_api_key = options[:serverlove_api_key] || Fog.credentials[:serverlove_api_key] @serverlove_api_key = options[:serverlove_api_key] || Fog.credentials[:serverlove_api_key]
end end
def request(options) def request(options)
raise "Not implemented" raise "Not implemented"
end end
end end
class Real class Real
def initialize(options) def initialize(options)
@api_uuid = options[:serverlove_uuid] || Fog.credentials[:serverlove_uuid] @api_uuid = options[:serverlove_uuid] || Fog.credentials[:serverlove_uuid]
@api_key = options[:serverlove_api_key] || Fog.credentials[:serverlove_api_key] @api_key = options[:serverlove_api_key] || Fog.credentials[:serverlove_api_key]
@api_host = options[:serverlove_api_url] || Fog.credentials[:serverlove_api_url] || API_HOST @api_host = options[:serverlove_api_url] || Fog.credentials[:serverlove_api_url] || API_HOST
@connection = Fog::Connection.new("https://#{@api_uuid}:#{@api_key}@#{@api_host}") @connection = Fog::Connection.new("https://#{@api_uuid}:#{@api_key}@#{@api_host}")
end end
def request(params) def request(params)
params = params.merge!( params = params.merge!(
:headers => { :headers => {
@ -68,14 +68,14 @@ module Fog
) )
params[:body] = encode_pairs(params[:options]) unless params[:options].nil? params[:body] = encode_pairs(params[:options]) unless params[:options].nil?
response = @connection.request(params) response = @connection.request(params)
raise_if_error!(response) raise_if_error!(response)
response.body = Fog::JSON.decode(response.body) if response.body && response.body.length > 0 response.body = Fog::JSON.decode(response.body) if response.body && response.body.length > 0
response response
end end
def encode_pairs(params) def encode_pairs(params)
params.keys.collect do |key| params.keys.collect do |key|
"#{key} #{params[key]}" "#{key} #{params[key]}"
@ -85,13 +85,13 @@ module Fog
# TODO # TODO
def raise_if_error!(response) def raise_if_error!(response)
case response.status case response.status
when 400 then when 400 then
raise 'omg' raise 'omg'
end end
end end
end end
end end
end end
end end