mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Use multi_json gem
This commit is contained in:
parent
843cbc37ac
commit
507127a0c5
19 changed files with 34 additions and 34 deletions
|
@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_dependency('builder')
|
s.add_dependency('builder')
|
||||||
s.add_dependency('excon', '~>0.6.4')
|
s.add_dependency('excon', '~>0.6.4')
|
||||||
s.add_dependency('formatador', '~>0.1.5')
|
s.add_dependency('formatador', '~>0.1.5')
|
||||||
s.add_dependency('json')
|
s.add_dependency('multi_json', '~> 1.0')
|
||||||
s.add_dependency('mime-types')
|
s.add_dependency('mime-types')
|
||||||
s.add_dependency('net-scp', '~>1.0.4')
|
s.add_dependency('net-scp', '~>1.0.4')
|
||||||
s.add_dependency('net-ssh', '~>2.1.4')
|
s.add_dependency('net-ssh', '~>2.1.4')
|
||||||
|
|
|
@ -43,7 +43,7 @@ module Fog
|
||||||
# * CloudFormation object with connection to AWS.
|
# * CloudFormation object with connection to AWS.
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'fog/core/parser'
|
require 'fog/core/parser'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
|
|
||||||
@aws_access_key_id = options[:aws_access_key_id]
|
@aws_access_key_id = options[:aws_access_key_id]
|
||||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||||
|
|
|
@ -98,7 +98,7 @@ module Fog
|
||||||
# * IAM object with connection to AWS.
|
# * IAM object with connection to AWS.
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'fog/core/parser'
|
require 'fog/core/parser'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
|
|
||||||
@aws_access_key_id = options[:aws_access_key_id]
|
@aws_access_key_id = options[:aws_access_key_id]
|
||||||
@aws_secret_access_key = options[:aws_secret_access_key]
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
credentials = Fog::Rackspace.authenticate(options)
|
credentials = Fog::Rackspace.authenticate(options)
|
||||||
@auth_token = credentials['X-Auth-Token']
|
@auth_token = credentials['X-Auth-Token']
|
||||||
@enabled = false
|
@enabled = false
|
||||||
|
@ -85,7 +85,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
|
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@bluebox_api_key = options[:bluebox_api_key]
|
@bluebox_api_key = options[:bluebox_api_key]
|
||||||
@bluebox_customer_id = options[:bluebox_customer_id]
|
@bluebox_customer_id = options[:bluebox_customer_id]
|
||||||
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
|
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
|
||||||
|
@ -83,7 +83,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -88,7 +88,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
require "json"
|
require 'multi_json'
|
||||||
# Currently authentication and api endpoints are the same but may change
|
# Currently authentication and api endpoints are the same but may change
|
||||||
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
|
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
|
||||||
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
|
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
|
||||||
|
@ -106,7 +106,7 @@ module Fog
|
||||||
response = authenticated_request(params)
|
response = authenticated_request(params)
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response = JSON.parse(response.body)
|
response = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ module Fog
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:body => @authentication_body
|
:body => @authentication_body
|
||||||
})
|
})
|
||||||
@oauth_token = JSON.parse(response.body)["access_token"]
|
@oauth_token = ::MultiJson.decode(response.body)["access_token"]
|
||||||
return @oauth_token
|
return @oauth_token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ module Fog
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@go_grid_api_key = options[:go_grid_api_key]
|
@go_grid_api_key = options[:go_grid_api_key]
|
||||||
@go_grid_shared_secret = options[:go_grid_shared_secret]
|
@go_grid_shared_secret = options[:go_grid_shared_secret]
|
||||||
@host = options[:host] || "api.gogrid.com"
|
@host = options[:host] || "api.gogrid.com"
|
||||||
|
@ -100,7 +100,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
response
|
response
|
||||||
|
|
|
@ -77,7 +77,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@linode_api_key = options[:linode_api_key]
|
@linode_api_key = options[:linode_api_key]
|
||||||
@host = options[:host] || "api.linode.com"
|
@host = options[:host] || "api.linode.com"
|
||||||
@port = options[:port] || 443
|
@port = options[:port] || 443
|
||||||
|
@ -96,7 +96,7 @@ module Fog
|
||||||
response = @connection.request(params.merge!({:host => @host}))
|
response = @connection.request(params.merge!({:host => @host}))
|
||||||
|
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
if data = response.body['ERRORARRAY'].first
|
if data = response.body['ERRORARRAY'].first
|
||||||
error = case data['ERRORCODE']
|
error = case data['ERRORCODE']
|
||||||
when 5
|
when 5
|
||||||
|
|
|
@ -172,7 +172,7 @@ module Fog
|
||||||
|
|
||||||
def setup(credentials = {})
|
def setup(credentials = {})
|
||||||
requires :identity, :public_ip_address, :username
|
requires :identity, :public_ip_address, :username
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
|
|
||||||
commands = [
|
commands = [
|
||||||
%{mkdir .ssh},
|
%{mkdir .ssh},
|
||||||
|
|
|
@ -60,7 +60,7 @@ module Fog
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
require "json"
|
require 'multi_json'
|
||||||
|
|
||||||
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
|
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
|
||||||
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
|
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
|
||||||
|
@ -76,7 +76,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
require "json"
|
require 'multi_json'
|
||||||
|
|
||||||
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
|
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
|
||||||
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
|
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
|
||||||
|
@ -104,7 +104,7 @@ module Fog
|
||||||
# Because the response is some weird xml-json thing, we need to try and mung
|
# Because the response is some weird xml-json thing, we need to try and mung
|
||||||
# the values out with a prefix, and if there is an empty data entry return an
|
# the values out with a prefix, and if there is an empty data entry return an
|
||||||
# empty version of the expected type (if provided)
|
# empty version of the expected type (if provided)
|
||||||
response = JSON.parse(response.body)
|
response = ::MultiJson.decode(response.body)
|
||||||
if options.has_key? :response_prefix
|
if options.has_key? :response_prefix
|
||||||
keys = options[:response_prefix].split('/')
|
keys = options[:response_prefix].split('/')
|
||||||
keys.each do |k|
|
keys.each do |k|
|
||||||
|
|
|
@ -58,7 +58,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@rackspace_username = options[:rackspace_username]
|
@rackspace_username = options[:rackspace_username]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@rackspace_api_key = options[:rackspace_api_key]
|
@rackspace_api_key = options[:rackspace_api_key]
|
||||||
@rackspace_username = options[:rackspace_username]
|
@rackspace_username = options[:rackspace_username]
|
||||||
@rackspace_auth_url = options[:rackspace_auth_url]
|
@rackspace_auth_url = options[:rackspace_auth_url]
|
||||||
|
@ -120,7 +120,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -82,7 +82,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
uri = URI.parse(options[:storm_on_demand_auth_url] ||= API_URL)
|
uri = URI.parse(options[:storm_on_demand_auth_url] ||= API_URL)
|
||||||
@host = uri.host
|
@host = uri.host
|
||||||
@path = uri.path
|
@path = uri.path
|
||||||
|
@ -118,7 +118,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
if response.body.keys.include?('full_error')
|
if response.body.keys.include?('full_error')
|
||||||
raise(Fog::Compute::StormOnDemand::Error, response.body.inspect)
|
raise(Fog::Compute::StormOnDemand::Error, response.body.inspect)
|
||||||
|
|
|
@ -116,7 +116,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(options = {})
|
def to_json(options = {})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
self.map {|member| member.attributes}.to_json(options)
|
self.map {|member| member.attributes}.to_json(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(options = {})
|
def to_json(options = {})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
attributes.to_json(options)
|
attributes.to_json(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
|
|
||||||
@dnsimple_email = options[:dnsimple_email]
|
@dnsimple_email = options[:dnsimple_email]
|
||||||
@dnsimple_password = options[:dnsimple_password]
|
@dnsimple_password = options[:dnsimple_password]
|
||||||
|
@ -82,7 +82,7 @@ module Fog
|
||||||
response = @connection.request(params.merge!({:host => @host}))
|
response = @connection.request(params.merge!({:host => @host}))
|
||||||
|
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,7 +77,7 @@ module Fog
|
||||||
# * dns object with connection to aws.
|
# * dns object with connection to aws.
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'fog/core/parser'
|
require 'fog/core/parser'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
|
|
||||||
@dnsmadeeasy_api_key = options[:dnsmadeeasy_api_key]
|
@dnsmadeeasy_api_key = options[:dnsmadeeasy_api_key]
|
||||||
@dnsmadeeasy_secret_key = options[:dnsmadeeasy_secret_key]
|
@dnsmadeeasy_secret_key = options[:dnsmadeeasy_secret_key]
|
||||||
|
@ -117,7 +117,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
response
|
response
|
||||||
|
|
|
@ -50,7 +50,7 @@ module Fog
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@linode_api_key = options[:linode_api_key]
|
@linode_api_key = options[:linode_api_key]
|
||||||
@host = options[:host] || "api.linode.com"
|
@host = options[:host] || "api.linode.com"
|
||||||
@port = options[:port] || 443
|
@port = options[:port] || 443
|
||||||
|
@ -69,7 +69,7 @@ module Fog
|
||||||
response = @connection.request(params.merge!({:host => @host}))
|
response = @connection.request(params.merge!({:host => @host}))
|
||||||
|
|
||||||
unless response.body.empty?
|
unless response.body.empty?
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
if data = response.body['ERRORARRAY'].first
|
if data = response.body['ERRORARRAY'].first
|
||||||
error = case data['ERRORCODE']
|
error = case data['ERRORCODE']
|
||||||
when 5
|
when 5
|
||||||
|
|
|
@ -75,7 +75,7 @@ module Fog
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
require 'mime/types'
|
require 'mime/types'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
@rackspace_api_key = options[:rackspace_api_key]
|
@rackspace_api_key = options[:rackspace_api_key]
|
||||||
@rackspace_username = options[:rackspace_username]
|
@rackspace_username = options[:rackspace_username]
|
||||||
@rackspace_cdn_ssl = options[:rackspace_cdn_ssl]
|
@rackspace_cdn_ssl = options[:rackspace_cdn_ssl]
|
||||||
|
@ -115,7 +115,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
|
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
|
||||||
response.body = JSON.parse(response.body)
|
response.body = ::MultiJson.decode(response.body)
|
||||||
end
|
end
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ module Fog
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:query => {'policy' => nil}
|
:query => {'policy' => nil}
|
||||||
})
|
})
|
||||||
response.body = JSON.parse(response.body) unless response.body.nil?
|
response.body = ::MultiJson.decode(response.body) unless response.body.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue