Sha256: a9f448aa2f3afa6e74ab9d3628975e887d9404c32196643c710caa255cbaafcc

Contents?: true

Size: 1.35 KB

Versions: 16

Compression:

Stored size: 1.35 KB

Contents

require 'fog/core/collection'
require 'fog/compute/models/aws/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 = filters, options = {})
          unless filters.is_a?(Hash)
            Formatador.display_line("[yellow][WARN] 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

16 entries across 16 versions & 2 rubygems

Version Path
fog-0.8.2 lib/fog/compute/models/aws/snapshots.rb
fog-0.8.1 lib/fog/compute/models/aws/snapshots.rb
fog-0.8.0 lib/fog/compute/models/aws/snapshots.rb
fog-0.7.2 lib/fog/compute/models/aws/snapshots.rb
fog-0.7.1 lib/fog/compute/models/aws/snapshots.rb
fog-0.7.0 lib/fog/compute/models/aws/snapshots.rb
fog-0.6.0 lib/fog/compute/models/aws/snapshots.rb
fog-0.5.3 lib/fog/compute/models/aws/snapshots.rb
fog-0.5.2 lib/fog/compute/models/aws/snapshots.rb
fog-0.5.1 lib/fog/compute/models/aws/snapshots.rb
fog-0.5.0 lib/fog/compute/models/aws/snapshots.rb
phpfog-fog-0.4.1.3 lib/fog/compute/models/aws/snapshots.rb
phpfog-fog-0.4.1.2 lib/fog/compute/models/aws/snapshots.rb
phpfog-fog-0.4.1.1 lib/fog/compute/models/aws/snapshots.rb
phpfog-fog-0.4.1 lib/fog/compute/models/aws/snapshots.rb
fog-0.4.1 lib/fog/compute/models/aws/snapshots.rb