mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
36 lines
668 B
Ruby
36 lines
668 B
Ruby
require 'fog/collection'
|
|
require 'fog/aws/models/ec2/image'
|
|
|
|
module Fog
|
|
module AWS
|
|
class EC2
|
|
|
|
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'])
|
|
end
|
|
|
|
def get(image_id)
|
|
if image_id
|
|
all(image_id).first
|
|
end
|
|
rescue Fog::Errors::NotFound
|
|
nil
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|