lib/fog/rackspace/load_balancers.rb in fog-1.12.1 vs lib/fog/rackspace/load_balancers.rb in fog-1.13.0
- old
+ new
@@ -117,44 +117,28 @@
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
- def request(params)
- #TODO - Unify code with other rackspace services
- begin
- response = @connection.request(params.merge!({
- :headers => {
- 'Content-Type' => 'application/json',
- 'Accept' => 'application/json',
- 'X-Auth-Token' => auth_token
- }.merge!(params[:headers] || {}),
- :host => endpoint_uri.host,
- :path => "#{endpoint_uri.path}/#{params[:path]}"
- }))
- rescue Excon::Errors::NotFound => error
- raise NotFound.slurp(error, region)
- rescue Excon::Errors::BadRequest => error
- raise BadRequest.slurp error
- rescue Excon::Errors::InternalServerError => error
- raise InternalServerError.slurp error
- rescue Excon::Errors::HTTPStatusError => error
- raise ServiceError.slurp error
- end
- unless response.body.empty?
- response.body = Fog::JSON.decode(response.body)
- end
- response
+ def request(params, parse_json = true, &block)
+ super(params, parse_json, &block)
+ rescue Excon::Errors::NotFound => error
+ raise NotFound.slurp(error, region)
+ rescue Excon::Errors::BadRequest => error
+ raise BadRequest.slurp error
+ rescue Excon::Errors::InternalServerError => error
+ raise InternalServerError.slurp error
+ rescue Excon::Errors::HTTPStatusError => error
+ raise ServiceError.slurp error
end
- def authenticate
- options = {
+ def authenticate(options={})
+ super({
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url,
:connection_options => @connection_options
- }
- super(options)
+ })
end
def service_name
:cloudLoadBalancers
end