Class: Fog::Compute::CloudSigma::Volume

Inherits:
Fog::CloudSigma::CloudsigmaModel show all
Defined in:
lib/fog/cloudsigma/models/volume.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

#clone(clone_params = {}) ⇒ Object



62
63
64
65
66
67
# File 'lib/fog/cloudsigma/models/volume.rb', line 62

def clone(clone_params={})
  requires :identity
  response = service.clone_volume(identity, clone_params)

  self.class.new(response.body['objects'].first)
end

#createObject



32
33
34
35
36
37
38
39
# File 'lib/fog/cloudsigma/models/volume.rb', line 32

def create
  requires :name, :size, :media
  data = attributes

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

#destroyObject Also known as: delete



52
53
54
55
56
57
58
# File 'lib/fog/cloudsigma/models/volume.rb', line 52

def destroy
  requires :identity

  service.delete_volume(identity)

  true
end

#saveObject



24
25
26
27
28
29
30
# File 'lib/fog/cloudsigma/models/volume.rb', line 24

def save
  if persisted?
    update
  else
    create
  end
end

#updateObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/cloudsigma/models/volume.rb', line 41

def update
  requires :identity, :name, :size, :media

  data = attributes()

  response = service.update_volume(identity, data)
  new_attributes = response.body
  merge_attributes(new_attributes)

end