Permalink
Browse files

First version of describe_tags

  • Loading branch information...
1 parent af56815 commit a5eb3b55989ae492da4a0d482da9373debd3c238 Thomas Dudziak committed Oct 15, 2010
Showing with 46 additions and 17 deletions.
  1. +17 −16 amazon-ec2.gemspec
  2. +10 −1 lib/AWS.rb
  3. +19 −0 lib/AWS/EC2/tags.rb
View
@@ -1,6 +1,6 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.date = %q{2010-10-15}
s.description = %q{A Ruby library for accessing the Amazon Web Services EC2, ELB, RDS, Cloudwatch, and Autoscaling APIs.}
s.email = %q{glenn@rempe.us}
- s.executables = ["awshell", "ec2sh", "ec2-gem-profile.rb", "setup.rb", "ec2-gem-example.rb"]
+ s.executables = ["awshell", "ec2-gem-example.rb", "ec2-gem-profile.rb", "ec2sh", "setup.rb"]
s.extra_rdoc_files = [
"ChangeLog",
"LICENSE",
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
"lib/AWS/EC2/spot_instance_requests.rb",
"lib/AWS/EC2/spot_prices.rb",
"lib/AWS/EC2/subnets.rb",
+ "lib/AWS/EC2/tags.rb",
"lib/AWS/EC2/volumes.rb",
"lib/AWS/ELB.rb",
"lib/AWS/ELB/load_balancers.rb",
@@ -101,27 +102,27 @@ Gem::Specification.new do |s|
s.rubygems_version = %q{1.3.5}
s.summary = %q{Amazon EC2 Ruby Gem}
s.test_files = [
- "test/test_EC2_console.rb",
- "test/test_EC2_keypairs.rb",
- "test/test_EC2_volumes.rb",
+ "test/test_Autoscaling_groups.rb",
+ "test/test_EC2.rb",
+ "test/test_EC2_availability_zones.rb",
+ "test/test_EC2_console.rb",
+ "test/test_EC2_elastic_ips.rb",
"test/test_EC2_image_attributes.rb",
- "test/test_EC2_snapshots.rb",
- "test/test_EC2_products.rb",
- "test/test_RDS.rb",
"test/test_EC2_images.rb",
- "test/test_EC2_s3_xmlsimple.rb",
- "test/test_ELB_load_balancers.rb",
"test/test_EC2_instances.rb",
- "test/test_Autoscaling_groups.rb",
+ "test/test_EC2_keypairs.rb",
+ "test/test_EC2_products.rb",
+ "test/test_EC2_responses.rb",
+ "test/test_EC2_s3_xmlsimple.rb",
"test/test_EC2_security_groups.rb",
- "test/test_EC2.rb",
- "test/test_EC2_availability_zones.rb",
+ "test/test_EC2_snapshots.rb",
"test/test_EC2_spot_instance_requests.rb",
- "test/test_EC2_responses.rb",
"test/test_EC2_spot_prices.rb",
- "test/test_helper.rb",
"test/test_EC2_subnets.rb",
- "test/test_EC2_elastic_ips.rb"
+ "test/test_EC2_volumes.rb",
+ "test/test_ELB_load_balancers.rb",
+ "test/test_helper.rb",
+ "test/test_RDS.rb"
]
if s.respond_to? :specification_version then
View
@@ -219,7 +219,14 @@ def pathhashlist(key, arr_of_hashes, mappings)
params = {}
arr_of_hashes.each_with_index do |hash, i|
hash.each do |attribute, value|
- params["#{key}.#{i+1}.#{mappings[attribute]}"] = value.to_s
+ if value.is_a? Array
+ params["#{key}.#{i+1}.Name"] = mappings[attribute]
+ value.each_with_index do |item, j|
+ params["#{key}.#{i+1}.Value.#{j+1}"] = item.to_s
+ end
+ else
+ params["#{key}.#{i+1}.#{mappings[attribute]}"] = value.to_s
+ end
end
end
params
@@ -248,6 +255,8 @@ def make_request(action, params, data='')
CGI::escape(param[0]) + "=" + CGI::escape(param[1])
end.join("&") + "&Signature=" + sig
+puts(query);
+
req = Net::HTTP::Post.new("/")
req.content_type = 'application/x-www-form-urlencoded'
req['User-Agent'] = "github-amazon-ec2-ruby-gem"
View
@@ -0,0 +1,19 @@
+module AWS
+ module EC2
+ class Base < AWS::Base
+
+ # The DescribeTags operation lists the tags, If you do not specify any filters, all tags will be returned.
+ #
+ # @option options [optional, Array] :filters ([]) An array of Hashes representing the filters. e.g. [{:key => 'name'}, {:resource_type => 'instance'},...]
+ #
+ def describe_tags( options = {} )
+ params = {}
+ if options[:filters]
+ params.merge!(pathhashlist('Filter', options[:filters], {:key => 'key', :resource_id => 'resource-id', :resource_type => 'resource-type', :value => 'value' }))
+ end
+ return response_generator(:action => "DescribeTags", :params => params)
+ end
+ end
+ end
+end
+

0 comments on commit a5eb3b5

Please sign in to comment.