Class: Fog::AWS::EC2::Images

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

Instance Method Summary collapse

Methods inherited from Collection

#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #inspect, #merge_attributes, model, #model, #new, #reload

Constructor Details

#initialize(attributes) ⇒ Images

Returns a new instance of Images.



15
16
17
18
# File 'lib/fog/aws/models/ec2/images.rb', line 15

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

Instance Method Details

#all(image_id = @image_id) ⇒ Object



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

def all(image_id = @image_id)
  @image_id = image_id
  if @loaded
    clear
  end
  @loaded = true
  data = connection.describe_images('ImageId' => image_id).body
  data['imagesSet'].each do |image|
    self << new(image)
  end
  self
end

#get(image_id) ⇒ Object



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

def get(image_id)
  if image_id
    all(image_id).first
  end
rescue Excon::Errors::BadRequest
  nil
end