1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/requests/compute/describe_images.rb

71 lines
2.5 KiB
Ruby
Raw Normal View History

2010-03-16 18:46:21 -04:00
module Fog
module AWS
2010-09-08 17:40:02 -04:00
class Compute
2010-03-16 18:46:21 -04:00
class Real
2009-09-12 14:58:05 -04:00
2010-09-08 17:40:02 -04:00
require 'fog/aws/parsers/compute/describe_images'
2010-06-12 18:31:17 -04:00
2009-09-12 14:58:05 -04:00
# Describe all or specified images.
#
# ==== Params
# * options<~Hash> - Optional params
# * 'ExecutableBy'<~String> - Only return images that the executable_by
# user has explicit permission to launch
# * 'ImageId'<~Array> - Ids of images to describe
# * 'Owner'<~String> - Only return images belonging to owner.
#
# ==== Returns
# * response<~Excon::Response>:
2009-09-12 14:58:05 -04:00
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'imagesSet'<~Array>:
# * 'architecture'<~String> - Architecture of the image
# * 'blockDeviceMapping'<~Array> - An array of mapped block devices
2009-09-12 14:58:05 -04:00
# * 'imageId'<~String> - Id of the image
# * 'imageLocation'<~String> - Location of the image
# * 'imageOwnerId'<~String> - Id of the owner of the image
# * 'imageState'<~String> - State of the image
# * 'imageType'<~String> - Type of the image
# * 'isPublic'<~Boolean> - Whether or not the image is public
# * 'kernelId'<~String> - Kernel id associated with image, if any
# * 'platform'<~String> - Operating platform of the image
# * 'productCodes'<~Array> - Product codes for the image
# * 'ramdiskId'<~String> - Ramdisk id associated with image, if any
# * 'rootDeviceName'<~String> - Root device name, e.g. /dev/sda1
# * 'rootDeviceType'<~String> - Root device type, ebs or instance-store
2009-09-12 14:58:05 -04:00
def describe_images(options = {})
if image_id = options.delete('ImageId')
options.merge!(AWS.indexed_param('ImageId', image_id))
2009-09-12 14:58:05 -04:00
end
request({
'Action' => 'DescribeImages',
:idempotent => true,
2010-09-08 17:40:02 -04:00
:parser => Fog::Parsers::AWS::Compute::DescribeImages.new
}.merge!(options))
end
2009-09-12 14:58:05 -04:00
end
2009-09-12 14:58:05 -04:00
2010-03-16 18:46:21 -04:00
class Mock
2009-09-12 14:58:05 -04:00
def describe_images(options = {})
2009-11-20 14:08:08 -05:00
response = Excon::Response.new
2009-09-12 14:58:05 -04:00
images = []
(rand(101 + 100)).times do
images << Fog::AWS::Mock.image
end
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'imagesSet' => images
}
response
end
end
end
end
end