Class: Nephophobia::Resource::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/nephophobia/resource/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Image

Returns a new instance of Image.



4
5
6
# File 'lib/nephophobia/resource/image.rb', line 4

def initialize client
  @client = client
end

Instance Method Details

#all(filter = {}) ⇒ Object

Returns information about AMIs, AKIs, and ARIs. Images returned include public images, private images that @client owns, and private images owned by other AWS accounts but for which @client has explicit launch permissions.

filter: An optional Hash, intended for filtering.

See the API Reference for further details.
{
  "Filter.1.Name"    => "instance-type",
  "Filter.1.Value.1" => "m1.small",
  "ExecutableBy.1"   => "self",
}


22
23
24
25
26
27
28
# File 'lib/nephophobia/resource/image.rb', line 22

def all filter = {}
  response = @client.action "DescribeImages", filter

  item = response.body['DescribeImagesResponse']['imagesSet']['item'].collect do |data|
    Response::Image.new data
  end
end

#find(image_id) ⇒ Object

Returns information about the given ‘image_id’.

image_id: A String representing the ID of the image.



35
36
37
38
39
40
41
42
43
# File 'lib/nephophobia/resource/image.rb', line 35

def find image_id
  params = {
    "ImageId.1" => image_id
  }

  response = @client.action "DescribeImages", params

  Response::Image.new response.body['DescribeImagesResponse']['imagesSet']['item']
end

#runnableObject

Return information about all public images.



48
49
50
51
52
# File 'lib/nephophobia/resource/image.rb', line 48

def runnable
  all.select do |image|
    runnable? image
  end
end