Fixes #39 joyent server resize command requires expected response code
This commit is contained in:
parent
cae566a7d5
commit
55c720ba9f
|
@ -162,6 +162,8 @@ module Fog
|
|||
raise_if_error!(request, response)
|
||||
|
||||
response
|
||||
rescue Excon::Errors::Error => e
|
||||
raise_if_error(e.request, e.response)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -213,27 +215,27 @@ module Fog
|
|||
def raise_if_error!(request, response)
|
||||
case response.status
|
||||
when 401 then
|
||||
raise Errors::Unauthorized.new('Invalid credentials were used', request, response)
|
||||
raise Joyent::Errors::Unauthorized.new('Invalid credentials were used', request, response)
|
||||
when 403 then
|
||||
raise Errors::Forbidden.new('No permissions to the specified resource', request, response)
|
||||
raise Joyent::Errors::Forbidden.new('No permissions to the specified resource', request, response)
|
||||
when 404 then
|
||||
raise Errors::NotFound.new('Requested resource was not found', request, response)
|
||||
raise Joyent::Errors::NotFound.new('Requested resource was not found', request, response)
|
||||
when 405 then
|
||||
raise Errors::MethodNotAllowed.new('Method not supported for the given resource', request, response)
|
||||
raise Joyent::Errors::MethodNotAllowed.new('Method not supported for the given resource', request, response)
|
||||
when 406 then
|
||||
raise Errors::NotAcceptable.new('Try sending a different Accept header', request, response)
|
||||
raise Joyent::Errors::NotAcceptable.new('Try sending a different Accept header', request, response)
|
||||
when 409 then
|
||||
raise Errors::Conflict.new('Most likely invalid or missing parameters', request, response)
|
||||
raise Joyent::Errors::Conflict.new('Most likely invalid or missing parameters', request, response)
|
||||
when 414 then
|
||||
raise Errors::RequestEntityTooLarge.new('You sent too much data', request, response)
|
||||
raise Joyent::Errors::RequestEntityTooLarge.new('You sent too much data', request, response)
|
||||
when 415 then
|
||||
raise Errors::UnsupportedMediaType.new('You encoded your request in a format we don\'t understand', request, response)
|
||||
raise Joyent::Errors::UnsupportedMediaType.new('You encoded your request in a format we don\'t understand', request, response)
|
||||
when 420 then
|
||||
raise Errors::PolicyNotForfilled.new('You are sending too many requests', request, response)
|
||||
raise Joyent::Errors::PolicyNotForfilled.new('You are sending too many requests', request, response)
|
||||
when 449 then
|
||||
raise Errors::RetryWith.new('Invalid API Version requested; try with a different API Version', request, response)
|
||||
raise Joyent::Errors::RetryWith.new('Invalid API Version requested; try with a different API Version', request, response)
|
||||
when 503 then
|
||||
raise Errors::ServiceUnavailable.new('Either there\'s no capacity in this datacenter, or we\'re in a maintenance window', request, response)
|
||||
raise Joyent::Errors::ServiceUnavailable.new('Either there\'s no capacity in this datacenter, or we\'re in a maintenance window', request, response)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ module Fog
|
|||
request(
|
||||
:method => "POST",
|
||||
:path => "/my/machines/#{id}",
|
||||
:query => {"action" => "resize", "package" => package}
|
||||
:query => {"action" => "resize", "package" => package},
|
||||
:expects => [202]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue