mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add describe images spec
This commit is contained in:
parent
2ef2a53f4c
commit
68209cb97b
4 changed files with 93 additions and 0 deletions
|
@ -109,6 +109,31 @@ module Fog
|
|||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
|
||||
end
|
||||
|
||||
# Describe all or specified images.
|
||||
#
|
||||
# ==== Params
|
||||
# :options<~Hash>:: Optional params
|
||||
# :executable_by<~String>:: Only return images the user specified by
|
||||
# executable_by has explicit permission to launch
|
||||
# :image_id<~Array>:: Ids of images to describe
|
||||
# :owner<~String>:: Only return images belonging to owner.
|
||||
#
|
||||
# ==== Returns
|
||||
def describe_images(options = {})
|
||||
params, index = {}, 1
|
||||
if options[:image_id]
|
||||
for image in [*options[:image_id]]
|
||||
params["ImageId.#{index}"] = image
|
||||
image += 1
|
||||
end
|
||||
end
|
||||
request({
|
||||
'Action' => 'DescribeImages',
|
||||
'ExecutableBy' => options[:executable_by],
|
||||
'Owner' => options[:owner]
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeImages.new)
|
||||
end
|
||||
|
||||
# Describe all or specified volumes.
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -81,6 +81,47 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
class DescribeImages < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@image = {}
|
||||
@response = { :image_set => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'architecture'
|
||||
@image[:architecture] = @value
|
||||
when 'imageId'
|
||||
@image[:image_id] = @value
|
||||
when 'imageLocation'
|
||||
@image[:image_location] = @value
|
||||
when 'imageOwnerId'
|
||||
@image[:image_owner_id] = @value
|
||||
when 'imageState'
|
||||
@image[:image_state] = @value
|
||||
when 'imageType'
|
||||
@image[:image_type] = @value
|
||||
when 'isPublic'
|
||||
if @value == 'true'
|
||||
@image[:is_public] = true
|
||||
else
|
||||
@image[:is_public] = false
|
||||
end
|
||||
when 'item'
|
||||
@response[:image_set] << @image
|
||||
@image = {}
|
||||
when 'kernelId'
|
||||
@image[:kernel_id] = @value
|
||||
when 'ramdiskId'
|
||||
@image[:ramdisk_id] = @value
|
||||
when 'requestId'
|
||||
@response[:request_id] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class DescribeVolumes < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
|
|
20
spec/aws/ec2/describe_images_spec.rb
Normal file
20
spec/aws/ec2/describe_images_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe 'EC2.describe_images' do
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = ec2.describe_images
|
||||
actual.body[:request_id].should be_a(String)
|
||||
image = actual.body[:image_set].first
|
||||
image[:architecture].should be_a(String)
|
||||
image[:image_id].should be_a(String)
|
||||
image[:image_location].should be_a(String)
|
||||
image[:image_owner_id].should be_a(String)
|
||||
image[:image_state].should be_a(String)
|
||||
image[:image_type].should be_a(String)
|
||||
[false, true].should include(image[:is_public])
|
||||
end
|
||||
|
||||
it "should return proper attributes with params"
|
||||
|
||||
end
|
7
spec/aws/simpledb/select_spec.rb
Normal file
7
spec/aws/simpledb/select_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe 'SimpleDB.select' do
|
||||
|
||||
it "should have some specs"
|
||||
|
||||
end
|
Loading…
Reference in a new issue