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

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/fog/riakcs/usage.rb,
lib/fog/riakcs/requests/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

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



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

def initialize(options = {})
  require 'mime/types'
  require 'multi_json'

  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
  )
end

Instance Method Details

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



36
37
38
39
40
41
42
43
# File 'lib/fog/riakcs/requests/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 = MultiJson.decode(response.body)
  end
  response
end