Class: Fog::Compute::Packet::Volume

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/packet/models/volume.rb

Overview

Volume Model

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Volume

Returns a new instance of Volume.



28
29
30
# File 'lib/fog/compute/packet/models/volume.rb', line 28

def initialize(attributes = {})
  super
end

Instance Method Details

#attach(device_id) ⇒ Object



60
61
62
63
64
65
# File 'lib/fog/compute/packet/models/volume.rb', line 60

def attach(device_id)
  requires :id

  response = service.attach_volume(id, device_id)
  merge_attributes(response.body)
end

#destroyObject



74
75
76
77
78
79
# File 'lib/fog/compute/packet/models/volume.rb', line 74

def destroy
  requires :id

  response = service.delete_volume(id)
  true if response.status == 204
end

#detachObject



67
68
69
70
71
72
# File 'lib/fog/compute/packet/models/volume.rb', line 67

def detach
  requires :id

  response = service.detach_volume(id)
  true if response.status == 204
end

#ready?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/fog/compute/packet/models/volume.rb', line 90

def ready?
  state == "active"
end

#reloadObject



81
82
83
84
85
86
87
88
# File 'lib/fog/compute/packet/models/volume.rb', line 81

def reload
  requires :id

  data = service.get_volume(id)

  return unless data.body
  merge_attributes(data.body)
end

#saveObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/compute/packet/models/volume.rb', line 32

def save
  requires :project_id, :facility, :plan, :size

  options = {}
  options[:size] = size
  options[:facility] = facility
  options[:plan] = plan
  options[:description] = description if description
  options[:billing_cycle] = billing_cycle if billing_cycle
  options[:snapshot_policies] = snapshot_policies if snapshot_policies

  response = service.create_volume(project_id, options)
  merge_attributes(response.body)
end

#updateObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/compute/packet/models/volume.rb', line 47

def update
  requires :id

  options = {}
  options[:description] = description if description
  options[:billing_cycle] = billing_cycle if billing_cycle
  options[:size] = size if size
  options[:locked] = locked if locked

  response = service.update_volume(id, options)
  merge_attributes(response.body)
end