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

Merge pull request #2172 from burns/remove_deprecated_block

[rackspace] remove deprecated response block from request
This commit is contained in:
Kyle Rames 2013-09-24 13:40:57 -07:00
commit 66d4aefc95
11 changed files with 77 additions and 82 deletions

View file

@ -87,8 +87,8 @@ module Fog
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error

View file

@ -13,13 +13,13 @@ module Fog
request :post_container
request :put_container
request :delete_object
module Base
URI_HEADERS = {
URI_HEADERS = {
"X-Cdn-Ios-Uri" => :ios_uri,
"X-Cdn-Uri" => :uri,
"X-Cdn-Streaming-Uri" => :streaming_uri,
"X-Cdn-Streaming-Uri" => :streaming_uri,
"X-Cdn-Ssl-Uri" => :ssl_uri
}.freeze
@ -53,7 +53,7 @@ module Fog
return {} unless publish
urls_from_headers(response.headers)
end
# Returns hash of urls for container
# @param [Fog::Storage::Rackspace::Directory] container to retrieve urls for
# @return [Hash] hash containing urls for published container
@ -62,7 +62,7 @@ module Fog
# @raise [Fog::Storage::Rackspace::ServiceError]
# @note If unable to find container or container is not published this method will return an empty hash.
def urls(container)
begin
begin
response = head_container(container.key)
return {} unless response.headers['X-Cdn-Enabled'] == 'True'
urls_from_headers response.headers
@ -70,17 +70,17 @@ module Fog
{}
end
end
private
def urls_from_headers(headers)
h = {}
URI_HEADERS.keys.each do | header |
key = URI_HEADERS[header]
key = URI_HEADERS[header]
h[key] = headers[header]
end
h
end
end
end
class Mock < Fog::Rackspace::Service
@ -103,16 +103,16 @@ module Fog
def data
self.class.data[@rackspace_username]
end
def purge(object)
return true if object.is_a? Fog::Storage::Rackspace::File
raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object
return true if object.is_a? Fog::Storage::Rackspace::File
raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object
end
def reset_data
self.class.data.delete(@rackspace_username)
end
end
class Real < Fog::Rackspace::Service
@ -122,7 +122,7 @@ module Fog
# api_key and username missing from instance variable sets
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@connection_options = options[:connection_options] || {}
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_cdn_url = options[:rackspace_cdn_url]
@ -147,7 +147,7 @@ module Fog
def reload
@cdn_connection.reset
end
# Purges File
# @param [Fog::Storage::Rackspace::File] file to be purged from the CDN
# @raise [Fog::Errors::NotImplemented] returned when non file parameters are specified
@ -155,13 +155,13 @@ module Fog
unless file.is_a? Fog::Storage::Rackspace::File
raise Fog::Errors::NotImplemented.new("#{object.class} does not support CDN purging") if object
end
delete_object file.directory.key, file.key
true
end
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise Fog::Storage::Rackspace::NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
@ -171,9 +171,9 @@ module Fog
rescue Excon::Errors::HTTPStatusError => error
raise Fog::Storage::Rackspace::ServiceError.slurp(error, self)
end
private
private
def authenticate_v1(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
endpoint_uri credentials['X-CDN-Management-Url']

View file

@ -205,8 +205,8 @@ module Fog
@connection.reset
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error

View file

@ -148,8 +148,8 @@ module Fog
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error

View file

@ -85,8 +85,8 @@ module Fog
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error

View file

@ -111,22 +111,20 @@ module Fog
private
def request(params, parse_json = true, &block)
begin
super(params, parse_json, &block)
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
raise BadRequest.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp(error, self)
rescue Excon::Errors::ServiceUnavailable => error
raise ServiceUnavailable.slurp(error, self)
rescue Excon::Errors::Conflict => error
raise Conflict.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp(error, self)
end
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
raise BadRequest.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp(error, self)
rescue Excon::Errors::ServiceUnavailable => error
raise ServiceUnavailable.slurp(error, self)
rescue Excon::Errors::Conflict => error
raise Conflict.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp(error, self)
end
def array_to_query_string(arr)

View file

@ -120,8 +120,8 @@ module Fog
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error

View file

@ -129,20 +129,20 @@ module Fog
private
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
rescue Excon::Errors::BadRequest => error
raise BadRequest.slurp(error, self)
rescue Excon::Errors::Conflict => error
raise Conflict.slurp(error, self)
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::ServiceUnavailable => error
raise ServiceUnavailable.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp(error, self)
def request(params, parse_json = true)
super
rescue Excon::Errors::BadRequest => error
raise BadRequest.slurp(error, self)
rescue Excon::Errors::Conflict => error
raise Conflict.slurp(error, self)
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::ServiceUnavailable => error
raise ServiceUnavailable.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp(error, self)
end
def authenticate

View file

@ -13,19 +13,17 @@ module Fog
# @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500
# @raise [Fog::Storage::Rackspace::ServiceError]
def get_object(container, object, &block)
params = {}
if block_given?
params[:response_block] = Proc.new
end
request(params.merge!({
params = {
:expects => 200,
:method => 'GET',
:path => "#{Fog::Rackspace.escape(container)}/#{Fog::Rackspace.escape(object)}"
}),
false,
&block)
}
if block_given?
params[:response_block] = block
end
request(params, false)
end
end

View file

@ -30,17 +30,17 @@ module Fog
self.send authentication_method, options
end
def request_without_retry(params, parse_json = true, &block)
response = @connection.request(request_params(params), &block)
def request_without_retry(params, parse_json = true)
response = @connection.request(request_params(params))
process_response(response) if parse_json
response
end
def request(params, parse_json = true, &block)
def request(params, parse_json = true)
first_attempt = true
begin
response = @connection.request(request_params(params), &block)
response = @connection.request(request_params(params))
rescue Excon::Errors::Unauthorized => error
raise error unless first_attempt
first_attempt = false
@ -70,8 +70,7 @@ module Fog
end
def headers(options={})
h = {
'Content-Type' => 'application/json',
{ 'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Auth-Token' => auth_token
}.merge(options[:headers] || {})
@ -89,7 +88,7 @@ module Fog
if v2_authentication?
:authenticate_v2
else
Fog::Logger.deprecation "Authentication using a v1.0/v1.1 endpoint is deprecated. Please specify a v2.0 endpoint using :rackpace_auth_url.\
Fog::Logger.deprecation "Authentication using a v1.0/v1.1 endpoint is deprecated. Please specify a v2.0 endpoint using :rackpace_auth_url.\
For a list of v2.0 endpoints refer to http://docs.rackspace.com/auth/api/v2.0/auth-client-devguide/content/Endpoints-d1e180.html"
:authenticate_v1
end

View file

@ -145,8 +145,8 @@ module Fog
@connection.reset
end
def request(params, parse_json = true, &block)
super(params, parse_json, &block)
def request(params, parse_json = true)
super
rescue Excon::Errors::NotFound => error
raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error