Sha256: 2308cf515e8351c8bf204fe97da60a39b0ff06150f99b0740d0ec5376db78e04

Contents?: true

Size: 1.3 KB

Versions: 36

Compression:

Stored size: 1.3 KB

Contents

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

module Fog
  module AWS
    class Compute
      class Snapshots < Fog::Collection
        attribute :filters
        attribute :volume

        model Fog::AWS::Compute::Snapshot

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

        def all(filters_arg = filters, options = {})
          unless filters_arg.is_a?(Hash)
            Fog::Logger.deprecation("all with #{filters_arg.class} param is deprecated, use all('snapshot-id' => []) instead [light_black](#{caller.first})[/]")
            filters_arg = {'snapshot-id' => [*filters_arg]}
          end
          filters = filters_arg
          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

36 entries across 36 versions & 1 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.28.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.27.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.26.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.25.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.24.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.23.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.22.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.21.1 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.21.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.20.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.19.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.18.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.17.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.16.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.15.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.14.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.13.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.12.0 lib/fog/aws/models/compute/snapshots.rb
fog-aws-3.11.0 lib/fog/aws/models/compute/snapshots.rb