Sha256: a5107753f458043fc6da58589c492007dfb68537133375e90bc151ed78a8af13

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

require 'fog/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 :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
          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

8 entries across 8 versions & 1 rubygems

Version Path
fog-0.3.7 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.6 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.5 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.4 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.3 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.2 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.1 lib/fog/aws/models/compute/snapshot.rb
fog-0.3.0 lib/fog/aws/models/compute/snapshot.rb