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-1.22.0 lib/fog/aws/models/compute/snapshot.rb
fog-1.21.0 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/models/compute/snapshot.rb
fog-1.20.0 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/models/compute/snapshot.rb
fog-1.19.0 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/models/compute/snapshot.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/models/compute/snapshot.rb