mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix default API version for Joyent
This commit is contained in:
parent
670b5cf295
commit
21e9573576
1 changed files with 4 additions and 16 deletions
|
@ -6,7 +6,6 @@ module Fog
|
|||
class Joyent < Fog::Service
|
||||
requires :joyent_username
|
||||
|
||||
recognizes :joyent_password
|
||||
recognizes :joyent_url
|
||||
|
||||
recognizes :joyent_keyname
|
||||
|
@ -15,7 +14,7 @@ module Fog
|
|||
recognizes :joyent_keyphrase
|
||||
recognizes :joyent_version
|
||||
|
||||
secrets :joyent_password, :joyent_keydata, :joyent_keyphrase
|
||||
secrets :joyent_keydata, :joyent_keyphrase
|
||||
|
||||
model_path 'fog/joyent/models/compute'
|
||||
request_path 'fog/joyent/requests/compute'
|
||||
|
@ -100,7 +99,6 @@ module Fog
|
|||
|
||||
def initialize(options = {})
|
||||
@joyent_username = options[:joyent_username]
|
||||
@joyent_password = options[:joyent_password]
|
||||
end
|
||||
|
||||
def request(opts)
|
||||
|
@ -117,7 +115,7 @@ module Fog
|
|||
@persistent = options[:persistent] || false
|
||||
|
||||
@joyent_url = options[:joyent_url] || 'https://us-sw-1.api.joyentcloud.com'
|
||||
@joyent_version = options[:joyent_version] || '~6.5'
|
||||
@joyent_version = options[:joyent_version] || '~7'
|
||||
@joyent_username = options[:joyent_username]
|
||||
|
||||
unless @joyent_username
|
||||
|
@ -137,7 +135,6 @@ module Fog
|
|||
:keys_only => true,
|
||||
:passphrase => @joyent_keyphrase
|
||||
})
|
||||
@header_method = method(:header_for_signature_auth)
|
||||
|
||||
if options[:joyent_keyfile]
|
||||
if File.exist?(options[:joyent_keyfile])
|
||||
|
@ -154,11 +151,8 @@ module Fog
|
|||
@key_manager.add_key_data(@joyent_keydata)
|
||||
end
|
||||
end
|
||||
elsif options[:joyent_password]
|
||||
@joyent_password = options[:joyent_password]
|
||||
@header_method = method(:header_for_basic_auth)
|
||||
else
|
||||
raise ArgumentError, "Must provide either a joyent_password or joyent_keyname and joyent_keyfile pair"
|
||||
raise ArgumentError, "Must provide a joyent_keyname and joyent_keyfile pair"
|
||||
end
|
||||
|
||||
@connection = Fog::XML::Connection.new(
|
||||
|
@ -173,7 +167,7 @@ module Fog
|
|||
"X-Api-Version" => @joyent_version,
|
||||
"Content-Type" => "application/json",
|
||||
"Accept" => "application/json"
|
||||
}.merge(opts[:headers] || {}).merge(@header_method.call)
|
||||
}.merge(opts[:headers] || {}).merge(header_for_signature_auth)
|
||||
|
||||
if opts[:body]
|
||||
opts[:body] = Fog::JSON.encode(opts[:body])
|
||||
|
@ -199,12 +193,6 @@ module Fog
|
|||
decode_time_attrs(parsed)
|
||||
end
|
||||
|
||||
def header_for_basic_auth
|
||||
{
|
||||
"Authorization" => "Basic #{Base64.encode64("#{@joyent_username}:#{@joyent_password}").delete("\r\n")}"
|
||||
}
|
||||
end
|
||||
|
||||
def header_for_signature_auth
|
||||
date = Time.now.utc.httpdate
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue