Class: Fog::Compute::Packet::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Packet::Volume
- Defined in:
- lib/fog/compute/packet/models/volume.rb
Overview
Volume Model
Instance Method Summary collapse
- #attach(device_id) ⇒ Object
- #destroy ⇒ Object
- #detach ⇒ Object
-
#initialize(attributes = {}) ⇒ Volume
constructor
A new instance of Volume.
- #ready? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
- #update ⇒ Object
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 |
#destroy ⇒ Object
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 |
#detach ⇒ Object
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
90 91 92 |
# File 'lib/fog/compute/packet/models/volume.rb', line 90 def ready? state == "active" end |
#reload ⇒ Object
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 |
#save ⇒ Object
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 = {} [:size] = size [:facility] = facility [:plan] = plan [:description] = description if description [:billing_cycle] = billing_cycle if billing_cycle [:snapshot_policies] = snapshot_policies if snapshot_policies response = service.create_volume(project_id, ) merge_attributes(response.body) end |
#update ⇒ Object
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 = {} [:description] = description if description [:billing_cycle] = billing_cycle if billing_cycle [:size] = size if size [:locked] = locked if locked response = service.update_volume(id, ) merge_attributes(response.body) end |