mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|identity] Better checking around hash/array responses.
Instead of simply checking for the existence of a key in Identity API responses, this checks the type of the expected response. This should be a less fragile way of handling hash/array responses.
This commit is contained in:
parent
6e2ddec2b1
commit
6dee2184e8
4 changed files with 4 additions and 4 deletions
|
@ -9,7 +9,7 @@ module Fog
|
||||||
:path => "users/#{user_id}/OS-KSADM/credentials"
|
:path => "users/#{user_id}/OS-KSADM/credentials"
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.body.include? 'credential'
|
unless response.body['credentials'].is_a?(Array)
|
||||||
response.body['credentials'] = [response.body['credential']]
|
response.body['credentials'] = [response.body['credential']]
|
||||||
response.body.delete('credential')
|
response.body.delete('credential')
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
||||||
:path => 'tenants'
|
:path => 'tenants'
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.body.include? 'tenant'
|
unless response.body['tenants'].is_a?(Array)
|
||||||
response.body['tenants'] = [response.body['tenant']]
|
response.body['tenants'] = [response.body['tenant']]
|
||||||
response.body.delete('tenant')
|
response.body.delete('tenant')
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
||||||
:path => "users/#{user_id}/roles"
|
:path => "users/#{user_id}/roles"
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.body.include? 'role'
|
unless response.body['roles'].is_a?(Array)
|
||||||
response.body['roles'] = [response.body['role']]
|
response.body['roles'] = [response.body['role']]
|
||||||
response.body.delete('role')
|
response.body.delete('role')
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
||||||
:path => 'users'
|
:path => 'users'
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.body.include? 'user'
|
unless response.body['users'].is_a?(Array)
|
||||||
response.body['users'] = [response.body['user']]
|
response.body['users'] = [response.body['user']]
|
||||||
response.body.delete('user')
|
response.body.delete('user')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue