Class: Fog::RiakCS::Usage::Real

Inherits:
Object
  • Object
show all
Includes:
Utils, Fog::RiakCS::Utils
Defined in:
lib/fog/riakcs/usage.rb,
lib/fog/riakcs/usage/get_usage.rb

Constant Summary

Constants included from Utils

Utils::DEFAULT_FORMAT, Utils::DEFAULT_TYPES, Utils::TYPES_TO_STRING

Instance Method Summary collapse

Methods included from Utils

#format_and_types_to_path, #request_uri, #sanitize_and_convert_time

Methods included from Fog::RiakCS::Utils

#configure_uri_options, #riakcs_uri

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fog/riakcs/usage.rb', line 41

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,
    :scheme                => @scheme,
    :connection_options    => @connection_options
  )
end

Instance Method Details

#get_usage(access_key_id, options = {}) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/fog/riakcs/usage/get_usage.rb', line 36

def get_usage(access_key_id, options = {})
  response = @connection.get_object('riak-cs', ["usage", request_uri(access_key_id, options)].join("/"))

  if !response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end