Sha256: 6016dacba2c309c263d5f35b4430bc7971d33c63bd1b82d282efb37ebd2151ef

Contents?: true

Size: 1.32 KB

Versions: 65

Compression:

Stored size: 1.32 KB

Contents

require 'fog/core/collection'
require 'fog/aws/models/compute/snapshot'

module Fog
  module Compute
    class AWS

      class Snapshots < Fog::Collection

        attribute :filters
        attribute :volume

        model Fog::Compute::AWS::Snapshot

        def initialize(attributes)
          self.filters ||= { 'RestorableBy' => 'self' }
          super
        end

        def all(filters = filters, options = {})
          unless filters.is_a?(Hash)
            Fog::Logger.deprecation("all with #{filters.class} param is deprecated, use all('snapshot-id' => []) instead [light_black](#{caller.first})[/]")
            filters = {'snapshot-id' => [*filters]}
          end
          self.filters = filters
          data = service.describe_snapshots(filters.merge!(options)).body
          load(data['snapshotSet'])
          if volume
            self.replace(self.select {|snapshot| snapshot.volume_id == volume.id})
          end
          self
        end

        def get(snapshot_id)
          if snapshot_id
            self.class.new(:service => service).all('snapshot-id' => snapshot_id).first
          end
        end

        def new(attributes = {})
          if volume
            super({ 'volumeId' => volume.id }.merge!(attributes))
          else
            super
          end
        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/snapshots.rb
fog-1.21.0 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/models/compute/snapshots.rb
fog-1.20.0 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/models/compute/snapshots.rb
fog-1.19.0 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/models/compute/snapshots.rb