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/images.rb

49 lines
905 B
Ruby
Raw Normal View History

2010-03-16 18:46:21 -04:00
require 'fog/collection'
require 'fog/aws/models/ec2/image'
2010-01-10 16:35:20 -05:00
module Fog
module AWS
2010-03-16 18:46:21 -04:00
module EC2
2010-01-10 16:35:20 -05:00
2010-03-16 18:46:21 -04:00
class Mock
def images
Fog::AWS::EC2::Images.new(:connection => self)
end
end
class Real
def images
Fog::AWS::EC2::Images.new(:connection => self)
end
2010-01-10 16:35:20 -05:00
end
class Images < Fog::Collection
attribute :image_id
model Fog::AWS::EC2::Image
def initialize(attributes)
@image_id ||= []
super
end
def all(image_id = @image_id)
@image_id = image_id
data = connection.describe_images('ImageId' => image_id).body
load(data['imagesSet'])
2010-01-10 16:35:20 -05:00
end
def get(image_id)
if image_id
all(image_id).first
end
rescue Excon::Errors::BadRequest
nil
end
end
end
end
end