Sha256: b24a173a267ece4ac8c018078be833f5c38977eec937943f8d0df4d73ee06d9a

Contents?: true

Size: 1.33 KB

Versions: 32

Compression:

Stored size: 1.33 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 = connection.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(:connection => connection).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

32 entries across 32 versions & 12 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/aws/models/compute/snapshots.rb
fog-nirvanix-1.8.1 lib/fog/aws/models/compute/snapshots.rb
fog-parser-fix-1.6.1 lib/fog/aws/models/compute/snapshots.rb
fog-test-again-1.6.0 lib/fog/aws/models/compute/snapshots.rb
fog-parser-fix-1.6.0 lib/fog/aws/models/compute/snapshots.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/aws/models/compute/snapshots.rb
fog-sgonyea-1.8.1 lib/fog/aws/models/compute/snapshots.rb
fog-1.8.0 lib/fog/aws/models/compute/snapshots.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/aws/models/compute/snapshots.rb
fog-1.7.0 lib/fog/aws/models/compute/snapshots.rb
fog-1.6.0 lib/fog/aws/models/compute/snapshots.rb
fog-1.5.0 lib/fog/aws/models/compute/snapshots.rb
fog-1.4.0 lib/fog/aws/models/compute/snapshots.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/snapshots.rb
michiels-fog-1.3.1 lib/fog/aws/models/compute/snapshots.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/aws/models/compute/snapshots.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/snapshots.rb
fog-1.3.1 lib/fog/aws/models/compute/snapshots.rb
fog-1.3.0 lib/fog/aws/models/compute/snapshots.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/aws/models/compute/snapshots.rb