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, #load, #merge_attributes, model, #model, #new, #reload, #table, #to_json

Constructor Details

#initialize(attributes) ⇒ Images

Returns a new instance of Images.


26
27
28
29
# File 'lib/fog/aws/models/ec2/images.rb', line 26

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

Instance Method Details

#all(image_id = @image_id) ⇒ Object


31
32
33
34
35
# File 'lib/fog/aws/models/ec2/images.rb', line 31

def all(image_id = @image_id)
  @image_id = image_id
  data = connection.describe_images('ImageId' => image_id).body
  load(data['imagesSet'])
end

#get(image_id) ⇒ Object


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

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