nirvdrum-amazon-ec2 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +9 -0
  2. data/.yardopts +1 -0
  3. data/ChangeLog +304 -0
  4. data/LICENSE +66 -0
  5. data/README.rdoc +359 -0
  6. data/README_dev.rdoc +10 -0
  7. data/Rakefile +70 -0
  8. data/VERSION +1 -0
  9. data/amazon-ec2.gemspec +142 -0
  10. data/bin/ec2-gem-example.rb +137 -0
  11. data/bin/ec2-gem-profile.rb +10 -0
  12. data/bin/ec2sh +62 -0
  13. data/bin/setup.rb +29 -0
  14. data/deps.rip +1 -0
  15. data/lib/AWS.rb +321 -0
  16. data/lib/AWS/Autoscaling.rb +70 -0
  17. data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
  18. data/lib/AWS/Cloudwatch.rb +32 -0
  19. data/lib/AWS/Cloudwatch/monitoring.rb +80 -0
  20. data/lib/AWS/EC2.rb +33 -0
  21. data/lib/AWS/EC2/availability_zones.rb +29 -0
  22. data/lib/AWS/EC2/console.rb +25 -0
  23. data/lib/AWS/EC2/devpay.rb +18 -0
  24. data/lib/AWS/EC2/elastic_ips.rb +86 -0
  25. data/lib/AWS/EC2/image_attributes.rb +133 -0
  26. data/lib/AWS/EC2/images.rb +117 -0
  27. data/lib/AWS/EC2/instances.rb +234 -0
  28. data/lib/AWS/EC2/keypairs.rb +47 -0
  29. data/lib/AWS/EC2/products.rb +21 -0
  30. data/lib/AWS/EC2/security_groups.rb +164 -0
  31. data/lib/AWS/EC2/snapshots.rb +102 -0
  32. data/lib/AWS/EC2/spot_instance_requests.rb +105 -0
  33. data/lib/AWS/EC2/volumes.rb +100 -0
  34. data/lib/AWS/ELB.rb +71 -0
  35. data/lib/AWS/ELB/load_balancers.rb +178 -0
  36. data/lib/AWS/RDS.rb +73 -0
  37. data/lib/AWS/RDS/rds.rb +522 -0
  38. data/lib/AWS/exceptions.rb +200 -0
  39. data/lib/AWS/responses.rb +21 -0
  40. data/perftools/ec2prof +0 -0
  41. data/perftools/ec2prof-results.dot +132 -0
  42. data/perftools/ec2prof-results.txt +100 -0
  43. data/perftools/ec2prof.symbols +102 -0
  44. data/test/test_Autoscaling_groups.rb +337 -0
  45. data/test/test_EC2.rb +68 -0
  46. data/test/test_EC2_availability_zones.rb +49 -0
  47. data/test/test_EC2_console.rb +54 -0
  48. data/test/test_EC2_elastic_ips.rb +144 -0
  49. data/test/test_EC2_image_attributes.rb +238 -0
  50. data/test/test_EC2_images.rb +229 -0
  51. data/test/test_EC2_instances.rb +611 -0
  52. data/test/test_EC2_keypairs.rb +123 -0
  53. data/test/test_EC2_products.rb +48 -0
  54. data/test/test_EC2_responses.rb +53 -0
  55. data/test/test_EC2_s3_xmlsimple.rb +80 -0
  56. data/test/test_EC2_security_groups.rb +205 -0
  57. data/test/test_EC2_snapshots.rb +83 -0
  58. data/test/test_EC2_spot_instance_requests.rb +178 -0
  59. data/test/test_EC2_volumes.rb +142 -0
  60. data/test/test_ELB_load_balancers.rb +239 -0
  61. data/test/test_RDS.rb +354 -0
  62. data/test/test_helper.rb +23 -0
  63. data/wsdl/2007-08-29.ec2.wsdl +1269 -0
  64. data/wsdl/2008-02-01.ec2.wsdl +1614 -0
  65. data/wsdl/2008-05-05.ec2.wsdl +2052 -0
  66. data/wsdl/2008-12-01.ec2.wsdl +2354 -0
  67. data/wsdl/2009-10-31.ec2.wsdl +4261 -0
  68. data/wsdl/2009-11-30.ec2.wsdl +4668 -0
  69. metadata +199 -0
@@ -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["FinalDBSnapshotIdentifier"] = 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
+