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-maestrodev-1.15.0.20130927082724 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/aws/models/compute/snapshot.rb
fog-1.15.0 lib/fog/aws/models/compute/snapshot.rb
gapinc-fog-1.14.0 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/aws/models/compute/snapshot.rb
fog-1.14.0 lib/fog/aws/models/compute/snapshot.rb
fog-1.13.0 lib/fog/aws/models/compute/snapshot.rb
gapinc-fog-1.12.1.2 lib/fog/aws/models/compute/snapshot.rb
gapinc-fog-1.12.1.1 lib/fog/aws/models/compute/snapshot.rb
gapinc-fog-1.12.1a lib/fog/aws/models/compute/snapshot.rb
gapinc-fog-1.12.1 lib/fog/aws/models/compute/snapshot.rb
fog-1.12.1 lib/fog/aws/models/compute/snapshot.rb
fog-1.12.0 lib/fog/aws/models/compute/snapshot.rb
hpfog-0.0.20 lib/fog/aws/models/compute/snapshot.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/models/compute/snapshot.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/aws/models/compute/snapshot.rb
fog-1.11.1 lib/fog/aws/models/compute/snapshot.rb
fog-1.11.0 lib/fog/aws/models/compute/snapshot.rb
fog-1.10.1 lib/fog/aws/models/compute/snapshot.rb
fog-test-me-1.10.0 lib/fog/aws/models/compute/snapshot.rb