Class: Fog::AWS::EC2::Snapshots
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::EC2::Snapshots
- Defined in:
- lib/fog/aws/models/ec2/snapshots.rb
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
- #all(snapshot_id = @snapshot_id, options = {}) ⇒ Object
- #get(snapshot_id) ⇒ Object
-
#initialize(attributes) ⇒ Snapshots
constructor
A new instance of Snapshots.
- #new(attributes = {}) ⇒ Object
Methods inherited from Collection
#clear, #create, #inspect, #load, model, #model, #reload, #table, #to_json
Methods included from Fog::Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity
Methods included from Fog::Attributes::InstanceMethods
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
#initialize(attributes) ⇒ Snapshots
Returns a new instance of Snapshots.
33 34 35 36 |
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 33 def initialize(attributes) @snapshot_id ||= [] super end |
Instance Method Details
#all(snapshot_id = @snapshot_id, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 38 def all(snapshot_id = @snapshot_id, = {}) = { 'Owner' => @owner || 'self', 'RestorableBy' => @restorable_by } = .reject {|key,value| value.nil? || value.to_s.empty?} merge_attributes() data = connection.describe_snapshots(snapshot_id).body load(data['snapshotSet']) if volume self.replace(self.select {|snapshot| snapshot.volume_id == volume.id}) end self end |
#get(snapshot_id) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 53 def get(snapshot_id) if snapshot_id all(snapshot_id).first end rescue Fog::Errors::NotFound nil end |
#new(attributes = {}) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 61 def new(attributes = {}) if volume super({ 'volumeId' => volume.id }.merge!(attributes)) else super end end |