Class: Fog::AWS::EC2::Volumes
Instance Method Summary
collapse
Methods inherited from Collection
aliases, attribute, attributes, #attributes, #inspect, #merge_attributes
Constructor Details
#initialize(attributes) ⇒ Volumes
Returns a new instance of Volumes.
16
17
18
19
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 16
def initialize(attributes)
@volume_id ||= []
super
end
|
Instance Method Details
#all(volume_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/volumes.rb', line 21
def all(volume_id = [])
data = connection.describe_volumes(volume_id).body
volumes = Fog::AWS::EC2::Volumes.new({
:connection => connection,
:volume_id => volume_id
}.merge!(attributes))
data['volumeSet'].each do |volume|
volumes << Fog::AWS::EC2::Volume.new({
:connection => connection,
:volumes => self
}.merge!(volume))
end
if instance_id
volumes = volumes.select {|volume| volume.instance_id == instance_id}
end
volumes
end
|
#create(attributes = {}) ⇒ Object
39
40
41
42
43
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 39
def create(attributes = {})
volume = new(attributes)
volume.save
volume
end
|
#get(volume_id) ⇒ Object
45
46
47
48
49
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 45
def get(volume_id)
all(volume_id).first
rescue Fog::Errors::BadRequest
nil
end
|
#new(attributes = {}) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 51
def new(attributes = {})
Fog::AWS::EC2::Volume.new(
attributes.merge!(
:connection => connection,
:volumes => self
)
)
end
|
#reload ⇒ Object
60
61
62
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 60
def reload
all(volume_id)
end
|