mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
d48d376e9c
* take the liberty of correcting Aws naming
53 lines
1.3 KiB
Ruby
53 lines
1.3 KiB
Ruby
require 'fog/core/model'
|
|
|
|
module Fog
|
|
module Compute
|
|
class Aws
|
|
class Snapshot < Fog::Model
|
|
identity :id, :aliases => 'snapshotId'
|
|
|
|
attribute :description
|
|
attribute :encrypted
|
|
attribute :progress
|
|
attribute :created_at, :aliases => 'startTime'
|
|
attribute :owner_id, :aliases => 'ownerId'
|
|
attribute :state, :aliases => 'status'
|
|
attribute :tags, :aliases => 'tagSet'
|
|
attribute :volume_id, :aliases => 'volumeId'
|
|
attribute :volume_size, :aliases => 'volumeSize'
|
|
|
|
def destroy
|
|
requires :id
|
|
|
|
service.delete_snapshot(id)
|
|
true
|
|
end
|
|
|
|
def ready?
|
|
state == 'completed'
|
|
end
|
|
|
|
def save
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
|
requires :volume_id
|
|
|
|
data = service.create_snapshot(volume_id, description).body
|
|
new_attributes = data.reject {|key,value| key == 'requestId'}
|
|
merge_attributes(new_attributes)
|
|
true
|
|
end
|
|
|
|
def volume
|
|
requires :id
|
|
service.describe_volumes(volume_id)
|
|
end
|
|
|
|
private
|
|
|
|
def volume=(new_volume)
|
|
self.volume_id = new_volume.volume_id
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|