Class: Fog::AWS::EC2::Snapshots
Instance Method Summary
collapse
Methods inherited from Collection
aliases, attribute, attributes, #attributes, #inspect, #merge_attributes
Constructor Details
#initialize(attributes) ⇒ Snapshots
Returns a new instance of Snapshots.
16
17
18
19
|
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 16
def initialize(attributes)
@snapshot_id ||= []
super
end
|
Instance Method Details
#all(snapshot_id = []) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 21
def all(snapshot_id = [])
data = connection.describe_snapshots(snapshot_id).body
snapshots = Fog::AWS::EC2::Snapshots.new({
:connection => connection,
:snapshot_id => snapshot_id
}.merge!(attributes))
data['snapshotSet'].each do |snapshot|
snapshots << Fog::AWS::EC2::Snapshot.new({
:connection => connection,
:snapshots => self
}.merge!(snapshot))
end
if volume_id
snapshots = snapshots.select {|snapshot| snapshot.volume_id == volume_id}
end
snapshots
end
|
#create(attributes = {}) ⇒ Object
39
40
41
42
43
|
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 39
def create(attributes = {})
snapshot = new(attributes)
snapshot.save
snapshot
end
|
#get(snapshot_id) ⇒ Object
45
46
47
48
49
|
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 45
def get(snapshot_id)
all(snapshot_id).first
rescue Fog::Errors::BadRequest
nil
end
|
#new(attributes = {}) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 51
def new(attributes = {})
snapshot = Fog::AWS::EC2::Snapshot.new(
attributes.merge!(
:connection => connection,
:snapshots => self
)
)
if volume_id
snapshot.volume_id = volume_id
end
snapshot
end
|
#reload ⇒ Object
64
65
66
|
# File 'lib/fog/aws/models/ec2/snapshots.rb', line 64
def reload
all(snapshot_id)
end
|