Class: Fog::Compute::CloudSigma::Subscription

Inherits:
Fog::CloudSigma::CloudsigmaModel show all
Defined in:
lib/fog/cloudsigma/models/subscription.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Fog::CloudSigma::CloudsigmaModel

model_attribute, model_attribute_array

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
# File 'lib/fog/cloudsigma/models/subscription.rb', line 28

def create
  requires :resource, :amount
  data = attributes

  response = service.create_subscription(data)
  new_attributes = response.body['objects'].first
  merge_attributes(new_attributes)
end

#extend(period = nil, end_time = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/cloudsigma/models/subscription.rb', line 37

def extend(period=nil, end_time=nil)
  requires :identity
  data = {}
  if period
    data[:period] = period
  elsif end_time
    data[:end_time] = end_time
  end
  response = service.extend_subscription(identity, data)

  self.class.new(response.body)
end

#saveObject



24
25
26
# File 'lib/fog/cloudsigma/models/subscription.rb', line 24

def save
  create
end