Module: Fog::Compute::CloudSigma::CommonMockAndReal

Included in:
Mock, Real
Defined in:
lib/fog/cloudsigma/compute.rb

Instance Method Summary collapse

Instance Method Details

#balanceObject



94
95
96
97
98
# File 'lib/fog/cloudsigma/compute.rb', line 94

def balance
  response = get_balance

  Balance.new(response.body)
end

#currencyObject



106
107
108
109
# File 'lib/fog/cloudsigma/compute.rb', line 106

def currency
  # Cache since currency does not change
  @currency ||= profile.currency
end

#current_pricingObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/fog/cloudsigma/compute.rb', line 147

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_levelsObject



117
118
119
120
121
# File 'lib/fog/cloudsigma/compute.rb', line 117

def current_pricing_levels
  resp = get_pricing(currency)

  resp.body['current']
end

#current_usageObject



100
101
102
103
104
# File 'lib/fog/cloudsigma/compute.rb', line 100

def current_usage
  response = get_current_usage

  CurrentUsage.new(response.body['usage'])
end

#initialize(options = {}) ⇒ Object



83
84
85
86
87
# File 'lib/fog/cloudsigma/compute.rb', line 83

def initialize(options={})
  @init_options = options

  setup_connection(options)
end

#next_pricingObject



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/fog/cloudsigma/compute.rb', line 165

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_levelsObject



123
124
125
126
127
# File 'lib/fog/cloudsigma/compute.rb', line 123

def next_pricing_levels
  resp = get_pricing(currency)

  resp.body['next']
end

#pricingObject



111
112
113
114
115
# File 'lib/fog/cloudsigma/compute.rb', line 111

def pricing
  resp = get_princing(currency)

  resp.body['objects']
end

#profileObject



89
90
91
92
# File 'lib/fog/cloudsigma/compute.rb', line 89

def profile
  response = get_profile
  Profile.new(response.body)
end

#subscription_pricingObject



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/fog/cloudsigma/compute.rb', line 129

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