amazon-ec2 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,12 @@ Amazon Web Services offers a compute power on demand capability known as the Ela
6
6
 
7
7
  This 'amazon-ec2' Ruby Gem is an interface library that can be used to interact with the Amazon EC2 system and control server resources on demand from your Ruby scripts, or from applications written in your Ruby framework of choice (Ruby on Rails, Merb, etc.).
8
8
 
9
+ More recently, support has been added for the following EC2 related AWS API's as well:
10
+
11
+ * Autoscaling
12
+ * Cloudwatch
13
+ * Elastic Load Balancing
14
+
9
15
  For the most complete and up-to date README information please visit the project homepage at:
10
16
 
11
17
  http://github.com/grempe/amazon-ec2/tree/master
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.2
1
+ 0.7.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{amazon-ec2}
8
- s.version = "0.6.2"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Glenn Rempe"]
12
- s.date = %q{2009-10-14}
12
+ s.date = %q{2009-10-29}
13
13
  s.description = %q{A Ruby library for accessing the Amazon Web Services Elastic Compute Cloud (EC2), Elastic Load Balancer (ELB), Cloudwatch, and Autoscaling API's.}
14
14
  s.email = %q{glenn@rempe.us}
15
15
  s.executables = ["ec2-gem-example.rb", "ec2-gem-profile.rb", "ec2sh", "setup.rb"]
@@ -53,6 +53,8 @@ Gem::Specification.new do |s|
53
53
  "lib/AWS/EC2/volumes.rb",
54
54
  "lib/AWS/ELB.rb",
55
55
  "lib/AWS/ELB/load_balancers.rb",
56
+ "lib/AWS/RDS.rb",
57
+ "lib/AWS/RDS/rds.rb",
56
58
  "lib/AWS/exceptions.rb",
57
59
  "lib/AWS/responses.rb",
58
60
  "perftools/ec2prof",
@@ -75,6 +77,7 @@ Gem::Specification.new do |s|
75
77
  "test/test_EC2_snapshots.rb",
76
78
  "test/test_EC2_volumes.rb",
77
79
  "test/test_ELB_load_balancers.rb",
80
+ "test/test_RDS.rb",
78
81
  "test/test_helper.rb",
79
82
  "wsdl/2007-08-29.ec2.wsdl",
80
83
  "wsdl/2008-02-01.ec2.wsdl",
@@ -104,7 +107,8 @@ Gem::Specification.new do |s|
104
107
  "test/test_EC2_snapshots.rb",
105
108
  "test/test_EC2_volumes.rb",
106
109
  "test/test_ELB_load_balancers.rb",
107
- "test/test_helper.rb"
110
+ "test/test_helper.rb",
111
+ "test/test_RDS.rb"
108
112
  ]
109
113
 
110
114
  if s.respond_to? :specification_version then
@@ -20,6 +20,7 @@ if ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY']
20
20
  @ec2 = AWS::EC2::Base.new(opts)
21
21
  @elb = AWS::ELB::Base.new(opts)
22
22
  @as = AWS::Autoscaling::Base.new(opts)
23
+ @rds = AWS::RDS::Base.new(opts)
23
24
  end
24
25
 
25
26
  puts "EC2 Server: #{opts[:server]}"
data/lib/AWS.rb CHANGED
@@ -28,6 +28,14 @@ class Hash
28
28
  self[meth.to_s] || self[meth.to_sym]
29
29
  end
30
30
  end
31
+
32
+ def has?(key)
33
+ self[key] && !self[key].to_s.empty?
34
+ end
35
+
36
+ def does_not_have?(key)
37
+ self[key].nil? || self[key].to_s.empty?
38
+ end
31
39
  end
32
40
 
33
41
 
@@ -214,7 +222,7 @@ module AWS
214
222
  req['User-Agent'] = "github-amazon-ec2-ruby-gem"
215
223
 
216
224
  response = @http.request(req, query)
217
-
225
+
218
226
  # Make a call to see if we need to throw an error based on the response given by EC2
219
227
  # All error classes are defined in EC2/exceptions.rb
220
228
  aws_error?(response)
