diff --git a/lib/fog/brightbox/compute.rb b/lib/fog/brightbox/compute.rb index a7ed86ffe..1e6cef0a6 100644 --- a/lib/fog/brightbox/compute.rb +++ b/lib/fog/brightbox/compute.rb @@ -89,11 +89,13 @@ module Fog get_oauth_token response = authenticated_request(params) end - response + unless response.body.empty? + response = JSON.parse(response.body) + end end def account - Fog::Brightbox::Compute::Account.new(JSON.parse(get_account.body)) + Fog::Brightbox::Compute::Account.new(get_account) end private diff --git a/lib/fog/brightbox/models/compute/account.rb b/lib/fog/brightbox/models/compute/account.rb index 868dbd2a9..5b3143d07 100644 --- a/lib/fog/brightbox/models/compute/account.rb +++ b/lib/fog/brightbox/models/compute/account.rb @@ -41,8 +41,7 @@ module Fog def reset_ftp_password requires :identity - response = connection.reset_ftp_password_account(identity) - JSON.parse(response.body)["library_ftp_password"] + connection.reset_ftp_password_account(identity)["library_ftp_password"] end end diff --git a/lib/fog/brightbox/models/compute/cloud_ips.rb b/lib/fog/brightbox/models/compute/cloud_ips.rb index c20a60387..2a93e9516 100644 --- a/lib/fog/brightbox/models/compute/cloud_ips.rb +++ b/lib/fog/brightbox/models/compute/cloud_ips.rb @@ -10,20 +10,20 @@ module Fog model Fog::Brightbox::Compute::CloudIp def all - data = JSON.parse(connection.list_cloud_ips.body) + data = connection.list_cloud_ips load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = JSON.parse(connection.get_cloud_ip(identifier).body) + data = connection.get_cloud_ip(identifier) new(data) rescue Excon::Errors::NotFound nil end def allocate - data = JSON.parse(connection.create_cloud_ip.body) + data = connection.create_cloud_ip new(data) end diff --git a/lib/fog/brightbox/models/compute/flavors.rb b/lib/fog/brightbox/models/compute/flavors.rb index bbab0165a..50c4b4232 100644 --- a/lib/fog/brightbox/models/compute/flavors.rb +++ b/lib/fog/brightbox/models/compute/flavors.rb @@ -10,13 +10,13 @@ module Fog model Fog::Brightbox::Compute::Flavor def all - data = connection.list_server_types.body - load(JSON.parse(data)) + data = connection.list_server_types + load(data) end def get(identifier) - response = connection.get_server_type(identifier) - new(JSON.parse(response.body)) + data = connection.get_server_type(identifier) + new(data) rescue Excon::Errors::NotFound nil end diff --git a/lib/fog/brightbox/models/compute/image.rb b/lib/fog/brightbox/models/compute/image.rb index f05a430c3..cb922a10e 100644 --- a/lib/fog/brightbox/models/compute/image.rb +++ b/lib/fog/brightbox/models/compute/image.rb @@ -34,8 +34,7 @@ module Fog :name => @name, :description => @description }.delete_if {|k,v| v.nil? || v == "" } - response = connection.create_image(options) - data = JSON.parse(response.body) + data = connection.create_image(options) merge_attributes(data) true end diff --git a/lib/fog/brightbox/models/compute/images.rb b/lib/fog/brightbox/models/compute/images.rb index a8ce3c362..55e743656 100644 --- a/lib/fog/brightbox/models/compute/images.rb +++ b/lib/fog/brightbox/models/compute/images.rb @@ -10,13 +10,13 @@ module Fog model Fog::Brightbox::Compute::Image def all - data = connection.list_images.body - load(JSON.parse(data)) + data = connection.list_images + load(data) end def get(identifier) - response = connection.get_image(identifier) - new(JSON.parse(response.body)) + data = connection.get_image(identifier) + new(data) rescue Excon::Errors::NotFound nil end diff --git a/lib/fog/brightbox/models/compute/server.rb b/lib/fog/brightbox/models/compute/server.rb index 98d2bb288..c202c22a5 100644 --- a/lib/fog/brightbox/models/compute/server.rb +++ b/lib/fog/brightbox/models/compute/server.rb @@ -87,8 +87,7 @@ module Fog :zone => @zone_id, :user_data => @user_data }.delete_if {|k,v| v.nil? || v == "" } - response = connection.create_server(options) - data = JSON.parse(response.body) + data = connection.create_server(options) merge_attributes(data) true end diff --git a/lib/fog/brightbox/models/compute/servers.rb b/lib/fog/brightbox/models/compute/servers.rb index 9b99fb4a6..cbe2494f5 100644 --- a/lib/fog/brightbox/models/compute/servers.rb +++ b/lib/fog/brightbox/models/compute/servers.rb @@ -10,13 +10,13 @@ module Fog model Fog::Brightbox::Compute::Server def all - data = JSON.parse(connection.list_servers.body) + data = connection.list_servers load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = JSON.parse(connection.get_server(identifier).body) + data = connection.get_server(identifier) new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/brightbox/models/compute/user.rb b/lib/fog/brightbox/models/compute/user.rb index fb49762f2..fec5a4704 100644 --- a/lib/fog/brightbox/models/compute/user.rb +++ b/lib/fog/brightbox/models/compute/user.rb @@ -27,8 +27,7 @@ module Fog :name => @name } - response = connection.update_user(identity, options) - data = JSON.parse(response.body) + data = connection.update_user(identity, options) merge_attributes(data) true end diff --git a/lib/fog/brightbox/models/compute/users.rb b/lib/fog/brightbox/models/compute/users.rb index 28f352a75..25fa39c5b 100644 --- a/lib/fog/brightbox/models/compute/users.rb +++ b/lib/fog/brightbox/models/compute/users.rb @@ -10,13 +10,13 @@ module Fog model Fog::Brightbox::Compute::User def all - data = JSON.parse(connection.list_users.body) + data = connection.list_users load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = JSON.parse(connection.get_user(identifier).body) + data = connection.get_user(identifier) new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/brightbox/models/compute/zones.rb b/lib/fog/brightbox/models/compute/zones.rb index 3342469e8..529b6bedf 100644 --- a/lib/fog/brightbox/models/compute/zones.rb +++ b/lib/fog/brightbox/models/compute/zones.rb @@ -10,13 +10,13 @@ module Fog model Fog::Brightbox::Compute::Zone def all - data = JSON.parse(connection.list_zones.body) + data = connection.list_zones load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = JSON.parse(connection.get_zone(identifier).body) + data = connection.get_zone(identifier) new(data) rescue Excon::Errors::NotFound nil