Class: Fog::AWS::EC2::Volumes

Inherits:
Collection show all
Defined in:
lib/fog/aws/models/ec2/volumes.rb

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.



13
14
15
16
# File 'lib/fog/aws/models/ec2/volumes.rb', line 13

def initialize(attributes)
  @volume_id ||= []
  super
end

Instance Method Details

#all(volume_id = []) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/aws/models/ec2/volumes.rb', line 18

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
  volumes
end

#create(attributes = {}) ⇒ Object



33
34
35
36
37
# File 'lib/fog/aws/models/ec2/volumes.rb', line 33

def create(attributes = {})
  volume = new(attributes)
  volume.save
  volume
end

#get(volume_id) ⇒ Object



39
40
41
42
43
# File 'lib/fog/aws/models/ec2/volumes.rb', line 39

def get(volume_id)
  all(volume_id).first
rescue Fog::Errors::BadRequest
  nil
end

#new(attributes = {}) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/fog/aws/models/ec2/volumes.rb', line 45

def new(attributes = {})
  Fog::AWS::EC2::Volume.new(
    attributes.merge!(
      :connection => connection,
      :volumes    => self
    )
  )
end

#reloadObject



54
55
56
# File 'lib/fog/aws/models/ec2/volumes.rb', line 54

def reload
  all(volume_id)
end