2014-02-01 21:13:17 -05:00
|
|
|
require 'fog/riakcs/core'
|
2012-03-28 17:34:50 -04:00
|
|
|
require 'time'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module RiakCS
|
|
|
|
class Usage < Fog::Service
|
|
|
|
|
|
|
|
requires :riakcs_access_key_id, :riakcs_secret_access_key
|
|
|
|
recognizes :host, :path, :port, :scheme, :persistent
|
|
|
|
|
|
|
|
request_path 'fog/riakcs/requests/usage'
|
|
|
|
request :get_usage
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
include Utils
|
|
|
|
|
|
|
|
def self.data
|
2013-06-14 01:55:03 -04:00
|
|
|
@data ||= Hash.new do |hash, key|
|
2012-03-28 17:34:50 -04:00
|
|
|
hash[key] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reset
|
|
|
|
@data = nil
|
|
|
|
end
|
|
|
|
|
2013-06-14 01:55:03 -04:00
|
|
|
def initialize(options = {})
|
2012-03-28 17:34:50 -04:00
|
|
|
configure_uri_options(options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def data
|
|
|
|
self.class.data[riakcs_uri]
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_data
|
|
|
|
self.class.data.delete(riakcs_uri)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Real
|
|
|
|
include Utils
|
|
|
|
|
|
|
|
def initialize(options = {})
|
|
|
|
configure_uri_options(options)
|
|
|
|
@riakcs_access_key_id = options[:riakcs_access_key_id]
|
|
|
|
@riakcs_secret_access_key = options[:riakcs_secret_access_key]
|
|
|
|
@connection_options = options[:connection_options] || {}
|
|
|
|
@persistent = options[:persistent] || false
|
|
|
|
|
|
|
|
@connection = Fog::Storage.new(
|
|
|
|
:provider => 'AWS',
|
|
|
|
:aws_access_key_id => @riakcs_access_key_id,
|
|
|
|
:aws_secret_access_key => @riakcs_secret_access_key,
|
|
|
|
:host => @host,
|
|
|
|
:port => @port,
|
2013-06-26 08:45:37 -04:00
|
|
|
:scheme => @scheme,
|
|
|
|
:connection_options => @connection_options
|
2012-03-28 17:34:50 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|