module Fog::Compute::CloudSigma::CommonMockAndReal

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 92
def initialize(options={})
  @init_options = options

  setup_connection(options)
end

Public Instance Methods

balance() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 103
def balance
  response = get_balance

  Balance.new(response.body)
end
currency() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 115
def currency
  # Cache since currency does not change
  @currency ||= profile.currency
end
current_pricing() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 156
def current_pricing
  resp = get_pricing(currency)

  current_levels = resp.body['current']
  current_prices = resp.body['objects']

  current_pricing_pairs = current_levels.map do |resource, level|
    price_for_resource_and_level = current_prices.find do |price|
      price['level'] == level && price['resource'] == resource
    end
    price_for_resource_and_level ||= {}

    [resource, price_for_resource_and_level]
  end

  Pricing.new(Hash[current_pricing_pairs])
end
current_pricing_levels() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 126
def current_pricing_levels
  resp = get_pricing(currency)

  resp.body['current']
end
current_usage() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 109
def current_usage
  response = get_current_usage

  CurrentUsage.new(response.body['usage'])
end
next_pricing() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 174
def next_pricing
  resp = get_pricing(currency)

  current_levels = resp.body['next']
  current_prices = resp.body['objects']

  current_pricing_pairs = current_levels.map do |resource, level|
    price_for_resource_and_level = current_prices.find do |price|
      price['level'] == level && price['resource'] == resource
    end
    price_for_resource_and_level ||= {}

    [resource, price_for_resource_and_level]
  end

  Pricing.new(Hash[current_pricing_pairs])
end
next_pricing_levels() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 132
def next_pricing_levels
  resp = get_pricing(currency)

  resp.body['next']
end
pricing() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 120
def pricing
  resp = get_princing(currency)

  resp.body['objects']
end
profile() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 98
def profile
  response = get_profile
  Profile.new(response.body)
end
subscription_pricing() click to toggle source
# File lib/fog/cloudsigma/compute.rb, line 138
def subscription_pricing
  resp = get_pricing(currency, true)

  current_levels = resp.body['current']
  current_prices = resp.body['objects']

  current_pricing_pairs = current_levels.map do |resource, level|
    price_for_resource_and_level = current_prices.find do |price|
      price['resource'] == resource
    end
    price_for_resource_and_level ||= {}

    [resource, price_for_resource_and_level]
  end

  Pricing.new(Hash[current_pricing_pairs])
end