2012-07-30 16:50:16 -04:00
|
|
|
require 'fog/core/collection'
|
2012-07-30 18:22:16 -04:00
|
|
|
require 'fog/rackspace/models/compute_v2/image'
|
2012-07-30 16:50:16 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::RackspaceV2::Image
|
|
|
|
|
2013-01-30 10:05:10 -05:00
|
|
|
# Returns list of images
|
|
|
|
# @return [Array<Fog::Compute::RackspaceV2::Image>] Retrieves a list images.
|
|
|
|
# @note Fog's current implementation only returns 1000 images.
|
|
|
|
# @note Fog does not retrieve all image details. Please use get to retrieve all details for a specific image.
|
|
|
|
# @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Images-d1e4435.html
|
2012-07-30 16:50:16 -04:00
|
|
|
def all
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_images.body['images']
|
2012-07-30 16:50:16 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2013-01-30 10:05:10 -05:00
|
|
|
# Retrieve image
|
|
|
|
# @param [String] image_id id of image
|
|
|
|
# @return [Fog::Compute::RackspaceV2:Image] image
|
|
|
|
# @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Get_Image_Details-d1e4848.html
|
2012-07-30 16:50:16 -04:00
|
|
|
def get(image_id)
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.get_image(image_id).body['image']
|
2012-07-30 16:50:16 -04:00
|
|
|
new(data)
|
|
|
|
rescue Fog::Compute::RackspaceV2::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|