@@ -0,0 +1,73 @@
1
+ module AWS
2
+ module RDS
3
+
4
+ # Which host FQDN will we connect to for all API calls to AWS?
5
+ # If RDS_URL is defined in the users ENV we can override the default with that.
6
+ #
7
+ # @example
8
+ # export RDS_URL='https://rds.amazonaws.com'
9
+ if ENV['RDS_URL']
10
+ RDS_URL = ENV['RDS_URL']
11
+ VALID_HOSTS = ['rds.amazonaws.com']
12
+ raise ArgumentError, "Invalid RDS_URL environment variable : #{RDS_URL}" unless VALID_HOSTS.include?(RDS_URL)
13
+ DEFAULT_HOST = URI.parse(RDS_URL).host
14
+ else
15
+ # Default US API endpoint
16
+ DEFAULT_HOST = 'rds.amazonaws.com'
17
+ end
18
+
19
+ API_VERSION = '2009-10-16'
20
+
21
+ class Base < AWS::Base
22
+ def api_version
23
+ API_VERSION
24
+ end
25
+
26
+ def default_host
27
+ DEFAULT_HOST
28
+ end
29
+
30
+ # Raises the appropriate error if the specified Net::HTTPResponse object
31
+ # contains an Amazon EC2 error; returns +false+ otherwise.
32
+ def aws_error?(response)
33
+
34
+ # return false if we got a HTTP 200 code,
35
+ # otherwise there is some type of error (40x,50x) and
36
+ # we should try to raise an appropriate exception
37
+ # from one of our exception classes defined in
38
+ # exceptions.rb
39
+ return false if response.is_a?(Net::HTTPSuccess)
40
+
41
+ # parse the XML document so we can walk through it
42
+ doc = REXML::Document.new(response.body)
43
+
44
+ # Check that the Error element is in the place we would expect.
45
+ # and if not raise a generic error exception
46
+ unless doc.root.elements[1].name == "Error"
47
+ raise Error, "Unexpected error format. response.body is: #{response.body}"
48
+ end
49
+
50
+ # An valid error response looks like this:
51
+ # <?xml version="1.0"?><Response><Errors><Error><Code>InvalidParameterCombination</Code><Message>Unknown parameter: foo</Message></Error></Errors><RequestID>291cef62-3e86-414b-900e-17246eccfae8</RequestID></Response>
52
+ # AWS EC2 throws some exception codes that look like Error.SubError. Since we can't name classes this way
53
+ # we need to strip out the '.' in the error 'Code' and we name the error exceptions with this
54
+ # non '.' name as well.
55
+ error_code = doc.root.elements['//ErrorResponse/Error/Code'].text.gsub('.', '')
56
+ error_message = doc.root.elements['//ErrorResponse/Error/Message'].text
57
+
58
+ # Raise one of our specific error classes if it exists.
59
+ # otherwise, throw a generic EC2 Error with a few details.
60
+ if AWS.const_defined?(error_code)
61
+ raise AWS.const_get(error_code), error_message
62
+ else
63
+ raise AWS::Error, error_message
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
@@ -0,0 +1,522 @@
1
+ module AWS
2
+ module RDS
3
+ class Base < AWS::Base
4
+
5
+ # This API creates a new DB instance. Once the call has completed
6
+ # successfully, a new DB instance will be created, but it will not be
7
+ #
8
+ # @option options [String] :db_instance_identifier (nil) the name of the db_instance
9
+ # @option options [String] :allocated_storage in gigabytes (nil)
10
+ # @option options [String] :db_instance_class in contains compute and memory capacity (nil)
11
+ # @option options [String] :engine type i.e. MySQL5.1 (nil)
12
+ # @option options [String] :master_username is the master username for the db instance (nil)
13
+ # @option options [String] :master_user_password is the master password for the db instance (nil)
14
+ # @option options [String] :port is the port the database accepts connections on (3306)
15
+ # @option options [String] :db_name contains the name of the database to create when created (nil)
16
+ # @option options [String] :db_parameter_group is the database parameter group to associate with this instance (nil)
17
+ # @option options [String] :db_security_groups are the list of db security groups to associate with the instance (nil)
18
+ # @option options [String] :availability_zone is the availability_zone to create the instance in (nil)
19
+ # @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
20
+ # @option options [String] :backend_retention_period is the number of days which automated backups are retained (1)
21
+ # @option options [String] :preferred_backup_window is the daily time range for which automated backups are created
22
+ #
23
+ def create_db_instance( options = {})
24
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
25
+ raise ArgumentError, "No :allocated_storage provided" if options.does_not_have?(:allocated_storage)
26
+ raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class)
27
+ raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine)
28
+ raise ArgumentError, "No :master_username provided" if options.does_not_have?(:master_username)
29
+ raise ArgumentError, "No :master_user_password provided" if options.does_not_have?(:master_user_password)
30
+ raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class)
31
+
32
+ params = {}
33
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier]
34
+ params["AllocatedStorage"] = options[:allocated_storage].to_s
35
+ params["DBInstanceClass"] = options[:db_instance_class]
36
+ params["Engine"] = options[:engine]
37
+ params["MasterUsername"] = options[:master_username]
38
+ params["MasterUserPassword"] = options[:master_user_password]
39
+
40
+ params["Port"] = options[:port].to_s if options.has?(:port)
41
+ params["DBName"] = options[:db_name] if options.has?(:db_name)
42
+ params["DBParameterGroup"] = options[:db_parameter_group] if options.has?(:db_parameter_group)
43
+ params["DBSecurityGroups"] = options[:db_security_groups] if options.has?(:db_security_groups)
44
+ params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone)
45
+ params["PreferredMaintenanceWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
46
+ params["BackupRetentionPeriod"] = options[:backend_retention_period] if options.has?(:backend_retention_period)
47
+ params["PreferredBackupWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
48
+
49
+ return response_generator(:action => "CreateDBInstance", :params => params)
50
+ end
51
+
52
+ # This API method deletes a db instance identifier
53
+ #
54
+ # @option options [String] :db_instance_identifier is the instance identifier for the DB instance to be deleted (nil)
55
+ # @option options [String] :skip_final_snapshot determines to create a snapshot or not before it's deleted (no)
56
+ # @option options [String] :final_db_snapshot_identifier is the name of the snapshot created before the instance is deleted (name)
57
+ #
58
+ def delete_db_instance( options = {} )
59
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
60
+
61
+ params = {}
62
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier]
63
+
64
+ params["SkipFinalSnapshot"] = options[:skip_final_snapshot].to_s if options.has?(:skip_final_snapshot)
65
+ params["FinalDBSnapshot­Identifier"] = options[:final_db_snapshot_identifier].to_s if options.has?(:final_db_snapshot_identifier)
66
+
67
+ return response_generator(:action => "DeleteDBInstance", :params => params)
68
+ end
69
+
70
+ # This API method creates a db parameter group
71
+ #
72
+ # @option options [String] :db_parameter_group_name is the name of the parameter group (nil)
73
+ # @option options [String] :engine is the engine the db parameter group can be used with (nil)
74
+ # @option options [String] :description is the description of the paramter group
75
+ #
76
+ def create_db_parameter_group( options = {} )
77
+ raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name)
78
+ raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine)
79
+ raise ArgumentError, "No :description provided" if options.does_not_have?(:description)
80
+
81
+ params = {}
82
+ params['DBParameterGroupName'] = options[:db_parameter_group_name]
83
+ params['Engine'] = options[:engine]
84
+ params['Description'] = options[:description]
85
+
86
+ return response_generator(:action => "CreateDBParameterGroup", :params => params)
87
+ end
88
+
89
+ # This API method creates a db security group
90
+ #
91
+ # @option options [String] :db_security_group_name is the name of the db security group (nil)
92
+ # @option options [String] :db_security_group_description is the description of the db security group
93
+ #
94
+ def create_db_security_group( options = {} )
95
+ raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name)
96
+ raise ArgumentError, "No :db_security_group_description provided" if options.does_not_have?(:db_security_group_description)
97
+
98
+ params = {}
99
+ params['DBSecurityGroupName'] = options[:db_security_group_name]
100
+ params['DBSecurityGroupDescription'] = options[:db_security_group_description]
101
+
102
+ return response_generator(:action => "CreateDBSecurityGroup", :params => params)
103
+ end
104
+
105
+ # This API method creates a restoreable db snapshot
106
+ #
107
+ # @option options [String] :db_snapshot_identifier is the identifier of the db snapshot
108
+ # @option options [String] :db_instance_identifier is the identifier of the db instance
109
+ #
110
+ def create_db_snapshot( options = {} )
111
+ raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier)
112
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
113
+
114
+ params = {}
115
+ params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier]
116
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier]
117
+
118
+ return response_generator(:action => "CreateDBSnapshot", :params => params)
119
+ end
120
+
121
+ # This API method authorizes network ingress for an amazon ec2 group
122
+ #
123
+ # @option options [String] :db_security_group_name is the name of the db security group
124
+ # @option options [String] :cidrip is the network ip to authorize
125
+ # @option options [String] :ec2_security_group_name is the name of the ec2 security group to authorize
126
+ # @option options [String] :ec2_security_group_owner_id is the owner id of the security group
127
+ #
128
+ def authorize_db_security_group( options = {} )
129
+ raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name)
130
+
131
+ params = {}
132
+ params['DBSecurityGroupName'] = options[:db_security_group_name]
133
+
134
+ if options.has?(:cidrip)
135
+ params['CIDRIP'] = options[:cidrip]
136
+ elsif options.has?(:ec2_security_group_name) && options.has?(:ec2_security_group_owner_id)
137
+ params['EC2SecurityGroupName'] = options[:ec2_security_group_name]
138
+ params['EC2SecurityGroupOwnerId'] = options[:ec2_security_group_owner_id]
139
+ else
140
+ raise ArgumentError, "No :cidrip or :ec2_security_group_name and :ec2_security_group_owner_id provided"
141
+ end
142
+
143
+ return response_generator(:action => "AuthorizeDBSecurityGroupIngress", :params => params)
144
+ end
145
+
146
+ # This API method deletes a db paramter group
147
+ #
148
+ # @option options [String] :db_parameter_group_name is the name of the db paramter group to be deleted (nil)
149
+ #
150
+ def delete_db_parameter_group( options = {} )
151
+ raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name)
152
+
153
+ params = {}
154
+ params['DBParameterGroupName'] = options[:db_parameter_group_name]
155
+
156
+ return response_generator(:action => "DeleteDBParameterGroup", :params => params)
157
+ end
158
+
159
+ # This API method deletes a db security group
160
+ #
161
+ # @option options [String] :db_parameter_group_name is the name of the db security group to be deleted (nil)
162
+ #
163
+ def delete_db_security_group( options = {} )
164
+ raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name)
165
+
166
+ params = {}
167
+ params['DBSecurityGroupName'] = options[:db_security_group_name]
168
+
169
+ return response_generator(:action => "DeleteDBSecurityGroup", :params => params)
170
+ end
171
+
172
+ # This API method deletes a db snapshot
173
+ #
174
+ # @option options [String] :db_snapshot_identifier is the name of the db snapshot to be deleted (nil)
175
+ #
176
+ def delete_db_snapshot( options = {} )
177
+ raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier)
178
+
179
+ params = {}
180
+ params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier]
181
+
182
+ return response_generator(:action => "DeleteDBSnapshot", :params => params)
183
+ end
184
+
185
+ # This API method describes the db instances
186
+ #
187
+ # @option options [String] :db_instance_identifier if passed, only the description for the db instance matching this identifier is returned
188
+ # @option options [String] :max_records is the maximum number of records to include in the response
189
+ # @option options [String] :marker provided in the previous request
190
+ #
191
+ def describe_db_instances( options = {} )
192
+ params = {}
193
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier] if options.has?(:db_instance_identifier)
194
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
195
+ params['Marker'] = options[:marker] if options.has?(:marker)
196
+
197
+ return response_generator(:action => "DescribeDBInstances", :params => params)
198
+ end
199
+
200
+ # This API method describes the default engine parameters
201
+ #
202
+ # @option options [String] :engine is the name of the database engine
203
+ # @option options [String] :max_records is the maximum number of records to include in the response
204
+ # @option options [String] :marker provided in the previous request
205
+ #
206
+ def describe_engine_default_parameters( options = {} )
207
+ raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine)
208
+
209
+ params = {}
210
+ params['Engine'] = options[:engine]
211
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
212
+ params['Marker'] = options[:marker] if options.has?(:marker)
213
+
214
+ return response_generator(:action => "DescribeEngineDefaultParameters", :params => params)
215
+ end
216
+
217
+ # This API method returns information about all DB Parameter Groups for an account if no
218
+ # DB Parameter Group name is supplied, or displays information about a specific named DB Parameter Group.
219
+ # You can call this operation recursively using the Marker parameter.
220
+ #
221
+ # @option options [String] :db_parameter_group_name is the name of the parameter group
222
+ # @option options [String] :max_records is the maximum number of records to include in the response
223
+ # @option options [String] :marker provided in the previous request
224
+ #
225
+ def describe_db_parameter_groups( options = {} )
226
+ params = {}
227
+ params['DBParameterGroupName'] = options[:db_parameter_group_name] if options.has?(:db_parameter_group_name)
228
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
229
+ params['Marker'] = options[:marker] if options.has?(:marker)
230
+
231
+ return response_generator(:action => "DescribeDBParameterGroups", :params => params)
232
+ end
233
+
234
+ # This API method returns information about parameters that are part of a parameter group.
235
+ # You can optionally request only parameters from a specific source.
236
+ # You can call this operation recursively using the Marker parameter.
237
+ #
238
+ # @option options [String] :db_parameter_group_name is the name parameter group
239
+ # @option options [String] :source is the type of parameter to return
240
+ # @option options [String] :max_records is the maximum number of records to include in the response
241
+ # @option options [String] :marker provided in the previous request
242
+ #
243
+ def describe_db_parameters( options = {} )
244
+ raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name)
245
+
246
+ params = {}
247
+ params['DBParameterGroupName'] = options[:db_parameter_group_name]
248
+ params['Source'] = options[:source] if options.has?(:source)
249
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
250
+ params['Marker'] = options[:marker] if options.has?(:marker)
251
+
252
+ return response_generator(:action => "DescribeDBParameters", :params => params)
253
+ end
254
+
255
+ # This API method returns all the DB Security Group details for a particular AWS account,
256
+ # or for a particular DB Security Group if a name is specified.
257
+ # You can call this operation recursively using the Marker parameter.
258
+ #
259
+ # @option options [String] :db_security_group_name is the name of the security group
260
+ # @option options [String] :max_records is the maximum number of records to include in the response
261
+ # @option options [String] :marker provided in the previous request
262
+ #
263
+ def describe_db_security_groups( options = {} )
264
+ params = {}
265
+ params['DBSecurityGroupName'] = options[:db_security_group_name] if options.has?(:db_security_group_name)
266
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
267
+ params['Marker'] = options[:marker] if options.has?(:marker)
268
+
269
+ return response_generator(:action => "DescribeDBSecurityGroups", :params => params)
270
+ end
271
+
272
+ # This API method returns information about the DB Snapshots for this account.
273
+ # If you pass in a DBInstanceIdentifier, it returns information only about DB Snapshots taken for that DB Instance.
274
+ # If you pass in a DBSnapshotIdentifier,it will return information only about the specified snapshot.
275
+ # If you omit both DBInstanceIdentifier and DBSnapshotIdentifier, it returns all snapshot information for all
276
+ # database instances, up to the maximum number of records specified. Passing both DBInstanceIdentifier and
277
+ # DBSnapshotIdentifier results in an error.
278
+ #
279
+ # @option options [String] :db_instance_identifier is the unique identifier that identifies a DB instance
280
+ # @option options [String] :db_snapshot_identifier is a unique identifier for an amazon RDS snapshot
281
+ # @option options [String] :max_records is the maximum number of records to include in the response
282
+ # @option options [String] :marker provided in the previous request
283
+ #
284
+ def describe_db_snapshots( options = {} )
285
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
286
+
287
+ params = {}
288
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier]
289
+
290
+ params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier] if options.has?(:db_snapshot_identifier)
291
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
292
+ params['Marker'] = options[:marker] if options.has?(:marker)
293
+
294
+ return response_generator(:action => "DescribeDBSnapshots", :params => params)
295
+ end
296
+
297
+ # This API method Returns information about events related to your DB Instances, DB Security Groups,
298
+ # and DB Parameter Groups for up to the past 14 days.
299
+ # You can get events specific to a particular DB Instance or DB Security Group by providing the name as a parameter.
300
+ # By default, the past hour of events are returned.
301
+ #
302
+ # If neither DBInstanceIdentifier or DBSecurityGroupName are provided,
303
+ # all events are be retrieved for DB Instances and DB Security Groups.
304
+ #
305
+ # @option options [String] :source_identifier is the identifier for the source for which events will be included
306
+ # @option options [String] :source_type is the type of event sources to return
307
+ # @option options [String] :start_time is the beginning of the time interval to return records for (ISO 8601 format)
308
+ # @option options [String] :end_time is the end of the time interval to return records (ISO 8601 format)
309
+ # @option options [String] :duration is the number of minutes to return events for.
310
+ # @option options [String] :max_records is the maximum number of records to include in the response
311
+ # @option options [String] :marker provided in the previous request
312
+ #
313
+ def describe_events( options = {} )
314
+ params = {}
315
+ params['SourceIdentifier'] = options[:source_identifier] if options.has?(:source_identifier)
316
+ params['SourceType'] = options[:source_type] if options.has?(:source_type)
317
+ params['StartTime'] = options[:start_time] if options.has?(:start_time)
318
+ params['EndTime'] = options[:end_time] if options.has?(:end_time)
319
+ params['Duration'] = options[:duration] if options.has?(:duration)
320
+ params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)
321
+ params['Marker'] = options[:marker] if options.has?(:marker)
322
+
323
+ return response_generator(:action => "DescribeEvents", :params => params)
324
+ end
325
+
326
+ # This API changes the settings of an existing DB Instance.
327
+ #
328
+ # Changes are applied in the following manner: A ModifyDBInstance API call to modify security groups or to
329
+ # change the maintenance windows results in immediate action. Modification of the DB Parameter Group applies
330
+ # immediate parameters as soon as possible and pending-reboot parameters only when the RDS instance is rebooted.
331
+ # A request to scale the DB Instance class results puts the database instance into the modifying state.
332
+ #
333
+ # The DB Instance must be in available or modifying state for this API to accept changes.
334
+ #
335
+ # @option options [String] :db_instance_identifier (nil) the name of the db_instance
336
+ # @option options [String] :allocated_storage in gigabytes (nil)
337
+ # @option options [String] :db_instance_class in contains compute and memory capacity (nil)
338
+ # @option options [String] :engine type i.e. MySQL5.1 (nil)
339
+ # @option options [String] :master_username is the master username for the db instance (nil)
340
+ # @option options [String] :master_user_password is the master password for the db instance (nil)
341
+ # @option options [String] :port is the port the database accepts connections on (3306)
342
+ # @option options [String] :db_name contains the name of the database to create when created (nil)
343
+ # @option options [String] :db_parameter_group_name is the database parameter group to associate with this instance (nil)
344
+ # @option options [String] :db_security_groups are the list of db security groups to associate with the instance (nil)
345
+ # @option options [String] :availability_zone is the availability_zone to create the instance in (nil)
346
+ # @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
347
+ # @option options [String] :backend_retention_period is the number of days which automated backups are retained (1)
348
+ # @option options [String] :preferred_backup_window is the daily time range for which automated backups are created
349
+ #
350
+ def modify_db_instance( options = {})
351
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
352
+
353
+ params = {}
354
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier]
355
+
356
+ params["AllocatedStorage"] = options[:allocated_storage].to_s if options.has?(:allocated_storage)
357
+ params["DBInstanceClass"] = options[:db_instance_class] if options.has?(:db_instance_class)
358
+ params["Engine"] = options[:engine] if options.has?(:engine)
359
+ params["MasterUsername"] = options[:master_username] if options.has?(:master_username)
360
+ params["MasterUserPassword"] = options[:master_user_password] if options.has?(:master_user_password)
361
+ params["Port"] = options[:port].to_s if options.has?(:port)
362
+ params["DBName"] = options[:db_name] if options.has?(:db_name)
363
+ params["DBParameterGroupName"] = options[:db_parameter_group_name] if options.has?(:db_parameter_group_name)
364
+ params["DBSecurityGroups"] = options[:db_security_groups] if options.has?(:db_security_groups)
365
+ params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone)
366
+ params["PreferredMaintenanceWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
367
+ params["BackupRetentionPeriod"] = options[:backend_retention_period] if options.has?(:backend_retention_period)
368
+ params["PreferredBackupWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
369
+
370
+ return response_generator(:action => "ModifyDBInstance", :params => params)
371
+ end
372
+
373
+ # This API method modifies the parameters of a DB Parameter Group.
374
+ # To modify more than one parameter, submit a list of the following: ParameterName, ParameterValue, and ApplyMethod.
375
+ # You can modify a maximum of 20 parameters in a single request.
376
+ #
377
+ # @option options [String] :db_parameter_group_name is the name of the parameter group to modify
378
+ # @option options [String] :parameters is the array of parameters to update in a hash format
379
+ # {:name => "ParameterName", :value => "ParameterValue", :apply_method => "pending-reboot"}
380
+ #
381
+ def modify_db_parameter_group( options = {} )
382
+ raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name)
383
+ raise ArgumentError, "No :parameters provided" if options.does_not_have?(:parameters)
384
+
385
+ params = {}
386
+ params['DBParameterGroupName'] = options[:db_parameter_group_name]
387
+ params.merge!(pathhashlist('Parameters.member', [options[:parameters]].flatten, {
388
+ :name => 'ParameterName',
389
+ :value => 'ParameterValue',
390
+ :apply_method => "ApplyMethod"
391
+ }))
392
+
393
+ return response_generator(:action => "ModifyDBParameterGroup", :params => params)
394
+ end
395
+
396
+ # This API method reboots a DB Instance.
397
+ # Once started, the process cannot be stopped, and the database instance will be unavailable until the reboot completes.
398
+ #
399
+ # @option options [String] :db_instance_identifier is the identifier for the db instance to restart
400
+ #
401
+ def reboot_db_instance( options = {} )
402
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier
403
+ )
404
+ params = {}
405
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier] if options.has?(:db_instance_identifier)
406
+
407
+ return response_generator(:action => "RebootDBInstance", :params => params)
408
+ end
409
+
410
+ # This API method modifies the parameters of a DB Parameter Group.
411
+ # To modify more than one parameter, submit a list of the following: ParameterName, ParameterValue, and ApplyMethod.
412
+ # You can modify a maximum of 20 parameters in a single request.
413
+ #
414
+ # @option options [String] :db_parameter_group_name is the name of the parameter group to modify
415
+ # @option options [String] :reset_all_parameters specified whether to reset all the db parameters
416
+ # @option options [String] :parameters is the array of parameters to update in a hash format
417
+ # {:name => "ParameterName", :apply_method => "pending-reboot"}
418
+ #
419
+ def reset_db_parameter_group( options = {} )
420
+ raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name)
421
+ raise ArgumentError, "No :parameters provided" if options.does_not_have?(:parameters)
422
+
423
+ params = {}
424
+ params['DBParameterGroupName'] = options[:db_parameter_group_name]
425
+ params.merge!(pathhashlist('Parameters.member', [options[:parameters]].flatten, {
426
+ :name => 'ParameterName',
427
+ :apply_method => "ApplyMethod"
428
+ }))
429
+ params['ResetAllParameters'] = options[:reset_all_parameters] if options.has?(:reset_all_parameters)
430
+
431
+ return response_generator(:action => "ResetDBParameterGroup", :params => params)
432
+ end
433
+
434
+ # This API method restores a db instance to a snapshot of the instance
435
+ #
436
+ # @option options [String] :db_snapshot_identifier is the db identifier of the snapshot to restore from
437
+ # @option options [String] :db_instance_identifier is the identifier of the db instance
438
+ # @option options [String] :db_instance_class is the class of db compute and memory instance for the db instance
439
+ # @option options [String] :port is the port which the db can accept connections on
440
+ # @option options [String] :availability_zone is the EC2 zone which the db instance will be created
441
+ #
442
+ def restore_db_instance_from_snapshot( options = {} )
443
+ raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier)
444
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
445
+ raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class)
446
+
447
+ params = {}
448
+ params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier]
449
+ params['DBInstanceIdentifier'] = options[:db_instance_identifier]
450
+ params['DBInstanceClass'] = options[:db_instance_class]
451
+
452
+ params['Port'] = options[:port].to_s if options.has?(:port)
453
+ params['AvailabilityZone'] = options[:availability_zone] if options.has?(:availability_zone)
454
+
455
+ return response_generator(:action => "RestoreDBInstanceFromDBSnapshot", :params => params)
456
+ end
457
+
458
+ # This API method restores a DB Instance to a specified time, creating a new DB Instance.
459
+ #
460
+ # Some characteristics of the new DB Instance can be modified using optional parameters.
461
+ # If these options are omitted, the new DB Instance defaults to the characteristics of the DB Instance from which the
462
+ # DB Snapshot was created.
463
+ #
464
+ # @option options [String] :source_db_instance_identifier the identifier of the source DB Instance from which to restore.
465
+ # @option options [String] :target_db_instance_identifier is the name of the new database instance to be created.
466
+ # @option options [String] :use_latest_restorable_time specifies that the db be restored to the latest restored time
467
+ # @option options [String] :restore_time specifies the date and time to restore from
468
+ # @option options [String] :db_instance_class specifies the class of the compute and memory of the EC2 instance
469
+ # @option options [String] :port is the port which the db can accept connections on
470
+ # @option options [String] :availability_zone is the EC2 zone which the db instance will be created
471
+ #
472
+ def restore_db_instance_to_point_in_time( options = {} )
473
+ raise ArgumentError, "No :db_snapshot_identifier provided" if options.does_not_have?(:db_snapshot_identifier)
474
+ raise ArgumentError, "No :db_instance_identifier provided" if options.does_not_have?(:db_instance_identifier)
475
+ raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class)
476
+
477
+ params = {}
478
+ params['SourceDBInstanceIdentifier'] = options[:source_db_instance_identifier]
479
+ params['TargetDBInstanceIdentifier'] = options[:target_db_instance_identifier]
480
+
481
+ if options[:use_latest_restorable_time]
482
+ params['UseLatestRestorableTime'] = options[:use_latest_restorable_time]
483
+ elsif options[:restore_time]
484
+ params['RestoreTime'] = options[:restore_time]
485
+ end
486
+
487
+ params['DBInstanceClass'] = options[:db_instance_class] if options.has?(:db_instance_class)
488
+ params['Port'] = options[:port].to_s if options.has?(:port)
489
+ params['AvailabilityZone'] = options[:availability_zone] if options.has?(:availability_zone)
490
+
491
+ return response_generator(:action => "RestoreDBInstanceToPointInTime", :params => params)
492
+ end
493
+
494
+ # This API method authorizes network ingress for an amazon ec2 group
495
+ #
496
+ # @option options [String] :db_security_group_name is the name of the db security group
497
+ # @option options [String] :cidrip is the network ip to revoke
498
+ # @option options [String] :ec2_security_group_name is the name of the ec2 security group to authorize
499
+ # @option options [String] :ec2_security_group_owner_id is the owner id of the security group
500
+ #
501
+ def revoke_db_security_group( options = {} )
502
+ raise ArgumentError, "No :db_security_group_name provided" if options.does_not_have?(:db_security_group_name)
503
+
504
+ params = {}
505
+ params['DBSecurityGroupName'] = options[:db_security_group_name]
506
+
507
+ if options.has?(:cidrip)
508
+ params['CIDRIP'] = options[:cidrip]
509
+ elsif options.has?(:ec2_security_group_name) && options.has?(:ec2_security_group_owner_id)
510
+ params['EC2SecurityGroupName'] = options[:ec2_security_group_name]
511
+ params['EC2SecurityGroupOwnerId'] = options[:ec2_security_group_owner_id]
512
+ else
513
+ raise ArgumentError, "No :cidrip or :ec2_security_group_name and :ec2_security_group_owner_id provided"
514
+ end
515
+
516
+ return response_generator(:action => "RevokeDBSecurityGroupIngress", :params => params)
517
+ end
518
+
519
+ end
520
+ end
521
+ end
522
+
@@ -0,0 +1,354 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ context "rds databases " do
4
+ before do
5
+ @rds = AWS::RDS::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
6
+
7
+ @create_db_instance_body = <<-RESPONSE
8
+ <CreateDBInstanceResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
9
+ <CreateDBInstanceResult>
10
+ <DBInstance>
11
+ <Engine>MySQL5.1</Engine>
12
+ <BackupRetentionPeriod>1</BackupRetentionPeriod>
13
+ <DBInstanceStatus>creating</DBInstanceStatus>
14
+ <DBInstanceIdentifier>mydbinstance</DBInstanceIdentifier>
15
+ <PreferredBackupWindow>03:00-05:00</PreferredBackupWindow>
16
+ <DBSecurityGroups>
17
+ <DBSecurityGroup>
18
+ <Status>active</Status>
19
+ <DBSecurityGroupName>default</DBSecurityGroupName>
20
+ </DBSecurityGroup>
21
+ </DBSecurityGroups>
22
+ <PreferredMaintenanceWindow>sun:05:00-sun:09:00</PreferredMaintenanceWindow>
23
+ <AllocatedStorage>10</AllocatedStorage>
24
+ <DBInstanceClass>db.m1.large</DBInstanceClass>
25
+ <MasterUsername>master</MasterUsername>
26
+ </DBInstance>
27
+ </CreateDBInstanceResult>
28
+ <ResponseMetadata>
29
+ <RequestId>e6fb58c5-bf34-11de-b88d-993294bf1c81</RequestId>
30
+ </ResponseMetadata>
31
+ </CreateDBInstanceResponse>
32
+ RESPONSE
33
+ @create_db_security_group = <<-RESPONSE
34
+ <CreateDBSecurityGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
35
+ <CreateDBSecurityGroupResult>
36
+ <DBSecurityGroup>
37
+ <EC2SecurityGroups/>
38
+ <DBSecurityGroupDescription>My new DBSecurityGroup</DBSecurityGroupDescription>
39
+ <IPRanges/>
40
+ <OwnerId>621567473609</OwnerId>
41
+ <DBSecurityGroupName>mydbsecuritygroup4</DBSecurityGroupName>
42
+ </DBSecurityGroup>
43
+ </CreateDBSecurityGroupResult>
44
+ <ResponseMetadata>
45
+ <RequestId>c9cf9ff2-bf36-11de-b88d-993294bf1c81</RequestId>
46
+ </ResponseMetadata>
47
+ </CreateDBSecurityGroupResponse>
48
+ RESPONSE
49
+ end
50
+
51
+ specify "should be able to be create a db_instance" do
52
+ @rds.stubs(:make_request).with('CreateDBInstance', {'Engine' => 'MySQL5.1',
53
+ 'MasterUsername' => 'master',
54
+ 'DBInstanceClass' => 'db.m1.large',
55
+ 'DBInstanceIdentifier' => 'testdb',
56
+ 'AllocatedStorage' => '10',
57
+ 'MasterUserPassword' => 'SecretPassword01'}).
58
+ returns stub(:body => @create_db_instance_body, :is_a? => true)
59
+ response = @rds.create_db_instance(
60
+ :db_instance_class => "db.m1.large",
61
+ :db_instance_identifier=>"testdb",
62
+ :allocated_storage => 10,
63
+ :engine => "MySQL5.1",
64
+ :master_user_password => "SecretPassword01",
65
+ :master_username => "master"
66
+ )
67
+ response.should.be.an.instance_of Hash
68
+
69
+ assert_equal response.CreateDBInstanceResult.DBInstance.AllocatedStorage, "10"
70
+ end
71
+
72
+ specify "should be able to create_db_security_group" do
73
+ @rds.stubs(:make_request).with('CreateDBSecurityGroup', {
74
+ 'DBSecurityGroupName' => 'mydbsecuritygroup',
75
+ 'DBSecurityGroupDescription' => 'My new DBSecurityGroup'}).
76
+ returns stub(:body => @create_db_security_group, :is_a? => true)
77
+ response = @rds.create_db_security_group(
78
+ :db_security_group_name => "mydbsecuritygroup",
79
+ :db_security_group_description => "My new DBSecurityGroup"
80
+ )
81
+ response.should.be.an.instance_of Hash
82
+
83
+ assert_equal response.CreateDBSecurityGroupResult.DBSecurityGroup.DBSecurityGroupName, "mydbsecuritygroup4"
84
+ end
85
+
86
+ specify "should be able to create_db_parameter_group" do
87
+ body =<<-EOE
88
+ <CreateDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
89
+ <CreateDBParameterGroupResult>
90
+ <DBParameterGroup>
91
+ <Engine>mysql5.1</Engine>
92
+ <Description>My new DBParameterGroup</Description>
93
+ <DBParameterGroupName>mydbparametergroup3</DBParameterGroupName>
94
+ </DBParameterGroup>
95
+ </CreateDBParameterGroupResult>
96
+ <ResponseMetadata>
97
+ <RequestId>0b447b66-bf36-11de-a88b-7b5b3d23b3a7</RequestId>
98
+ </ResponseMetadata>
99
+ </CreateDBParameterGroupResponse>
100
+ EOE
101
+ @rds.stubs(:make_request).with('CreateDBParameterGroup', {'Engine' => 'MySQL5.1',
102
+ 'DBParameterGroupName' => 'mydbsecuritygroup',
103
+ 'Description' => 'My test DBSecurity group'}).
104
+ returns stub(:body => body, :is_a? => true)
105
+ response = @rds.create_db_parameter_group(
106
+ :db_parameter_group_name => "mydbsecuritygroup",
107
+ :description => "My test DBSecurity group",
108
+ :engine => "MySQL5.1"
109
+ )
110
+ response.should.be.an.instance_of Hash
111
+
112
+ assert_equal response.CreateDBParameterGroupResult.DBParameterGroup.DBParameterGroupName, "mydbparametergroup3"
113
+ end
114
+
115
+ specify "should be able to create_db_snapshot" do
116
+ body =<<-EOE
117
+ <CreateDBSnapshotResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
118
+ <CreateDBSnapshotResult>
119
+ <DBSnapshot>
120
+ <Port>3306</Port>
121
+ <Status>creating</Status>
122
+ <Engine>mysql5.1</Engine>
123
+ <AvailabilityZone>us-east-1d</AvailabilityZone>
124
+ <InstanceCreateTime>2009-10-21T04:05:43.609Z</InstanceCreateTime>
125
+ <AllocatedStorage>50</AllocatedStorage>
126
+ <DBInstanceIdentifier>mynewdbinstance</DBInstanceIdentifier>
127
+ <MasterUsername>sa</MasterUsername>
128
+ <DBSnapshotIdentifier>mynewdbsnapshot3</DBSnapshotIdentifier>
129
+ </DBSnapshot>
130
+ </CreateDBSnapshotResult>
131
+ <ResponseMetadata>
132
+ <RequestId>48e870fd-bf38-11de-a88b-7b5b3d23b3a7</RequestId>
133
+ </ResponseMetadata>
134
+ </CreateDBSnapshotResponse>
135
+ EOE
136
+ @rds.stubs(:make_request).with('CreateDBSnapshot', {'DBSnapshotIdentifier' => 'mynewdbsnapshot3', 'DBInstanceIdentifier' => 'mynewdbinstance'}).
137
+ returns stub(:body => body, :is_a? => true)
138
+ response = @rds.create_db_snapshot(
139
+ :db_snapshot_identifier => "mynewdbsnapshot3",
140
+ :db_instance_identifier => "mynewdbinstance"
141
+ )
142
+ response.should.be.an.instance_of Hash
143
+
144
+ assert_equal response.CreateDBSnapshotResult.DBSnapshot.DBSnapshotIdentifier, "mynewdbsnapshot3"
145
+ end
146
+
147
+ specify "should be able to authorize_db_security_group" do
148
+ body =<<-EOE
149
+ <AuthorizeDBSecurityGroupIngressResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
150
+ <AuthorizeDBSecurityGroupIngressResult>
151
+ <DBSecurityGroup>
152
+ <EC2SecurityGroups/>
153
+ <DBSecurityGroupDescription>My new DBSecurityGroup</DBSecurityGroupDescription>
154
+ <IPRanges>
155
+ <IPRange>
156
+ <CIDRIP>192.168.1.1/24</CIDRIP>
157
+ <Status>authorizing</Status>
158
+ </IPRange>
159
+ </IPRanges>
160
+ <OwnerId>621567473609</OwnerId>
161
+ <DBSecurityGroupName>mydbsecuritygroup</DBSecurityGroupName>
162
+ </DBSecurityGroup>
163
+ </AuthorizeDBSecurityGroupIngressResult>
164
+ <ResponseMetadata>
165
+ <RequestId>d9799197-bf2d-11de-b88d-993294bf1c81</RequestId>
166
+ </ResponseMetadata>
167
+ </AuthorizeDBSecurityGroupIngressResponse>
168
+ EOE
169
+ @rds.stubs(:make_request).with('AuthorizeDBSecurityGroupIngress', {'CIDRIP' => '192.168.1.1/24', 'DBSecurityGroupName' => 'mydbsecuritygroup'}).
170
+ returns stub(:body => body, :is_a? => true)
171
+ response = @rds.authorize_db_security_group(
172
+ :db_security_group_name => "mydbsecuritygroup",
173
+ :cidrip => "192.168.1.1/24"
174
+ )
175
+ response.should.be.an.instance_of Hash
176
+
177
+ assert_equal response.AuthorizeDBSecurityGroupIngressResult.DBSecurityGroup.IPRanges.IPRange.CIDRIP, "192.168.1.1/24"
178
+ end
179
+
180
+ specify "should be able to delete_db_parameter_group" do
181
+ body =<<-EOE
182
+ <DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
183
+ <ResponseMetadata>
184
+ <RequestId>4dc38be9-bf3b-11de-a88b-7b5b3d23b3a7</RequestId>
185
+ </ResponseMetadata>
186
+ </DeleteDBParameterGroupResponse>
187
+ EOE
188
+ @rds.stubs(:make_request).with('DeleteDBParameterGroup', {'DBParameterGroupName' => 'mydbsecuritygroup'}).
189
+ returns stub(:body => body, :is_a? => true)
190
+ response = @rds.delete_db_parameter_group(
191
+ :db_parameter_group_name => "mydbsecuritygroup"
192
+ )
193
+ response.should.be.an.instance_of Hash
194
+ end
195
+
196
+ specify "should be able to delete_db_security_group" do
197
+ body =<<-EOE
198
+ <DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
199
+ <ResponseMetadata>
200
+ <RequestId>4dc38be9-bf3b-11de-a88b-7b5b3d23b3a7</RequestId>
201
+ </ResponseMetadata>
202
+ </DeleteDBParameterGroupResponse>
203
+ EOE
204
+ @rds.stubs(:make_request).with('DeleteDBSecurityGroup', {'DBSecurityGroupName' => 'mydbsecuritygroup'}).
205
+ returns stub(:body => body, :is_a? => true)
206
+ response = @rds.delete_db_security_group(
207
+ :db_security_group_name => "mydbsecuritygroup"
208
+ )
209
+ response.should.be.an.instance_of Hash
210
+ end
211
+
212
+ specify "should be able to delete_db_snapshot" do
213
+ body =<<-EOE
214
+ <DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
215
+ <ResponseMetadata>
216
+ <RequestId>4dc38be9-bf3b-11de-a88b-7b5b3d23b3a7</RequestId>
217
+ </ResponseMetadata>
218
+ </DeleteDBParameterGroupResponse>
219
+ EOE
220
+ @rds.stubs(:make_request).with('DeleteDBSnapshot', {'DBSnapshotIdentifier' => 'snapshotname'}).
221
+ returns stub(:body => body, :is_a? => true)
222
+ response = @rds.delete_db_snapshot(
223
+ :db_snapshot_identifier => "snapshotname"
224
+ )
225
+ response.should.be.an.instance_of Hash
226
+ end
227
+
228
+ specify "should be able to describe_db_instances" do
229
+ body =<<-EOE
230
+ <DescribeDBInstancesResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
231
+ <DescribeDBInstancesResult>
232
+ <DBInstances>
233
+ <DBInstance>
234
+ <LatestRestorableTime>2009-10-22T18:59:59Z</LatestRestorableTime>
235
+ <Engine>mysql5.1</Engine>
236
+ <BackupRetentionPeriod>3</BackupRetentionPeriod>
237
+ <DBInstanceStatus>available</DBInstanceStatus>
238
+ <DBParameterGroups>
239
+ <DBParameterGroup>
240
+ <ParameterApplyStatus>pending-reboot</ParameterApplyStatus>
241
+ <DBParameterGroupName>default.mysql5.1</DBParameterGroupName>
242
+ </DBParameterGroup>
243
+ </DBParameterGroups>
244
+ <Endpoint>
245
+ <Port>8443</Port>
246
+ <Address>dbinstancename.clouwupjnvmq.us-east-1-devo.rds.amazonaws.com</Address>
247
+ </Endpoint>
248
+ <DBInstanceIdentifier>dbinstancename</DBInstanceIdentifier>
249
+ <PreferredBackupWindow>03:00-05:00</PreferredBackupWindow>
250
+ <DBSecurityGroups>
251
+ <DBSecurityGroup>
252
+ <Status>active</Status>
253
+ <DBSecurityGroupName>default</DBSecurityGroupName>
254
+ </DBSecurityGroup>
255
+ </DBSecurityGroups>
256
+ <DBName>testdb</DBName>
257
+ <PreferredMaintenanceWindow>sun:05:00-sun:09:00</PreferredMaintenanceWindow>
258
+ <AvailabilityZone>us-east-1a</AvailabilityZone>
259
+ <InstanceCreateTime>2009-09-11T00:50:45.523Z</InstanceCreateTime>
260
+ <AllocatedStorage>20</AllocatedStorage>
261
+ <DBInstanceClass>db.m1.xlarge</DBInstanceClass>
262
+ <MasterUsername>sa</MasterUsername>
263
+ </DBInstance>
264
+ </DBInstances>
265
+ </DescribeDBInstancesResult>
266
+ <ResponseMetadata>
267
+ <RequestId>4f1fae46-bf3d-11de-a88b-7b5b3d23b3a7</RequestId>
268
+ </ResponseMetadata>
269
+ </DescribeDBInstancesResponse>
270
+ EOE
271
+ @rds.stubs(:make_request).with('DescribeDBInstances', {'MaxRecords' => '100'}).
272
+ returns stub(:body => body, :is_a? => true)
273
+ response = @rds.describe_db_instances(
274
+ :max_records => "100"
275
+ )
276
+ response.should.be.an.instance_of Hash
277
+ end
278
+
279
+ specify "should be able to describe_db_instances" do
280
+ body =<<-EOE
281
+ <DescribeEngineDefaultParametersResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
282
+ <DescribeEngineDefaultParametersResult>
283
+ <EngineDefaults>
284
+ <Engine>mysql5.1</Engine>
285
+ <Marker>bWF4X3VzZXJfY29ubmVjdGlvbnM=</Marker>
286
+ <Parameters>
287
+ <Parameter>
288
+ <DataType>boolean</DataType>
289
+ <Source>engine-default</Source>
290
+ <IsModifiable>true</IsModifiable>
291
+ <Description>Controls whether user-defined functions that have only an xxx symbol for the main function can be loaded</Description>
292
+ <ApplyType>static</ApplyType>
293
+ <AllowedValues>ON,OFF</AllowedValues>
294
+ <ParameterName>allow-suspicious-udfs</ParameterName>
295
+ </Parameter>
296
+ <Parameter>
297
+ <DataType>integer</DataType>
298
+ <Source>engine-default</Source>
299
+ <IsModifiable>true</IsModifiable>
300
+ <Description>Intended for use with master-to-master replication, and can be used to control the operation of AUTO_INCREMENT columns</Description>
301
+ <ApplyType>dynamic</ApplyType>
302
+ <AllowedValues>1-65535</AllowedValues>
303
+ <ParameterName>auto_increment_increment</ParameterName>
304
+ </Parameter>
305
+ </Parameters>
306
+ </EngineDefaults>
307
+ </DescribeEngineDefaultParametersResult>
308
+ <ResponseMetadata>
309
+ <RequestId>811f4032-bf3e-11de-b88d-993294bf1c81</RequestId>
310
+ </ResponseMetadata>
311
+ </DescribeEngineDefaultParametersResponse>
312
+ EOE
313
+ @rds.stubs(:make_request).with('DescribeEngineDefaultParameters', {'Engine' => 'MySQL5.1'}).
314
+ returns stub(:body => body, :is_a? => true)
315
+ response = @rds.describe_engine_default_parameters(
316
+ :engine => "MySQL5.1"
317
+ )
318
+ response.should.be.an.instance_of Hash
319
+ end
320
+
321
+ specify "should be able to describe_db_instances" do
322
+ body =<<-EOE
323
+ <ModifyDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
324
+ <ModifyDBParameterGroupResult>
325
+ <DBParameterGroupName>mydbparametergroup</DBParameterGroupName>
326
+ </ModifyDBParameterGroupResult>
327
+ <ResponseMetadata>
328
+ <RequestId>5ba91f97-bf51-11de-bf60-ef2e377db6f3</RequestId>
329
+ </ResponseMetadata>
330
+ </ModifyDBParameterGroupResponse>
331
+ EOE
332
+
333
+ @rds.stubs(:make_request).with('ModifyDBParameterGroup', {
334
+ 'DBParameterGroupName' => 'mytestdb',
335
+ 'Parameters.member.1.ParameterName' => 'max_user_connections',
336
+ 'Parameters.member.1.ParameterValue' => '24',
337
+ 'Parameters.member.1.ApplyMethod' => 'pending-reboot',
338
+ 'Parameters.member.2.ParameterName' => 'max_allowed_packet',
339
+ 'Parameters.member.2.ParameterValue' => '1024',
340
+ 'Parameters.member.2.ApplyMethod' => 'immediate',
341
+ }).
342
+ returns stub(:body => body, :is_a? => true)
343
+ response = @rds.modify_db_parameter_group(
344
+ :db_parameter_group_name => "mytestdb",
345
+ :parameters => [
346
+ {:name => "max_user_connections", :value => "24", :apply_method => "pending-reboot"},
347
+ {:name => "max_allowed_packet", :value => "1024", :apply_method => "immediate"}
348
+ ]
349
+ )
350
+ response.should.be.an.instance_of Hash
351
+ end
352
+
353
+ end
354
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Rempe
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-14 00:00:00 -07:00
12
+ date: 2009-10-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -110,6 +110,8 @@ files:
110
110
  - lib/AWS/EC2/volumes.rb
111
111
  - lib/AWS/ELB.rb
112
112
  - lib/AWS/ELB/load_balancers.rb
113
+ - lib/AWS/RDS.rb
114
+ - lib/AWS/RDS/rds.rb
113
115
  - lib/AWS/exceptions.rb
114
116
  - lib/AWS/responses.rb
115
117
  - perftools/ec2prof
@@ -132,6 +134,7 @@ files:
132
134
  - test/test_EC2_snapshots.rb
133
135
  - test/test_EC2_volumes.rb
134
136
  - test/test_ELB_load_balancers.rb
137
+ - test/test_RDS.rb
135
138
  - test/test_helper.rb
136
139
  - wsdl/2007-08-29.ec2.wsdl
137
140
  - wsdl/2008-02-01.ec2.wsdl
@@ -187,3 +190,4 @@ test_files:
187
190
  - test/test_EC2_volumes.rb
188
191
  - test/test_ELB_load_balancers.rb
189
192
  - test/test_helper.rb
193
+ - test/test_RDS.rb