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.18.0.20131209090811 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131126122111 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/aws/models/compute/snapshot.rb
gapinc-fog-1.12.1.2.1 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/aws/models/compute/snapshot.rb
fog-1.18.0 lib/fog/aws/models/compute/snapshot.rb
fog-1.17.0 lib/fog/aws/models/compute/snapshot.rb
fog-1.16.0 lib/fog/aws/models/compute/snapshot.rb