2011-02-27 16:09:12 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class RDS
|
|
|
|
|
|
|
|
class Snapshot < Fog::Model
|
|
|
|
|
|
|
|
identity :id, :aliases => ['DBSnapshotIdentifier', :name]
|
|
|
|
attribute :instance_id, :aliases => 'DBInstanceIdentifier'
|
|
|
|
attribute :created_at, :aliases => 'SnapshotCreateTime', :type => :time
|
|
|
|
attribute :instance_created_at, :aliases => 'InstanceCreateTime', :type => :time
|
|
|
|
attribute :engine, :aliases => 'Engine'
|
|
|
|
attribute :engine_version, :aliases => 'EngineVersion'
|
|
|
|
attribute :master_username, :aliases => 'MasterUsername'
|
|
|
|
attribute :state, :aliases => 'Status'
|
|
|
|
attribute :port, :aliases => 'Port', :type => :integer
|
|
|
|
attribute :allocated_storage, :aliases => 'AllocatedStorage', :type => :integer
|
|
|
|
attribute :availability_zone, :aliases => 'AvailabilityZone'
|
2012-09-06 13:46:14 -04:00
|
|
|
attribute :type, :aliases => 'SnapshotType'
|
2011-02-27 16:09:12 -05:00
|
|
|
|
|
|
|
def ready?
|
|
|
|
state == 'available'
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
|
2012-12-22 18:30:24 -05:00
|
|
|
service.delete_db_snapshot(id)
|
2011-02-27 16:09:12 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :instance_id
|
|
|
|
requires :id
|
|
|
|
|
2012-12-22 18:30:24 -05:00
|
|
|
data = service.create_db_snapshot(instance_id, id).body['CreateDBSnapshotResult']['DBSnapshot']
|
2011-02-27 16:09:12 -05:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def server
|
|
|
|
requires :instance_id
|
2012-12-22 18:30:24 -05:00
|
|
|
service.servers.get(instance_id)
|
2011-02-27 16:09:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|