Sha256: e5530728a035bd16c9e6e8bae9fd6bd0614c013459009db5ae440afad1e6ea39

Contents?: true

Size: 1.37 KB

Versions: 15

Compression:

Stored size: 1.37 KB

Contents

require 'fog/core/model'

module Fog
  module AWS
    class Compute

      class Snapshot < Fog::Model
        extend Fog::Deprecation
        deprecate(:status, :state)

        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

          connection.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 identity
          requires :volume_id

          data = connection.create_snapshot(@volume_id, @description).body
          new_attributes = data.reject {|key,value| key == 'requestId'}
          merge_attributes(new_attributes)
          true
        end

        def volume
          requires :id
          connection.describe_volumes(@volume_id)
        end

        private

        def volume=(new_volume)
          @volume_id = new_volume.volume_id
        end

      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-0.3.22 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.21 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.20 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.19 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.18 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.17 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.16 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.15 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.14 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.13 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.12 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.11 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.10 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.9 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.8 lib/fog/aws/models/compute/snapshot.rb