diff --git a/amazon-ec2.gemspec b/amazon-ec2.gemspec index 835ac37..19f4df0 100644 --- a/amazon-ec2.gemspec +++ b/amazon-ec2.gemspec @@ -1,10 +1,10 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "AWS/version" +require "AWSAPI/version" Gem::Specification.new do |s| s.name = "amazon-ec2" - s.version = AWS::VERSION + s.version = AWSAPI::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Glenn Rempe"] s.email = ["glenn@rempe.us"] diff --git a/bin/awshell b/bin/awshell index 0961f65..3e663bd 100755 --- a/bin/awshell +++ b/bin/awshell @@ -15,7 +15,7 @@ require 'irb' # CREDITS : Credit for this bit of shameful ripoff coolness # goes to Marcel Molina and his AWS::S3 gem. Thanks! -require File.dirname(__FILE__) + '/../lib/AWS' +require File.dirname(__FILE__) + '/../lib/AWSAPI' setup = File.dirname(__FILE__) + '/setup' @@ -69,7 +69,7 @@ def welcome! returns : Pretty Print a Hash describing your EC2 images >> @ec2.describe_images(:owner_id => ['self']) - returns : an Array of AWS::Response objects, each an EC2 image and its data + returns : an Array of AWSAPI::Response objects, each an EC2 image and its data >> @ec2.describe_images(:owner_id => ['self']).imagesSet.item >> @ec2.describe_images(:owner_id => ['self']).imagesSet.item[0] MESSAGE diff --git a/bin/ec2-gem-example.rb b/bin/ec2-gem-example.rb index 761e041..f22b061 100755 --- a/bin/ec2-gem-example.rb +++ b/bin/ec2-gem-example.rb @@ -34,10 +34,10 @@ # test different servers by running something like: # export EC2_URL='https://ec2.amazonaws.com';./bin/ec2-gem-example.rb if ENV['EC2_URL'] - ec2 = AWS::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['EC2_URL']).host ) + ec2 = AWSAPI::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['EC2_URL']).host ) else # default server is US ec2.amazonaws.com - ec2 = AWS::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY ) + ec2 = AWSAPI::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY ) end puts "----- ec2.methods.sort -----" @@ -68,9 +68,9 @@ # ELB examples # Autoscaling examples if ENV['ELB_URL'] - elb = AWS::ELB::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['ELB_URL']).host ) + elb = AWSAPI::ELB::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['ELB_URL']).host ) else - elb = AWS::ELB::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY) + elb = AWSAPI::ELB::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY) end puts "----- creating an elastic load balancer -----" @@ -88,9 +88,9 @@ # Autoscaling examples if ENV['AS_URL'] - as = AWS::Autoscaling::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['AS_URL']).host ) + as = AWSAPI::Autoscaling::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['AS_URL']).host ) else - as = AWS::Autoscaling::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY) + as = AWSAPI::Autoscaling::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY) end puts "---- creating a launch configuration group -----" diff --git a/bin/ec2-gem-profile.rb b/bin/ec2-gem-profile.rb index 573a047..cc22179 100755 --- a/bin/ec2-gem-profile.rb +++ b/bin/ec2-gem-profile.rb @@ -6,6 +6,6 @@ ACCESS_KEY_ID = ENV['AWS_ACCESS_KEY_ID'] || ENV['AMAZON_ACCESS_KEY_ID'] SECRET_ACCESS_KEY = ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY'] -ec2 = AWS::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY ) +ec2 = AWSAPI::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY ) @images = ec2.describe_images diff --git a/bin/setup.rb b/bin/setup.rb index c9ffcef..b125d34 100755 --- a/bin/setup.rb +++ b/bin/setup.rb @@ -11,11 +11,11 @@ -if(AWS::ACCESS_KEY_ID and AWS::SECRET_ACCESS_KEY) +if(AWSAPI::ACCESS_KEY_ID and AWSAPI::SECRET_ACCESS_KEY) opts = { - :access_key_id => AWS::ACCESS_KEY_ID, - :secret_access_key => AWS::SECRET_ACCESS_KEY + :access_key_id => AWSAPI::ACCESS_KEY_ID, + :secret_access_key => AWSAPI::SECRET_ACCESS_KEY } if ENV['EC2_URL'] @@ -30,37 +30,37 @@ opts[:use_ssl] = false end end - @ec2 = AWS::EC2::Base.new(opts) + @ec2 = AWSAPI::EC2::Base.new(opts) else - @ec2 = AWS::EC2::Base.new(opts) + @ec2 = AWSAPI::EC2::Base.new(opts) end if ENV['ELB_URL'] opts[:server] = URI.parse(ENV['ELB_URL']).host - @elb = AWS::ELB::Base.new(opts) + @elb = AWSAPI::ELB::Base.new(opts) else - @elb = AWS::ELB::Base.new(opts) + @elb = AWSAPI::ELB::Base.new(opts) end if ENV['AS_URL'] opts[:server] = URI.parse(ENV['AS_URL']).host - @as = AWS::Autoscaling::Base.new(opts) + @as = AWSAPI::Autoscaling::Base.new(opts) else - @as = AWS::Autoscaling::Base.new(opts) + @as = AWSAPI::Autoscaling::Base.new(opts) end if ENV['RDS_URL'] opts[:server] = URI.parse(ENV['RDS_URL']).host - @rds = AWS::RDS::Base.new(opts) + @rds = AWSAPI::RDS::Base.new(opts) else - @rds = AWS::RDS::Base.new(opts) + @rds = AWSAPI::RDS::Base.new(opts) end if ENV['AWS_CLOUDWATCH_URL'] opts[:server] = URI.parse(ENV['AWS_CLOUDWATCH_URL']).host - @cw = AWS::Cloudwatch::Base.new(opts) + @cw = AWSAPI::Cloudwatch::Base.new(opts) else - @cw = AWS::Cloudwatch::Base.new(opts) + @cw = AWSAPI::Cloudwatch::Base.new(opts) end puts "" diff --git a/lib/AWS.rb b/lib/AWS.rb deleted file mode 100644 index 23afd2c..0000000 --- a/lib/AWS.rb +++ /dev/null @@ -1,375 +0,0 @@ -#-- -# Amazon Web Services EC2 + ELB API Ruby library -# -# Ruby Gem Name:: amazon-ec2 -# Author:: Glenn Rempe (mailto:glenn@rempe.us) -# Copyright:: Copyright (c) 2007-2009 Glenn Rempe -# License:: Distributes under the same terms as Ruby -# Home:: http://github.com/grempe/amazon-ec2/tree/master -#++ - -%w[ base64 cgi openssl digest/sha1 net/https net/http rexml/document time ostruct ].each { |f| require f } - -begin - require 'URI' unless defined? URI -rescue Exception => e - # nothing -end - -begin - require 'xmlsimple' unless defined? XmlSimple -rescue Exception => e - require 'xml-simple' unless defined? XmlSimple -end - - -# A custom implementation of Hash that allows us to access hash values using dot notation -# -# @example Access the hash keys in the standard way or using dot notation -# foo[:bar] => "baz" -# foo.bar => "baz" -class Hash - def method_missing(meth, *args, &block) - if args.size == 0 - self[meth.to_s] || self[meth.to_sym] - end - end - - def type - self['type'] - end - - def has?(key) - self[key] && !self[key].to_s.empty? - end - - def does_not_have?(key) - self[key].nil? || self[key].to_s.empty? - end -end - - -module AWS - ACCESS_KEY_ID = ENV['AWS_ACCESS_KEY_ID'] || ENV['AMAZON_ACCESS_KEY_ID'] || "" - SECRET_ACCESS_KEY = ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AMAZON_SECRET_ACCESS_KEY'] || "" - - # Builds the canonical string for signing requests. This strips out all '&', '?', and '=' - # from the query string to be signed. The parameters in the path passed in must already - # be sorted in case-insensitive alphabetical order and must not be url encoded. - # - # @param [String] params the params that will be sorted and encoded as a canonical string. - # @param [String] host the hostname of the API endpoint. - # @param [String] method the HTTP method that will be used to submit the params. - # @param [String] base the URI path that this information will be submitted to. - # @return [String] the canonical request description string. - def AWS.canonical_string(params, host, method="POST", base="/") - # Sort, and encode parameters into a canonical string. - sorted_params = params.sort {|x,y| x[0] <=> y[0]} - encoded_params = sorted_params.collect do |p| - encoded = (CGI::escape(p[0].to_s) + - "=" + CGI::escape(p[1].to_s)) - # Ensure spaces are encoded as '%20', not '+' - encoded = encoded.gsub('+', '%20') - # According to RFC3986 (the scheme for values expected by signing requests), '~' - # should not be encoded - encoded = encoded.gsub('%7E', '~') - end - sigquery = encoded_params.join("&") - - # Generate the request description string - req_desc = - method + "\n" + - host + "\n" + - base + "\n" + - sigquery - - end - - # Encodes the given string with the secret_access_key by taking the - # hmac-sha1 sum, and then base64 encoding it. Optionally, it will also - # url encode the result of that to protect the string if it's going to - # be used as a query string parameter. - # - # @param [String] secret_access_key the user's secret access key for signing. - # @param [String] str the string to be hashed and encoded. - # @param [Boolean] urlencode whether or not to url encode the result., true or false - # @return [String] the signed and encoded string. - def AWS.encode(secret_access_key, str, urlencode=true) - digest = OpenSSL::Digest::Digest.new('sha256') - b64_hmac = - Base64.encode64( - OpenSSL::HMAC.digest(digest, secret_access_key, str)).gsub("\n","") - - if urlencode - return CGI::escape(b64_hmac) - else - return b64_hmac - end - end - - # This class provides all the methods for using the EC2 or ELB service - # including the handling of header signing and other security concerns. - # This class uses the Net::HTTP library to interface with the AWS Query API - # interface. You should not instantiate this directly, instead - # you should setup an instance of 'AWS::EC2::Base' or 'AWS::ELB::Base'. - class Base - attr_reader :use_ssl, :server, :proxy_server, :port - - # @option options [String] :access_key_id ("") The user's AWS Access Key ID - # @option options [String] :secret_access_key ("") The user's AWS Secret Access Key - # @option options [Boolean] :use_ssl (true) Connect using SSL? - # @option options [String] :server ("ec2.amazonaws.com") The server API endpoint host - # @option options [String] :proxy_server (nil) An HTTP proxy server FQDN - # @return [Object] the object. - def initialize( options = {} ) - - options = { :access_key_id => ACCESS_KEY_ID, - :secret_access_key => SECRET_ACCESS_KEY, - :use_ssl => true, - :server => default_host, - :path => "/", - :proxy_server => nil - }.merge(options) - - @server = options[:server] - @proxy_server = options[:proxy_server] - @use_ssl = options[:use_ssl] - @path = options[:path] - - raise ArgumentError, "No :access_key_id provided" if options[:access_key_id].nil? || options[:access_key_id].empty? - raise ArgumentError, "No :secret_access_key provided" if options[:secret_access_key].nil? || options[:secret_access_key].empty? - raise ArgumentError, "No :use_ssl value provided" if options[:use_ssl].nil? - raise ArgumentError, "Invalid :use_ssl value provided, only 'true' or 'false' allowed" unless options[:use_ssl] == true || options[:use_ssl] == false - raise ArgumentError, "No :server provided" if options[:server].nil? || options[:server].empty? - - if options[:port] - # user-specified port - @port = options[:port] - elsif @use_ssl - # https - @port = 443 - else - # http - @port = 80 - end - - @access_key_id = options[:access_key_id] - @secret_access_key = options[:secret_access_key] - - # Use proxy server if defined - # Based on patch by Mathias Dalheimer. 20070217 - proxy = @proxy_server ? URI.parse(@proxy_server) : OpenStruct.new - @http = Net::HTTP::Proxy( proxy.host, - proxy.port, - proxy.user, - proxy.password).new(options[:server], @port) - - @http.use_ssl = @use_ssl - - # Don't verify the SSL certificates. Avoids SSL Cert warning in log on every GET. - @http.verify_mode = OpenSSL::SSL::VERIFY_NONE - - end - - # If :user_data is passed in then URL escape and Base64 encode it - # as needed. Need for URL Escape + Base64 encoding is determined - # by :base64_encoded param. - def extract_user_data( options = {} ) - return unless options[:user_data] - if options[:user_data] - if options[:base64_encoded] - Base64.encode64(options[:user_data]).gsub(/\n/, "").strip() - else - options[:user_data] - end - end - end - - - protected - - # pathlist is a utility method which takes a key string and and array as input. - # It converts the array into a Hash with the hash key being 'Key.n' where - # 'n' increments by 1 for each iteration. So if you pass in args - # ("ImageId", ["123", "456"]) you should get - # {"ImageId.1"=>"123", "ImageId.2"=>"456"} returned. - def pathlist(key, arr) - params = {} - - # ruby 1.9 will barf if we pass in a string instead of the array expected. - # it will fail on each_with_index below since string is not enumerable. - if arr.is_a? String - new_arr = [] - new_arr << arr - arr = new_arr - end - - arr.each_with_index do |value, i| - params["#{key}.#{i+1}"] = value - end - params - end - - # Same as _pathlist_ except it deals with arrays of hashes. - # So if you pass in args - # ("People", [{:name=>'jon', :age=>'22'}, {:name=>'chris'}], {:name => 'Name', :age => 'Age'}) you should get - # {"People.1.Name"=>"jon", "People.1.Age"=>'22', 'People.2.Name'=>'chris'} - def pathhashlist(key, arr_of_hashes, mappings) - raise ArgumentError, "expected a key that is a String" unless key.is_a? String - raise ArgumentError, "expected a arr_of_hashes that is an Array" unless arr_of_hashes.is_a? Array - arr_of_hashes.each{|h| raise ArgumentError, "expected each element of arr_of_hashes to be a Hash" unless h.is_a?(Hash)} - raise ArgumentError, "expected a mappings that is an Hash" unless mappings.is_a? Hash - params = {} - arr_of_hashes.each_with_index do |hash, i| - hash.each do |attribute, value| - 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 - end - - # Same as _pathhashlist_ except it generates explicit .Key= and .Value or .Value.1, .Value.2 - # depending on whether the value is a scalar or an array. - # - # So if you pass in args - # ("People", [{:name=>'jon'}, {:names=>['chris', 'bob']} with key_name = 'Key' and value_name = 'Value', - # you should get - # {"People.1.Key"=>"name", "People.1.Value"=>'jon', "People.2.Key"=>'names', 'People.2.Value.1'=>'chris', 'People.2.Value.2'=>'bob'} - def pathkvlist(key, arr_of_hashes, key_name, value_name, mappings) - raise ArgumentError, "expected a key that is a String" unless key.is_a? String - raise ArgumentError, "expected a arr_of_hashes that is an Array" unless arr_of_hashes.is_a? Array - arr_of_hashes.each{|h| raise ArgumentError, "expected each element of arr_of_hashes to be a Hash" unless h.is_a?(Hash)} - raise ArgumentError, "expected a key_nam that is a String" unless key_name.is_a? String - raise ArgumentError, "expected a value_name that is a String" unless value_name.is_a? String - raise ArgumentError, "expected a mappings that is an Hash" unless mappings.is_a? Hash - params = {} - arr_of_hashes.each_with_index do |hash, i| - hash.each do |attribute, value| - params["#{key}.#{i+1}.#{key_name}"] = mappings.fetch(attribute, attribute) - if !value.nil? - if value.is_a? Array - value.each_with_index do |item, j| - params["#{key}.#{i+1}.#{value_name}.#{j+1}"] = item.to_s - end - else - params["#{key}.#{i+1}.#{value_name}"] = value.to_s - end - end - end - end - params - end - - # Make the connection to AWS EC2 passing in our request. This is generally called from - # within a 'Response' class object or one of its sub-classes so the response is interpreted - # in its proper context. See lib/EC2/responses.rb - def make_request(action, params, data='') - - @http.start do - - # remove any keys that have nil or empty values - params.reject! { |key, value| value.nil? or value.empty?} - - params.merge!( {"Action" => action, - "SignatureVersion" => "2", - "SignatureMethod" => 'HmacSHA256', - "AWSAccessKeyId" => @access_key_id, - "Version" => api_version, - "Timestamp"=>Time.now.getutc.iso8601} ) - - sig = get_aws_auth_param(params, @secret_access_key, @server) - - query = params.sort.collect do |param| - CGI::escape(param[0]) + "=" + CGI::escape(param[1]) - end.join("&") + "&Signature=" + sig - - req = Net::HTTP::Post.new(@path) - req.content_type = 'application/x-www-form-urlencoded' - req['User-Agent'] = "github-amazon-ec2-ruby-gem" - - response = @http.request(req, query) - - # Make a call to see if we need to throw an error based on the response given by EC2 - # All error classes are defined in EC2/exceptions.rb - aws_error?(response) - return response - - end - - end - - # Set the Authorization header using AWS signed header authentication - def get_aws_auth_param(params, secret_access_key, server) - canonical_string = AWS.canonical_string(params, server,"POST", @path) - encoded_canonical = AWS.encode(secret_access_key, canonical_string) - end - - # allow us to have a one line call in each method which will do all of the work - # in making the actual request to AWS. - def response_generator( options = {} ) - - options = { - :action => "", - :params => {} - }.merge(options) - - raise ArgumentError, ":action must be provided to response_generator" if options[:action].nil? || options[:action].empty? - - http_response = make_request(options[:action], options[:params]) - http_xml = http_response.body - - return Response.parse(:xml => http_xml) - end - - # Raises the appropriate error if the specified Net::HTTPResponse object - # contains an AWS error; returns +false+ otherwise. - def aws_error?(response) - - # return false if we got a HTTP 200 code, - # otherwise there is some type of error (40x,50x) and - # we should try to raise an appropriate exception - # from one of our exception classes defined in - # exceptions.rb - return false if response.is_a?(Net::HTTPSuccess) - - raise AWS::Error, "Unexpected server error. response.body is: #{response.body}" if response.is_a?(Net::HTTPServerError) - - # parse the XML document so we can walk through it - doc = REXML::Document.new(response.body) - - # Check that the Error element is in the place we would expect. - # and if not raise a generic error exception - unless doc.root.elements['Errors'].elements['Error'].name == 'Error' - raise Error, "Unexpected error format. response.body is: #{response.body}" - end - - # An valid error response looks like this: - # InvalidParameterCombinationUnknown parameter: foo291cef62-3e86-414b-900e-17246eccfae8 - # AWS throws some exception codes that look like Error.SubError. Since we can't name classes this way - # we need to strip out the '.' in the error 'Code' and we name the error exceptions with this - # non '.' name as well. - error_code = doc.root.elements['Errors'].elements['Error'].elements['Code'].text.gsub('.', '') - error_message = doc.root.elements['Errors'].elements['Error'].elements['Message'].text - - # Raise one of our specific error classes if it exists. - # otherwise, throw a generic EC2 Error with a few details. - if AWS.const_defined?(error_code) - raise AWS.const_get(error_code), error_message - else - raise AWS::Error, error_message - end - - end - - end -end - -Dir[File.join(File.dirname(__FILE__), 'AWS/**/*.rb')].sort.each { |lib| require lib } - diff --git a/lib/AWS/Autoscaling.rb b/lib/AWS/Autoscaling.rb deleted file mode 100644 index 0d78b2a..0000000 --- a/lib/AWS/Autoscaling.rb +++ /dev/null @@ -1,68 +0,0 @@ -module AWS - module Autoscaling - # Which host FQDN will we connect to for all API calls to AWS? - # If AS_URL is defined in the users ENV we can override the default with that. - # - # @example - # export AS_URL='http://autoscaling.amazonaws.com' - if ENV['AS_URL'] - AS_URL = ENV['AS_URL'] - DEFAULT_HOST = URI.parse(AS_URL).host - else - # Default US API endpoint - DEFAULT_HOST = 'autoscaling.amazonaws.com' - end - - API_VERSION = '2009-05-15' - - class Base < AWS::Base - def api_version - API_VERSION - end - - def default_host - DEFAULT_HOST - end - - # Raises the appropriate error if the specified Net::HTTPResponse object - # contains an Amazon EC2 error; returns +false+ otherwise. - def aws_error?(response) - - # return false if we got a HTTP 200 code, - # otherwise there is some type of error (40x,50x) and - # we should try to raise an appropriate exception - # from one of our exception classes defined in - # exceptions.rb - return false if response.is_a?(Net::HTTPSuccess) - - # parse the XML document so we can walk through it - doc = REXML::Document.new(response.body) - - # Check that the Error element is in the place we would expect. - # and if not raise a generic error exception - unless doc.root.elements[1].name == "Error" - raise Error, "Unexpected error format. response.body is: #{response.body}" - end - - # An valid error response looks like this: - # InvalidParameterCombinationUnknown parameter: foo291cef62-3e86-414b-900e-17246eccfae8 - # AWS EC2 throws some exception codes that look like Error.SubError. Since we can't name classes this way - # we need to strip out the '.' in the error 'Code' and we name the error exceptions with this - # non '.' name as well. - error_code = doc.root.elements['//ErrorResponse/Error/Code'].text.gsub('.', '') - error_message = doc.root.elements['//ErrorResponse/Error/Message'].text - - # Raise one of our specific error classes if it exists. - # otherwise, throw a generic EC2 Error with a few details. - if AWS.const_defined?(error_code) - raise AWS.const_get(error_code), error_message - else - raise AWS::Error, error_message - end - - end - - end - - end -end \ No newline at end of file diff --git a/lib/AWS/Autoscaling/autoscaling.rb b/lib/AWS/Autoscaling/autoscaling.rb deleted file mode 100644 index c916ea4..0000000 --- a/lib/AWS/Autoscaling/autoscaling.rb +++ /dev/null @@ -1,275 +0,0 @@ -module AWS - module Autoscaling - class Base < AWS::Base - - # Create a launch configuration - # Creates a new Launch Configuration. Please note that the launch configuration name used must be unique, within the scope of your AWS account, and the maximum limit of launch configurations must not yet have been met, or else the call will fail. - # Once created, the new launch configuration is available for immediate use. - # - # @option options [String] :launch_configuration_name (nil) the name of the launch configuration - # @option options [String] :image_id (nil) the image id to use with this launch configuration - # @option options [String] :instance_type (nil) the type of instance to launch - # @option options [Array] :security_groups (nil) the names of security_groups to launch within - # @option options [String] :key_name (nil) the name of the EC2 key pair - # @option options [String] :user_data (nil) the user data available to the launched EC2 instances - # @option options [String] :kernel_id (nil) the ID of the kernel associated with the EC2 ami - # @option options [String] :ramdisk_id (nil) the name of the RAM disk associated with the EC2 ami - # @option options [Array] :block_device_mappings (nil) specifies how block devices are exposed to the instance - def create_launch_configuration( options = {}) - raise ArgumentError, "No :image_id provided" if options[:image_id].nil? || options[:image_id].empty? - raise ArgumentError, "No :launch_configuration_name provided" if options[:launch_configuration_name].nil? || options[:launch_configuration_name].empty? - raise ArgumentError, "No :instance_type provided" if options[:instance_type].nil? || options[:instance_type].empty? - - params = {} - params["ImageId"] = options[:image_id] - params["KeyName"] = options[:key_name] if options[:key_name] - params["LaunchConfigurationName"] = options[:launch_configuration_name] - params.merge!(pathlist('SecurityGroups.member', [options[:security_groups]].flatten)) if options[:security_groups] - params["UserData"] = options[:user_data] if options[:user_data] - params["InstanceType"] = options[:instance_type] if options[:instance_type] - params["KernelId"] = options[:kernel_id] if options[:kernel_id] - params["RamdiskId"] = options[:ramdisk_id] if options[:ramdisk_id] - params.merge!(pathlist('BlockDeviceMappings.member', [options[:block_device_mappings]].flatten)) if options[:block_device_mappings] - - return response_generator(:action => "CreateLaunchConfiguration", :params => params) - end - - # Creates a new AutoScalingGroup with the specified name. - # You must not have already used up your entire quota of AutoScalingGroups in order for this call to be successful. Once the creation request is completed, the AutoScalingGroup is ready to be used in other calls. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling group - # @option options [Array] :availability_zones (nil) The availability_zones for the group - # @option options [String] :launch_configuration_name (nil) the name of the launch_configuration group - # @option options [String] :min_size (nil) minimum size of the group - # @option options [String] :max_size (nil) the maximum size of the group - # @option options [optional,Array] :load_balancer_names (nil) the names of the load balancers - # @option options [optional,String] :cooldown (nil) the amount of time after a scaling activity complese before any further trigger-related scaling activities can start - def create_autoscaling_group( options = {} ) - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - raise ArgumentError, "No :availability_zones provided" if options[:availability_zones].nil? || options[:availability_zones].empty? - raise ArgumentError, "No :launch_configuration_name provided" if options[:launch_configuration_name].nil? || options[:launch_configuration_name].empty? - raise ArgumentError, "No :min_size provided" if options[:min_size].nil? - raise ArgumentError, "No :max_size provided" if options[:max_size].nil? - - params = {} - - params.merge!(pathlist('AvailabilityZones.member', [options[:availability_zones]].flatten)) - params['LaunchConfigurationName'] = options[:launch_configuration_name] - params['AutoScalingGroupName'] = options[:autoscaling_group_name] - params['MinSize'] = options[:min_size].to_s - params['MaxSize'] = options[:max_size].to_s - params.merge!(pathlist("LoadBalancerNames.member", [options[:load_balancer_names]].flatten)) if options.has_key?(:load_balancer_names) - params['Cooldown'] = options[:cooldown] if options[:cooldown] - - return response_generator(:action => "CreateAutoScalingGroup", :params => params) - end - - # Create or update scaling trigger - # This call sets the parameters that governs when and how to scale an AutoScalingGroup. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling group - # @option options [Array|Hash] :dimensions (nil) The dimensions associated with the metric used by the trigger to determine whether to activate - # This must be given as either an array or a hash - # When called as a hash, the values must look like: {:name => "name", :value => "value"} - # In the array format, the first value is assumed to be the name and the second is assumed to be the value - # @option options [String] :measure_name (nil) the measure name associated with the metric used by the trigger - # @option options [optional,String] :namespace (nil) namespace of the metric on which to trigger. Used to describe the monitoring metric. - # @option options [String|Integer] :period (nil) the period associated with the metric in seconds - # @option options [String] :statistic (nil) The particular statistic used by the trigger when fetching metric statistics to examine. Must be one of the following: Minimum, Maximum, Sum, Average - # @option options [String] :trigger_name (nil) the name for this trigger - # @option options [String] :unit (nil) the standard unit of measurement for a given measure - # @option options [String|Integer] :lower_threshold (nil) the lower limit for the metric. If all datapoints in the last :breach_duration seconds fall below the lower threshold, the trigger will activate - # @option options [String|Integer] :lower_breach_scale_increment (nil) the incremental amount to use when performing scaling activities when the lower threshold has been breached - # @option options [String|Integer] :upper_threshold (nil) the upper limit for the metric. If all datapoints in the last :breach_duration seconds exceed the upper threshold, the trigger will activate - # @option options [String|Integer] :upper_breach_scale_increment (nil) the incremental amount to use when performing scaling activities when the upper threshold has been breached - def create_or_updated_scaling_trigger( options = {} ) - if options[:dimensions].nil? || options[:dimensions].empty? - raise ArgumentError, "No :dimensions provided" - end - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - raise ArgumentError, "No :measure_name provided" if options[:measure_name].nil? || options[:measure_name].empty? - raise ArgumentError, "No :statistic provided" if options[:statistic].nil? || options[:statistic].empty? - raise ArgumentError, "No :period provided" if options[:period].nil? - raise ArgumentError, "No :trigger_name provided" if options[:trigger_name].nil? || options[:trigger_name].empty? - raise ArgumentError, "No :lower_threshold provided" if options[:lower_threshold].nil? - raise ArgumentError, "No :lower_breach_scale_increment provided" if options[:lower_breach_scale_increment].nil? - raise ArgumentError, "No :upper_threshold provided" if options[:upper_threshold].nil? - raise ArgumentError, "No :upper_breach_scale_increment provided" if options[:upper_breach_scale_increment].nil? - raise ArgumentError, "No :breach_duration provided" if options[:breach_duration].nil? - statistic_option_list = %w(minimum maximum average sum) - unless statistic_option_list.include?(options[:statistic].downcase) - - raise ArgumentError, "The statistic option must be one of the following: #{statistic_option_list.join(", ")}" - end - - params = {} - params['Unit'] = options[:unit] if options[:unit] - params['AutoScalingGroupName'] = options[:autoscaling_group_name] - case options[:dimensions] - when Array - params["Dimensions.member.1.Name"] = options[:dimensions][0] - params["Dimensions.member.1.Value"] = options[:dimensions][1] - when Hash - params["Dimensions.member.1.Name"] = options[:dimensions][:name] - params["Dimensions.member.1.Value"] = options[:dimensions][:value] - else - raise ArgumentError, "Dimensions must be either an array or a hash" - end - params['MeasureName'] = options[:measure_name] - params['Namespace'] = options[:namespace] if options[:namespace] - params['Statistic'] = options[:statistic] - params['Period'] = options[:period].to_s - params['TriggerName'] = options[:trigger_name] - params['LowerThreshold'] = options[:lower_threshold].to_s - params['LowerBreachScaleIncrement'] = options[:lower_breach_scale_increment].to_s - params['UpperThreshold'] = options[:upper_threshold].to_s - params['UpperBreachScaleIncrement'] = options[:upper_breach_scale_increment].to_s - params['BreachDuration'] = options[:breach_duration].to_s - - return response_generator(:action => "CreateOrUpdateScalingTrigger", :params => params) - end - - # Deletes all configuration for this AutoScalingGroup and also deletes the group. - # In order to successfully call this API, no triggers (and therefore, Scaling Activity) can be currently in progress. Once this call successfully executes, no further triggers will begin and the AutoScalingGroup will not be available for use in other API calls. See key term Trigger. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling group - def delete_autoscaling_group( options = {} ) - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - params = { 'AutoScalingGroupName' => options[:autoscaling_group_name] } - return response_generator(:action => "DeleteAutoScalingGroup", :params => params) - end - - # Deletes the given Launch Configuration. - # The launch configuration to be deleted must not be currently attached to any AutoScalingGroup. Once this call completes, the launch configuration is no longer available for use by any other API call. - # - # @option options [String] :launch_configuration_name (nil) the name of the launch_configuration - def delete_launch_configuration( options = {} ) - raise ArgumentError, "No :launch_configuration_name provided" if options[:launch_configuration_name].nil? || options[:launch_configuration_name].empty? - params = { 'LaunchConfigurationName' => options[:launch_configuration_name] } - return response_generator(:action => "DeleteLaunchConfiguration", :params => params) - end - - # Deletes the given trigger - # If a trigger is currently in progress, it will continue to run until its activities are complete. - # - # @option options [String] :trigger_name (nil) the name of the trigger to delete - def delete_trigger( options = {} ) - raise ArgumentError, "No :trigger_name provided" if options[:trigger_name].nil? || options[:trigger_name].empty? - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - params = { 'TriggerName' => options[:trigger_name], 'AutoScalingGroupName' => options[:autoscaling_group_name] } - return response_generator(:action => "DeleteTrigger", :params => params) - end - - # Describe autoscaling group - # Returns a full description of the AutoScalingGroups from the given list. This includes all EC2 instances that are members of the group. If a list of names is not provided, then the full details of all AutoScalingGroups is returned. This style conforms to the EC2 DescribeInstances API behavior. See key term AutoScalingGroup. - # - # @option options [Array] :autoscaling_group_names (nil) the name of the autoscaling groups to describe - def describe_autoscaling_groups( options = {} ) - options = { :autoscaling_group_names => [] }.merge(options) - params = pathlist("AutoScalingGroupNames.member", options[:autoscaling_group_names]) - return response_generator(:action => "DescribeAutoScalingGroups", :params => params) - end - - # Describe launch configurations - # Returns a full description of the launch configurations given the specified names. If no names are specified, then the full details of all launch configurations are returned. See key term Launch Configuration. - # - # @option options [Array] :launch_configuration_names (nil) the name of the launch_configurations to describe - def describe_launch_configurations( options = {} ) - options = { :launch_configuration_names => [] }.merge(options) - params = pathlist("AutoScalingGroupNames.member", options[:launch_configuration_names]) - params['MaxRecords'] = options[:max_records].to_s if options.has_key?(:max_records) - return response_generator(:action => "DescribeLaunchConfigurations", :params => params) - end - - # Describe autoscaling activities - # Returns the scaling activities specified for the given group. If the input list is empty, all the activities from the past six weeks will be returned. Activities will be sorted by completion time. Activities that have no completion time will be considered as using the most recent possible time. See key term Scaling Activity. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling_group_name - # @option options [String] :max_records (nil) the maximum number of scaling activities to return - # @option options [String] :launch_configuration_names (nil) activity_ids to return - def describe_scaling_activities( options = {} ) - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - - params = {} - params['AutoScalingGroupName'] = options[:autoscaling_group_name] - params['MaxRecords'] = options[:max_records] if options.has_key?(:max_records) - params['ActivityIds'] = options[:activity_ids] if options.has_key?(:activity_ids) - return response_generator(:action => "DescribeScalingActivities", :params => params) - end - - # Describe triggers - # Returns a full description of the trigger (see Trigger), in the specified AutoScalingGroup. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling_group_name - def describe_triggers( options = {} ) - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - params = {} - params['AutoScalingGroupName'] = options[:autoscaling_group_name] - - return response_generator(:action => "DescribeTriggers", :params => params) - end - - # Set desired capacity - # This API adjusts the desired size of the AutoScalingGroup by initiating scaling activities, as necessary. When adjusting the size of the group downward, it is not possible to define which EC2 instances will be terminated. This applies to any auto-scaling decisions that might result in the termination of instances. - # To check the scaling status of the system, query the desired capacity using DescribeAutoScalingGroups and then query the actual capacity using DescribeAutoScalingGroups and looking at the instance lifecycle state in order to understand how close the system is to the desired capacity at any given time. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling_group_name - # @option options [String] :desired_capacity (nil) the new capacity setting for the group - def set_desired_capacity( options = {} ) - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - raise ArgumentError, "No :desired_capacity provided" if options[:desired_capacity].nil? || options[:desired_capacity].empty? - - params = {} - params['AutoScalingGroupName'] = options[:autoscaling_group_name] - params['DesiredCapacity'] = options[:desired_capacity].to_s - - return response_generator(:action => "SetDesiredCapacity", :params => params) - end - - - # Terminate instance in an autoscaling group - # This call will terminate the specified Instance. Optionally, the desired group size can be adjusted. If set to true, the default, the AutoScalingGroup size will decrease by one. If the AutoScalingGroup is associated with a LoadBalancer, the system will deregister the instance before terminating it. - # This call simply registers a termination request. The termination of the instance can not happen immediately. - # - # @option options [String] :instance_id (nil) the instance id to terminate - # @option options [String] :decrement_desired_capacity (nil) specified whether terminating this instance should also decrement the size of the autoscaling group - def terminate_instance_in_autoscaling_group( options = {} ) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - - params = {} - params['InstanceId'] = options[:instance_id] - params['ShouldDecrementDesiredCapacity'] = options[:decrement_desired_capacity].to_s if options.has_key?(:decrement_desired_capacity) - - return response_generator(:action => "TerminateInstanceInAutoScalingGroup", :params => params) - end - - # Creates a new AutoScalingGroup with the specified name. - # Updates the configuration for the given AutoScalingGroup. If MaxSize is lower than the current size, then there will be an implicit call to SetDesiredCapacity to set the group to the new MaxSize. The same is true for MinSize there will also be an implicit call to SetDesiredCapacity. All optional parameters are left unchanged if not passed in the request.= - # The new settings are registered upon the completion of this call. Any launch configuration settings will take effect on any triggers after this call returns. However, triggers that are currently in progress can not be affected. See key term Trigger. - # - # @option options [String] :autoscaling_group_name (nil) the name of the autoscaling group - # @option options [Array] :availability_zones (nil) The availability_zones for the group - # @option options [String] :launch_configuration_name (nil) the name of the launch_configuration group - # @option options [String] :min_size (nil) minimum size of the group - # @option options [String] :max_size (nil) the maximum size of the group - # @option options [String] :cooldown (nil) the amount of time after a scaling activity complese before any further trigger-related scaling activities can start - def update_autoscaling_group( options = {}) - raise ArgumentError, "No :autoscaling_group_name provided" if options[:autoscaling_group_name].nil? || options[:autoscaling_group_name].empty? - - params = {} - - params.merge!(pathlist('AvailabilityZones.member', [options[:availability_zones]].flatten)) if options.has_key?(:availability_zones) - params['LaunchConfigurationName'] = options[:launch_configuration_name] if options.has_key?(:launch_configuration_name) - params['AutoScalingGroupName'] = options[:autoscaling_group_name] - params['MinSize'] = options[:min_size] if options.has_key?(:min_size) - params['MaxSize'] = options[:max_size] if options.has_key?(:max_size) - params['Cooldown'] = options[:cooldown] if options.has_key?(:cooldown) - - return response_generator(:action => "UpdateAutoScalingGroup", :params => params) - - end - - end - end -end - diff --git a/lib/AWS/Cloudwatch.rb b/lib/AWS/Cloudwatch.rb deleted file mode 100644 index 1db4266..0000000 --- a/lib/AWS/Cloudwatch.rb +++ /dev/null @@ -1,30 +0,0 @@ -module AWS - module Cloudwatch - - # Which host FQDN will we connect to for all API calls to AWS? - # If AWS_CLOUDWATCH_URL is defined in the users ENV we can override the default with that. - # - # @example - # export AWS_CLOUDWATCH_URL='https://montoring.amazonaws.com' - if ENV['AWS_CLOUDWATCH_URL'] - AWS_CLOUDWATCH_URL = ENV['AWS_CLOUDWATCH_URL'] - DEFAULT_HOST = URI.parse(AWS_CLOUDWATCH_URL).host - else - # Default US API endpoint - DEFAULT_HOST = 'monitoring.amazonaws.com' - end - - API_VERSION = '2009-05-15' - - class Base < AWS::Base - def api_version - API_VERSION - end - - def default_host - DEFAULT_HOST - end - end - - end -end \ No newline at end of file diff --git a/lib/AWS/Cloudwatch/monitoring.rb b/lib/AWS/Cloudwatch/monitoring.rb deleted file mode 100644 index 538debe..0000000 --- a/lib/AWS/Cloudwatch/monitoring.rb +++ /dev/null @@ -1,95 +0,0 @@ -module AWS - module Cloudwatch - class Base < AWS::Base - - # This method call lists available Cloudwatch metrics attached to your EC2 - # account. To get further information from the metrics, you'll then need to - # call get_metric_statistics. - # - # there are no options available to this method. - def list_metrics - return response_generator(:action => 'ListMetrics', :params => {}) - end - - # get_metric_statistics pulls a hashed array from Cloudwatch with the stats - # of your requested metric. - # Once you get the data out, if you assign the results into an object like: - # res = @mon.get_metric_statistics(:measure_name => 'RequestCount', \ - # :statistics => 'Average', :namespace => 'AWS/ELB') - # - # This call gets the average request count against your ELB at each sampling period - # for the last 24 hours. You can then attach a block to the following iterator - # to do whatever you need to: - # res['GetMetricStatisticsResult']['Datapoints']['member'].each - # - # @option options [String] :custom_unit (nil) not currently available, placeholder - # @option options [String] :dimensions (nil) Option to filter your data on. Check the developer guide - # @option options [Time] :end_time (Time.now()) Outer bound of the date range you want to view - # @option options [String] :measure_name (nil) The measure you want to check. Must correspond to - # => provided options - # @option options [String] :namespace ('AWS/EC2') The namespace of your measure_name. Currently, 'AWS/EC2' and 'AWS/ELB' are available - # @option options [Integer] :period (60) Granularity in seconds of the returned datapoints. Multiples of 60 only - # @option options [String] :statistics (nil) The statistics to be returned for your metric. See the developer guide for valid options. Required. - # @option options [Time] :start_time (Time.now() - 86400) Inner bound of the date range you want to view. Defaults to 24 hours ago - # @option options [String] :unit (nil) Standard unit for a given Measure. See the developer guide for valid options. - def get_metric_statistics ( options ={} ) - options = { :custom_unit => nil, - :dimensions => nil, - :end_time => Time.now(), #req - :measure_name => "", #req - :namespace => "AWS/EC2", - :period => 60, - :statistics => "", # req - :start_time => (Time.now() - 86400), # Default to yesterday - :unit => "" }.merge(options) - - raise ArgumentError, ":end_time must be provided" if options[:end_time].nil? - raise ArgumentError, ":end_time must be a Time object" if options[:end_time].class != Time - raise ArgumentError, ":start_time must be provided" if options[:start_time].nil? - raise ArgumentError, ":start_time must be a Time object" if options[:start_time].class != Time - raise ArgumentError, ":start_time must be before :end_time" if options[:start_time] > options[:end_time] - raise ArgumentError, ":measure_name must be provided" if options[:measure_name].nil? || options[:measure_name].empty? - raise ArgumentError, ":statistics must be provided" if options[:statistics].nil? || options[:statistics].empty? - - params = { - "CustomUnit" => options[:custom_unit], - "EndTime" => options[:end_time].iso8601, - "MeasureName" => options[:measure_name], - "Namespace" => options[:namespace], - "Period" => options[:period].to_s, - "StartTime" => options[:start_time].iso8601, - "Unit" => options[:unit] - } - - # FDT: Fix statistics and dimensions values - if !(options[:statistics].nil? || options[:statistics].empty?) - stats_params = {} - i = 1 - options[:statistics].split(',').each{ |stat| - stats_params.merge!( "Statistics.member.#{i}" => "#{stat}" ) - i += 1 - } - params.merge!( stats_params ) - end - - if !(options[:dimensions].nil? || options[:dimensions].empty?) - dims_params = {} - i = 1 - options[:dimensions].split(',').each{ |dimension| - dimension_var = dimension.split('=') - dims_params = dims_params.merge!( "Dimensions.member.#{i}.Name" => "#{dimension_var[0]}", "Dimensions.member.#{i}.Value" => "#{dimension_var[1]}" ) - i += 1 - } - params.merge!( dims_params ) - end - - return response_generator(:action => 'GetMetricStatistics', :params => params) - - end - - end - - end - -end - diff --git a/lib/AWS/EC2.rb b/lib/AWS/EC2.rb deleted file mode 100644 index 5850b28..0000000 --- a/lib/AWS/EC2.rb +++ /dev/null @@ -1,31 +0,0 @@ -module AWS - module EC2 - - # Which host FQDN will we connect to for all API calls to AWS? - # If EC2_URL is defined in the users ENV we can override the default with that. - # - # @example - # export EC2_URL='https://ec2.amazonaws.com' - if ENV['EC2_URL'] - EC2_URL = ENV['EC2_URL'] - DEFAULT_HOST = URI.parse(EC2_URL).host - else - # Default US API endpoint - DEFAULT_HOST = 'ec2.amazonaws.com' - end - - API_VERSION = '2010-08-31' - - class Base < AWS::Base - def api_version - API_VERSION - end - - def default_host - DEFAULT_HOST - end - end - - end -end - diff --git a/lib/AWS/EC2/availability_zones.rb b/lib/AWS/EC2/availability_zones.rb deleted file mode 100644 index 6775120..0000000 --- a/lib/AWS/EC2/availability_zones.rb +++ /dev/null @@ -1,29 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - # The DescribeAvailabilityZones operation describes availability zones that are currently - # available to the account and their states. - # - # An optional list of zone names can be passed. - # - # @option options [optional, String] :zone_name ([]) an Array of zone names - # - def describe_availability_zones( options = {} ) - options = { :zone_name => [] }.merge(options) - params = pathlist("ZoneName", options[:zone_name] ) - return response_generator(:action => "DescribeAvailabilityZones", :params => params) - end - - # Not yet implemented - # - # @todo Implement this method - # - def describe_regions( options = {} ) - raise "Not yet implemented" - end - - end - end -end - diff --git a/lib/AWS/EC2/console.rb b/lib/AWS/EC2/console.rb deleted file mode 100644 index 99078e3..0000000 --- a/lib/AWS/EC2/console.rb +++ /dev/null @@ -1,25 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - - # The GetConsoleOutput operation retrieves console output that has been posted for the specified instance. - # - # Instance console output is buffered and posted shortly after instance boot, reboot and once the instance - # is terminated. Only the most recent 64 KB of posted output is available. Console output is available for - # at least 1 hour after the most recent post. - # - # @option options [String] :instance_id ("") an Instance ID - # - def get_console_output( options = {} ) - options = {:instance_id => ""}.merge(options) - raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = { "InstanceId" => options[:instance_id] } - return response_generator(:action => "GetConsoleOutput", :params => params) - end - - - end - end -end - diff --git a/lib/AWS/EC2/devpay.rb b/lib/AWS/EC2/devpay.rb deleted file mode 100644 index 3587648..0000000 --- a/lib/AWS/EC2/devpay.rb +++ /dev/null @@ -1,18 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - - # Not yet implemented - # - # @todo Implement this method - # - def confirm_product_instance( options = {} ) - raise "Not yet implemented" - end - - - end - end -end - diff --git a/lib/AWS/EC2/elastic_ips.rb b/lib/AWS/EC2/elastic_ips.rb deleted file mode 100644 index e117dde..0000000 --- a/lib/AWS/EC2/elastic_ips.rb +++ /dev/null @@ -1,86 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - - # The AllocateAddress operation acquires an elastic IP address for use with your account. - # - def allocate_address - return response_generator(:action => "AllocateAddress") - end - - - # The AssociateAddress operation associates an elastic IP address with an instance. - # - # If the IP address is currently assigned to another instance, the IP address - # is assigned to the new instance. This is an idempotent operation. If you enter - # it more than once, Amazon EC2 does not return an error. - # - # @option options [String] :instance_id ('') the instance ID to associate an IP with. - # @option options [String] :public_ip ('') the public IP to associate an instance with. - # - def associate_address( options = {} ) - options = { :instance_id => '', :public_ip => '' }.merge(options) - raise ArgumentError, "No ':instance_id' provided" if options[:instance_id].nil? || options[:instance_id].empty? - raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty? - params = { - "InstanceId" => options[:instance_id], - "PublicIp" => options[:public_ip] - } - return response_generator(:action => "AssociateAddress", :params => params) - end - - - # The DescribeAddresses operation lists elastic IP addresses assigned to your account. - # - # @option options [Array] :public_ip ([]) an IP address to be described - # - def describe_addresses( options = {} ) - options = { :public_ip => [] }.merge(options) - params = pathlist("PublicIp", options[:public_ip]) - return response_generator(:action => "DescribeAddresses", :params => params) - end - - - # The DisassociateAddress operation disassociates the specified elastic IP - # address from the instance to which it is assigned. This is an idempotent - # operation. If you enter it more than once, Amazon EC2 does not return - # an error. - # - # @option options [String] :public_ip ('') the public IP to be dis-associated. - # - def disassociate_address( options = {} ) - options = { :public_ip => '' }.merge(options) - raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty? - params = { "PublicIp" => options[:public_ip] } - return response_generator(:action => "DisassociateAddress", :params => params) - end - - - # The ReleaseAddress operation releases an elastic IP address associated with your account. - # - # If you run this operation on an elastic IP address that is already released, the address - # might be assigned to another account which will cause Amazon EC2 to return an error. - # - # Note : Releasing an IP address automatically disassociates it from any instance - # with which it is associated. For more information, see DisassociateAddress. - # - # Important! After releasing an elastic IP address, it is released to the IP - # address pool and might no longer be available to your account. Make sure - # to update your DNS records and any servers or devices that communicate - # with the address. - # - # @option options [String] :public_ip ('') an IP address to be released. - # - def release_address( options = {} ) - options = { :public_ip => '' }.merge(options) - raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty? - params = { "PublicIp" => options[:public_ip] } - return response_generator(:action => "ReleaseAddress", :params => params) - end - - - end - end -end - diff --git a/lib/AWS/EC2/image_attributes.rb b/lib/AWS/EC2/image_attributes.rb deleted file mode 100644 index f232d9c..0000000 --- a/lib/AWS/EC2/image_attributes.rb +++ /dev/null @@ -1,133 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - # The ModifyImageAttribute operation modifies an attribute of an AMI. The following attributes may - # currently be modified: - # - # 'launchPermission' : Controls who has permission to launch the AMI. Launch permissions can be - # granted to specific users by adding userIds. The AMI can be made public by adding the 'all' group. - # - # 'productCodes' : Associates product codes with AMIs. This allows a developer to charge a user extra - # for using the AMIs. productCodes is a write once attribute - once it has been set it can not be - # changed or removed. Currently only one product code is supported per AMI. - # - # @option options [String] :image_id ("") - # @option options [String] :attribute ("launchPermission") An attribute to modify, "launchPermission" or "productCodes" - # @option options [String] :operation_type ("") - # @option options [optional, Array] :user_id ([]) - # @option options [optional, Array] :group ([]) - # @option options [optional, Array] :product_code ([]) - # - def modify_image_attribute( options = {} ) - - # defaults - options = { :image_id => "", - :attribute => "launchPermission", - :operation_type => "", - :user_id => [], - :group => [], - :product_code => [] }.merge(options) - - raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty? - raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty? - - # OperationType is not required if modifying a product code. - unless options[:attribute] == 'productCodes' - raise ArgumentError, "No ':operation_type' provided" if options[:operation_type].nil? || options[:operation_type].empty? - end - - params = { - "ImageId" => options[:image_id], - "Attribute" => options[:attribute], - "OperationType" => options[:operation_type] - } - - # test options provided and make sure they are valid - case options[:attribute] - when "launchPermission" - - unless options[:operation_type] == "add" || options[:operation_type] == "remove" - raise ArgumentError, ":operation_type was #{options[:operation_type].to_s} but must be either 'add' or 'remove'" - end - - if (options[:user_id].nil? || options[:user_id].empty?) && (options[:group].nil? || options[:group].empty?) - raise ArgumentError, "Option :attribute=>'launchPermission' requires ':user_id' or ':group' options to also be specified" - end - params.merge!(pathlist("UserId", options[:user_id])) unless options[:user_id].nil? - params.merge!(pathlist("Group", options[:group])) unless options[:group].nil? - when "productCodes" - if (options[:product_code].nil? || options[:product_code].empty?) - raise ArgumentError, "Option :attribute=>'productCodes' requires ':product_code' to be specified" - end - params.merge!(pathlist("ProductCode", options[:product_code])) unless options[:product_code].nil? - else - raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute." - end - - return response_generator(:action => "ModifyImageAttribute", :params => params) - - end - - # The DescribeImageAttribute operation returns information about an attribute of an AMI. - # - # @option options [String] :image_id ("") - # @option options [String] :attribute ("launchPermission") An attribute to describe, "launchPermission" or "productCodes" - # - def describe_image_attribute( options = {} ) - - # defaults - options = {:image_id => "", - :attribute => "launchPermission" - }.merge(options) - - raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty? - raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty? - - params = { "ImageId" => options[:image_id], "Attribute" => options[:attribute] } - - # test options provided and make sure they are valid - case options[:attribute] - when "launchPermission", "productCodes" - # these args are ok - else - raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute." - end - - return response_generator(:action => "DescribeImageAttribute", :params => params) - - end - - - # The ResetImageAttribute operation resets an attribute of an AMI to its default value. - # - # @option options [String] :image_id ("") - # @option options [String] :attribute ("launchPermission") An attribute to reset - # - def reset_image_attribute( options = {} ) - - # defaults - options = {:image_id => "", - :attribute => "launchPermission"}.merge(options) - - raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty? - raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty? - - params = {"ImageId" => options[:image_id], - "Attribute" => options[:attribute] } - - # test options provided and make sure they are valid - case options[:attribute] - when "launchPermission" - # these args are ok - else - raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute." - end - - return response_generator(:action => "ResetImageAttribute", :params => params) - - end - - end - end -end \ No newline at end of file diff --git a/lib/AWS/EC2/images.rb b/lib/AWS/EC2/images.rb deleted file mode 100644 index e579af9..0000000 --- a/lib/AWS/EC2/images.rb +++ /dev/null @@ -1,160 +0,0 @@ -module AWS - module EC2 - - class Base < AWS::Base - - # Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance. - # - # AMIs that use an Amazon EBS root device boot faster than AMIs that use instance stores. - # They can be up to 1 TiB in size, use storage that persists on instance failure, and can be - # stopped and started. - # - # @option options [String] :instance_id ("") The ID of the instance. - # @option options [String] :name ("") The name of the AMI that was provided during image creation. Constraints 3-128 alphanumeric characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_) - # @option options [optional,String] :description ("") The description of the AMI that was provided during image creation. - # @option options [optional,Boolean] :no_reboot (false) By default this property is set to false, which means Amazon EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. When set to true, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed. - # - def create_image( options = {} ) - options = { :instance_id => "", :name => "" }.merge(options) - raise ArgumentError, "No :instance_id provided" if options.does_not_have? :instance_id - raise ArgumentError, "No :name provided" if options.does_not_have? :name - raise ArgumentError, "Invalid string length for :name provided" if options[:name] && options[:name].size < 3 || options[:name].size > 128 - raise ArgumentError, "Invalid string length for :description provided (too long)" if options[:description] && options[:description].size > 255 - raise ArgumentError, ":no_reboot option must be a Boolean" unless options[:no_reboot].nil? || [true, false].include?(options[:no_reboot]) - params = {} - params["InstanceId"] = options[:instance_id].to_s - params["Name"] = options[:name].to_s - params["Description"] = options[:description].to_s - params["NoReboot"] = options[:no_reboot].to_s - return response_generator(:action => "CreateImage", :params => params) - end - - - # The DeregisterImage operation deregisters an AMI. Once deregistered, instances of the AMI may no - # longer be launched. - # - # @option options [String] :image_id ("") - # - def deregister_image( options = {} ) - options = { :image_id => "" }.merge(options) - raise ArgumentError, "No :image_id provided" if options[:image_id].nil? || options[:image_id].empty? - params = { "ImageId" => options[:image_id] } - return response_generator(:action => "DeregisterImage", :params => params) - end - - - # Registers an AMI with Amazon EC2. Images must be registered before they can be launched. - # To launch instances, use the RunInstances operation. Each AMI is associated with an unique ID - # which is provided by the Amazon EC2 service through this operation. If needed, you can deregister - # an AMI at any time. - # - # AMIs backed by Amazon EBS are automatically registered when you create the image. - # However, you can use this to register a snapshot of an instance backed by Amazon EBS. - # - # Amazon EBS snapshots are not guaranteed to be bootable. For information on creating AMIs - # backed by Amazon EBS, go to the Amazon Elastic Compute Cloud Developer Guide or Amazon - # Elastic Compute Cloud User Guide. - # - # Any modifications to an AMI backed by Amazon S3 invalidates this registration. - # If you make changes to an image, deregister the previous image and register the new image. - # - # If an :image_location is specified then an old-style S3-backed AMI is created. If the other - # parameters are used then a new style EBS-backed AMI is created from a pre-existing snapshot. - # - # @option options [optional, String] :image_location ("") S3 URL for the XML manifest - # @option options [optional, String] :name ("") Name of EBS image - # @option options [optional, String] :description ("") Description of EBS image - # @option options [optional, String] :architecture ("") Architecture of EBS image, currently 'i386' or 'x86_64' - # @option options [optional, String] :kernel_id ("") Kernel ID of EBS image - # @option options [optional, String] :ramdisk_id ("") Ramdisk ID of EBS image - # @option options [optional, String] :root_device_name ("") Root device name of EBS image, eg '/dev/sda1' - # @option options [optional, Array] :block_device_mapping ([]) An array of Hashes representing the elements of the block device mapping. e.g. [{:device_name => '/dev/sdh', :virtual_name => '', :ebs_snapshot_id => '', :ebs_volume_size => '', :ebs_delete_on_termination => ''},{},...] - # - def register_image( options = {} ) - params = {} - if options.does_not_have?(:image_location) && options.does_not_have?(:root_device_name) - raise ArgumentError, "No :image_location or :root_device_name" - end - params["ImageLocation"] = options[:image_location].to_s unless options[:image_location].nil? - params["Name"] = options[:name].to_s unless options[:name].nil? - params["Description"] = options[:description].to_s unless options[:description].nil? - params["Architecture"] = options[:architecture].to_s unless options[:architecture].nil? - params["KernelId"] = options[:kernel_id].to_s unless options[:kernel_id].nil? - params["RamdiskId"] = options[:ramdisk_id].to_s unless options[:ramdisk_id].nil? - params["RootDeviceName"] = options[:root_device_name].to_s unless options[:root_device_name].nil? - if options[:block_device_mapping] - params.merge!(pathhashlist("BlockDeviceMapping", options[:block_device_mapping].flatten, { - :device_name => "DeviceName", - :virtual_name => "VirtualName", - :ebs_snapshot_id => "Ebs.SnapshotId", - :ebs_volume_size => "Ebs.VolumeSize", - :ebs_delete_on_termination => "Ebs.DeleteOnTermination" - })) - end - return response_generator(:action => "RegisterImage", :params => params) - end - - - # The DescribeImages operation returns information about AMIs available for use by the user. This - # includes both public AMIs (those available for any user to launch) and private AMIs (those owned by - # the user making the request and those owned by other users that the user making the request has explicit - # launch permissions for). - # - # The list of AMIs returned can be modified via optional lists of AMI IDs, owners or users with launch - # permissions. If all three optional lists are empty all AMIs the user has launch permissions for are - # returned. Launch permissions fall into three categories: - # - # Launch Permission Description - # - # public - The all group has launch permissions for the AMI. All users have launch permissions for these AMIs. - # explicit - The owner of the AMIs has granted a specific user launch permissions for the AMI. - # implicit - A user has implicit launch permissions for all AMIs he or she owns. - # - # If one or more of the lists are specified the result set is the intersection of AMIs matching the criteria of - # the individual lists. - # - # Providing the list of AMI IDs requests information for those AMIs only. If no AMI IDs are provided, - # information of all relevant AMIs will be returned. If an AMI is specified that does not exist a fault is - # returned. If an AMI is specified that exists but the user making the request does not have launch - # permissions for, then that AMI will not be included in the returned results. - # - # Providing the list of owners requests information for AMIs owned by the specified owners only. Only - # AMIs the user has launch permissions for are returned. The items of the list may be account ids for - # AMIs owned by users with those account ids, amazon for AMIs owned by Amazon or self for AMIs - # owned by the user making the request. - # - # The executable list may be provided to request information for AMIs that only the specified users have - # launch permissions for. The items of the list may be account ids for AMIs owned by the user making the - # request that the users with the specified account ids have explicit launch permissions for, self for AMIs - # the user making the request has explicit launch permissions for or all for public AMIs. - # - # Deregistered images will be included in the returned results for an unspecified interval subsequent to - # deregistration. - # - # The results can be filtered using the filter argument. The EC2 API reference for a full description of - # filter types and arguments. - # - # @example - # @ec2.describe_images(:owner_id => ['self'], :filter => [{"tag:Role" => "App"}]) - # - # @option options [Array] :image_id ([]) - # @option options [Array] :owner_id ([]) - # @option options [Array] :executable_by ([]) - # @option options [Array] :filter ([]) - # - def describe_images( options = {} ) - options = { :image_id => [], :owner_id => [], :executable_by => [] }.merge(options) - params = pathlist( "ImageId", options[:image_id] ) - params.merge!(pathlist( "Owner", options[:owner_id] )) - params.merge!(pathlist( "ExecutableBy", options[:executable_by] )) - if options[:filter] - params.merge!(pathkvlist('Filter', options[:filter], 'Name', 'Value', {})) - end - return response_generator(:action => "DescribeImages", :params => params) - end - - - end - end -end - diff --git a/lib/AWS/EC2/instances.rb b/lib/AWS/EC2/instances.rb deleted file mode 100644 index 71f7653..0000000 --- a/lib/AWS/EC2/instances.rb +++ /dev/null @@ -1,299 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - # Launches a specified number of instances of an AMI for which you have permissions. - # - # Amazon API Docs : HTML[http://docs.amazonwebservices.com/AWSEC2/2009-10-31/APIReference/index.html?ApiReference-query-RunInstances.html] - # - # @option options [String] :image_id ("") Unique ID of a machine image. - # @option options [Integer] :min_count (1) Minimum number of instances to launch. If the value is more than Amazon EC2 can launch, no instances are launched at all. - # @option options [Integer] :max_count (1) Maximum number of instances to launch. If the value is more than Amazon EC2 can launch, the largest possible number above minCount will be launched instead. - # @option options [optional, String] :key_name (nil) The name of the key pair. - # @option options [optional, Array] :security_group (nil) Name of the security group(s). Array of Strings or String. - # @option options [optional, String] :additional_info (nil) Specifies additional information to make available to the instance(s). - # @option options [optional, String] :user_data (nil) MIME, Base64-encoded user data. - # @option options [optional, String] :instance_type (nil) Specifies the instance type. - # @option options [optional, String] :availability_zone (nil) Specifies the placement constraints (Availability Zones) for launching the instances. - # @option options [optional, String] :kernel_id (nil) The ID of the kernel with which to launch the instance. - # @option options [optional, String] :ramdisk_id (nil) The ID of the RAM disk with which to launch the instance. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk. To find kernel requirements, go to the Resource Center and search for the kernel ID. - # @option options [optional, Array] :block_device_mapping ([]) An array of Hashes representing the elements of the block device mapping. e.g. [{:device_name => '/dev/sdh', :virtual_name => '', :ebs_snapshot_id => '', :ebs_volume_size => '', :ebs_delete_on_termination => ''},{},...] - # @option options [optional, Boolean] :monitoring_enabled (false) Enables monitoring for the instance. - # @option options [optional, String] :subnet_id (nil) Specifies the Amazon VPC subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud. - # @option options [optional, Boolean] :disable_api_termination (true) Specifies whether the instance can be terminated using the APIs. You must modify this attribute before you can terminate any "locked" instances from the APIs. - # @option options [optional, String] :instance_initiated_shutdown_behavior ('stop') Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the instance is shut down. Valid values : 'stop', 'terminate' - # @option options [optional, Boolean] :base64_encoded (false) - # @option options [optional, String] :client_token (nil) Unique, case-sensitive identifier you provide to ensure idempotency of the request - # - def run_instances( options = {} ) - options = { :image_id => "", - :min_count => 1, - :max_count => 1, - :base64_encoded => false }.merge(options) - - raise ArgumentError, ":addressing_type has been deprecated." if options[:addressing_type] - raise ArgumentError, ":group_id has been deprecated." if options[:group_id] - - raise ArgumentError, ":image_id must be provided" if options[:image_id].nil? || options[:image_id].empty? - raise ArgumentError, ":min_count is not valid" unless options[:min_count].to_i > 0 - raise ArgumentError, ":max_count is not valid or must be >= :min_count" unless options[:max_count].to_i > 0 && options[:max_count].to_i >= options[:min_count].to_i - raise ArgumentError, ":instance_type must specify a valid instance type" unless options[:instance_type].nil? || ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].include?(options[:instance_type]) - raise ArgumentError, ":monitoring_enabled must be 'true' or 'false'" unless options[:monitoring_enabled].nil? || [true, false].include?(options[:monitoring_enabled]) - raise ArgumentError, ":disable_api_termination must be 'true' or 'false'" unless options[:disable_api_termination].nil? || [true, false].include?(options[:disable_api_termination]) - raise ArgumentError, ":instance_initiated_shutdown_behavior must be 'stop' or 'terminate'" unless options[:instance_initiated_shutdown_behavior].nil? || ["stop", "terminate"].include?(options[:instance_initiated_shutdown_behavior]) - raise ArgumentError, ":base64_encoded must be 'true' or 'false'" unless [true, false].include?(options[:base64_encoded]) - - user_data = extract_user_data(options) - - params = {} - - if options[:security_group] - params.merge!(pathlist("SecurityGroup", options[:security_group])) - end - - if options[:block_device_mapping] - params.merge!(pathhashlist('BlockDeviceMapping', options[:block_device_mapping].flatten, {:device_name => 'DeviceName', :virtual_name => 'VirtualName', :ebs_snapshot_id => 'Ebs.SnapshotId', :ebs_volume_size => 'Ebs.VolumeSize', :ebs_delete_on_termination => 'Ebs.DeleteOnTermination' })) - end - - params["ImageId"] = options[:image_id] - params["MinCount"] = options[:min_count].to_s - params["MaxCount"] = options[:max_count].to_s - params["KeyName"] = options[:key_name] unless options[:key_name].nil? - params["AdditionalInfo"] = options[:additional_info] unless options[:additional_info].nil? - params["UserData"] = user_data unless user_data.nil? - params["InstanceType"] = options[:instance_type] unless options[:instance_type].nil? - params["Placement.AvailabilityZone"] = options[:availability_zone] unless options[:availability_zone].nil? - params["KernelId"] = options[:kernel_id] unless options[:kernel_id].nil? - params["RamdiskId"] = options[:ramdisk_id] unless options[:ramdisk_id].nil? - params["Monitoring.Enabled"] = options[:monitoring_enabled].to_s unless options[:monitoring_enabled].nil? - params["SubnetId"] = options[:subnet_id] unless options[:subnet_id].nil? - params["DisableApiTermination"] = options[:disable_api_termination].to_s unless options[:disable_api_termination].nil? - params["InstanceInitiatedShutdownBehavior"] = options[:instance_initiated_shutdown_behavior] unless options[:instance_initiated_shutdown_behavior].nil? - params["ClientToken"] = options[:client_token].to_s unless options[:client_token].nil? - - return response_generator(:action => "RunInstances", :params => params) - end - - # The DescribeInstances operation returns information about instances owned by the user - # making the request. - # - # An optional list of instance IDs may be provided to request information for those instances only. If no - # instance IDs are provided, information of all relevant instances information will be returned. If an - # instance is specified that does not exist a fault is returned. If an instance is specified that exists but is not - # owned by the user making the request, then that instance will not be included in the returned results. - # - # Recently terminated instances will be included in the returned results for a small interval subsequent to - # their termination. This interval is typically of the order of one hour - # - # @option options [Array] :instance_id ([]) - # - def describe_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - params = pathlist("InstanceId", options[:instance_id]) - return response_generator(:action => "DescribeInstances", :params => params) - end - - - # Returns information about an attribute of an instance. - # - # @option options [String] :instance_id (nil) ID of the instance on which the attribute will be queried. - # @option options [String] :attribute (nil) Specifies the attribute to query.. - # - def describe_instance_attribute( options = {} ) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - raise ArgumentError, "No :attribute provided" if options[:attribute].nil? || options[:attribute].empty? - valid_attributes = %w(instanceType kernel ramdisk userData disableApiTermination instanceInitiatedShutdownBehavior rootDevice blockDeviceMapping) - raise ArgumentError, "Invalid :attribute provided" unless valid_attributes.include?(options[:attribute].to_s) - params = {} - params["InstanceId"] = options[:instance_id] - params["Attribute"] = options[:attribute] - return response_generator(:action => "DescribeInstanceAttribute", :params => params) - end - - - # Modifies an attribute of an instance. - # - # @option options [String] :instance_id (nil) ID of the instance on which the attribute will be modified. - # @option options [String] :attribute (nil) Specifies the attribute to modify. - # @option options [String] :value (nil) The value of the attribute being modified. - # - def modify_instance_attribute( options = {} ) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - raise ArgumentError, "No :attribute provided" if options[:attribute].nil? || options[:attribute].empty? - raise ArgumentError, "No :value provided" if options[:value].nil? - valid_attributes = %w(instanceType kernel ramdisk userData disableApiTermination instanceInitiatedShutdownBehavior rootDevice blockDeviceMapping) - raise ArgumentError, "Invalid :attribute provided" unless valid_attributes.include?(options[:attribute].to_s) - params = {} - params["InstanceId"] = options[:instance_id] - params["Attribute"] = options[:attribute] - params["Value"] = options[:value].to_s - return response_generator(:action => "ModifyInstanceAttribute", :params => params) - end - - - # Resets an attribute of an instance to its default value. - # - # @option options [String] :instance_id (nil) ID of the instance on which the attribute will be reset. - # @option options [String] :attribute (nil) The instance attribute to reset to the default value. - # - def reset_instance_attribute( options = {} ) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - raise ArgumentError, "No :attribute provided" if options[:attribute].nil? || options[:attribute].empty? - valid_attributes = %w(kernel ramdisk) - raise ArgumentError, "Invalid :attribute provided" unless valid_attributes.include?(options[:attribute].to_s) - params = {} - params["InstanceId"] = options[:instance_id] - params["Attribute"] = options[:attribute] - return response_generator(:action => "ResetInstanceAttribute", :params => params) - end - - - # Starts an instance that uses an Amazon EBS volume as its root device. - # - # @option options [Array] :instance_id ([]) Array of unique instance ID's of stopped instances. - # - def start_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = {} - params.merge!(pathlist("InstanceId", options[:instance_id])) - return response_generator(:action => "StartInstances", :params => params) - end - - - # Stops an instance that uses an Amazon EBS volume as its root device. - # - # @option options [Array] :instance_id ([]) Unique instance ID of a running instance. - # @option options [optional, Boolean] :force (false) Forces the instance to stop. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances. - # - def stop_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - raise ArgumentError, ":force must be 'true' or 'false'" unless options[:force].nil? || [true, false].include?(options[:force]) - params = {} - params.merge!(pathlist("InstanceId", options[:instance_id])) - params["Force"] = options[:force].to_s unless options[:force].nil? - return response_generator(:action => "StopInstances", :params => params) - end - - - # The RebootInstances operation requests a reboot of one or more instances. This operation is - # asynchronous; it only queues a request to reboot the specified instance(s). The operation will succeed - # provided the instances are valid and belong to the user. Terminated instances will be ignored. - # - # @option options [Array] :instance_id ([]) - # - def reboot_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - raise ArgumentError, "No instance IDs provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = pathlist("InstanceId", options[:instance_id]) - return response_generator(:action => "RebootInstances", :params => params) - end - - - # The TerminateInstances operation shuts down one or more instances. This operation is idempotent - # and terminating an instance that is in the process of shutting down (or already terminated) will succeed. - # Terminated instances remain visible for a short period of time (approximately one hour) after - # termination, after which their instance ID is invalidated. - # - # @option options [Array] :instance_id ([]) - # - def terminate_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = pathlist("InstanceId", options[:instance_id]) - return response_generator(:action => "TerminateInstances", :params => params) - end - - - # The MonitorInstances operation tells Cloudwatch to begin logging metrics from one or more EC2 instances - # - # @option options [Array] :instance_id ([]) - # - def monitor_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = pathlist("InstanceId", options[:instance_id]) - return response_generator(:action => "MonitorInstances", :params => params) - end - - - # The UnmonitorInstances operation tells Cloudwatch to stop logging metrics from one or more EC2 instances - # - # @option options [Array] :instance_id ([]) - # - def unmonitor_instances( options = {} ) - options = { :instance_id => [] }.merge(options) - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = pathlist("InstanceId", options[:instance_id]) - return response_generator(:action => "UnmonitorInstances", :params => params) - end - - - # Not yet implemented - # - # @todo Implement this method - # - def describe_reserved_instances( options = {} ) - raise "Not yet implemented" - end - - - # Not yet implemented - # - # @todo Implement this method - # - def describe_reserved_instances_offerings( options = {} ) - raise "Not yet implemented" - end - - - # Not yet implemented - # - # @todo Implement this method - # - def purchase_reserved_instances_offering( options = {} ) - raise "Not yet implemented" - end - - - - end - - # - # A set of methods for querying amazon's ec2 meta-data service. - # Note : This can ONLY be run on an actual running EC2 instance. - # - # Example Class Method Usage : - # instance_id = AWS::EC2::Instance.local_instance_id - # - class Instance - - EC2_META_URL_BASE = 'http://169.254.169.254/latest/meta-data/' - - # - # Returns the current instance-id when called from a host within EC2. - # - def self.local_instance_id - Net::HTTP.get URI.parse(EC2_META_URL_BASE + 'instance-id') - end - - # - # Returns a hash of all available instance meta data. - # - def self.local_instance_meta_data - meta_data = {} - - Net::HTTP.get(URI.parse(EC2_META_URL_BASE)).split("\n").each do |meta_type| - meta_data.merge!({meta_type => Net::HTTP.get(URI.parse(EC2_META_URL_BASE + meta_type)) }) - end - - return meta_data - end - - end - - - end -end - diff --git a/lib/AWS/EC2/keypairs.rb b/lib/AWS/EC2/keypairs.rb deleted file mode 100644 index ff58f17..0000000 --- a/lib/AWS/EC2/keypairs.rb +++ /dev/null @@ -1,47 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - - # The CreateKeyPair operation creates a new 2048 bit RSA keypair and returns a unique ID that can be - # used to reference this keypair when launching new instances. - # - # @option options [String] :key_name ("") - # - def create_keypair( options = {} ) - options = { :key_name => "" }.merge(options) - raise ArgumentError, "No :key_name provided" if options[:key_name].nil? || options[:key_name].empty? - params = { "KeyName" => options[:key_name] } - return response_generator(:action => "CreateKeyPair", :params => params) - end - - - # The DescribeKeyPairs operation returns information about keypairs available for use by the user - # making the request. Selected keypairs may be specified or the list may be left empty if information for - # all registered keypairs is required. - # - # @option options [Array] :key_name ([]) - # - def describe_keypairs( options = {} ) - options = { :key_name => [] }.merge(options) - params = pathlist("KeyName", options[:key_name] ) - return response_generator(:action => "DescribeKeyPairs", :params => params) - end - - - # The DeleteKeyPair operation deletes a keypair. - # - # @option options [String] :key_name ("") - # - def delete_keypair( options = {} ) - options = { :key_name => "" }.merge(options) - raise ArgumentError, "No :key_name provided" if options[:key_name].nil? || options[:key_name].empty? - params = { "KeyName" => options[:key_name] } - return response_generator(:action => "DeleteKeyPair", :params => params) - end - - - end - end -end - diff --git a/lib/AWS/EC2/password.rb b/lib/AWS/EC2/password.rb deleted file mode 100644 index 06c9d16..0000000 --- a/lib/AWS/EC2/password.rb +++ /dev/null @@ -1,20 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - - # The GetPasswordData operation retrieves the encrypted administrator password for the instances running Window. - # - # @option options [String] :instance_id ("") an Instance ID - # - def get_password_data( options = {} ) - options = {:instance_id => ""}.merge(options) - raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = { "InstanceId" => options[:instance_id] } - return response_generator(:action => "GetPasswordData", :params => params) - end - - - end - end -end diff --git a/lib/AWS/EC2/products.rb b/lib/AWS/EC2/products.rb deleted file mode 100644 index 88ad654..0000000 --- a/lib/AWS/EC2/products.rb +++ /dev/null @@ -1,21 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - # The ConfirmProductInstance operation returns true if the given product code is attached to the instance - # with the given instance id. False is returned if the product code is not attached to the instance. - # - # @option options [String] :product_code ("") - # @option options [String] :instance_id ("") - # - def confirm_product_instance( options ={} ) - options = {:product_code => "", :instance_id => ""}.merge(options) - raise ArgumentError, "No product code provided" if options[:product_code].nil? || options[:product_code].empty? - raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty? - params = { "ProductCode" => options[:product_code], "InstanceId" => options[:instance_id] } - return response_generator(:action => "ConfirmProductInstance", :params => params) - end - - end - end -end \ No newline at end of file diff --git a/lib/AWS/EC2/security_groups.rb b/lib/AWS/EC2/security_groups.rb deleted file mode 100644 index 53073f9..0000000 --- a/lib/AWS/EC2/security_groups.rb +++ /dev/null @@ -1,166 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - - # The CreateSecurityGroup operation creates a new security group. Every instance is launched - # in a security group. If none is specified as part of the launch request then instances - # are launched in the default security group. Instances within the same security group have - # unrestricted network access to one another. Instances will reject network access attempts from other - # instances in a different security group. As the owner of instances you may grant or revoke specific - # permissions using the AuthorizeSecurityGroupIngress and RevokeSecurityGroupIngress operations. - # - # @option options [String] :group_name ("") - # @option options [String] :group_description ("") - # - def create_security_group( options = {} ) - options = {:group_name => "", - :group_description => "" - }.merge(options) - raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty? - raise ArgumentError, "No :group_description provided" if options[:group_description].nil? || options[:group_description].empty? - params = { - "GroupName" => options[:group_name], - "GroupDescription" => options[:group_description] - } - return response_generator(:action => "CreateSecurityGroup", :params => params) - end - - - # The DescribeSecurityGroups operation returns information about security groups owned by the - # user making the request. - # - # An optional list of security group names may be provided to request information for those security - # groups only. If no security group names are provided, information of all security groups will be - # returned. If a group is specified that does not exist an exception is returned. - # - # @option options [optional, Array] :group_name ([]) - # - def describe_security_groups( options = {} ) - options = { :group_name => [] }.merge(options) - params = pathlist("GroupName", options[:group_name] ) - return response_generator(:action => "DescribeSecurityGroups", :params => params) - end - - - # The DeleteSecurityGroup operation deletes a security group. - # - # If an attempt is made to delete a security group and any instances exist that are members of that group a - # fault is returned. - # - # @option options [String] :group_name ("") - # - def delete_security_group( options = {} ) - options = { :group_name => "" }.merge(options) - raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty? - params = { "GroupName" => options[:group_name] } - return response_generator(:action => "DeleteSecurityGroup", :params => params) - end - - - # The AuthorizeSecurityGroupIngress operation adds permissions to a security group. - # - # Permissions are specified in terms of the IP protocol (TCP, UDP or ICMP), the source of the request (by - # IP range or an Amazon EC2 user-group pair), source and destination port ranges (for TCP and UDP), - # and ICMP codes and types (for ICMP). When authorizing ICMP, -1 may be used as a wildcard in the - # type and code fields. - # - # Permission changes are propagated to instances within the security group being modified as quickly as - # possible. However, a small delay is likely, depending on the number of instances that are members of - # the indicated group. - # - # When authorizing a user/group pair permission, GroupName, SourceSecurityGroupName and - # SourceSecurityGroupOwnerId must be specified. When authorizing a CIDR IP permission, - # GroupName, IpProtocol, FromPort, ToPort and CidrIp must be specified. Mixing these two types - # of parameters is not allowed. - # - # @option options [String] :group_name ("") - # @option options [optional, String] :ip_protocol (nil) Required when authorizing CIDR IP permission - # @option options [optional, Integer] :from_port (nil) Required when authorizing CIDR IP permission - # @option options [optional, Integer] :to_port (nil) Required when authorizing CIDR IP permission - # @option options [optional, String] :cidr_ip (nil) Required when authorizing CIDR IP permission - # @option options [optional, String] :source_security_group_name (nil) Required when authorizing user group pair permissions - # @option options [optional, String] :source_security_group_user_id (nil) Required when authorizing user group pair permissions - # - def authorize_security_group_ingress( options = {} ) - options = { :group_name => nil, - :ip_protocol => nil, - :from_port => nil, - :to_port => nil, - :cidr_ip => nil, - :source_security_group_name => nil, - :source_security_group_user_id => nil }.merge(options) - - # lets not validate the rest of the possible permutations of required params and instead let - # EC2 sort it out on the server side. We'll only require :group_name as that is always needed. - raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty? - - params = { "GroupName" => options[:group_name], - "IpPermissions.1.IpProtocol" => options[:ip_protocol], - "IpPermissions.1.FromPort" => options[:from_port].to_s, - "IpPermissions.1.ToPort" => options[:to_port].to_s, - "IpPermissions.1.IpRanges.1" => options[:cidr_ip], - "IpPermissions.1.Groups.1.GroupName" => options[:source_security_group_name], - "IpPermissions.1.Groups.1.UserId" => options[:source_security_group_user_id] - } - - return response_generator(:action => "AuthorizeSecurityGroupIngress", :params => params) - end - - - # The RevokeSecurityGroupIngress operation revokes existing permissions that were previously - # granted to a security group. The permissions to revoke must be specified using the same values - # originally used to grant the permission. - # - # Permissions are specified in terms of the IP protocol (TCP, UDP or ICMP), the source of the request (by - # IP range or an Amazon EC2 user-group pair), source and destination port ranges (for TCP and UDP), - # and ICMP codes and types (for ICMP). When authorizing ICMP, -1 may be used as a wildcard in the - # type and code fields. - # - # Permission changes are propagated to instances within the security group being modified as quickly as - # possible. However, a small delay is likely, depending on the number of instances that are members of - # the indicated group. - # - # When revoking a user/group pair permission, GroupName, SourceSecurityGroupName and - # SourceSecurityGroupOwnerId must be specified. When authorizing a CIDR IP permission, - # GroupName, IpProtocol, FromPort, ToPort and CidrIp must be specified. Mixing these two types - # of parameters is not allowed. - # - # @option options [String] :group_name ("") - # @option options [optional, String] :ip_protocol (nil) Required when revoking CIDR IP permission - # @option options [optional, Integer] :from_port (nil) Required when revoking CIDR IP permission - # @option options [optional, Integer] :to_port (nil) Required when revoking CIDR IP permission - # @option options [optional, String] :cidr_ip (nil) Required when revoking CIDR IP permission - # @option options [optional, String] :source_security_group_name (nil) Required when revoking user group pair permissions - # @option options [optional, String] :source_security_group_user_id (nil) Required when revoking user group pair permissions - # - def revoke_security_group_ingress( options = {} ) - options = { :group_name => nil, - :ip_protocol => nil, - :from_port => nil, - :to_port => nil, - :cidr_ip => nil, - :source_security_group_name => nil, - :source_security_group_user_id => nil }.merge(options) - - # lets not validate the rest of the possible permutations of required params and instead let - # EC2 sort it out on the server side. We'll only require :group_name as that is always needed. - raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty? - - params = { "GroupName" => options[:group_name], - "IpPermissions.1.IpProtocol" => options[:ip_protocol], - "IpPermissions.1.FromPort" => options[:from_port].to_s, - "IpPermissions.1.ToPort" => options[:to_port].to_s, - "IpPermissions.1.IpRanges.1" => options[:cidr_ip], - "IpPermissions.1.Groups.1.GroupName" => options[:source_security_group_name], - "IpPermissions.1.Groups.1.UserId" => options[:source_security_group_user_id] - } - - return response_generator(:action => "RevokeSecurityGroupIngress", :params => params) - end - - - end - end -end - diff --git a/lib/AWS/EC2/snapshots.rb b/lib/AWS/EC2/snapshots.rb deleted file mode 100644 index e339517..0000000 --- a/lib/AWS/EC2/snapshots.rb +++ /dev/null @@ -1,104 +0,0 @@ -module AWS - module EC2 - - 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,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["RestorableBy"] = options[:restorable_by] unless options[:restorable_by].nil? - params["Owner"] = options[:owner] unless options[:owner].nil? - return response_generator(:action => "DescribeSnapshots", :params => params) - end - - - # The CreateSnapshot operation creates a snapshot of an Amazon EBS volume and stores it in Amazon S3. You can use snapshots for backups, to launch instances from identical snapshots, and to save data before shutting down an instance. - # - # @option options [String] :volume_id ('') - # @option options [optional,String] :description ('') Description of the Amazon EBS snapshot. - # - def create_snapshot( options = {} ) - options = { :volume_id => '' }.merge(options) - raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty? - params = { - "VolumeId" => options[:volume_id] - } - params["Description"] = options[:description] unless options[:description].nil? - return response_generator(:action => "CreateSnapshot", :params => params) - end - - - # The DeleteSnapshot operation deletes a snapshot of an Amazon EBS volume that is stored in Amazon S3. - # - # @option options [String] :snapshot_id ('') - # - def delete_snapshot( options = {} ) - options = { :snapshot_id => '' }.merge(options) - raise ArgumentError, "No :snapshot_id provided" if options[:snapshot_id].nil? || options[:snapshot_id].empty? - params = { - "SnapshotId" => options[:snapshot_id] - } - return response_generator(:action => "DeleteSnapshot", :params => params) - end - - - # The DescribeSnapshotAttribute operation returns information about an attribute of a snapshot. Only one attribute can be specified per call. - # - # @option options [String] :attribute ('createVolumePermission') Attribute to modify. - # @option options [optional,Array] :snapshot_id ([]) The ID of the Amazon EBS snapshot. - # - def describe_snapshot_attribute( options = {} ) - params = { "Attribute" => options[:attribute] || 'createVolumePermission' } - params.merge!(pathlist("SnapshotId", options[:snapshot_id] )) unless options[:snapshot_id].nil? || options[:snapshot_id] == [] - return response_generator(:action => "DescribeSnapshotAttribute", :params => params) - end - - - # The ModifySnapshotAttribute operation adds or remove permission settings for the specified snapshot. - # - # @option options [String] :snapshot_id ('') The ID of the Amazon EBS snapshot. - # @option options [String] :attribute ('createVolumePermission') Attribute to modify. - # @option options [String] :operation_type ('') Operation to perform on the attribute. - # @option options [optional,String] :user_id ('') Account ID of a user that can create volumes from the snapshot. - # @option options [optional,String] :user_group ('') Group that is allowed to create volumes from the snapshot. - # - def modify_snapshot_attribute( options = {} ) - options = { :snapshot_id => '' }.merge(options) - raise ArgumentError, "No :snapshot_id provided" if options[:snapshot_id].nil? || options[:snapshot_id].empty? - options = { :operation_type => '' }.merge(options) - raise ArgumentError, "No :operation_type provided" if options[:snapshot_id].nil? || options[:snapshot_id].empty? - params = { - "Attribute" => options[:attribute] || 'createVolumePermission', - "SnapshotId" => options[:snapshot_id], - "OperationType" => options[:operation_type] - } - params["UserId"] = options[:user_id] unless options[:user_id].nil? - params["UserGroup"] = options[:user_group] unless options[:user_group].nil? - return response_generator(:action => "ModifySnapshotAttribute", :params => params) - end - - - # The ResetSnapshotAttribute operation resets permission settings for the specified snapshot. - # - # @option options [optional,Array] :snapshot_id ([]) The ID of the Amazon EBS snapshot. - # @option options [String] :attribute ('createVolumePermission') Attribute to reset. - # - def reset_snapshot_attribute( options = {} ) - options = { :snapshot_id => '' }.merge(options) - raise ArgumentError, "No :snapshot_id provided" if options[:snapshot_id].nil? || options[:snapshot_id].empty? - params = { "Attribute" => options[:attribute] || 'createVolumePermission' } - params["SnapshotId"] = options[:snapshot_id] unless options[:snapshot_id].nil? || options[:snapshot_id].empty? - return response_generator(:action => "ResetSnapshotAttribute", :params => params) - end - - end - end -end - diff --git a/lib/AWS/EC2/spot_instance_requests.rb b/lib/AWS/EC2/spot_instance_requests.rb deleted file mode 100644 index 52cc1cc..0000000 --- a/lib/AWS/EC2/spot_instance_requests.rb +++ /dev/null @@ -1,108 +0,0 @@ -module AWS - module EC2 - - class Base < AWS::Base - - # Creates a Spot Instance request. Spot Instances are instances that Amazon EC2 starts on your behalf - # when the maximum price that you specify exceeds the current Spot Price. Amazon EC2 periodically sets - # the Spot Price based on available Spot Instance capacity and current spot instance requests. For conceptual - # information about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon Elastic - # Compute Cloud User Guide. - # - # @option options [String] :spot_price (nil) Specifies the maximum hourly price for any Spot Instance launched to fulfill the request. - # @option options [optional,Integer] :instance_count (1) The maximum number of Spot Instances to launch. - # @option options [optional,String] :type (nil) Specifies the Spot Instance type. - # @option options [optional,Date] :valid_from (nil) Start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled. - # @option options [optional,Date] :valid_until (nil) End date of the request. If this is a one-time request, the request remains active until all instances launch, the request is canceled, or this date is reached. If the request is persistent, it remains active until it is canceled or this date and time is reached. - # @option options [optional,String] :launch_group (nil) Specifies the instance launch group. Launch groups are Spot Instances that launch together and terminate together. - # @option options [optional,String] :availability_zone_group ("") Specifies the Availability Zone group. If you specify the same Availability Zone group for all Spot Instance requests, all Spot Instances are launched in the same Availability Zone. - # @option options [optional,String] :image_id (nil) The AMI ID. - # @option options [optional,String] :key_name (nil) The name of the key pair. - # @option options [optional,Array of Strings or String] :security_group (nil) Name of the security group(s). - # @option options [optional,String] :user_data (nil) MIME, Base64-encoded user data. - # @option options [optional,String] :instance_type ("m1.small") Specifies the instance type. - # @option options [optional,String] :kernel_id (nil) The ID of the kernel to select. - # @option options [optional,String] :ramdisk_id (nil) The ID of the RAM disk to select. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk and search for the kernel ID. - # @option options [optional,String] :subnet_id (nil) Specifies the Amazon VPC subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud. - # @option options [optional,String] :availability_zone (nil) Specifies the placement constraints (Availability Zones) for launching the instances. - # @option options [optional, Array] :block_device_mapping ([]) An array of Hashes representing the elements of the block device mapping. e.g. [{:device_name => '/dev/sdh', :virtual_name => '', :ebs_snapshot_id => '', :ebs_volume_size => '', :ebs_delete_on_termination => ''},{},...] - # @option options [optional, Boolean] :monitoring_enabled (false) Enables monitoring for the instance. - # @option options [optional, Boolean] :base64_encoded (false) - # - def request_spot_instances( options = {} ) - options = { :instance_count => 1, - :instance_type => 'm1.small', - :base64_encoded => false }.merge(options) - - raise ArgumentError, ":addressing_type has been deprecated." if options[:addressing_type] - raise ArgumentError, ":spot_price must be provided" if options[:spot_price].nil? || options[:spot_price].empty? - raise ArgumentError, ":base64_encoded must be 'true' or 'false'" unless [true, false].include?(options[:base64_encoded]) - raise ArgumentError, ":instance_type must specify a valid instance type" unless options[:instance_type].nil? || ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].include?(options[:instance_type]) - - user_data = extract_user_data(options) - - params = {} - - if options[:security_group] - params.merge!(pathlist("LaunchSpecification.SecurityGroup", options[:security_group])) - end - - if options[:block_device_mapping] - params.merge!(pathhashlist('LaunchSpecification.BlockDeviceMapping', options[:block_device_mapping].flatten, {:device_name => 'DeviceName', :virtual_name => 'VirtualName', :ebs_snapshot_id => 'Ebs.SnapshotId', :ebs_volume_size => 'Ebs.VolumeSize', :ebs_delete_on_termination => 'Ebs.DeleteOnTermination' })) - end - - params["SpotPrice"] = options[:spot_price] - params["InstanceCount"] = options[:instance_count].to_s - params["Type"] = options[:type] unless options[:type].nil? - params["ValidFrom"] = options[:valid_from].to_s unless options[:valid_from].nil? - params["ValidUntil"] = options[:valid_until].to_s unless options[:valid_until].nil? - params["LaunchGroup"] = options[:launch_group] unless options[:launch_group].nil? - params["AvailabilityZoneGroup"] = options[:availability_zone_group] unless options[:availability_zone_group].nil? - params["LaunchSpecification.ImageId"] = options[:image_id] unless options[:image_id].nil? - params["LaunchSpecification.KeyName"] = options[:key_name] unless options[:key_name].nil? - params["LaunchSpecification.UserData"] = user_data unless user_data.nil? - params["LaunchSpecification.InstanceType"] = options[:instance_type] unless options[:instance_type].nil? - params["LaunchSpecification.KernelId"] = options[:kernel_id] unless options[:kernel_id].nil? - params["LaunchSpecification.RamdiskId"] = options[:ramdisk_id] unless options[:ramdisk_id].nil? - params["LaunchSpecification.SubnetId"] = options[:subnet_id] unless options[:subnet_id].nil? - params["LaunchSpecification.Placement.AvailabilityZone"] = options[:availability_zone] unless options[:availability_zone].nil? - params["LaunchSpecification.Monitoring.Enabled"] = options[:monitoring_enabled].to_s unless options[:monitoring_enabled].nil? - - return response_generator(:action => "RequestSpotInstances", :params => params) - end - - # Describes Spot Instance requests. Spot Instances are instances that Amazon EC2 starts on your behalf when the - # maximum price that you specify exceeds the current Spot Price. Amazon EC2 periodically sets the Spot Price - # based on available Spot Instance capacity and current spot instance requests. For conceptual information about - # Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide. - # - # @option options [Array] :spot_instance_request_id ([]) - # - def describe_spot_instance_requests( options = {} ) - options = { :spot_instance_request_id => []}.merge(options) - params = pathlist( "SpotInstanceRequestId", options[:spot_instance_request_id] ) - - return response_generator(:action => "DescribeSpotInstanceRequests", :params => params) - end - - # Cancels one or more Spot Instance requests. Spot Instances are instances that Amazon EC2 starts on your behalf - # when the maximum price that you specify exceeds the current Spot Price. Amazon EC2 periodically sets the Spot - # Price based on available Spot Instance capacity and current spot instance requests. For conceptual information - # about Spot Instances, refer to the Amazon Elastic Compute Cloud Developer Guide or Amazon Elastic Compute Cloud - # User Guide. - # - # NB: Canceling a Spot Instance request does not terminate running Spot Instances associated with the request. - # - # @option options [Array] :spot_instance_request_id ([]) - # - def cancel_spot_instance_requests( options = {} ) - options = { :spot_instance_request_id => []}.merge(options) - params = pathlist( "SpotInstanceRequestId", options[:spot_instance_request_id] ) - - return response_generator(:action => "CancelSpotInstanceRequests", :params => params) - end - - end - end -end - diff --git a/lib/AWS/EC2/spot_prices.rb b/lib/AWS/EC2/spot_prices.rb deleted file mode 100644 index c0c9c7f..0000000 --- a/lib/AWS/EC2/spot_prices.rb +++ /dev/null @@ -1,34 +0,0 @@ -module AWS - module EC2 - - class Base < AWS::Base - - # This method returns historical information about spot prices. - # - # Amazon periodically sets the spot price for each instance type based on - # available capacity and current spot instance requests. - # - # @option options [Time] :start_time (nil) - # @option options [Time] :end_time (nil) - # @option options [String] :instance_type (nil) - # @option options [String] :product_description (nil) - # - def describe_spot_price_history( options = {} ) - raise ArgumentError, ":start_time must be a Time object" unless options[:start_time].nil? || options[:start_time].kind_of?(Time) - raise ArgumentError, ":end_time must be a Time object" unless options[:end_time].nil? || options[:end_time].kind_of?(Time) - raise ArgumentError, ":instance_type must specify a valid instance type" unless options[:instance_type].nil? || ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge", "cg1.4xlarge"].include?(options[:instance_type]) - raise ArgumentError, ":product_description must be 'Linux/UNIX' or 'Windows'" unless options[:product_description].nil? || ["Linux/UNIX", "Windows"].include?(options[:product_description]) - - params = {} - params.merge!("StartTime" => options[:start_time].iso8601) if options[:start_time] - params.merge!("EndTime" => options[:end_time].iso8601) if options[:end_time] - params.merge!("InstanceType" => options[:instance_type]) if options[:instance_type] - params.merge!("ProductDescription" => options[:product_description]) if options[:product_description] - - return response_generator(:action => "DescribeSpotPriceHistory", :params => params) - end - - end - end -end - diff --git a/lib/AWS/EC2/subnets.rb b/lib/AWS/EC2/subnets.rb deleted file mode 100644 index bdba2f8..0000000 --- a/lib/AWS/EC2/subnets.rb +++ /dev/null @@ -1,20 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - # The DescribeSubnets operation returns information about subnets available for use by the user - # making the request. Selected subnets may be specified or the list may be left empty if information for - # all registered subnets is required. - # - # @option options [Array] :subnet_id ([]) - # - def describe_subnets( options = {} ) - options = { :subnet_id => [] }.merge(options) - params = pathlist("SubnetId", options[:subnet_id] ) - return response_generator(:action => "DescribeSubnets", :params => params) - end - - end - end -end - diff --git a/lib/AWS/EC2/tags.rb b/lib/AWS/EC2/tags.rb deleted file mode 100644 index 632ab04..0000000 --- a/lib/AWS/EC2/tags.rb +++ /dev/null @@ -1,64 +0,0 @@ -module AWS - module EC2 - class Base < AWS::Base - - # The CreateTags operation adds or overwrites tags for the specified resource(s). - # - # @example Tag instance i-123456789 with the name 'Test Instance'. - # create_tags(:resource_id => 'i-123456789', - # :tag => [{'Name' => 'Test Instance'}]) - # - # @option options [Array] :resource_id ([]) The ids of the resource(s) to tag - # @option options [Array] :tag ([]) An array of Hashes representing the tags as string name/value pairs. Use nil or empty string to get a tag without a value - # - def create_tags( options = {} ) - raise ArgumentError, "No :resource_id provided" if options[:resource_id].nil? || options[:resource_id].empty? - raise ArgumentError, "No :tag provided" if options[:tag].nil? || options[:tag].empty? - - params = pathlist("ResourceId", options[:resource_id] ) - params.merge!(pathkvlist('Tag', options[:tag], 'Key', 'Value', {})) - return response_generator(:action => "CreateTags", :params => params) - end - - # The DescribeTags operation lists the tags. If you do not specify any filters, all tags will be returned. - # - # @example Find any instances tagged with the name 'Test Instance'. - # describe_tags(:filter => [{'resource-type' => ['instance']}, - # {'key' => ['Name']}, - # {'value' => ['Test Instance']}]) - # - # @option options [optional, Array] :filter ([]) An array of Hashes representing the filters. Note that the values in the hashes have to be arrays - # - def describe_tags( options = {} ) - params = {} - if options[:filter] - params.merge!(pathkvlist('Filter', options[:filter], 'Name', 'Value', {:resource_id => 'resource-id', :resource_type => 'resource-type' })) - end - return response_generator(:action => "DescribeTags", :params => params) - end - - # The DeleteTags operation deletes tags for the specified resource(s). - # - # @example Remove the name tag from instance i-123456789. - # delete_tags(:resource_id => 'i-123456789', - # :tag => [{'Name' => nil}]) - # - # @example Remove the name tag from instance i-123456789, but only if it's 'Test Instance'. - # delete_tags(:resource_id => 'i-123456789', - # :tag => [{'Name' => 'Test Instance'}]) - # - # @option options [Array] :resource_id ([]) The ids of the resource(s) to tag - # @option options [Array] :tag ([]) An array of Hashes representing the tags as string name/value pairs. If a value is given (instead of nil or an empty string), then the tag is only deleted if it has the specified value - # - def delete_tags( options = {} ) - raise ArgumentError, "No :resource_id provided" if options[:resource_id].nil? || options[:resource_id].empty? - raise ArgumentError, "No :tag provided" if options[:tag].nil? || options[:tag].empty? - - params = pathlist("ResourceId", options[:resource_id] ) - params.merge!(pathkvlist('Tag', options[:tag], 'Key', 'Value', {})) - return response_generator(:action => "DeleteTags", :params => params) - end - end - end -end - diff --git a/lib/AWS/EC2/volumes.rb b/lib/AWS/EC2/volumes.rb deleted file mode 100644 index dfdbece..0000000 --- a/lib/AWS/EC2/volumes.rb +++ /dev/null @@ -1,100 +0,0 @@ -module AWS - module EC2 - 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 ([]) - # - def describe_volumes( options = {} ) - options = { :volume_id => [] }.merge(options) - params = pathlist("VolumeId", options[:volume_id] ) - return response_generator(:action => "DescribeVolumes", :params => params) - end - - - # The CreateVolume operation creates a new Amazon EBS volume that you can mount from any Amazon EC2 instance. - # - # @option options [String] :availability_zone ('') - # @option options [optional, String] :size ('') - # @option options [optional, String] :snapshot_id ('') - # - def create_volume( options = {} ) - options = { :availability_zone => '' }.merge(options) - raise ArgumentError, "No :availability_zone provided" if options[:availability_zone].nil? || options[:availability_zone].empty? - options = { :size => '' }.merge(options) - options = { :snapshot_id => '' }.merge(options) - params = { - "AvailabilityZone" => options[:availability_zone], - "Size" => options[:size], - "SnapshotId" => options[:snapshot_id] - } - return response_generator(:action => "CreateVolume", :params => params) - end - - - # The DeleteVolume operation deletes an Amazon EBS volume. - # - # @option options [String] :volume_id ('') - # - def delete_volume( options = {} ) - options = { :volume_id => '' }.merge(options) - raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty? - params = { - "VolumeId" => options[:volume_id] - } - return response_generator(:action => "DeleteVolume", :params => params) - end - - - # The AttachVolume operation attaches an Amazon EBS volume to an instance. - # - # @option options [String] :volume_id ('') - # @option options [String] :instance_id ('') - # @option options [String] :device ('') - # - def attach_volume( options = {} ) - options = { :volume_id => '' }.merge(options) - options = { :instance_id => '' }.merge(options) - options = { :device => '' }.merge(options) - raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty? - raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty? - raise ArgumentError, "No :device provided" if options[:device].nil? || options[:device].empty? - - params = { - "VolumeId" => options[:volume_id], - "InstanceId" => options[:instance_id], - "Device" => options[:device] - } - return response_generator(:action => "AttachVolume", :params => params) - end - - - # The DetachVolume operation detaches an Amazon EBS volume from an instance. - # - # @option options [String] :volume_id ('') - # @option options [optional, String] :instance_id ('') - # @option options [optional, String] :device ('') - # @option options [optional, Boolean] :force ('') - # - def detach_volume( options = {} ) - options = { :volume_id => '' }.merge(options) - raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty? - options = { :instance_id => '' }.merge(options) - options = { :device => '' }.merge(options) - options = { :force => '' }.merge(options) - params = { - "VolumeId" => options[:volume_id], - "InstanceId" => options[:instance_id], - "Device" => options[:device], - "Force" => options[:force].to_s - } - return response_generator(:action => "DetachVolume", :params => params) - end - - - end - end -end - diff --git a/lib/AWS/ELB.rb b/lib/AWS/ELB.rb deleted file mode 100644 index dfe613a..0000000 --- a/lib/AWS/ELB.rb +++ /dev/null @@ -1,69 +0,0 @@ -module AWS - module ELB - - # Which host FQDN will we connect to for all API calls to AWS? - # If ELB_URL is defined in the users ENV we can override the default with that. - # - # @example - # export ELB_URL='https://elasticloadbalancing.amazonaws.com' - if ENV['ELB_URL'] - ELB_URL = ENV['ELB_URL'] - DEFAULT_HOST = URI.parse(ELB_URL).host - else - # Default US API endpoint - DEFAULT_HOST = 'elasticloadbalancing.amazonaws.com' - end - - API_VERSION = '2009-05-15' - - class Base < AWS::Base - def api_version - API_VERSION - end - - def default_host - DEFAULT_HOST - end - - # Raises the appropriate error if the specified Net::HTTPResponse object - # contains an Amazon EC2 error; returns +false+ otherwise. - def aws_error?(response) - - # return false if we got a HTTP 200 code, - # otherwise there is some type of error (40x,50x) and - # we should try to raise an appropriate exception - # from one of our exception classes defined in - # exceptions.rb - return false if response.is_a?(Net::HTTPSuccess) - - # parse the XML document so we can walk through it - doc = REXML::Document.new(response.body) - - # Check that the Error element is in the place we would expect. - # and if not raise a generic error exception - unless doc.root.elements[1].name == "Error" - raise Error, "Unexpected error format. response.body is: #{response.body}" - end - - # An valid error response looks like this: - # InvalidParameterCombinationUnknown parameter: foo291cef62-3e86-414b-900e-17246eccfae8 - # AWS EC2 throws some exception codes that look like Error.SubError. Since we can't name classes this way - # we need to strip out the '.' in the error 'Code' and we name the error exceptions with this - # non '.' name as well. - error_code = doc.root.elements['//ErrorResponse/Error/Code'].text.gsub('.', '') - error_message = doc.root.elements['//ErrorResponse/Error/Message'].text - - # Raise one of our specific error classes if it exists. - # otherwise, throw a generic EC2 Error with a few details. - if AWS.const_defined?(error_code) - raise AWS.const_get(error_code), error_message - else - raise AWS::Error, error_message - end - - end - - end - - end -end \ No newline at end of file diff --git a/lib/AWS/ELB/load_balancers.rb b/lib/AWS/ELB/load_balancers.rb deleted file mode 100644 index cc04ee4..0000000 --- a/lib/AWS/ELB/load_balancers.rb +++ /dev/null @@ -1,214 +0,0 @@ -module AWS - module ELB - class Base < AWS::Base - - # This API creates a new LoadBalancer. Once the call has completed - # successfully, a new LoadBalancer will be created, but it will not be - # usable until at least one instance has been registered. When the - # LoadBalancer creation is completed, you can check whether it is usable - # by using the DescribeInstanceHealth API. The LoadBalancer is usable as - # soon as any registered instance is InService. - # - # @option options [String] :load_balancer_name (nil) the name of the load balancer - # @option options [Array] :availability_zones (nil) - # @option options [Array] :listeners (nil) An Array of Hashes (:protocol, :load_balancer_port, :instance_port) - # @option options [Array] :availability_zones (nil) An Array of Strings - # - def create_load_balancer( options = {} ) - raise ArgumentError, "No :availability_zones provided" if options[:availability_zones].nil? || options[:availability_zones].empty? - raise ArgumentError, "No :listeners provided" if options[:listeners].nil? || options[:listeners].empty? - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - - params = {} - - params.merge!(pathlist('AvailabilityZones.member', [options[:availability_zones]].flatten)) - params.merge!(pathhashlist('Listeners.member', [options[:listeners]].flatten, { - :protocol => 'Protocol', - :load_balancer_port => 'LoadBalancerPort', - :instance_port => 'InstancePort' - })) - params['LoadBalancerName'] = options[:load_balancer_name] - - return response_generator(:action => "CreateLoadBalancer", :params => params) - end - - # This API deletes the specified LoadBalancer. On deletion, all of the - # configured properties of the LoadBalancer will be deleted. If you - # attempt to recreate the LoadBalancer, you need to reconfigure all the - # settings. The DNS name associated with a deleted LoadBalancer is no - # longer be usable. Once deleted, the name and associated DNS record of - # the LoadBalancer no longer exist and traffic sent to any of its IP - # addresses will no longer be delivered to your instances. You will not - # get the same DNS name even if you create a new LoadBalancer with same - # LoadBalancerName. - # - # @option options [String] :load_balancer_name the name of the load balancer - # - def delete_load_balancer( options = {} ) - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - params = { 'LoadBalancerName' => options[:load_balancer_name] } - return response_generator(:action => "DeleteLoadBalancer", :params => params) - end - - # This API returns detailed configuration information for the specified - # LoadBalancers, or if no LoadBalancers are specified, then the API - # returns configuration information for all LoadBalancers created by the - # caller. For more information, please see LoadBalancer. - # - # You must have created the specified input LoadBalancers in order to - # retrieve this information. In other words, in order to successfully call - # this API, you must provide the same account credentials as those that - # were used to create the LoadBalancer. - # - # @option options [Array] :load_balancer_names ([]) An Array of names of load balancers to describe. - # - def describe_load_balancers( options = {} ) - options = { :load_balancer_names => [] }.merge(options) - params = pathlist("LoadBalancerName.member", options[:load_balancer_names]) - return response_generator(:action => "DescribeLoadBalancers", :params => params) - end - - # This API adds new instances to the LoadBalancer. - # - # Once the instance is registered, it starts receiving traffic and - # requests from the LoadBalancer. Any instance that is not in any of the - # Availability Zones registered for the LoadBalancer will be moved to - # the OutOfService state. It will move to the InService state when the - # Availability Zone is added to the LoadBalancer. - # - # You must have been the one who created the LoadBalancer. In other - # words, in order to successfully call this API, you must provide the - # same account credentials as those that were used to create the - # LoadBalancer. - # - # NOTE: Completion of this API does not guarantee that operation has - # completed. Rather, it means that the request has been registered and - # the changes will happen shortly. - # - # @option options [Array] :instances An Array of instance names to add to the load balancer. - # @option options [String] :load_balancer_name The name of the load balancer. - # - def register_instances_with_load_balancer( options = {} ) - raise ArgumentError, "No :instances provided" if options[:instances].nil? || options[:instances].empty? - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - params = {} - params.merge!(pathhashlist('Instances.member', options[:instances].flatten.collect{|e| {:instance_id => e}}, {:instance_id => 'InstanceId'})) - params['LoadBalancerName'] = options[:load_balancer_name] - return response_generator(:action => "RegisterInstancesWithLoadBalancer", :params => params) - end - - # This API deregisters instances from the LoadBalancer. Trying to - # deregister an instance that is not registered with the LoadBalancer - # does nothing. - # - # In order to successfully call this API, you must provide the same - # account credentials as those that were used to create the - # LoadBalancer. - # - # Once the instance is deregistered, it will stop receiving traffic from - # the LoadBalancer. - # - # @option options [Array] :instances An Array of instance names to remove from the load balancer. - # @option options [String] :load_balancer_name The name of the load balancer. - # - def deregister_instances_from_load_balancer( options = {} ) - raise ArgumentError, "No :instances provided" if options[:instances].nil? || options[:instances].empty? - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - params = {} - params.merge!(pathhashlist('Instances.member', options[:instances].flatten.collect{|e| {:instance_id => e}}, {:instance_id => 'InstanceId'})) - params['LoadBalancerName'] = options[:load_balancer_name] - return response_generator(:action => "DeregisterInstancesFromLoadBalancer", :params => params) - end - - # This API enables you to define an application healthcheck for the - # instances. - # - # Note: Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly. - # - # @option options [String] :load_balancer_name The name of the load balancer. - # @option options [Hash] :health_check A Hash with the key values provided as String or FixNum values (:timeout, :interval, :unhealthy_threshold, :healthy_threshold) - # - def configure_health_check( options = {} ) - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - raise ArgumentError, "No :health_check Hash provided" if options[:health_check].nil? || options[:health_check].empty? - - params = {} - - params['LoadBalancerName'] = options[:load_balancer_name] - params['HealthCheck.Target'] = options[:health_check][:target] unless options[:health_check][:target].nil? - params['HealthCheck.Timeout'] = options[:health_check][:timeout].to_s unless options[:health_check][:timeout].nil? - params['HealthCheck.Interval'] = options[:health_check][:interval].to_s unless options[:health_check][:interval].nil? - params['HealthCheck.UnhealthyThreshold'] = options[:health_check][:unhealthy_threshold].to_s unless options[:health_check][:unhealthy_threshold].nil? - params['HealthCheck.HealthyThreshold'] = options[:health_check][:healthy_threshold].to_s unless options[:health_check][:healthy_threshold].nil? - - return response_generator(:action => "ConfigureHealthCheck", :params => params) - end - - # This API returns the current state of the instances of the specified LoadBalancer. If no instances are specified, - # the state of all the instances for the LoadBalancer is returned. - # - # You must have been the one who created in the LoadBalancer. In other words, in order to successfully call this API, - # you must provide the same account credentials as those that were used to create the LoadBalancer. - # - # @option options [Array] :instances List of instances IDs whose state is being queried. - # @option options [String] :load_balancer_name The name of the load balancer - # - def describe_instance_health( options = {} ) - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - - params = {} - - params['LoadBalancerName'] = options[:load_balancer_name] - params.merge!(pathlist('Instances.member', [options[:instances]].flatten)) if options.has_key?(:instances) - - return response_generator(:action => "DescribeInstanceHealth", :params => params) - end - - # This API removes the specified EC2 Availability Zones from the set of configured Availability Zones for the - # LoadBalancer. Once an Availability Zone is removed, all the instances registered with the LoadBalancer that - # are in the removed Availability Zone go into the OutOfService state. Upon Availability Zone removal, the - # LoadBalancer attempts to equally balance the traffic among its remaining usable Availability Zones. Trying to - # remove an Availability Zone that was not associated with the LoadBalancer does nothing. - # - # There must be at least one Availability Zone registered with a LoadBalancer at all times. You cannot remove - # all the Availability Zones from a LoadBalancer. - # - # In order for this call to be successful, you must have created the LoadBalancer. In other words, in order to - # successfully call this API, you must provide the same account credentials as those that were used to create - # the LoadBalancer. - # - # @option options [Array] :availability_zones List of Availability Zones to be removed from the LoadBalancer. - # @option options [String] :load_balancer_name The name of the load balancer - # - def disable_availability_zones_for_load_balancer( options = {} ) - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - raise ArgumentError, "No :availability_zones provided" if options[:availability_zones].nil? || options[:availability_zones].empty? - - params = {} - - params['LoadBalancerName'] = options[:load_balancer_name] - params.merge!(pathlist('AvailabilityZones.member', [options[:availability_zones]].flatten)) - - return response_generator(:action => "DisableAvailabilityZonesForLoadBalancer", :params => params) - end - - # This API is used to add one or more EC2 Availability Zones to the LoadBalancer. - # - # @option options [Array] :availability_zones List of Availability Zones to be added to the LoadBalancer. - # @option options [String] :load_balancer_name The name of the load balancer - # - def enable_availability_zones_for_load_balancer( options = {} ) - raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty? - raise ArgumentError, "No :availability_zones provided" if options[:availability_zones].nil? || options[:availability_zones].empty? - - params = {} - - params['LoadBalancerName'] = options[:load_balancer_name] - params.merge!(pathlist('AvailabilityZones.member', [options[:availability_zones]].flatten)) - - return response_generator(:action => "EnableAvailabilityZonesForLoadBalancer", :params => params) - end - - end - end -end \ No newline at end of file diff --git a/lib/AWS/RDS.rb b/lib/AWS/RDS.rb deleted file mode 100644 index 2fdc4ad..0000000 --- a/lib/AWS/RDS.rb +++ /dev/null @@ -1,71 +0,0 @@ -module AWS - module RDS - - # Which host FQDN will we connect to for all API calls to AWS? - # If RDS_URL is defined in the users ENV we can override the default with that. - # - # @example - # export RDS_URL='https://rds.amazonaws.com' - if ENV['RDS_URL'] - RDS_URL = ENV['RDS_URL'] - DEFAULT_HOST = URI.parse(RDS_URL).host - else - # Default US API endpoint - DEFAULT_HOST = 'rds.amazonaws.com' - end - - API_VERSION = '2009-10-16' - - class Base < AWS::Base - def api_version - API_VERSION - end - - def default_host - DEFAULT_HOST - end - - # Raises the appropriate error if the specified Net::HTTPResponse object - # contains an Amazon EC2 error; returns +false+ otherwise. - def aws_error?(response) - - # return false if we got a HTTP 200 code, - # otherwise there is some type of error (40x,50x) and - # we should try to raise an appropriate exception - # from one of our exception classes defined in - # exceptions.rb - return false if response.is_a?(Net::HTTPSuccess) - - # parse the XML document so we can walk through it - doc = REXML::Document.new(response.body) - - # Check that the Error element is in the place we would expect. - # and if not raise a generic error exception - unless doc.root.elements[1].name == "Error" - raise Error, "Unexpected error format. response.body is: #{response.body}" - end - - # An valid error response looks like this: - # InvalidParameterCombinationUnknown parameter: foo291cef62-3e86-414b-900e-17246eccfae8 - # AWS EC2 throws some exception codes that look like Error.SubError. Since we can't name classes this way - # we need to strip out the '.' in the error 'Code' and we name the error exceptions with this - # non '.' name as well. - error_code = doc.root.elements['//ErrorResponse/Error/Code'].text.gsub('.', '') - error_message = doc.root.elements['//ErrorResponse/Error/Message'].text - - # Raise one of our specific error classes if it exists. - # otherwise, throw a generic EC2 Error with a few details. - if AWS.const_defined?(error_code) - raise AWS.const_get(error_code), error_message - else - raise AWS::Error, error_message - end - - end - - end - - end - -end - diff --git a/lib/AWS/RDS/rds.rb b/lib/AWS/RDS/rds.rb deleted file mode 100644 index 2539e52..0000000 --- a/lib/AWS/RDS/rds.rb +++ /dev/null @@ -1,538 +0,0 @@ -module AWS - module RDS - class Base < AWS::Base - - # This API creates a new DB instance. Once the call has completed - # successfully, a new DB instance will be created, but it will not be - # - # @option options [String] :db_instance_identifier (nil) the name of the db_instance - # @option options [String] :allocated_storage in gigabytes (nil) - # @option options [String] :db_instance_class in contains compute and memory capacity (nil) - # @option options [String] :engine type i.e. MySQL5.1 (nil) - # @option options [String] :master_username is the master username for the db instance (nil) - # @option options [String] :master_user_password is the master password for the db instance (nil) - # @option options [String] :port is the port the database accepts connections on (3306) - # @option options [String] :db_name contains the name of the database to create when created (nil) - # @option options [String] :db_parameter_group is the database parameter group to associate with this instance (nil) - # @option options [Array] :db_security_groups are the list of db security groups to associate with the instance (nil) - # @option options [String] :availability_zone is the availability_zone to create the instance in (nil) - # @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil) - # @option options [String] :backup_retention_period is the number of days which automated backups are retained (1) - # @option options [String] :preferred_backup_window is the daily time range for which automated backups are created - # - def create_db_instance( options = {}) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier) - raise ArgumentError, "No :allocated_storage provided" if options.does_not_have?(:allocated_storage) - raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class) - raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine) - raise ArgumentError, "No :master_username provided" if options.does_not_have?(:master_username) - raise ArgumentError, "No :master_user_password provided" if options.does_not_have?(:master_user_password) - raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class) - - # handle a former argument that was misspelled - raise ArgumentError, "Perhaps you meant :backup_retention_period" if options.has?(:backend_retention_period) - - params = {} - params['DBInstanceIdentifier'] = options[:db_instance_identifier] - params["AllocatedStorage"] = options[:allocated_storage].to_s - params["DBInstanceClass"] = options[:db_instance_class] - params["Engine"] = options[:engine] - params["MasterUsername"] = options[:master_username] - params["MasterUserPassword"] = options[:master_user_password] - - params["Port"] = options[:port].to_s if options.has?(:port) - params["DBName"] = options[:db_name] if options.has?(:db_name) - params["DBParameterGroup"] = options[:db_parameter_group] if options.has?(:db_parameter_group) - params.merge!(pathlist("DBSecurityGroups.member", [options[:db_security_groups]].flatten)) if options.has_key?(:db_security_groups) - params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone) - params["PreferredMaintenanceWindow"] = options[:preferred_maintenance_window] if options.has?(:preferred_maintenance_window) - params["BackupRetentionPeriod"] = options[:backup_retention_period].to_s if options.has?(:backup_retention_period) - params["PreferredBackupWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window) - - return response_generator(:action => "CreateDBInstance", :params => params) - end - - # This API method deletes a db instance identifier - # - # @option options [String] :db_instance_identifier is the instance identifier for the DB instance to be deleted (nil) - # @option options [String] :skip_final_snapshot determines to create a snapshot or not before it's deleted (no) - # @option options [String] :final_db_snapshot_identifier is the name of the snapshot created before the instance is deleted (name) - # - def delete_db_instance( options = {} ) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier) - - params = {} - params['DBInstanceIdentifier'] = options[:db_instance_identifier] - - params["SkipFinalSnapshot"] = options[:skip_final_snapshot].to_s if options.has?(:skip_final_snapshot) - params["FinalDBSnapshotIdentifier"] = options[:final_db_snapshot_identifier].to_s if options.has?(:final_db_snapshot_identifier) - - return response_generator(:action => "DeleteDBInstance", :params => params) - end - - # This API method creates a db parameter group - # - # @option options [String] :db_parameter_group_name is the name of the parameter group (nil) - # @option options [String] :engine is the engine the db parameter group can be used with (nil) - # @option options [String] :description is the description of the paramter group - # - def create_db_parameter_group( options = {} ) - raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name) - raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine) - raise ArgumentError, "No :description provided" if options.does_not_have?(:description) - - params = {} - params['DBParameterGroupName'] = options[:db_parameter_group_name] - params['Engine'] = options[:engine] - params['Description'] = options[:description] - - return response_generator(:action => "CreateDBParameterGroup", :params => params) - end - - # This API method creates a db security group - # - # @option options [String] :db_security_group_name is the name of the db security group (nil) - # @option options [String] :db_security_group_description is the description of the db security group - # - def create_db_security_group( options = {} ) - raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name) - raise ArgumentError, "No :db_security_group_description provided" if options.does_not_have?(:db_security_group_description) - - params = {} - params['DBSecurityGroupName'] = options[:db_security_group_name] - params['DBSecurityGroupDescription'] = options[:db_security_group_description] - - return response_generator(:action => "CreateDBSecurityGroup", :params => params) - end - - # This API method creates a restoreable db snapshot - # - # @option options [String] :db_snapshot_identifier is the identifier of the db snapshot - # @option options [String] :db_instance_identifier is the identifier of the db instance - # - def create_db_snapshot( options = {} ) - raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier) - - params = {} - params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier] - params['DBInstanceIdentifier'] = options[:db_instance_identifier] - - return response_generator(:action => "CreateDBSnapshot", :params => params) - end - - # This API method authorizes network ingress for an amazon ec2 group - # - # @option options [String] :db_security_group_name is the name of the db security group - # @option options [String] :cidrip is the network ip to authorize - # @option options [String] :ec2_security_group_name is the name of the ec2 security group to authorize - # @option options [String] :ec2_security_group_owner_id is the owner id of the security group - # - def authorize_db_security_group( options = {} ) - raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name) - - params = {} - params['DBSecurityGroupName'] = options[:db_security_group_name] - - if options.has?(:cidrip) - params['CIDRIP'] = options[:cidrip] - elsif options.has?(:ec2_security_group_name) && options.has?(:ec2_security_group_owner_id) - params['EC2SecurityGroupName'] = options[:ec2_security_group_name] - params['EC2SecurityGroupOwnerId'] = options[:ec2_security_group_owner_id] - else - raise ArgumentError, "No :cidrip or :ec2_security_group_name and :ec2_security_group_owner_id provided" - end - - return response_generator(:action => "AuthorizeDBSecurityGroupIngress", :params => params) - end - - # This API method deletes a db paramter group - # - # @option options [String] :db_parameter_group_name is the name of the db paramter group to be deleted (nil) - # - def delete_db_parameter_group( options = {} ) - raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name) - - params = {} - params['DBParameterGroupName'] = options[:db_parameter_group_name] - - return response_generator(:action => "DeleteDBParameterGroup", :params => params) - end - - # This API method deletes a db security group - # - # @option options [String] :db_security_group_name is the name of the db security group to be deleted (nil) - # - def delete_db_security_group( options = {} ) - raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name) - - params = {} - params['DBSecurityGroupName'] = options[:db_security_group_name] - - return response_generator(:action => "DeleteDBSecurityGroup", :params => params) - end - - # This API method deletes a db snapshot - # - # @option options [String] :db_snapshot_identifier is the name of the db snapshot to be deleted (nil) - # - def delete_db_snapshot( options = {} ) - raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier) - - params = {} - params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier] - - return response_generator(:action => "DeleteDBSnapshot", :params => params) - end - - # This API method describes the db instances - # - # @option options [String] :db_instance_identifier if passed, only the description for the db instance matching this identifier is returned - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_db_instances( options = {} ) - params = {} - params['DBInstanceIdentifier'] = options[:db_instance_identifier] if options.has?(:db_instance_identifier) - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeDBInstances", :params => params) - end - - # This API method describes the default engine parameters - # - # @option options [String] :engine is the name of the database engine - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_engine_default_parameters( options = {} ) - raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine) - - params = {} - params['Engine'] = options[:engine] - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeEngineDefaultParameters", :params => params) - end - - # This API method returns information about all DB Parameter Groups for an account if no - # DB Parameter Group name is supplied, or displays information about a specific named DB Parameter Group. - # You can call this operation recursively using the Marker parameter. - # - # @option options [String] :db_parameter_group_name is the name of the parameter group - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_db_parameter_groups( options = {} ) - params = {} - params['DBParameterGroupName'] = options[:db_parameter_group_name] if options.has?(:db_parameter_group_name) - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeDBParameterGroups", :params => params) - end - - # This API method returns information about parameters that are part of a parameter group. - # You can optionally request only parameters from a specific source. - # You can call this operation recursively using the Marker parameter. - # - # @option options [String] :db_parameter_group_name is the name parameter group - # @option options [String] :source is the type of parameter to return - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_db_parameters( options = {} ) - raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name) - - params = {} - params['DBParameterGroupName'] = options[:db_parameter_group_name] - params['Source'] = options[:source] if options.has?(:source) - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeDBParameters", :params => params) - end - - # This API method returns all the DB Security Group details for a particular AWS account, - # or for a particular DB Security Group if a name is specified. - # You can call this operation recursively using the Marker parameter. - # - # @option options [String] :db_security_group_name is the name of the security group - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_db_security_groups( options = {} ) - params = {} - params['DBSecurityGroupName'] = options[:db_security_group_name] if options.has?(:db_security_group_name) - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeDBSecurityGroups", :params => params) - end - - # This API method returns information about the DB Snapshots for this account. - # If you pass in a DBInstanceIdentifier, it returns information only about DB Snapshots taken for that DB Instance. - # If you pass in a DBSnapshotIdentifier,it will return information only about the specified snapshot. - # If you omit both DBInstanceIdentifier and DBSnapshotIdentifier, it returns all snapshot information for all - # database instances, up to the maximum number of records specified. Passing both DBInstanceIdentifier and - # DBSnapshotIdentifier results in an error. - # - # @option options [String] :db_instance_identifier is the unique identifier that identifies a DB instance - # @option options [String] :db_snapshot_identifier is a unique identifier for an amazon RDS snapshot - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_db_snapshots( options = {} ) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier) - - params = {} - params['DBInstanceIdentifier'] = options[:db_instance_identifier] - - params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier] if options.has?(:db_snapshot_identifier) - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeDBSnapshots", :params => params) - end - - # This API method Returns information about events related to your DB Instances, DB Security Groups, - # and DB Parameter Groups for up to the past 14 days. - # You can get events specific to a particular DB Instance or DB Security Group by providing the name as a parameter. - # By default, the past hour of events are returned. - # - # If neither DBInstanceIdentifier or DBSecurityGroupName are provided, - # all events are be retrieved for DB Instances and DB Security Groups. - # - # @option options [String] :source_identifier is the identifier for the source for which events will be included - # @option options [String] :source_type is the type of event sources to return - # @option options [String] :start_time is the beginning of the time interval to return records for (ISO 8601 format) - # @option options [String] :end_time is the end of the time interval to return records (ISO 8601 format) - # @option options [String] :duration is the number of minutes to return events for. - # @option options [String] :max_records is the maximum number of records to include in the response - # @option options [String] :marker provided in the previous request - # - def describe_events( options = {} ) - params = {} - params['SourceIdentifier'] = options[:source_identifier] if options.has?(:source_identifier) - params['SourceType'] = options[:source_type] if options.has?(:source_type) - params['StartTime'] = options[:start_time] if options.has?(:start_time) - params['EndTime'] = options[:end_time] if options.has?(:end_time) - params['Duration'] = options[:duration] if options.has?(:duration) - params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records) - params['Marker'] = options[:marker] if options.has?(:marker) - - return response_generator(:action => "DescribeEvents", :params => params) - end - - # This API changes the settings of an existing DB Instance. - # - # Changes are applied in the following manner: A ModifyDBInstance API call to modify security groups or to - # change the maintenance windows results in immediate action. Modification of the DB Parameter Group applies - # immediate parameters as soon as possible and pending-reboot parameters only when the RDS instance is rebooted. - # A request to scale the DB Instance class results puts the database instance into the modifying state. - # - # The DB Instance must be in available or modifying state for this API to accept changes. - # - # @option options [String] :db_instance_identifier (nil) the name of the db_instance - # @option options [String] :allocated_storage in gigabytes (nil) - # @option options [String] :db_instance_class in contains compute and memory capacity (nil) - # @option options [String] :engine type i.e. MySQL5.1 (nil) - # @option options [String] :master_username is the master username for the db instance (nil) - # @option options [String] :master_user_password is the master password for the db instance (nil) - # @option options [String] :port is the port the database accepts connections on (3306) - # @option options [String] :db_name contains the name of the database to create when created (nil) - # @option options [String] :db_parameter_group_name is the database parameter group to associate with this instance (nil) - # @option options [Array] :db_security_groups are the list of db security groups to associate with the instance (nil) - # @option options [String] :availability_zone is the availability_zone to create the instance in (nil) - # @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil) - # @option options [String] :backup_retention_period is the number of days which automated backups are retained (1) - # @option options [String] :preferred_backup_window is the daily time range for which automated backups are created - # - def modify_db_instance( options = {}) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier) - - # handle a former argument that was misspelled - raise ArgumentError, "Perhaps you meant :backup_retention_period" if options.has?(:backend_retention_period) - - params = {} - params['DBInstanceIdentifier'] = options[:db_instance_identifier] - - params["AllocatedStorage"] = options[:allocated_storage].to_s if options.has?(:allocated_storage) - params["DBInstanceClass"] = options[:db_instance_class] if options.has?(:db_instance_class) - params["Engine"] = options[:engine] if options.has?(:engine) - params["MasterUsername"] = options[:master_username] if options.has?(:master_username) - params["MasterUserPassword"] = options[:master_user_password] if options.has?(:master_user_password) - params["Port"] = options[:port].to_s if options.has?(:port) - params["DBName"] = options[:db_name] if options.has?(:db_name) - params["DBParameterGroupName"] = options[:db_parameter_group_name] if options.has?(:db_parameter_group_name) - params.merge!(pathlist("DBSecurityGroups.member", [options[:db_security_groups]].flatten)) if options.has_key?(:db_security_groups) - params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone) - params["PreferredMaintenanceWindow"] = options[:preferred_maintenance_window] if options.has?(:preferred_maintenance_window) - params["BackupRetentionPeriod"] = options[:backup_retention_period].to_s if options.has?(:backup_retention_period) - params["PreferredBackupWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window) - - return response_generator(:action => "ModifyDBInstance", :params => params) - end - - # This API method modifies the parameters of a DB Parameter Group. - # To modify more than one parameter, submit a list of the following: ParameterName, ParameterValue, and ApplyMethod. - # You can modify a maximum of 20 parameters in a single request. - # - # @option options [String] :db_parameter_group_name is the name of the parameter group to modify - # @option options [String] :parameters is the array of parameters to update in a hash format - # {:name => "ParameterName", :value => "ParameterValue", :apply_method => "pending-reboot"} - # - def modify_db_parameter_group( options = {} ) - raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name) - raise ArgumentError, "No :parameters provided" if options.does_not_have?(:parameters) - - params = {} - params['DBParameterGroupName'] = options[:db_parameter_group_name] - params.merge!(pathhashlist('Parameters.member', [options[:parameters]].flatten, { - :name => 'ParameterName', - :value => 'ParameterValue', - :apply_method => "ApplyMethod" - })) - - return response_generator(:action => "ModifyDBParameterGroup", :params => params) - end - - # This API method reboots a DB Instance. - # Once started, the process cannot be stopped, and the database instance will be unavailable until the reboot completes. - # - # @option options [String] :db_instance_identifier is the identifier for the db instance to restart - # - def reboot_db_instance( options = {} ) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier - ) - params = {} - params['DBInstanceIdentifier'] = options[:db_instance_identifier] if options.has?(:db_instance_identifier) - - return response_generator(:action => "RebootDBInstance", :params => params) - end - - # This API method modifies the parameters of a DB Parameter Group. - # To modify more than one parameter, submit a list of the following: ParameterName, ParameterValue, and ApplyMethod. - # You can modify a maximum of 20 parameters in a single request. - # - # @option options [String] :db_parameter_group_name is the name of the parameter group to modify - # @option options [String] :reset_all_parameters specified whether to reset all the db parameters - # @option options [String] :parameters is the array of parameters to update in a hash format - # {:name => "ParameterName", :apply_method => "pending-reboot"} - # - def reset_db_parameter_group( options = {} ) - raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name) - raise ArgumentError, "No :parameters provided" if options.does_not_have?(:parameters) - - params = {} - params['DBParameterGroupName'] = options[:db_parameter_group_name] - params.merge!(pathhashlist('Parameters.member', [options[:parameters]].flatten, { - :name => 'ParameterName', - :apply_method => "ApplyMethod" - })) - params['ResetAllParameters'] = options[:reset_all_parameters] if options.has?(:reset_all_parameters) - - return response_generator(:action => "ResetDBParameterGroup", :params => params) - end - - # This API method restores a db instance to a snapshot of the instance - # - # @option options [String] :db_snapshot_identifier is the db identifier of the snapshot to restore from - # @option options [String] :db_instance_identifier is the identifier of the db instance - # @option options [String] :db_instance_class is the class of db compute and memory instance for the db instance - # @option options [String] :port is the port which the db can accept connections on - # @option options [String] :availability_zone is the EC2 zone which the db instance will be created - # - def restore_db_instance_from_snapshot( options = {} ) - raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier) - raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier) - raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class) - - params = {} - params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier] - params['DBInstanceIdentifier'] = options[:db_instance_identifier] - params['DBInstanceClass'] = options[:db_instance_class] - - params['Port'] = options[:port].to_s if options.has?(:port) - params['AvailabilityZone'] = options[:availability_zone] if options.has?(:availability_zone) - - return response_generator(:action => "RestoreDBInstanceFromDBSnapshot", :params => params) - end - - # This API method restores a DB Instance to a specified time, creating a new DB Instance. - # - # Some characteristics of the new DB Instance can be modified using optional parameters. - # If these options are omitted, the new DB Instance defaults to the characteristics of the DB Instance from which the - # DB Snapshot was created. - # - # @option options [String] :source_db_instance_identifier the identifier of the source DB Instance from which to restore. - # @option options [optional, Boolean] :use_latest_restorable_time specifies that the db be restored to the latest restored time. Conditional, cannot be specified if :restore_time parameter is provided. - # @option options [optional, Date] :restore_time specifies the date and time to restore from. Conditional, cannot be specified if :use_latest_restorable_time parameter is true. - # @option options [String] :target_db_instance_identifier is the name of the new database instance to be created. - # @option options [optional, String] :db_instance_class specifies the class of the compute and memory of the EC2 instance, Options : db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge | db.cc1.4xlarge - # @option options [optional, Integer] :port is the port which the db can accept connections on. Constraints: Value must be 1115-65535 - # @option options [optional, String] :availability_zone is the EC2 zone which the db instance will be created - # - def restore_db_instance_to_point_in_time( options = {} ) - raise ArgumentError, "No :source_db_instance_identifier provided" if options.does_not_have?(:source_db_instance_identifier) - raise ArgumentError, "No :target_db_instance_identifier provided" if options.does_not_have?(:target_db_instance_identifier) - - params = {} - params['SourceDBInstanceIdentifier'] = options[:source_db_instance_identifier] - params['TargetDBInstanceIdentifier'] = options[:target_db_instance_identifier] - - if options.has?(:use_latest_restorable_time) && options.has?(:restore_time) - raise ArgumentError, "You cannot provide both :use_latest_restorable_time and :restore_time" - elsif options.has?(:use_latest_restorable_time) - params['UseLatestRestorableTime'] = case options[:use_latest_restorable_time] - when 'true', 'false' - options[:use_latest_restorable_time] - when true - 'true' - when false - 'false' - else - raise ArgumentError, "Invalid value provided for :use_latest_restorable_time. Expected boolean." - end - elsif options.has?(:restore_time) - params['RestoreTime'] = options[:restore_time] - end - - params['DBInstanceClass'] = options[:db_instance_class] if options.has?(:db_instance_class) - params['Port'] = options[:port].to_s if options.has?(:port) - params['AvailabilityZone'] = options[:availability_zone] if options.has?(:availability_zone) - - return response_generator(:action => "RestoreDBInstanceToPointInTime", :params => params) - end - - # This API method authorizes network ingress for an amazon ec2 group - # - # @option options [String] :db_security_group_name is the name of the db security group - # @option options [String] :cidrip is the network ip to revoke - # @option options [String] :ec2_security_group_name is the name of the ec2 security group to authorize - # @option options [String] :ec2_security_group_owner_id is the owner id of the security group - # - def revoke_db_security_group( options = {} ) - raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name) - - params = {} - params['DBSecurityGroupName'] = options[:db_security_group_name] - - if options.has?(:cidrip) - params['CIDRIP'] = options[:cidrip] - elsif options.has?(:ec2_security_group_name) && options.has?(:ec2_security_group_owner_id) - params['EC2SecurityGroupName'] = options[:ec2_security_group_name] - params['EC2SecurityGroupOwnerId'] = options[:ec2_security_group_owner_id] - else - raise ArgumentError, "No :cidrip or :ec2_security_group_name and :ec2_security_group_owner_id provided" - end - - return response_generator(:action => "RevokeDBSecurityGroupIngress", :params => params) - end - - end - end -end - diff --git a/lib/AWS/exceptions.rb b/lib/AWS/exceptions.rb deleted file mode 100644 index 7054100..0000000 --- a/lib/AWS/exceptions.rb +++ /dev/null @@ -1,200 +0,0 @@ -#-- -# AWS ERROR CODES -# AWS can throw error exceptions that contain a '.' in them. -# since we can't name an exception class with that '.' I compressed -# each class name into the non-dot version which allows us to retain -# the granularity of the exception. -#++ - -module AWS - - # All AWS errors are superclassed by Error < RuntimeError - class Error < RuntimeError; end - - # CLIENT : A client side argument error - class ArgumentError < Error; end - - # Elastic Compute Cloud - ############################ - - # EC2 : User has the maximum number of allowed IP addresses. - class AddressLimitExceeded < Error; end - - # EC2 : The limit on the number of Amazon EBS volumes attached to one instance has been exceeded. - class AttachmentLimitExceeded < Error; end - - # EC2 : User not authorized. - class AuthFailure < Error; end - - # EC2 : Volume is in incorrect state - class IncorrectState < Error; end - - # EC2 : User has max allowed concurrent running instances. - class InstanceLimitExceeded < Error; end - - # EC2 : The value of an item added to, or removed from, an image attribute is invalid. - class InvalidAMIAttributeItemValue < Error; end - - # EC2 : Specified AMI ID is not valid. - class InvalidAMIIDMalformed < Error; end - - # EC2 : Specified AMI ID does not exist. - class InvalidAMIIDNotFound < Error; end - - # EC2 : Specified AMI ID has been deregistered and is no longer available. - class InvalidAMIIDUnavailable < Error; end - - # EC2 : The instance cannot detach from a volume to which it is not attached. - class InvalidAttachmentNotFound < Error; end - - # EC2 : The device to which you are trying to attach (i.e. /dev/sdh) is already in use on the instance. - class InvalidDeviceInUse < Error; end - - # EC2 : Specified instance ID is not valid. - class InvalidInstanceIDMalformed < Error; end - - # EC2 : Specified instance ID does not exist. - class InvalidInstanceIDNotFound < Error; end - - # EC2 : Specified keypair name does not exist. - class InvalidKeyPairNotFound < Error; end - - # EC2 : Attempt to create a duplicate keypair. - class InvalidKeyPairDuplicate < Error; end - - # EC2 : Specified group name does not exist. - class InvalidGroupNotFound < Error; end - - # EC2 : Attempt to create a duplicate group. - class InvalidGroupDuplicate < Error; end - - # EC2 : Specified group can not be deleted because it is in use. - class InvalidGroupInUse < Error; end - - # EC2 : Specified group name is a reserved name. - class InvalidGroupReserved < Error; end - - # EC2 : Specified AMI has an unparsable manifest. - class InvalidManifest < Error; end - - # EC2 : RunInstances was called with minCount and maxCount set to 0 or minCount > maxCount. - class InvalidParameterCombination < Error; end - - # EC2 : The value supplied for a parameter was invalid. - class InvalidParameterValue < Error; end - - # EC2 : Attempt to authorize a permission that has already been authorized. - class InvalidPermissionDuplicate < Error; end - - # EC2 : Specified permission is invalid. - class InvalidPermissionMalformed < Error; end - - # EC2 : Specified reservation ID is invalid. - class InvalidReservationIDMalformed < Error; end - - # EC2 : Specified reservation ID does not exist. - class InvalidReservationIDNotFound < Error; end - - # EC2 : The snapshot ID that was passed as an argument was malformed. - class InvalidSnapshotIDMalformed < Error; end - - # EC2 : The specified snapshot does not exist. - class InvalidSnapshotIDNotFound < Error; end - - # EC2 : The user ID is neither in the form of an AWS account ID or one - # of the special values accepted by the owner or executableBy flags - # in the DescribeImages call. - class InvalidUserIDMalformed < Error; end - - # EC2 : Reserved Instances ID not found. - class InvalidReservedInstancesId < Error; end - - # EC2 : Reserved Instances Offering ID not found. - class InvalidReservedInstancesOfferingId < Error; end - - # EC2 : The volume ID that was passed as an argument was malformed. - class InvalidVolumeIDMalformed < Error; end - - # EC2 : The volume specified does not exist. - class InvalidVolumeIDNotFound < Error; end - - # EC2 : The volume already exists in the system. - class InvalidVolumeIDDuplicate < Error; end - - # EC2 : The specified volume ID and instance ID are in different Availability Zones. - class InvalidVolumeIDZoneMismatch < Error; end - - # EC2 : The zone specified does not exist. - class InvalidZoneNotFound < Error; end - - # EC2 : Insufficient Reserved Instances capacity. - class InsufficientReservedInstancesCapacity < Error; end - - # EC2 : The instance specified does not support EBS. - class NonEBSInstance < Error; end - - # EC2 : The limit on the number of Amazon EBS snapshots in the pending state has been exceeded. - class PendingSnapshotLimitExceeded < Error; end - - # EC2 : Your current quota does not allow you to purchase the required number of reserved instances. - class ReservedInstancesLimitExceeded < Error; end - - # EC2 : The limit on the number of Amazon EBS snapshots has been exceeded. - class SnapshotLimitExceeded < Error; end - - # EC2 : An unknown parameter was passed as an argument - class UnknownParameter < Error; end - - # EC2 : The limit on the number of Amazon EBS volumes has been exceeded. - class VolumeLimitExceeded < Error; end - - # Server Error Codes - ### - - # Server : Internal Error. - class InternalError < Error; end - - # Server : Not enough available addresses to satisfy your minimum request. - class InsufficientAddressCapacity < Error; end - - # Server : There are not enough available instances to satisfy your minimum request. - class InsufficientInstanceCapacity < Error; end - - # Server : There are not enough available reserved instances to satisfy your minimum request. - class InsufficientReservedInstanceCapacity < Error; end - - # Server : The server is overloaded and cannot handle the request. - class Unavailable < Error; end - - # Elastic Load Balancer - ############################ - - # ELB : The Load balancer specified was not found. - class LoadBalancerNotFound < Error; end - - # ELB : - class ValidationError < Error; end - - # ELB : - class DuplicateLoadBalancerName < Error; end - - # ELB : - class TooManyLoadBalancers < Error; end - - # ELB : - class InvalidInstance < Error; end - - # ELB : - class InvalidConfigurationRequest < Error; end - - # API Errors - ############################ - - # Server : Invalid AWS Account - class InvalidClientTokenId < Error; end - - # Server : The provided signature does not match. - class SignatureDoesNotMatch < Error; end - -end - diff --git a/lib/AWS/responses.rb b/lib/AWS/responses.rb deleted file mode 100644 index 669f418..0000000 --- a/lib/AWS/responses.rb +++ /dev/null @@ -1,21 +0,0 @@ -module AWS - - class Response - - # Parse the XML response from AWS - # - # @option options [String] :xml The XML response from AWS that we want to parse - # @option options [Hash] :parse_options Override the options for XmlSimple. - # @return [Hash] the input :xml converted to a custom Ruby Hash by XmlSimple. - def self.parse(options = {}) - options = { - :xml => "", - :parse_options => { 'forcearray' => ['item', 'member'], 'suppressempty' => nil, 'keeproot' => false } - }.merge(options) - response = XmlSimple.xml_in(options[:xml], options[:parse_options]) - end - - end # class Response - -end # module AWS - diff --git a/lib/AWS/version.rb b/lib/AWS/version.rb deleted file mode 100644 index 32062d4..0000000 --- a/lib/AWS/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module AWS - VERSION = "0.9.17" -end diff --git a/test/test_Autoscaling_groups.rb b/test/test_Autoscaling_groups.rb index 70ce3e1..d96b176 100644 --- a/test/test_Autoscaling_groups.rb +++ b/test/test_Autoscaling_groups.rb @@ -2,7 +2,7 @@ context "autoscaling " do before do - @as = AWS::Autoscaling::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @as = AWSAPI::Autoscaling::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @valid_create_launch_configuration_params = { :image_id => "ami-ed46a784", @@ -42,7 +42,7 @@ " end - specify "AWS::Autoscaling::Base should give back a nice response if there is an error" do + specify "AWSAPI::Autoscaling::Base should give back a nice response if there is an error" do @as.stubs(:make_request).with('CreateLaunchConfiguration', { 'ImageId' => 'ami-ed46a784', 'LaunchConfigurationName' => 'TestAutoscalingGroupName', @@ -54,7 +54,7 @@ response["Error"]["Message"].should.equal "Launch Configuration by this name already exists - A launch configuration already exists with the name TestAutoscalingGroupName" end - specify "AWS::Autoscaling::Base should destroy a launch configuration just fine" do + specify "AWSAPI::Autoscaling::Base should destroy a launch configuration just fine" do @as.stubs(:make_request).with('DeleteLaunchConfiguration', { 'LaunchConfigurationName' => 'TestAutoscalingGroupName1' }).returns stub(:body => @delete_launch_configuration_response, :is_a? => true) @@ -63,7 +63,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should create a launch configuration" do + specify "AWSAPI::Autoscaling::Base should create a launch configuration" do @as.stubs(:make_request).with('CreateLaunchConfiguration', { 'ImageId' => 'ami-ed46a784', 'LaunchConfigurationName' => 'CustomTestAutoscalingGroupName', @@ -74,7 +74,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should be able to create a new autoscaling group" do + specify "AWSAPI::Autoscaling::Base should be able to create a new autoscaling group" do @as.stubs(:make_request).with("CreateAutoScalingGroup", { 'AutoScalingGroupName' => 'CloudteamTestAutoscalingGroup1', 'AvailabilityZones.member.1' => 'us-east-1a', @@ -87,7 +87,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should destroy an autoscaling group" do + specify "AWSAPI::Autoscaling::Base should destroy an autoscaling group" do @as.stubs(:make_request).with('DeleteAutoScalingGroup', { 'AutoScalingGroupName' => 'TestAutoscalingGroupName1' }).returns stub(:body => @delete_autoscaling_group, :is_a? => true) @@ -96,7 +96,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should be able to create a new scaling trigger" do + specify "AWSAPI::Autoscaling::Base should be able to create a new scaling trigger" do @as.stubs(:make_request).with("CreateOrUpdateScalingTrigger", { 'AutoScalingGroupName' => 'AutoScalingGroupName', 'Unit' => "Seconds", @@ -117,14 +117,14 @@ valid_create_or_update_scaling_trigger_params = {:autoscaling_group_name => "AutoScalingGroupName", :dimensions => {:name => "AutoScalingGroupName", :value => "Bob"}, :unit => "Seconds", :measure_name => "CPUUtilization", :namespace => "AWS/EC2", :statistic => "Average", :period => 120, :trigger_name => "AFunNameForATrigger", :lower_threshold => 0.2, :lower_breach_scale_increment => "-1", :upper_threshold => 1.5, :upper_breach_scale_increment => 1, :breach_duration => 120} %w(dimensions autoscaling_group_name measure_name statistic period trigger_name lower_threshold lower_breach_scale_increment upper_threshold upper_breach_scale_increment breach_duration).each do |meth_str| - lambda { @as.create_or_updated_scaling_trigger(valid_create_or_update_scaling_trigger_params.merge(meth_str.to_sym=>nil)) }.should.raise(AWS::ArgumentError) + lambda { @as.create_or_updated_scaling_trigger(valid_create_or_update_scaling_trigger_params.merge(meth_str.to_sym=>nil)) }.should.raise(AWSAPI::ArgumentError) end response = @as.create_or_updated_scaling_trigger(valid_create_or_update_scaling_trigger_params) response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should destroy a launch configuration group" do + specify "AWSAPI::Autoscaling::Base should destroy a launch configuration group" do @as.stubs(:make_request).with('DeleteLaunchConfiguration', { 'LaunchConfigurationName' => 'LaunchConfiguration' }).returns stub(:body => " @@ -135,7 +135,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should destroy a scaling trigger" do + specify "AWSAPI::Autoscaling::Base should destroy a scaling trigger" do @as.stubs(:make_request).with('DeleteTrigger', { 'TriggerName' => 'DeletingTrigger', 'AutoScalingGroupName' => "Name" }).returns stub(:body => " @@ -148,7 +148,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should describe the autoscaling groups" do + specify "AWSAPI::Autoscaling::Base should describe the autoscaling groups" do @as.stubs(:make_request).with('DescribeAutoScalingGroups', { 'AutoScalingGroupNames.member.1' => "webtier" }).returns stub(:body => " @@ -184,7 +184,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should describe the launch configurations" do + specify "AWSAPI::Autoscaling::Base should describe the launch configurations" do @as.stubs(:make_request).with('DescribeLaunchConfigurations', { 'AutoScalingGroupNames.member.1' => "webtier" }).returns stub(:body => " @@ -214,7 +214,7 @@ end - specify "AWS::Autoscaling::Base should describe the launch configurations" do + specify "AWSAPI::Autoscaling::Base should describe the launch configurations" do @as.stubs(:make_request).with('DescribeScalingActivities', { 'AutoScalingGroupName' => "webtier" }).returns stub(:body => " @@ -239,7 +239,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should describe triggers" do + specify "AWSAPI::Autoscaling::Base should describe triggers" do @as.stubs(:make_request).with('DescribeTriggers', { 'AutoScalingGroupName' => "webtier" }).returns stub(:body => " @@ -279,7 +279,7 @@ response.should.be.an.instance_of Hash end - specify "AWS::Autoscaling::Base should describe triggers" do + specify "AWSAPI::Autoscaling::Base should describe triggers" do @as.stubs(:make_request).with('SetDesiredCapacity', { 'AutoScalingGroupName' => "name", 'DesiredCapacity' => '10' }).returns stub(:body => " @@ -294,7 +294,7 @@ end - specify "AWS::Autoscaling::Base should terminate an instance in an autoscaling group" do + specify "AWSAPI::Autoscaling::Base should terminate an instance in an autoscaling group" do @as.stubs(:make_request).with('TerminateInstanceInAutoScalingGroup', { 'InstanceId' => "i-instance1" }).returns stub(:body => " diff --git a/test/test_EC2.rb b/test/test_EC2.rb index 96d4cc9..5093ee1 100644 --- a/test/test_EC2.rb +++ b/test/test_EC2.rb @@ -15,8 +15,8 @@ before do end - specify "AWS::EC2::Base attribute readers should be available" do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", + specify "AWSAPI::EC2::Base attribute readers should be available" do + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret", :use_ssl => true, :server => "foo.example.com" ) @@ -26,8 +26,8 @@ @ec2.server.should.equal "foo.example.com" end - specify "AWS::EC2::Base should work with insecure connections as well" do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", + specify "AWSAPI::EC2::Base should work with insecure connections as well" do + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret", :use_ssl => false, :server => "foo.example.com" ) @@ -37,8 +37,8 @@ @ec2.server.should.equal "foo.example.com" end - specify "AWS::EC2::Base should allow specification of port" do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", + specify "AWSAPI::EC2::Base should allow specification of port" do + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret", :use_ssl => true, :server => "foo.example.com", @@ -49,20 +49,20 @@ @ec2.server.should.equal "foo.example.com" end - specify "AWS.canonical_string(path) should conform to Amazon's requirements " do + specify "AWSAPI.canonical_string(path) should conform to Amazon's requirements " do path = {"name1" => "value1", "name2" => "value2 has spaces", "name3" => "value3~"} if ENV['EC2_URL'].nil? || ENV['EC2_URL'] == 'https://ec2.amazonaws.com' - AWS.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\nec2.amazonaws.com\n/\nname1=value1&name2=value2%20has%20spaces&name3=value3~" + AWSAPI.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\nec2.amazonaws.com\n/\nname1=value1&name2=value2%20has%20spaces&name3=value3~" elsif ENV['EC2_URL'] == 'https://us-east-1.ec2.amazonaws.com' - AWS.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\nus-east-1.ec2.amazonaws.com\n/\nname1=value1&name2=value2%20has%20spaces&name3=value3~" + AWSAPI.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\nus-east-1.ec2.amazonaws.com\n/\nname1=value1&name2=value2%20has%20spaces&name3=value3~" elsif ENV['EC2_URL'] == 'https://eu-west-1.ec2.amazonaws.com' - AWS.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\neu-west-1.ec2.amazonaws.com\n/\nname1=value1&name2=value2%20has%20spaces&name3=value3~" + AWSAPI.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\neu-west-1.ec2.amazonaws.com\n/\nname1=value1&name2=value2%20has%20spaces&name3=value3~" end end - specify "AWS.encode should return the expected string" do - AWS.encode("secretaccesskey", "foobar123", urlencode=true).should.equal "CPzGGhtvlG3P3yp88fPZp0HKouUV8mQK1ZcdFGQeAug%3D" - AWS.encode("secretaccesskey", "foobar123", urlencode=false).should.equal "CPzGGhtvlG3P3yp88fPZp0HKouUV8mQK1ZcdFGQeAug=" + specify "AWSAPI.encode should return the expected string" do + AWSAPI.encode("secretaccesskey", "foobar123", urlencode=true).should.equal "CPzGGhtvlG3P3yp88fPZp0HKouUV8mQK1ZcdFGQeAug%3D" + AWSAPI.encode("secretaccesskey", "foobar123", urlencode=false).should.equal "CPzGGhtvlG3P3yp88fPZp0HKouUV8mQK1ZcdFGQeAug=" end end diff --git a/test/test_EC2_availability_zones.rb b/test/test_EC2_availability_zones.rb index 2c3ae7d..22fe5cc 100644 --- a/test/test_EC2_availability_zones.rb +++ b/test/test_EC2_availability_zones.rb @@ -13,7 +13,7 @@ context "EC2 availability zones" do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @describe_availability_zones_response_body = <<-RESPONSE diff --git a/test/test_EC2_console.rb b/test/test_EC2_console.rb index 00b16ec..45d8f9f 100644 --- a/test/test_EC2_console.rb +++ b/test/test_EC2_console.rb @@ -13,7 +13,7 @@ context "The EC2 console " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @get_console_output_response_body = <<-RESPONSE @@ -45,9 +45,9 @@ specify "method get_console_output should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.get_console_output() }.should.raise(AWS::ArgumentError) - lambda { @ec2.get_console_output(:instance_id => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.get_console_output(:instance_id => "") }.should.raise(AWS::ArgumentError) + lambda { @ec2.get_console_output() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.get_console_output(:instance_id => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.get_console_output(:instance_id => "") }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_elastic_ips.rb b/test/test_EC2_elastic_ips.rb index 337f135..89c63be 100644 --- a/test/test_EC2_elastic_ips.rb +++ b/test/test_EC2_elastic_ips.rb @@ -13,7 +13,7 @@ context "EC2 elastic IP addresses " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @allocate_address_body = <<-RESPONSE @@ -68,10 +68,10 @@ # @ec2.stubs(:make_request).with('CreateKeyPair', {"KeyName"=>"example-key-name"}). # returns stub(:body => @create_keypair_response_body, :is_a? => true) # - # lambda { @ec2.create_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWS::ArgumentError) - # lambda { @ec2.create_keypair() }.should.raise(AWS::ArgumentError) - # lambda { @ec2.create_keypair( :key_name => nil ) }.should.raise(AWS::ArgumentError) - # lambda { @ec2.create_keypair( :key_name => "" ) }.should.raise(AWS::ArgumentError) + # lambda { @ec2.create_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWSAPI::ArgumentError) + # lambda { @ec2.create_keypair() }.should.raise(AWSAPI::ArgumentError) + # lambda { @ec2.create_keypair( :key_name => nil ) }.should.raise(AWSAPI::ArgumentError) + # lambda { @ec2.create_keypair( :key_name => "" ) }.should.raise(AWSAPI::ArgumentError) #end @@ -113,10 +113,10 @@ @ec2.stubs(:make_request).with('AssociateAddress', {"InstanceId" => "i-2ea64347", "PublicIp"=>"67.202.55.255"}). returns stub(:body => @associate_address_response_body, :is_a? => true) - lambda { @ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.associate_address() }.should.raise(AWS::ArgumentError) - lambda { @ec2.associate_address( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.associate_address( :public_ip => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.associate_address() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.associate_address( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.associate_address( :public_ip => "" ) }.should.raise(AWSAPI::ArgumentError) end @@ -135,9 +135,9 @@ @ec2.stubs(:make_request).with('DisassociateAddress', {'PublicIp' => '67.202.55.255'}). returns stub(:body => @disassociate_address_response_body, :is_a? => true) - lambda { @ec2.disassociate_address( :public_ip => "67.202.55.255" ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.disassociate_address() }.should.raise(AWS::ArgumentError) - lambda { @ec2.disassociate_address( :public_ip => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.disassociate_address( :public_ip => "67.202.55.255" ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.disassociate_address() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.disassociate_address( :public_ip => "" ) }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_image_attributes.rb b/test/test_EC2_image_attributes.rb index 3946c90..11eca23 100644 --- a/test/test_EC2_image_attributes.rb +++ b/test/test_EC2_image_attributes.rb @@ -13,7 +13,7 @@ context "EC2 image_attributes " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @modify_image_attribute_response_body = <<-RESPONSE @@ -130,33 +130,33 @@ specify "should raise an exception when modify_image_attribute is called with incorrect arguments" do # method args can't be nil or empty - lambda { @ec2.modify_image_attribute() }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"") }.should.raise(AWS::ArgumentError) + lambda { @ec2.modify_image_attribute() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"") }.should.raise(AWSAPI::ArgumentError) # :image_id option must be not be empty or nil - lambda { @ec2.modify_image_attribute(:image_id=>nil, :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>nil, :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) # :attribute currently has two options which are 'launchPermission' and 'productCodes, it should fail with any other value, nil, or empty - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil, :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo", :operation_type=>"add", :group=>["all"]) }.should.raise(AWS::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil, :operation_type=>"add", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"", :operation_type=>"add", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo", :operation_type=>"add", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) # :attribute => 'launchPermission' option should fail if neither :group nor :user_id are also provided - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add") }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id => "") }.should.raise(AWS::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id => "") }.should.raise(AWSAPI::ArgumentError) # :attribute => 'productCodes' option should fail if :product_code isn't also provided - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes", :product_code=>nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes", :product_code=>"") }.should.raise(AWS::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes", :product_code=>nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes", :product_code=>"") }.should.raise(AWSAPI::ArgumentError) # :operation_type currently has two options which are 'add' and 'remove', and it should fail with any other, nil or empty - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>nil, :group=>["all"]) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"", :group=>["all"]) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"foo", :group=>["all"]) }.should.raise(AWS::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>nil, :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"foo", :group=>["all"]) }.should.raise(AWSAPI::ArgumentError) end @@ -191,22 +191,22 @@ specify "should raise an exception when describe_image_attribute is called with incorrect arguments" do # method args can't be nil or empty - lambda { @ec2.describe_image_attribute() }.should.raise(AWS::ArgumentError) - lambda { @ec2.describe_image_attribute(:image_id=>"") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_image_attribute() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>"") }.should.raise(AWSAPI::ArgumentError) # :image_id option must be not be empty or nil w/ launchPermission - lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError) - lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(AWSAPI::ArgumentError) # :image_id option must be not be empty or nil w/ productCodes - lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"productCodes") }.should.raise(AWS::ArgumentError) - lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"productCodes") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"productCodes") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"productCodes") }.should.raise(AWSAPI::ArgumentError) # :attribute currently has two options which are 'launchPermission' and 'productCodes', it should fail with any other values, # nil, or empty - lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(AWS::ArgumentError) - lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(AWSAPI::ArgumentError) end @@ -221,17 +221,17 @@ specify "should raise an exception when reset_image_attribute is called with incorrect arguments" do # method args can't be nil or empty - lambda { @ec2.reset_image_attribute() }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_image_attribute(:image_id=>"") }.should.raise(AWS::ArgumentError) + lambda { @ec2.reset_image_attribute() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_image_attribute(:image_id=>"") }.should.raise(AWSAPI::ArgumentError) # :image_id option must be not be empty or nil - lambda { @ec2.reset_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(AWS::ArgumentError) + lambda { @ec2.reset_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(AWSAPI::ArgumentError) # :attribute currently has one option which is 'launchPermission', it should fail with any other value, nil, or empty - lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(AWS::ArgumentError) + lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_images.rb b/test/test_EC2_images.rb index 8ca481f..3b7f609 100644 --- a/test/test_EC2_images.rb +++ b/test/test_EC2_images.rb @@ -13,7 +13,7 @@ context "An EC2 image " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @create_image_response_body = <<-RESPONSE @@ -71,20 +71,20 @@ specify "method create_image should raise an exception when called with nil/empty string arguments" do - lambda { @ec2.create_image() }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "", :name => "fooname") }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "fooid", :name => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => nil, :name => "fooname") }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "fooid", :name => nil) }.should.raise(AWS::ArgumentError) + lambda { @ec2.create_image() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "", :name => "fooname") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => nil, :name => "fooname") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => nil) }.should.raise(AWSAPI::ArgumentError) end specify "method create_image should raise an exception when called with bad arguments" do - lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*2) }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*129) }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*128, :description => "f"*256) }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*128, :no_reboot => "true") }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*128, :no_reboot => "false") }.should.raise(AWS::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*2) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*129) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*128, :description => "f"*256) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*128, :no_reboot => "true") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_image(:instance_id => "fooid", :name => "f"*128, :no_reboot => "false") }.should.raise(AWSAPI::ArgumentError) end @@ -125,8 +125,8 @@ specify "method register_image should raise an exception when called without :name or :root_device_name" do - lambda { @ec2.register_image() }.should.raise(AWS::ArgumentError) - lambda { @ec2.register_image(:image_location => "", :root_device_name => "") }.should.raise(AWS::ArgumentError) + lambda { @ec2.register_image() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.register_image(:image_location => "", :root_device_name => "") }.should.raise(AWSAPI::ArgumentError) end @@ -248,9 +248,9 @@ specify "method deregister_image should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.deregister_image() }.should.raise(AWS::ArgumentError) - lambda { @ec2.deregister_image( :image_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.deregister_image( :image_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.deregister_image() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.deregister_image( :image_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.deregister_image( :image_id => "" ) }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_instances.rb b/test/test_EC2_instances.rb index 2d771d4..f837a76 100644 --- a/test/test_EC2_instances.rb +++ b/test/test_EC2_instances.rb @@ -13,7 +13,7 @@ context "EC2 instances " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @run_instances_response_body = <<-RESPONSE @@ -296,99 +296,99 @@ @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances() }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances() }.should.raise(AWSAPI::ArgumentError) # :addressing_type is deprecated - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => nil ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => nil ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "foo" ) }.should.raise(AWSAPI::ArgumentError) # :group_id is deprecated - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :group_id => nil ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :group_id => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :group_id => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :group_id => nil ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :group_id => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :group_id => "foo" ) }.should.raise(AWSAPI::ArgumentError) # :image_id - lambda { @ec2.run_instances( :image_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "" ) }.should.raise(AWSAPI::ArgumentError) # :min_count - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1 ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 0 ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1 ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 0 ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => "foo" ) }.should.raise(AWSAPI::ArgumentError) # :max_count - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => 1 ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => 0 ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => 1 ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => 0 ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => "foo" ) }.should.raise(AWSAPI::ArgumentError) # :min_count & :max_count - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1 ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 2, :max_count => 1 ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1 ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 2, :max_count => 1 ) }.should.raise(AWSAPI::ArgumentError) # :instance_type ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].each do |type| @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceType" => type). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => type ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => type ) }.should.not.raise(AWSAPI::ArgumentError) end - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => "m1.notarealsize" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => "m1.notarealsize" ) }.should.raise(AWSAPI::ArgumentError) # :monitoring_enabled @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "Monitoring.Enabled" => 'true'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :monitoring_enabled => true ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :monitoring_enabled => true ) }.should.not.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "Monitoring.Enabled" => 'false'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :monitoring_enabled => false ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :monitoring_enabled => false ) }.should.not.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "Monitoring.Enabled" => 'false'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :monitoring_enabled => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :monitoring_enabled => "foo" ) }.should.raise(AWSAPI::ArgumentError) # :disable_api_termination @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "DisableApiTermination" => 'true'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :disable_api_termination => true ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :disable_api_termination => true ) }.should.not.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "DisableApiTermination" => 'false'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :disable_api_termination => false ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :disable_api_termination => false ) }.should.not.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "DisableApiTermination" => 'false'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :disable_api_termination => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :disable_api_termination => "foo" ) }.should.raise(AWSAPI::ArgumentError) # :instance_initiated_shutdown_behavior @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceInitiatedShutdownBehavior" => 'stop'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => 'stop' ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => 'stop' ) }.should.not.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceInitiatedShutdownBehavior" => 'terminate'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => 'terminate' ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => 'terminate' ) }.should.not.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceInitiatedShutdownBehavior" => 'stop'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => "foo" ) }.should.raise(AWSAPI::ArgumentError) @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceInitiatedShutdownBehavior" => 'stop'). returns stub(:body => @run_instances_response_body, :is_a? => true) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => true ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_initiated_shutdown_behavior => true ) }.should.raise(AWSAPI::ArgumentError) # :base64_encoded - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => true ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => false ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => "foo" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => true ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => false ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => "foo" ) }.should.raise(AWSAPI::ArgumentError) end specify "should be able specify a key_name" do @@ -534,9 +534,9 @@ specify "method reboot_instances should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.reboot_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.reboot_instances( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.reboot_instances( :instance_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.reboot_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reboot_instances( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reboot_instances( :instance_id => "" ) }.should.raise(AWSAPI::ArgumentError) end @@ -548,9 +548,9 @@ specify "method start_instances should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.start_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.start_instances( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.start_instances( :instance_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.start_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.start_instances( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.start_instances( :instance_id => "" ) }.should.raise(AWSAPI::ArgumentError) end @@ -562,9 +562,9 @@ specify "method stop_instances should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.stop_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.stop_instances( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.stop_instances( :instance_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.stop_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.stop_instances( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.stop_instances( :instance_id => "" ) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be stopped when provided with an :instance_id" do @@ -574,9 +574,9 @@ end specify "method terminate_instances should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.terminate_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.terminate_instances( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.terminate_instances( :instance_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.terminate_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.terminate_instances( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.terminate_instances( :instance_id => "" ) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be terminated when provided with an :instance_id" do @@ -600,9 +600,9 @@ end specify "method monitor_instances should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.monitor_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.monitor_instances( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.monitor_instances( :instance_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.monitor_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.monitor_instances( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.monitor_instances( :instance_id => "" ) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be monitored when provided with an :instance_id" do @@ -620,9 +620,9 @@ end specify "method unmonitor_instances should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.unmonitor_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.unmonitor_instances( :instance_id => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.unmonitor_instances( :instance_id => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.unmonitor_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.unmonitor_instances( :instance_id => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.unmonitor_instances( :instance_id => "" ) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be unmonitored when provided with an :instance_id" do @@ -640,47 +640,47 @@ end specify "should get an ArgumentError when trying to describe/modify/reset an instance attribute without an istance id" do - lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk") }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk") }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk") }.should.raise(AWSAPI::ArgumentError) - lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWSAPI::ArgumentError) - lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWSAPI::ArgumentError) end specify "should get an ArgumentError when trying to describe/modify/reset an instance attribute without an attribute" do - lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWSAPI::ArgumentError) - lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWSAPI::ArgumentError) - lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWSAPI::ArgumentError) end specify "should get an ArgumentError when trying to describe/modify/reset an instance attribute without a valid attribute" do - lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError) - lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWSAPI::ArgumentError) end specify "should not get an ArgumentError when trying to describe/modify/reset an instance attribute with a valid attribute" do @ec2.stubs(:make_request).returns stub(:body => @describe_instance_attribute_response_body, :is_a? => true) %w(instanceType kernel ramdisk userData disableApiTermination instanceInitiatedShutdownBehavior rootDevice blockDeviceMapping).each do |a| - lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => a) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => a) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWSAPI::ArgumentError) end %w(kernel ramdisk).each do |a| - lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError) + lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWSAPI::ArgumentError) end end diff --git a/test/test_EC2_keypairs.rb b/test/test_EC2_keypairs.rb index f56254b..8534249 100644 --- a/test/test_EC2_keypairs.rb +++ b/test/test_EC2_keypairs.rb @@ -13,7 +13,7 @@ context "EC2 keypairs " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @create_keypair_response_body = <<-RESPONSE @@ -83,10 +83,10 @@ @ec2.stubs(:make_request).with('CreateKeyPair', {"KeyName"=>"example-key-name"}). returns stub(:body => @create_keypair_response_body, :is_a? => true) - lambda { @ec2.create_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.create_keypair() }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_keypair( :key_name => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_keypair( :key_name => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.create_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_keypair() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_keypair( :key_name => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_keypair( :key_name => "" ) }.should.raise(AWSAPI::ArgumentError) end @@ -113,10 +113,10 @@ @ec2.stubs(:make_request).with('DeleteKeyPair', {"KeyName"=>"example-key-name"}). returns stub(:body => @delete_keypair_body, :is_a? => true) - lambda { @ec2.delete_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.delete_keypair() }.should.raise(AWS::ArgumentError) - lambda { @ec2.delete_keypair( :key_name => nil ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.delete_keypair( :key_name => "" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.delete_keypair( :key_name => "example-key-name" ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.delete_keypair() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.delete_keypair( :key_name => nil ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.delete_keypair( :key_name => "" ) }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_password.rb b/test/test_EC2_password.rb index 64cad38..bc85186 100644 --- a/test/test_EC2_password.rb +++ b/test/test_EC2_password.rb @@ -13,7 +13,7 @@ context "The EC2 password " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @get_password_data_response_body = <<-RESPONSE @@ -37,9 +37,9 @@ specify "method get_password_data should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.get_password_data() }.should.raise(AWS::ArgumentError) - lambda { @ec2.get_password_data(:instance_id => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.get_password_data(:instance_id => "") }.should.raise(AWS::ArgumentError) + lambda { @ec2.get_password_data() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.get_password_data(:instance_id => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.get_password_data(:instance_id => "") }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_products.rb b/test/test_EC2_products.rb index bf7c178..d89877f 100644 --- a/test/test_EC2_products.rb +++ b/test/test_EC2_products.rb @@ -13,7 +13,7 @@ context "An EC2 instance " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @confirm_product_instance_response_body = <<-RESPONSE @@ -37,11 +37,11 @@ specify "method get_console_output should raise an exception when called without nil/empty string arguments" do - lambda { @ec2.confirm_product_instance() }.should.raise(AWS::ArgumentError) - lambda { @ec2.confirm_product_instance(:product_code => "774F4FF8", :instance_id => nil) }.should.raise(AWS::ArgumentError) - lambda { @ec2.confirm_product_instance(:product_code => "774F4FF8", :instance_id => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.confirm_product_instance(:product_code => nil, :instance_id => "i-10a64379") }.should.raise(AWS::ArgumentError) - lambda { @ec2.confirm_product_instance(:product_code => "", :instance_id => "i-10a64379") }.should.raise(AWS::ArgumentError) + lambda { @ec2.confirm_product_instance() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.confirm_product_instance(:product_code => "774F4FF8", :instance_id => nil) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.confirm_product_instance(:product_code => "774F4FF8", :instance_id => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.confirm_product_instance(:product_code => nil, :instance_id => "i-10a64379") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.confirm_product_instance(:product_code => "", :instance_id => "i-10a64379") }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_responses.rb b/test/test_EC2_responses.rb index 999c4b8..f394a59 100644 --- a/test/test_EC2_responses.rb +++ b/test/test_EC2_responses.rb @@ -20,7 +20,7 @@ RESPONSE - @response = AWS::Response.parse(:xml => @http_xml) + @response = AWSAPI::Response.parse(:xml => @http_xml) end diff --git a/test/test_EC2_s3_xmlsimple.rb b/test/test_EC2_s3_xmlsimple.rb index 4ebe156..4aa48fe 100644 --- a/test/test_EC2_s3_xmlsimple.rb +++ b/test/test_EC2_s3_xmlsimple.rb @@ -17,7 +17,7 @@ context "EC2 aws-s3 compat test" do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @describe_instances_response_body = <<-RESPONSE diff --git a/test/test_EC2_security_groups.rb b/test/test_EC2_security_groups.rb index d44235b..e4d103e 100644 --- a/test/test_EC2_security_groups.rb +++ b/test/test_EC2_security_groups.rb @@ -13,7 +13,7 @@ context "EC2 security groups " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @create_security_group_response_body = <<-RESPONSE @@ -92,16 +92,16 @@ @ec2.stubs(:make_request).with('CreateSecurityGroup', {"GroupName"=>"WebServers", "GroupDescription"=>"Web"}). returns stub(:body => @create_security_group_response_body, :is_a? => true) - lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "Web" ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.create_security_group() }.should.raise(AWS::ArgumentError) + lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "Web" ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_security_group() }.should.raise(AWSAPI::ArgumentError) # :group_name can't be nil or empty - lambda { @ec2.create_security_group( :group_name => "", :group_description => "Web" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_security_group( :group_name => nil, :group_description => "Web" ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.create_security_group( :group_name => "", :group_description => "Web" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_security_group( :group_name => nil, :group_description => "Web" ) }.should.raise(AWSAPI::ArgumentError) # :group_description can't be nil or empty - lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => nil ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => nil ) }.should.raise(AWSAPI::ArgumentError) end @@ -116,12 +116,12 @@ @ec2.stubs(:make_request).with('DeleteSecurityGroup', {"GroupName"=>"WebServers"}). returns stub(:body => @delete_security_group_response_body, :is_a? => true) - lambda { @ec2.delete_security_group( :group_name => "WebServers" ) }.should.not.raise(AWS::ArgumentError) - lambda { @ec2.delete_security_group() }.should.raise(AWS::ArgumentError) + lambda { @ec2.delete_security_group( :group_name => "WebServers" ) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @ec2.delete_security_group() }.should.raise(AWSAPI::ArgumentError) # :group_name can't be nil or empty - lambda { @ec2.delete_security_group( :group_name => "" ) }.should.raise(AWS::ArgumentError) - lambda { @ec2.delete_security_group( :group_name => nil ) }.should.raise(AWS::ArgumentError) + lambda { @ec2.delete_security_group( :group_name => "" ) }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.delete_security_group( :group_name => nil ) }.should.raise(AWSAPI::ArgumentError) end @@ -156,7 +156,7 @@ @ec2.stubs(:make_request).with('DescribeSecurityGroups', {"GroupName.1"=>"WebServers"}). returns stub(:body => @describe_security_groups_response_body, :is_a? => true) - lambda { @ec2.describe_security_groups( :group_name => "WebServers" ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.describe_security_groups( :group_name => "WebServers" ) }.should.not.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_snapshots.rb b/test/test_EC2_snapshots.rb index 1a13513..41f1747 100644 --- a/test/test_EC2_snapshots.rb +++ b/test/test_EC2_snapshots.rb @@ -13,7 +13,7 @@ context "EC2 snaphots " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @describe_snapshots_response_body = <<-RESPONSE diff --git a/test/test_EC2_spot_instance_requests.rb b/test/test_EC2_spot_instance_requests.rb index c751ac0..a16c8ba 100644 --- a/test/test_EC2_spot_instance_requests.rb +++ b/test/test_EC2_spot_instance_requests.rb @@ -13,7 +13,7 @@ context "An EC2 spot instances request " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @create_spot_instances_request_response_body = <<-RESPONSE @@ -111,12 +111,12 @@ ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].each do |type| @ec2.stubs(:make_request).with('RequestSpotInstances', {"SpotPrice"=>"0.50", 'LaunchSpecification.InstanceType' => type, 'LaunchSpecification.ImageId' => 'ami-60a54009', "InstanceCount"=>"1"}). returns stub(:body => @create_spot_instances_request_response_body, :is_a? => true) - lambda { @ec2.request_spot_instances( :image_id => "ami-60a54009", :instance_type => type, :spot_price => '0.50' ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.request_spot_instances( :image_id => "ami-60a54009", :instance_type => type, :spot_price => '0.50' ) }.should.not.raise(AWSAPI::ArgumentError) end end specify "should raise an exception with a bad instance type" do - lambda { @ec2.request_spot_instances({"SpotPrice"=>"0.50", 'LaunchSpecification.InstanceType' => 'm1.notarealsize', "InstanceCount"=>"1"}) }.should.raise(AWS::ArgumentError) + lambda { @ec2.request_spot_instances({"SpotPrice"=>"0.50", 'LaunchSpecification.InstanceType' => 'm1.notarealsize', "InstanceCount"=>"1"}) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be created" do @@ -128,9 +128,9 @@ specify "method create_spot_instances_request should raise an exception when called with nil/empty string arguments" do - lambda { @ec2.request_spot_instances() }.should.raise(AWS::ArgumentError) - lambda { @ec2.request_spot_instances(:spot_price => "") }.should.raise(AWS::ArgumentError) - lambda { @ec2.request_spot_instances(:spot_price => nil) }.should.raise(AWS::ArgumentError) + lambda { @ec2.request_spot_instances() }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.request_spot_instances(:spot_price => "") }.should.raise(AWSAPI::ArgumentError) + lambda { @ec2.request_spot_instances(:spot_price => nil) }.should.raise(AWSAPI::ArgumentError) end diff --git a/test/test_EC2_spot_prices.rb b/test/test_EC2_spot_prices.rb index ec9b63d..8aa404c 100644 --- a/test/test_EC2_spot_prices.rb +++ b/test/test_EC2_spot_prices.rb @@ -3,7 +3,7 @@ context "Spot price history " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @describe_spot_price_history_response_body = <<-RESPONSE @@ -33,27 +33,27 @@ end specify "should reject a start_time which is not a Time object" do - lambda { @ec2.describe_spot_price_history(:start_time => "foo") }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_spot_price_history(:start_time => "foo") }.should.raise(AWSAPI::ArgumentError) end specify "should reject an end_time which is not a Time object" do - lambda { @ec2.describe_spot_price_history(:end_time => 42) }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_spot_price_history(:end_time => 42) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be requested with various instance types" do ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge", "cg1.4xlarge"].each do |type| @ec2.stubs(:make_request).with('DescribeSpotPriceHistory', {'InstanceType' => type}). returns stub(:body => @describe_spot_price_history_response_body, :is_a? => true) - lambda { @ec2.describe_spot_price_history( :instance_type => type ) }.should.not.raise(AWS::ArgumentError) + lambda { @ec2.describe_spot_price_history( :instance_type => type ) }.should.not.raise(AWSAPI::ArgumentError) end end specify "should reject an invalid instance type" do - lambda { @ec2.describe_spot_price_history(:instance_type => 'm1.tiny') }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_spot_price_history(:instance_type => 'm1.tiny') }.should.raise(AWSAPI::ArgumentError) end specify "should reject an invalid product description" do - lambda { @ec2.describe_spot_price_history(:product_description => 'Solaris') }.should.raise(AWS::ArgumentError) + lambda { @ec2.describe_spot_price_history(:product_description => 'Solaris') }.should.raise(AWSAPI::ArgumentError) end end diff --git a/test/test_EC2_subnets.rb b/test/test_EC2_subnets.rb index 19ece5e..a4804b0 100644 --- a/test/test_EC2_subnets.rb +++ b/test/test_EC2_subnets.rb @@ -13,7 +13,7 @@ context "The EC2 subnets " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @describe_subnets_response_body = <<-RESPONSE diff --git a/test/test_EC2_volumes.rb b/test/test_EC2_volumes.rb index c118ca1..e0ed99e 100644 --- a/test/test_EC2_volumes.rb +++ b/test/test_EC2_volumes.rb @@ -13,7 +13,7 @@ context "EC2 volumes " do before do - @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @ec2 = AWSAPI::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @describe_volumes_response_body = <<-RESPONSE diff --git a/test/test_ELB_load_balancers.rb b/test/test_ELB_load_balancers.rb index 48fa12d..e167e67 100644 --- a/test/test_ELB_load_balancers.rb +++ b/test/test_ELB_load_balancers.rb @@ -2,7 +2,7 @@ context "elb load balancers " do before do - @elb = AWS::ELB::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @elb = AWSAPI::ELB::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @valid_create_load_balancer_params = { :load_balancer_name => 'Test Name', @@ -132,13 +132,13 @@ 'Listeners.member.1.InstancePort' => '80' }).returns stub(:body => @create_load_balancer_response_body, :is_a? => true) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params) }.should.not.raise(AWS::ArgumentError) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:load_balancer_name=>'')) }.should.raise(AWS::ArgumentError) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:availability_zones=>'')) }.should.raise(AWS::ArgumentError) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:availability_zones=>[])) }.should.raise(AWS::ArgumentError) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:listeners=>[])) }.should.raise(AWS::ArgumentError) - lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:listeners=>nil)) }.should.raise(AWS::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:load_balancer_name=>'')) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:availability_zones=>'')) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:availability_zones=>[])) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:listeners=>[])) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:listeners=>nil)) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to be deleted with delete_load_balancer" do @@ -178,10 +178,10 @@ 'Instances.member.1.InstanceId' => 'i-6055fa09' }).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true) - lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params) }.should.not.raise(AWS::ArgumentError) - lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>[])) }.should.raise(AWS::ArgumentError) + lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>[])) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to deregister instances from load balancers with deregister_instances_from_load_balancer" do @@ -200,10 +200,10 @@ 'Instances.member.1.InstanceId' => 'i-6055fa09' }).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true) - lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params) }.should.not.raise(AWS::ArgumentError) - lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>[])) }.should.raise(AWS::ArgumentError) + lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>[])) }.should.raise(AWSAPI::ArgumentError) end specify "should be able to configure_health_check for instances from load balancers" do @@ -219,12 +219,12 @@ response = @elb.configure_health_check(@valid_configure_health_check_params) response.should.be.an.instance_of Hash - lambda { @elb.configure_health_check(@valid_configure_health_check_params) }.should.not.raise(AWS::ArgumentError) - lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name => nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name => "")) }.should.raise(AWS::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name => nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name => "")) }.should.raise(AWSAPI::ArgumentError) - lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => "")) }.should.raise(AWS::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => "")) }.should.raise(AWSAPI::ArgumentError) end @@ -267,9 +267,9 @@ 'HealthCheck.UnhealthyThreshold' => '2' }).returns stub(:body => @configure_health_check_response_body, :is_a? => true) - lambda { @elb.configure_health_check(@valid_configure_health_check_params) }.should.not.raise(AWS::ArgumentError) - lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError) - lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check=>nil)) }.should.raise(AWS::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params) }.should.not.raise(AWSAPI::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name=>nil)) }.should.raise(AWSAPI::ArgumentError) + lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check=>nil)) }.should.raise(AWSAPI::ArgumentError) end end diff --git a/test/test_RDS.rb b/test/test_RDS.rb index 083071d..e6a8838 100644 --- a/test/test_RDS.rb +++ b/test/test_RDS.rb @@ -2,7 +2,7 @@ context "rds databases " do before do - @rds = AWS::RDS::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) + @rds = AWSAPI::RDS::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" ) @create_db_instance_body = <<-RESPONSE diff --git a/test/test_helper.rb b/test/test_helper.rb index 14562e1..f5e8c0c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -19,5 +19,5 @@ end } -require File.dirname(__FILE__) + '/../lib/AWS' +require File.dirname(__FILE__) + '/../lib/AWSAPI'