Permalink
Browse files

Whitespace and RDS_URL.

  • Loading branch information...
1 parent 1e42445 commit fd20977c0bb1f5c9328f0212100ad67f76663f31 @grempe committed Oct 30, 2009
Showing with 143 additions and 141 deletions.
  1. +3 −2 lib/AWS.rb
  2. +10 −9 lib/AWS/RDS.rb
  3. +107 −107 lib/AWS/RDS/rds.rb
  4. +23 −23 test/test_RDS.rb
View
5 lib/AWS.rb
@@ -28,10 +28,11 @@ def method_missing(meth, *args, &block)
self[meth.to_s] || self[meth.to_sym]
end
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
@@ -221,7 +222,7 @@ def make_request(action, params, data='')
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)
View
19 lib/AWS/RDS.rb
@@ -2,15 +2,15 @@ module AWS
module RDS
# 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.
- #
+ # 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']
- ELB_URL = ENV['RDS_URL']
+ RDS_URL = ENV['RDS_URL']
VALID_HOSTS = ['rds.amazonaws.com']
- raise ArgumentError, "Invalid ELB_URL environment variable : #{ELB_URL}" unless VALID_HOSTS.include?(ELB_URL)
- DEFAULT_HOST = URI.parse(ELB_URL).host
+ raise ArgumentError, "Invalid RDS_URL environment variable : #{RDS_URL}" unless VALID_HOSTS.include?(RDS_URL)
+ DEFAULT_HOST = URI.parse(RDS_URL).host
else
# Default US API endpoint
DEFAULT_HOST = 'rds.amazonaws.com'
@@ -26,7 +26,7 @@ def api_version
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)
@@ -64,9 +64,10 @@ def aws_error?(response)
end
end
-
-
+
end
end
-end
+
+end
+
View
214 lib/AWS/RDS/rds.rb
@@ -1,7 +1,7 @@
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
#
@@ -19,7 +19,7 @@ class Base < AWS::Base
# @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
# @option options [String] :backend_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)
@@ -28,15 +28,15 @@ def create_db_instance( options = {})
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)
-
+
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)
@@ -45,10 +45,10 @@ def create_db_instance( options = {})
params["PreferredMaintenanceWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
params["BackupRetentionPeriod"] = options[:backend_retention_period] if options.has?(:backend_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)
@@ -57,13 +57,13 @@ def create_db_instance( options = {})
#
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["FinalDBSnapshot­Identifier"] = options[:final_db_snapshot_identifier].to_s if options.has?(:final_db_snapshot_identifier)
-
+
return response_generator(:action => "DeleteDBInstance", :params => params)
end
@@ -77,15 +77,15 @@ 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)
@@ -94,14 +94,14 @@ def create_db_parameter_group( options = {} )
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
@@ -110,14 +110,14 @@ def create_db_security_group( options = {} )
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
@@ -127,10 +127,10 @@ def create_db_snapshot( options = {} )
#
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)
@@ -139,20 +139,20 @@ def authorize_db_security_group( options = {} )
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
@@ -162,10 +162,10 @@ def delete_db_parameter_group( options = {} )
#
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
@@ -175,25 +175,25 @@ def delete_db_security_group( options = {} )
#
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 = {} )
+ 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
@@ -203,105 +203,105 @@ def describe_db_instances( options = {} )
# @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 = {} )
+ 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.
+ # 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 = {} )
+ 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.
+ # 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.
+ # 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 = {} )
+ 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
+ # 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 = {} )
+ 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.
+ # 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,
+ #
+ # 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)
@@ -310,7 +310,7 @@ def describe_db_snapshots( options = {} )
# @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 = {} )
+ 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)
@@ -319,17 +319,17 @@ def describe_events( options = {} )
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.
+ #
+ # 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
@@ -346,13 +346,13 @@ def describe_events( options = {} )
# @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
# @option options [String] :backend_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)
-
+
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)
@@ -366,13 +366,13 @@ def modify_db_instance( options = {})
params["PreferredMaintenanceWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
params["BackupRetentionPeriod"] = options[:backend_retention_period] if options.has?(:backend_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.
+ # 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
@@ -381,35 +381,35 @@ def modify_db_instance( options = {})
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.
+ # 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.
+ # 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
@@ -419,15 +419,15 @@ def reboot_db_instance( options = {} )
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
@@ -439,26 +439,26 @@ def reset_db_parameter_group( options = {} )
# @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 = {} )
+ 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
+ #
+ # 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.
@@ -469,25 +469,25 @@ def restore_db_instance_from_snapshot( options = {} )
# @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_to_point_in_time( options = {} )
+ def restore_db_instance_to_point_in_time( 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['SourceDBInstanceIdentifier'] = options[:source_db_instance_identifier]
params['TargetDBInstanceIdentifier'] = options[:target_db_instance_identifier]
-
+
if options[:use_latest_restorable_time]
params['UseLatestRestorableTime'] = options[:use_latest_restorable_time]
elsif options[: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
@@ -500,10 +500,10 @@ def restore_db_instance_to_point_in_time( options = {} )
#
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)
@@ -512,11 +512,11 @@ def revoke_db_security_group( options = {} )
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
+end
+
View
46 test/test_RDS.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/test_helper.rb'
-context "elb load balancers " do
+context "rds databases " do
before do
@rds = AWS::RDS::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
@@ -47,17 +47,17 @@
</CreateDBSecurityGroupResponse>
RESPONSE
end
-
+
specify "should be able to be create a db_instance" do
- @rds.stubs(:make_request).with('CreateDBInstance', {'Engine' => 'MySQL5.1',
- 'MasterUsername' => 'master',
- 'DBInstanceClass' => 'db.m1.large',
- 'DBInstanceIdentifier' => 'testdb',
- 'AllocatedStorage' => '10',
+ @rds.stubs(:make_request).with('CreateDBInstance', {'Engine' => 'MySQL5.1',
+ 'MasterUsername' => 'master',
+ 'DBInstanceClass' => 'db.m1.large',
+ 'DBInstanceIdentifier' => 'testdb',
+ 'AllocatedStorage' => '10',
'MasterUserPassword' => 'SecretPassword01'}).
returns stub(:body => @create_db_instance_body, :is_a? => true)
response = @rds.create_db_instance(
- :db_instance_class => "db.m1.large",
+ :db_instance_class => "db.m1.large",
:db_instance_identifier=>"testdb",
:allocated_storage => 10,
:engine => "MySQL5.1",
@@ -71,7 +71,7 @@
specify "should be able to create_db_security_group" do
@rds.stubs(:make_request).with('CreateDBSecurityGroup', {
- 'DBSecurityGroupName' => 'mydbsecuritygroup',
+ 'DBSecurityGroupName' => 'mydbsecuritygroup',
'DBSecurityGroupDescription' => 'My new DBSecurityGroup'}).
returns stub(:body => @create_db_security_group, :is_a? => true)
response = @rds.create_db_security_group(
@@ -82,7 +82,7 @@
assert_equal response.CreateDBSecurityGroupResult.DBSecurityGroup.DBSecurityGroupName, "mydbsecuritygroup4"
end
-
+
specify "should be able to create_db_parameter_group" do
body =<<-EOE
<CreateDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
@@ -98,8 +98,8 @@
</ResponseMetadata>
</CreateDBParameterGroupResponse>
EOE
- @rds.stubs(:make_request).with('CreateDBParameterGroup', {'Engine' => 'MySQL5.1',
- 'DBParameterGroupName' => 'mydbsecuritygroup',
+ @rds.stubs(:make_request).with('CreateDBParameterGroup', {'Engine' => 'MySQL5.1',
+ 'DBParameterGroupName' => 'mydbsecuritygroup',
'Description' => 'My test DBSecurity group'}).
returns stub(:body => body, :is_a? => true)
response = @rds.create_db_parameter_group(
@@ -143,7 +143,7 @@
assert_equal response.CreateDBSnapshotResult.DBSnapshot.DBSnapshotIdentifier, "mynewdbsnapshot3"
end
-
+
specify "should be able to authorize_db_security_group" do
body =<<-EOE
<AuthorizeDBSecurityGroupIngressResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
@@ -176,7 +176,7 @@
assert_equal response.AuthorizeDBSecurityGroupIngressResult.DBSecurityGroup.IPRanges.IPRange.CIDRIP, "192.168.1.1/24"
end
-
+
specify "should be able to delete_db_parameter_group" do
body =<<-EOE
<DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
@@ -192,7 +192,7 @@
)
response.should.be.an.instance_of Hash
end
-
+
specify "should be able to delete_db_security_group" do
body =<<-EOE
<DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
@@ -329,15 +329,15 @@
</ResponseMetadata>
</ModifyDBParameterGroupResponse>
EOE
-
+
@rds.stubs(:make_request).with('ModifyDBParameterGroup', {
- 'DBParameterGroupName' => 'mytestdb',
- 'Parameters.member.1.ParameterName' => 'max_user_connections',
- 'Parameters.member.1.ParameterValue' => '24',
+ 'DBParameterGroupName' => 'mytestdb',
+ 'Parameters.member.1.ParameterName' => 'max_user_connections',
+ 'Parameters.member.1.ParameterValue' => '24',
'Parameters.member.1.ApplyMethod' => 'pending-reboot',
'Parameters.member.2.ParameterName' => 'max_allowed_packet',
- 'Parameters.member.2.ParameterValue' => '1024',
- 'Parameters.member.2.ApplyMethod' => 'immediate',
+ 'Parameters.member.2.ParameterValue' => '1024',
+ 'Parameters.member.2.ApplyMethod' => 'immediate',
}).
returns stub(:body => body, :is_a? => true)
response = @rds.modify_db_parameter_group(
@@ -350,5 +350,5 @@
response.should.be.an.instance_of Hash
end
-
-end
+end
+

0 comments on commit fd20977

Please sign in to comment.