Sha256: 70ebd81280ea20a00bdbb73a5102673fbe589d1e1c37b0cadfda4bdc51902764

Contents?: true

Size: 1.3 KB

Versions: 65

Compression:

Stored size: 1.3 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class AWS

      class Snapshot < Fog::Model

        identity  :id,          :aliases => 'snapshotId'

        attribute :description
        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

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
fog-1.10.0 lib/fog/aws/models/compute/snapshot.rb
fog-1.9.0 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/aws/models/compute/snapshot.rb