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
|
2013-08-21 13:30:14 -04:00
|
|
|
|
|
|
|
# @!attribute [rw] name
|
|
|
|
# @return [String] Given a string value x, filters the list of images by image name.
|
|
|
|
attribute :name
|
|
|
|
|
|
|
|
# @!attribute [rw] status
|
|
|
|
# @return [String] Given a string value x, filters the list of images by status.
|
|
|
|
# @note Possible values are ACTIVE, DELETED, ERROR, SAVING, and UNKNOWN.
|
|
|
|
attribute :status
|
|
|
|
|
|
|
|
# @!attribute [rw] marker
|
|
|
|
# @return [String] Given a string value x, return object names greater in value than the specified marker.
|
|
|
|
# @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Large_Number_of_Objects-d1e1521.html
|
|
|
|
attribute :marker
|
|
|
|
|
|
|
|
# @!attribute [rw] limit
|
|
|
|
# @return [Integer] For an integer value n, limits the number of results to at most n values.
|
|
|
|
# @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Large_Number_of_Objects-d1e1521.html
|
|
|
|
attribute :limit
|
|
|
|
|
|
|
|
# @!attribute [rw] type
|
|
|
|
# @return [String] Given a string value x, filters the list of images by type.
|
|
|
|
# @note Valid values are BASE and SNAPSHOT
|
|
|
|
attribute :type
|
2012-07-30 16:50:16 -04:00
|
|
|
|
|
|
|
model Fog::Compute::RackspaceV2::Image
|
|
|
|
|
2013-01-30 10:05:10 -05:00
|
|
|
# Returns list of images
|
2013-03-27 10:50:30 -04:00
|
|
|
# @return [Fog::Compute::RackspaceV2::Images] Retrieves a list images.
|
2013-04-15 14:12:14 -04:00
|
|
|
# @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
2013-01-30 10:05:10 -05:00
|
|
|
# @note Fog's current implementation only returns 1000 images.
|
|
|
|
# @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Images-d1e4435.html
|
2013-08-21 13:30:14 -04:00
|
|
|
def all(options = {})
|
|
|
|
options = {
|
|
|
|
'name' => name,
|
|
|
|
'status' => status,
|
|
|
|
'marker' => marker,
|
|
|
|
'limit' => limit,
|
|
|
|
'type' => type
|
|
|
|
}.merge!(options)
|
|
|
|
merge_attributes(options)
|
2013-08-21 14:56:43 -04:00
|
|
|
|
2013-08-26 19:42:14 -04:00
|
|
|
data = service.list_images_detail(options).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
|
2013-04-15 14:12:14 -04:00
|
|
|
# @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
2013-01-30 10:05:10 -05:00
|
|
|
# @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
|