1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/ec2/volumes.rb
2009-09-23 21:23:54 -07:00

57 lines
1.2 KiB
Ruby

module Fog
module AWS
class EC2
def volumes
Fog::AWS::EC2::Volumes.new(:connection => self)
end
class Volumes < Fog::Collection
attribute :volume_id
def all(volume_id = [])
data = connection.describe_volumes(volume_id).body
volumes = Fog::AWS::EC2::Volumes.new(
:connection => connection,
:volume_id => volume_id
)
data['volumeSet'].each do |volume|
volumes << Fog::AWS::EC2::Volume.new({
:connection => connection,
:volumes => self
}.merge!(volume))
end
volumes
end
def create(attributes = {})
volume = new(attributes)
volume.save
volume
end
def get(volume_id)
all(volume_id).first
rescue Fog::Errors::BadRequest
nil
end
def new(attributes = {})
Fog::AWS::EC2::Volume.new(
attributes.merge!(
:connection => connection,
:volumes => self
)
)
end
def reload
all(volume_id)
end
end
end
end
end