use Fog::JSON
This commit is contained in:
parent
297a78e900
commit
40e8f458f2
|
@ -47,8 +47,6 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
@dreamhost_api_key = options[:dreamhost_api_key]
|
@dreamhost_api_key = options[:dreamhost_api_key]
|
||||||
if options[:dreamhost_url]
|
if options[:dreamhost_url]
|
||||||
uri = URI.parse(options[:dreamhost_url])
|
uri = URI.parse(options[:dreamhost_url])
|
||||||
|
@ -73,7 +71,7 @@ module Fog
|
||||||
response = @connection.request(params)
|
response = @connection.request(params)
|
||||||
|
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
if response.body['result'] != 'success'
|
if response.body['result'] != 'success'
|
||||||
raise response.body['data']
|
raise response.body['data']
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Fog
|
||||||
if message.nil? and !data.values.first.nil?
|
if message.nil? and !data.values.first.nil?
|
||||||
message = data.values.first['message']
|
message = data.values.first['message']
|
||||||
end
|
end
|
||||||
rescue MultiJson::DecodeError
|
rescue Fog::JSON::DecodeError
|
||||||
message = error.response.body #### body is not in JSON format, so just return as is
|
message = error.response.body #### body is not in JSON format, so just return as is
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,10 +10,9 @@ module Fog
|
||||||
# The intent is to provide common code for provider APIs using JSON but not
|
# The intent is to provide common code for provider APIs using JSON but not
|
||||||
# require it for those using XML.
|
# require it for those using XML.
|
||||||
#
|
#
|
||||||
# @todo Add +require "fog/json" and/or +include Fog::JSON+ to providers using
|
|
||||||
# its services
|
|
||||||
#
|
|
||||||
module JSON
|
module JSON
|
||||||
|
class EncodeError < Fog::Errors::Error; end
|
||||||
|
class DecodeError < Fog::Errors::Error; end
|
||||||
|
|
||||||
def self.sanitize(data)
|
def self.sanitize(data)
|
||||||
case data
|
case data
|
||||||
|
@ -35,10 +34,14 @@ module Fog
|
||||||
|
|
||||||
def self.encode(obj)
|
def self.encode(obj)
|
||||||
MultiJson.encode(obj)
|
MultiJson.encode(obj)
|
||||||
|
rescue => err
|
||||||
|
raise EncodeError.slurp(err)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.decode(obj)
|
def self.decode(obj)
|
||||||
MultiJson.decode(obj)
|
MultiJson.decode(obj)
|
||||||
|
rescue => err
|
||||||
|
raise DecodeError.slurp(err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -95,7 +95,6 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
@openstack_username = options[:openstack_username] || 'admin'
|
@openstack_username = options[:openstack_username] || 'admin'
|
||||||
@openstack_tenant = options[:openstack_tenant] || 'admin'
|
@openstack_tenant = options[:openstack_tenant] || 'admin'
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
|
@ -245,7 +244,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,6 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
@openstack_username = options[:openstack_username]
|
@openstack_username = options[:openstack_username]
|
||||||
@openstack_tenant = options[:openstack_tenant]
|
@openstack_tenant = options[:openstack_tenant]
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
|
@ -94,8 +93,6 @@ module Fog
|
||||||
attr_reader :current_tenant
|
attr_reader :current_tenant
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
|
|
||||||
unless @openstack_auth_token
|
unless @openstack_auth_token
|
||||||
|
@ -167,7 +164,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,6 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
@openstack_username = options[:openstack_username]
|
@openstack_username = options[:openstack_username]
|
||||||
@openstack_tenant = options[:openstack_tenant]
|
@openstack_tenant = options[:openstack_tenant]
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
|
@ -90,8 +89,6 @@ module Fog
|
||||||
attr_reader :current_tenant
|
attr_reader :current_tenant
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
|
|
||||||
unless @openstack_auth_token
|
unless @openstack_auth_token
|
||||||
|
@ -165,7 +162,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -179,8 +179,6 @@ module Fog
|
||||||
attr_reader :current_tenant
|
attr_reader :current_tenant
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
|
|
||||||
unless @openstack_auth_token
|
unless @openstack_auth_token
|
||||||
|
@ -254,7 +252,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
def add_flavor_access(flavor_ref, tenant_id)
|
def add_flavor_access(flavor_ref, tenant_id)
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode({
|
:body => Fog::JSON.encode({
|
||||||
"addTenantAccess" => {
|
"addTenantAccess" => {
|
||||||
"tenant" => tenant_id
|
"tenant" => tenant_id
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
||||||
def allocate_address(pool = nil)
|
def allocate_address(pool = nil)
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode({'pool' => pool}),
|
:body => Fog::JSON.encode({'pool' => pool}),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => 'os-floating-ips.json'
|
:path => 'os-floating-ips.json'
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => "servers/%s/os-volume_attachments" % [server_id]
|
:path => "servers/%s/os-volume_attachments" % [server_id]
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => '/os-volumes_boot.json'
|
:path => '/os-volumes_boot.json'
|
||||||
|
|
|
@ -35,7 +35,7 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => 'flavors'
|
:path => 'flavors'
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
||||||
data['keypair']['public_key'] = public_key unless public_key.nil?
|
data['keypair']['public_key'] = public_key unless public_key.nil?
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => 'os-keypairs.json'
|
:path => 'os-keypairs.json'
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => 'os-security-groups.json'
|
:path => 'os-security-groups.json'
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:path => 'os-security-group-rules.json'
|
:path => 'os-security-group-rules.json'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
||||||
data['volume'][key] = options[key]
|
data['volume'][key] = options[key]
|
||||||
end
|
end
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => "os-volumes"
|
:path => "os-volumes"
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => "os-snapshots"
|
:path => "os-snapshots"
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:path => '/v2.0/tenants'
|
:path => '/v2.0/tenants'
|
||||||
})
|
})
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
def remove_flavor_access(flavor_ref, tenant_id)
|
def remove_flavor_access(flavor_ref, tenant_id)
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode({
|
:body => Fog::JSON.encode({
|
||||||
"removeTenantAccess" => {
|
"removeTenantAccess" => {
|
||||||
"tenant" => tenant_id.to_s
|
"tenant" => tenant_id.to_s
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
||||||
def update_quota(tenant_id, options = {})
|
def update_quota(tenant_id, options = {})
|
||||||
options['tenant_id'] = tenant_id
|
options['tenant_id'] = tenant_id
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode({ 'quota_set' => options }),
|
:body => Fog::JSON.encode({ 'quota_set' => options }),
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'PUT',
|
:method => 'PUT',
|
||||||
:path => "/os-quota-sets/#{tenant_id}"
|
:path => "/os-quota-sets/#{tenant_id}"
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Fog
|
||||||
data = { 'tenant_id' => tenant_id }
|
data = { 'tenant_id' => tenant_id }
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => "users/#{user_id}/credentials/OS-EC2"
|
:path => "users/#{user_id}/credentials/OS-EC2"
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => '/OS-KSADM/roles'
|
:path => '/OS-KSADM/roles'
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => '/users'
|
:path => '/users'
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
||||||
def update_user(user_id, options = {})
|
def update_user(user_id, options = {})
|
||||||
url = options.delete('url') || "/users/#{user_id}"
|
url = options.delete('url') || "/users/#{user_id}"
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode({ 'user' => options }),
|
:body => Fog::JSON.encode({ 'user' => options }),
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'PUT',
|
:method => 'PUT',
|
||||||
:path => url
|
:path => url
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Fog
|
||||||
data = { 'memberships' => members }
|
data = { 'memberships' => members }
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'PUT',
|
:method => 'PUT',
|
||||||
:path => "images/#{image_id}/members"
|
:path => "images/#{image_id}/members"
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Fog
|
||||||
:expects => 201,
|
:expects => 201,
|
||||||
:path => 'stacks',
|
:path => 'stacks',
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:body => MultiJson.encode(params)
|
:body => Fog::JSON.encode(params)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ module Fog
|
||||||
:expects => 202,
|
:expects => 202,
|
||||||
:path => "stacks/#{stack_name}/#{stack_id}",
|
:path => "stacks/#{stack_name}/#{stack_id}",
|
||||||
:method => 'PUT',
|
:method => 'PUT',
|
||||||
:body => MultiJson.encode(params)
|
:body => Fog::JSON.encode(params)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
||||||
data['volume'][key] = options[key]
|
data['volume'][key] = options[key]
|
||||||
end
|
end
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => "volumes"
|
:path => "volumes"
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
||||||
}
|
}
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => MultiJson.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200, 202],
|
:expects => [200, 202],
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:path => "snapshots"
|
:path => "snapshots"
|
||||||
|
|
|
@ -61,7 +61,6 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
@openstack_username = options[:openstack_username]
|
@openstack_username = options[:openstack_username]
|
||||||
@openstack_tenant = options[:openstack_tenant]
|
@openstack_tenant = options[:openstack_tenant]
|
||||||
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
||||||
|
@ -108,8 +107,6 @@ module Fog
|
||||||
attr_reader :current_tenant
|
attr_reader :current_tenant
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
@openstack_auth_token = options[:openstack_auth_token]
|
@openstack_auth_token = options[:openstack_auth_token]
|
||||||
|
|
||||||
unless @openstack_auth_token
|
unless @openstack_auth_token
|
||||||
|
@ -181,7 +178,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,7 +66,7 @@ module Fog
|
||||||
Fog::Rackspace.json_response?(response)
|
Fog::Rackspace.json_response?(response)
|
||||||
begin
|
begin
|
||||||
response.body = Fog::JSON.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
rescue MultiJson::DecodeError => e
|
rescue Fog::JSON::DecodeError => e
|
||||||
Fog::Logger.warning("Error Parsing response json - #{e}")
|
Fog::Logger.warning("Error Parsing response json - #{e}")
|
||||||
response.body = {}
|
response.body = {}
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,9 +71,9 @@ module Fog
|
||||||
|
|
||||||
module UserUtils
|
module UserUtils
|
||||||
def update_riakcs_user(key_id, user)
|
def update_riakcs_user(key_id, user)
|
||||||
response = @s3_connection.put_object('riak-cs', "user/#{key_id}", MultiJson.encode(user), { 'Content-Type' => 'application/json' })
|
response = @s3_connection.put_object('riak-cs', "user/#{key_id}", Fog::JSON.encode(user), { 'Content-Type' => 'application/json' })
|
||||||
if !response.body.empty?
|
if !response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,8 +47,6 @@ module Fog
|
||||||
include Utils
|
include Utils
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
configure_uri_options(options)
|
configure_uri_options(options)
|
||||||
@riakcs_access_key_id = options[:riakcs_access_key_id]
|
@riakcs_access_key_id = options[:riakcs_access_key_id]
|
||||||
@riakcs_secret_access_key = options[:riakcs_secret_access_key]
|
@riakcs_secret_access_key = options[:riakcs_secret_access_key]
|
||||||
|
@ -89,7 +87,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !response.body.empty? && parse_response
|
if !response.body.empty? && parse_response
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Fog
|
||||||
class Provisioning
|
class Provisioning
|
||||||
class Real
|
class Real
|
||||||
def create_user(email, name, options = {})
|
def create_user(email, name, options = {})
|
||||||
payload = MultiJson.encode({ :email => email, :name => name })
|
payload = Fog::JSON.encode({ :email => email, :name => name })
|
||||||
headers = { 'Content-Type' => 'application/json' }
|
headers = { 'Content-Type' => 'application/json' }
|
||||||
|
|
||||||
if(options[:anonymous])
|
if(options[:anonymous])
|
||||||
|
@ -20,7 +20,7 @@ module Fog
|
||||||
if !response.body.empty?
|
if !response.body.empty?
|
||||||
case response.headers['Content-Type']
|
case response.headers['Content-Type']
|
||||||
when 'application/json'
|
when 'application/json'
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Fog
|
||||||
|
|
||||||
def get_user(key_id)
|
def get_user(key_id)
|
||||||
response = @s3_connection.get_object('riak-cs', "user/#{key_id}", { 'Accept' => 'application/json' })
|
response = @s3_connection.get_object('riak-cs', "user/#{key_id}", { 'Accept' => 'application/json' })
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
||||||
|
|
||||||
boundary = extract_boundary(response.headers['Content-Type'])
|
boundary = extract_boundary(response.headers['Content-Type'])
|
||||||
parts = parse(response.body, boundary)
|
parts = parse(response.body, boundary)
|
||||||
decoded = parts.map { |part| MultiJson.decode(part[:body]) }
|
decoded = parts.map { |part| Fog::JSON.decode(part[:body]) }
|
||||||
|
|
||||||
response.body = decoded.flatten
|
response.body = decoded.flatten
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ module Fog
|
||||||
response = @connection.get_object('riak-cs', ["usage", request_uri(access_key_id, options)].join("/"))
|
response = @connection.get_object('riak-cs', ["usage", request_uri(access_key_id, options)].join("/"))
|
||||||
|
|
||||||
if !response.body.empty?
|
if !response.body.empty?
|
||||||
response.body = MultiJson.decode(response.body)
|
response.body = Fog::JSON.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,8 +41,6 @@ module Fog
|
||||||
include Utils
|
include Utils
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
require 'multi_json'
|
|
||||||
|
|
||||||
configure_uri_options(options)
|
configure_uri_options(options)
|
||||||
@riakcs_access_key_id = options[:riakcs_access_key_id]
|
@riakcs_access_key_id = options[:riakcs_access_key_id]
|
||||||
@riakcs_secret_access_key = options[:riakcs_secret_access_key]
|
@riakcs_secret_access_key = options[:riakcs_secret_access_key]
|
||||||
|
|
|
@ -14,7 +14,6 @@ module Fog
|
||||||
changelog << ('=' * changelog[0].length)
|
changelog << ('=' * changelog[0].length)
|
||||||
changelog << ''
|
changelog << ''
|
||||||
|
|
||||||
require 'multi_json'
|
|
||||||
github_repo_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog', :headers => {'User-Agent' => 'geemus'}).body)
|
github_repo_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog', :headers => {'User-Agent' => 'geemus'}).body)
|
||||||
data = github_repo_data.reject {|key, value| !['forks', 'open_issues', 'watchers'].include?(key)}
|
data = github_repo_data.reject {|key, value| !['forks', 'open_issues', 'watchers'].include?(key)}
|
||||||
github_collaborator_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog/collaborators', :headers => {'User-Agent' => 'geemus'}).body)
|
github_collaborator_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog/collaborators', :headers => {'User-Agent' => 'geemus'}).body)
|
||||||
|
|
Loading…
Reference in New Issue