Class: Fog::Compute::AWS::Snapshots
- Inherits:
-
Fog::Collection
- Object
- Array
- Fog::Collection
- Fog::Compute::AWS::Snapshots
- Defined in:
- lib/rackspace-fog/aws/models/compute/snapshots.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
- #all(filters = filters, options = {}) ⇒ Object
- #get(snapshot_id) ⇒ Object
-
#initialize(attributes) ⇒ Snapshots
constructor
A new instance of Snapshots.
- #new(attributes = {}) ⇒ Object
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 Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes) ⇒ Snapshots
Returns a new instance of Snapshots.
15 16 17 18 |
# File 'lib/rackspace-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/rackspace-fog/aws/models/compute/snapshots.rb', line 20 def all(filters = filters, = {}) 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!()).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/rackspace-fog/aws/models/compute/snapshots.rb', line 34 def get(snapshot_id) if snapshot_id self.class.new(:connection => connection).all('snapshot-id' => snapshot_id).first end end |
#new(attributes = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/rackspace-fog/aws/models/compute/snapshots.rb', line 40 def new(attributes = {}) if volume super({ 'volumeId' => volume.id }.merge!(attributes)) else super end end |