Class: Fog::Compute::AWS::Snapshots

Inherits:
Fog::Collection show all
Defined in:
lib/fog/aws/models/compute/snapshots.rb

Instance Attribute Summary

Attributes inherited from Fog::Collection

#service

Instance Method Summary collapse

Methods inherited from Fog::Collection

#clear, #create, #destroy, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(attributes) ⇒ Snapshots

Returns a new instance of Snapshots.



15
16
17
18
# File 'lib/fog/aws/models/compute/snapshots.rb', line 15

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

Instance Method Details

#all(filters = filters, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/aws/models/compute/snapshots.rb', line 20

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

#get(snapshot_id) ⇒ Object



34
35
36
37
38
# File 'lib/fog/aws/models/compute/snapshots.rb', line 34

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

#new(attributes = {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fog/aws/models/compute/snapshots.rb', line 40

def new(attributes = {})
  if volume
    super({ 'volumeId' => volume.id }.merge!(attributes))
  else
    super
  end
end