Class: Fog::AWS::EC2::Volumes
Instance Method Summary
collapse
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #inspect, #merge_attributes, model, #model, #reload
Constructor Details
#initialize(attributes) ⇒ Volumes
Returns a new instance of Volumes.
18
19
20
21
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 18
def initialize(attributes)
@volume_id ||= []
super
end
|
Instance Method Details
#all(volume_id = @volume_id) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 23
def all(volume_id = @volume_id)
@volume_id = volume_id
if @loaded
clear
end
@loaded = true
data = connection.describe_volumes(volume_id).body
volumes = []
data['volumeSet'].each do |volume|
volumes << new(volume)
end
if server
volumes = volumes.select {|volume| volume.instance_id == server.id}
end
self.replace(volumes)
end
|
#get(volume_id) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 40
def get(volume_id)
if volume_id
all(volume_id).first
end
rescue Excon::Errors::BadRequest
nil
end
|
#new(attributes = {}) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/fog/aws/models/ec2/volumes.rb', line 48
def new(attributes = {})
if server
super({ :server => server }.merge!(attributes))
else
super
end
end
|