Sha256: 497e722152d89bfb6ec2c69e7219b613671b448b619a5c99d56fb12498289730

Contents?: true

Size: 1.38 KB

Versions: 31

Compression:

Stored size: 1.38 KB

Contents

module Fog
  module AWS
    class Compute
      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'
        attribute :status_message, :aliases => 'statusMessage'

        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

31 entries across 31 versions & 1 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.29.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.28.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.27.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.26.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.25.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.24.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.23.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.22.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.21.1 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.21.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.20.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.19.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.18.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.17.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.16.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.15.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.14.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.13.0 lib/fog/aws/models/compute/snapshot.rb
fog-aws-3.12.0 lib/fog/aws/models/compute/snapshot.rb