Class: Fog::Compute::Aliyun::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Aliyun::Volume
- Defined in:
- lib/fog/aliyun/models/compute/volume.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #image ⇒ Object
- #ready? ⇒ Boolean
- #save(options = {}) ⇒ Object
- #snapshots ⇒ Object
- #source ⇒ Object
Instance Method Details
#destroy ⇒ Object
45 46 47 48 49 50 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 45 def destroy requires :id service.delete_disk(id) true end |
#image ⇒ Object
74 75 76 77 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 74 def image requires :image_id Fog::Compute::Aliyun::Images.new(service: service).all(imageId: image_id)[0] end |
#ready? ⇒ Boolean
52 53 54 55 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 52 def ready? requires :state state == 'Available' end |
#save(options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fog/aliyun/models/compute/volume.rb', line 57 def save( = {}) # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? # requires :availability_zone requires_one :size, :snapshot_id [:name] = name if name [:description] = description if description if snapshot_id data = Fog::JSON.decode(service.create_disk_by_snapshot(snapshot_id, ).body) merge_attributes(data) elsif size data = Fog::JSON.decode(service.create_disk(size, ).body) merge_attributes(data) end true end |