Skip to content

Loading…

Filter snapshots and volumes #51

Open
wants to merge 1 commit into from

1 participant

@organicveggie

Modifications to support filtering on describe_volumes and describe_snapshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 20, 2011
  1. @organicveggie
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +2 −0 lib/AWS/EC2/snapshots.rb
  2. +2 −0 lib/AWS/EC2/volumes.rb
View
2 lib/AWS/EC2/snapshots.rb
@@ -7,12 +7,14 @@ class Base < AWS::Base
# The DescribeSnapshots operation describes the status of Amazon EBS snapshots.
#
# @option options [optional,Array] :snapshot_id ([]) The ID of the Amazon EBS snapshot.
+ # @option options [optional,Array] :filters ([]) Array of Hashes of filters.
# @option options [optional,String] :owner ('') Returns snapshots owned by the specified owner. Multiple owners can be specified. Valid values self | amazon | AWS Account ID
# @option options [optional,String] :restorable_by ('') Account ID of a user that can create volumes from the snapshot.
#
def describe_snapshots( options = {} )
params = {}
params.merge!(pathlist("SnapshotId", options[:snapshot_id] )) unless options[:snapshot_id].nil? || options[:snapshot_id] == []
+ params.merge!(pathkvlist("Filter", options[:filters], "Name", "Value", {} )) unless options[:filters].nil? || options[:filters] == []
params["RestorableBy"] = options[:restorable_by] unless options[:restorable_by].nil?
params["Owner"] = options[:owner] unless options[:owner].nil?
return response_generator(:action => "DescribeSnapshots", :params => params)
View
2 lib/AWS/EC2/volumes.rb
@@ -6,10 +6,12 @@ class Base < AWS::Base
# The DescribeVolumes operation lists one or more Amazon EBS volumes that you own, If you do not specify any volumes, Amazon EBS returns all volumes that you own.
#
# @option options [optional, String] :volume_id ([])
+ # @option options [optional,Array] :filters ([]) Array of Hashes of filters.
#
def describe_volumes( options = {} )
options = { :volume_id => [] }.merge(options)
params = pathlist("VolumeId", options[:volume_id] )
+ params.merge!(pathkvlist("Filter", options[:filters], "Name", "Value", {} )) unless options[:filters].nil? || options[:filters] == []
return response_generator(:action => "DescribeVolumes", :params => params)
end
Something went wrong with that request. Please try again.