right_aws 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/History.txt +22 -1
  2. data/Manifest.txt +11 -1
  3. data/README.txt +0 -4
  4. data/Rakefile +19 -25
  5. data/lib/acf/right_acf_interface.rb +199 -135
  6. data/lib/acf/right_acf_invalidations.rb +144 -0
  7. data/lib/acf/right_acf_origin_access_identities.rb +4 -4
  8. data/lib/acf/right_acf_streaming_interface.rb +19 -26
  9. data/lib/acw/right_acw_interface.rb +1 -2
  10. data/lib/as/right_as_interface.rb +6 -7
  11. data/lib/awsbase/right_awsbase.rb +287 -91
  12. data/lib/awsbase/support.rb +2 -82
  13. data/lib/awsbase/version.rb +9 -0
  14. data/lib/ec2/right_ec2.rb +101 -38
  15. data/lib/ec2/right_ec2_ebs.rb +71 -58
  16. data/lib/ec2/right_ec2_images.rb +82 -42
  17. data/lib/ec2/right_ec2_instances.rb +74 -44
  18. data/lib/ec2/right_ec2_placement_groups.rb +108 -0
  19. data/lib/ec2/right_ec2_reserved_instances.rb +50 -46
  20. data/lib/ec2/right_ec2_security_groups.rb +148 -32
  21. data/lib/ec2/right_ec2_spot_instances.rb +53 -27
  22. data/lib/ec2/right_ec2_tags.rb +139 -0
  23. data/lib/ec2/right_ec2_vpc.rb +151 -139
  24. data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
  25. data/lib/elb/right_elb_interface.rb +93 -18
  26. data/lib/iam/right_iam_access_keys.rb +71 -0
  27. data/lib/iam/right_iam_groups.rb +195 -0
  28. data/lib/iam/right_iam_interface.rb +341 -0
  29. data/lib/iam/right_iam_mfa_devices.rb +67 -0
  30. data/lib/iam/right_iam_users.rb +251 -0
  31. data/lib/rds/right_rds_interface.rb +513 -202
  32. data/lib/right_aws.rb +12 -12
  33. data/lib/route_53/right_route_53_interface.rb +630 -0
  34. data/lib/s3/right_s3.rb +9 -12
  35. data/lib/s3/right_s3_interface.rb +10 -11
  36. data/lib/sdb/active_sdb.rb +18 -33
  37. data/lib/sdb/right_sdb_interface.rb +36 -4
  38. data/lib/sqs/right_sqs.rb +1 -2
  39. data/lib/sqs/right_sqs_gen2.rb +0 -1
  40. data/lib/sqs/right_sqs_gen2_interface.rb +4 -5
  41. data/lib/sqs/right_sqs_interface.rb +6 -7
  42. data/right_aws.gemspec +91 -0
  43. data/test/awsbase/test_helper.rb +2 -0
  44. data/test/awsbase/test_right_awsbase.rb +12 -0
  45. data/test/s3/test_right_s3.rb +1 -1
  46. data/test/sdb/test_active_sdb.rb +1 -1
  47. data/test/sdb/test_batch_put_attributes.rb +54 -0
  48. data/test/sqs/test_right_sqs.rb +0 -6
  49. data/test/sqs/test_right_sqs_gen2.rb +1 -1
  50. metadata +109 -58
@@ -27,14 +27,14 @@ module RightAws
27
27
 
28
28
  include RightAwsBaseInterface
29
29
 
30
- API_VERSION = "2009-10-16"
30
+ API_VERSION = "2010-07-28"
31
31
  DEFAULT_HOST = 'rds.amazonaws.com'
32
32
  DEFAULT_PORT = 443
33
33
  DEFAULT_PROTOCOL = 'https'
34
34
  DEFAULT_PATH = '/'
35
35
 
36
36
  DEFAULT_INSTANCE_CLASS = 'db.m1.small'
37
- INSTANCE_CLASSES = ['db.m1.small', 'db.m1.large', 'db.m1.xlarge', 'db.m2.2xlarge', 'db.m2.4xlarge']
37
+ INSTANCE_CLASSES = ['db.m1.small', 'db.m1.large', 'db.m1.xlarge', 'db.m2.2xlarge', 'db.m2.2xlarge', 'db.m2.4xlarge']
38
38
 
39
39
  @@bench = AwsBenchmarkingBlock.new
40
40
  def self.bench_xml
@@ -51,7 +51,6 @@ module RightAws
51
51
  # * <tt>:server</tt>: RDS service host, default: DEFAULT_HOST
52
52
  # * <tt>:port</tt>: RDS service port, default: DEFAULT_PORT
53
53
  # * <tt>:protocol</tt>: 'http' or 'https', default: DEFAULT_PROTOCOL
54
- # * <tt>:multi_thread</tt>: true=HTTP connection per thread, false=per process
55
54
  # * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
56
55
  #
57
56
  # rds = RightAws::RdsInterface.new('xxxxxxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
@@ -94,7 +93,7 @@ module RightAws
94
93
  link = generate_request(action, params)
95
94
  last_response = request_info( link, parser_class.new(:logger => @logger))
96
95
  params['Marker'] = last_response[:marker]
97
- break unless block && block.call(last_response) && !last_response[:marker].blank?
96
+ break unless block && block.call(last_response) && !last_response[:marker].right_blank?
98
97
  end
99
98
  last_response
100
99
  end
@@ -113,20 +112,23 @@ module RightAws
113
112
  #
114
113
  # # Get a list of DB instances. The response is an +Array+ of instances.
115
114
  # rds.describe_db_instances #=>
116
- # [{:instance_class=>"Medium",
115
+ # [{:instance_class=>"db.m1.small",
117
116
  # :status=>"creating",
118
- # :engine=>"MySQL5.1",
119
- # :allocated_storage=>50,
120
- # :pending_modified_values=>{},
121
- # :db_parameter_group=>{:status=>"in-sync", :name=>"default.MySQL5.1"},
122
- # :db_security_groups=>
123
- # [{:status=>"active", :name=>"kd-2-test"},
124
- # {:status=>"active", :name=>"default"},
125
- # {:status=>"active", :name=>"kd-1-test"}],
126
- # :availability_zone=>"us-east-1b",
117
+ # :backup_retention_period=>1,
118
+ # :read_replica_db_instance_identifiers=>["kd-delete-me-01-replica-01"],
127
119
  # :master_username=>"username",
128
- # :aws_id=>"kd-my-awesome-db-2",
129
- # :preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}]
120
+ # :preferred_maintenance_window=>"sun:05:00-sun:09:00",
121
+ # :db_parameter_group=>{:status=>"in-sync", :name=>"default.mysql5.1"},
122
+ # :multi_az=>true,
123
+ # :engine=>"mysql",
124
+ # :auto_minor_version_upgrade=>false,
125
+ # :allocated_storage=>25,
126
+ # :availability_zone=>"us-east-1d",
127
+ # :aws_id=>"kd-delete-me-01",
128
+ # :preferred_backup_window=>"03:00-05:00",
129
+ # :engine_version=>"5.1.50",
130
+ # :pending_modified_values=>{:master_user_password=>"****"},
131
+ # :db_security_groups=>[{:status=>"active", :name=>"default"}]}]
130
132
  #
131
133
  # # Retrieve a custom DB instance.
132
134
  # # The response is an +Array+ with a single instance record.
@@ -136,24 +138,27 @@ module RightAws
136
138
  # rds.describe_db_instances(:max_records => 30) do |x|
137
139
  # puts x.inspect #=>
138
140
  # {:db_instances=>
139
- # [{:instance_class=>"Medium",
141
+ # [{:instance_class=>"db.m1.small",
140
142
  # :status=>"creating",
141
- # :engine=>"MySQL5.1",
142
- # :allocated_storage=>50,
143
- # :pending_modified_values=>{},
144
- # :db_parameter_group=>{:status=>"in-sync", :name=>"default.MySQL5.1"},
145
- # :db_security_groups=>
146
- # [{:status=>"active", :name=>"kd-2-test"},
147
- # {:status=>"active", :name=>"default"},
148
- # {:status=>"active", :name=>"kd-1-test"}],
149
- # :availability_zone=>"us-east-1b",
143
+ # :backup_retention_period=>1,
144
+ # :read_replica_db_instance_identifiers=>["kd-delete-me-01-replica-01"],
150
145
  # :master_username=>"username",
151
- # :aws_id=>"kd-my-awesome-db-2",
152
- # :preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}]}
146
+ # :preferred_maintenance_window=>"sun:05:00-sun:09:00",
147
+ # :db_parameter_group=>{:status=>"in-sync", :name=>"default.mysql5.1"},
148
+ # :multi_az=>true,
149
+ # :engine=>"mysql",
150
+ # :auto_minor_version_upgrade=>false,
151
+ # :allocated_storage=>25,
152
+ # :availability_zone=>"us-east-1d",
153
+ # :aws_id=>"kd-delete-me-01",
154
+ # :preferred_backup_window=>"03:00-05:00",
155
+ # :engine_version=>"5.1.50",
156
+ # :pending_modified_values=>{:master_user_password=>"****"},
157
+ # :db_security_groups=>[{:status=>"active", :name=>"default"}]}]}
153
158
  # true
154
159
  # end
155
160
  #
156
- def describe_db_instances(params={}, &block)
161
+ def describe_db_instances(*params, &block)
157
162
  item, params = AwsUtils::split_items_and_params(params)
158
163
  params = params.dup
159
164
  params['DBInstanceIdentifier'] = item if item
@@ -168,24 +173,30 @@ module RightAws
168
173
  # Create a new RDS instance of the type and size specified by you. The default storage engine for RDS Instances is InnoDB.
169
174
  #
170
175
  # Mandatory arguments: +aws_id+, +master_username+, +master_user_password+
171
- # Optional params: +:allocated_storage+ (25 by def), +:instance_class+, +:engine+ ('MySQL5.1' by def),
176
+ # Optional params: +:allocated_storage+ (25 by def), +:instance_class+, +:engine+ ('MySQL' by def),
172
177
  # +:endpoint_port+, +:db_name+, +:db_security_groups+, +:db_parameter_group+, +:availability_zone+, +:preferred_maintenance_window+
173
- # +:backup_retention_period+, +:preferred_backup_window+
178
+ # +:backup_retention_period+, +:preferred_backup_window+, +:multi_az+, +:engine_version+, +:auto_minor_version_upgrade+
174
179
  #
175
- # ds.create_db_instance('my-awesome-db', 'username', 'password') #=>
176
- # {:instance_class=>"Medium",
177
- # :status=>"creating",
178
- # :engine=>"MySQL5.1",
179
- # :allocated_storage=>50,
180
- # :pending_modified_values=>{},
181
- # :db_security_groups=>
182
- # [{:status=>"active", :name=>"kd-2-test"},
183
- # {:status=>"active", :name=>"default"},
184
- # {:status=>"active", :name=>"kd-1-test"}],
185
- # :availability_zone=>"us-east-1b",
186
- # :master_username=>"username",
187
- # :aws_id=>"kd-my-awesome-db-2",
188
- # :preferred_maintenance_window=>"Sun:05:00-Sun:09:00"}
180
+ # rds.create_db_instance('kd-delete-me-01', 'username', 'password',
181
+ # :db_instance_class => 'db.m1.small',
182
+ # :multi_az => true,
183
+ # :auto_minor_version_upgrade => false ) #=>
184
+ # {:instance_class=>"db.m1.small",
185
+ # :multi_az=>true,
186
+ # :status=>"creating",
187
+ # :backup_retention_period=>1,
188
+ # :read_replica_db_instance_identifiers=>[],
189
+ # :master_username=>"username",
190
+ # :preferred_maintenance_window=>"sun:05:00-sun:09:00",
191
+ # :auto_minor_version_upgrade=>false,
192
+ # :db_parameter_group=>{:status=>"in-sync", :name=>"default.mysql5.1"},
193
+ # :engine=>"mysql",
194
+ # :allocated_storage=>25,
195
+ # :aws_id=>"kd-delete-me-01",
196
+ # :preferred_backup_window=>"03:00-05:00",
197
+ # :engine_version=>"5.1.50",
198
+ # :pending_modified_values=>{:master_user_password=>"****"},
199
+ # :db_security_groups=>[{:status=>"active", :name=>"default"}]}
189
200
  #
190
201
  def create_db_instance(aws_id, master_username, master_user_password, params={})
191
202
  request_hash = {}
@@ -194,19 +205,21 @@ module RightAws
194
205
  request_hash['MasterUsername'] = master_username
195
206
  request_hash['MasterUserPassword'] = master_user_password
196
207
  # Mandatory with default values
197
- request_hash['DBInstanceClass'] = params[:instance_class].blank? ? DEFAULT_INSTANCE_CLASS : params[:instance_class].to_s
198
- request_hash['AllocatedStorage'] = params[:allocated_storage].blank? ? 25 : params[:allocated_storage]
199
- request_hash['Engine'] = params[:engine].blank? ? 'MySQL5.1' : params[:engine]
208
+ request_hash['DBInstanceClass'] = params[:instance_class].right_blank? ? DEFAULT_INSTANCE_CLASS : params[:instance_class].to_s
209
+ request_hash['AllocatedStorage'] = params[:allocated_storage].right_blank? ? 25 : params[:allocated_storage]
210
+ request_hash['Engine'] = params[:engine].right_blank? ? 'mysql' : params[:engine]
200
211
  # Optional
201
- request_hash['EndpointPort'] = params[:endpoint_port] unless params[:endpoint_port].blank?
202
- request_hash['DBName'] = params[:db_name] unless params[:db_name].blank?
203
- request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].blank?
204
- request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].blank?
205
- request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].blank?
206
- request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].blank?
212
+ request_hash['Port'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
213
+ request_hash['DBName'] = params[:db_name] unless params[:db_name].right_blank?
214
+ request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
215
+ request_hash['MultiAZ'] = params[:multi_az].to_s unless params[:multi_az].nil?
216
+ request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].right_blank?
217
+ request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].right_blank?
218
+ request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].right_blank?
219
+ request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].right_blank?
220
+ request_hash['EngineVersion'] = params[:engine_version] unless params[:engine_version].right_blank?
221
+ request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade].to_s unless params[:auto_minor_version_upgrade].nil?
207
222
  request_hash.merge!(amazonize_list('DBSecurityGroups.member', params[:db_security_groups]))
208
- # request_hash.merge!(amazonize_list('DBParameterGroups.member', params[:db_parameter_groups]))
209
- request_hash['DBParameterGroup'] = params[:db_parameter_group] unless params[:db_parameter_group].blank?
210
223
  link = generate_request('CreateDBInstance', request_hash)
211
224
  request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
212
225
  end
@@ -216,23 +229,60 @@ module RightAws
216
229
  # Mandatory arguments: +aws_id+.
217
230
  # Optional params: +:master_user_password+, +:instance_class+, +:db_security_groups+,
218
231
  # +:db_parameter_group+, +:preferred_maintenance_window+, +:allocated_storage+, +:apply_immediately+,
219
- # +:backup_retention_period+, +:preferred_backup_window+
232
+ # +:backup_retention_period+, +:preferred_backup_window+, +:multi_az+, +:engine_version+,
233
+ # +:auto_minor_version_upgrade+, +:allow_major_version_upgrade+
234
+ #
235
+ # rds.modify_db_instance('kd-delete-me-01',
236
+ # :master_user_password => 'newpassword',
237
+ # :instance_class => 'db.m1.large',
238
+ # :multi_az => false,
239
+ # :allocated_storage => 30,
240
+ # :allow_major_version_upgrade => true,
241
+ # :auto_minor_version_upgrade => true,
242
+ # :preferred_maintenance_window => 'sun:06:00-sun:10:00',
243
+ # :preferred_backup_window => '02:00-04:00',
244
+ # :apply_immediately => true,
245
+ # :backup_retention_period => 2) #=>
246
+ # {:engine_version=>"5.1.50",
247
+ # :aws_id=>"kd-delete-me-01",
248
+ # :multi_az=>true,
249
+ # :status=>"available",
250
+ # :read_replica_db_instance_identifiers=>[],
251
+ # :availability_zone=>"us-east-1d",
252
+ # :auto_minor_version_upgrade=>true,
253
+ # :master_username=>"username",
254
+ # :preferred_maintenance_window=>"sun:06:00-sun:10:00",
255
+ # :db_parameter_group=>{:status=>"in-sync", :name=>"default.mysql5.1"},
256
+ # :create_time=>"2010-11-17T10:21:59.720Z",
257
+ # :preferred_backup_window=>"02:00-04:00",
258
+ # :engine=>"mysql",
259
+ # :db_security_groups=>[{:status=>"active", :name=>"default"}],
260
+ # :endpoint_address=>"kd-delete-me-01.chxspydgchoo.us-east-1.rds.amazonaws.com",
261
+ # :instance_class=>"db.m1.small",
262
+ # :latest_restorable_time=>"2010-11-17T10:27:17.089Z",
263
+ # :backup_retention_period=>2,
264
+ # :pending_modified_values=>
265
+ # {:multi_az=>false, :master_user_password=>"****", :allocated_storage=>30, :instance_class=>"db.m1.large"},
266
+ # :allocated_storage=>25}
220
267
  #
221
268
  def modify_db_instance(aws_id, params={})
222
269
  request_hash = {}
223
270
  # Mandatory
224
271
  request_hash['DBInstanceIdentifier'] = aws_id
225
272
  # Optional
226
- request_hash['MasterUserPassword'] = params[:master_user_password] unless params[:master_user_password].blank?
227
- request_hash['DBInstanceClass'] = params[:instance_class].to_s.capitalize unless params[:instance_class].blank?
228
- request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].blank?
229
- request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].blank?
230
- request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].blank?
231
- request_hash['AllocatedStorage'] = params[:allocated_storage] unless params[:allocated_storage].blank?
232
- request_hash['ApplyImmediately'] = params[:apply_immediately].to_s unless params[:apply_immediately].blank?
273
+ request_hash['MasterUserPassword'] = params[:master_user_password] unless params[:master_user_password].right_blank?
274
+ request_hash['DBInstanceClass'] = params[:instance_class].to_s.capitalize unless params[:instance_class].right_blank?
275
+ request_hash['PreferredMaintenanceWindow'] = params[:preferred_maintenance_window] unless params[:preferred_maintenance_window].right_blank?
276
+ request_hash['BackupRetentionPeriod'] = params[:backup_retention_period] unless params[:backup_retention_period].right_blank?
277
+ request_hash['PreferredBackupWindow'] = params[:preferred_backup_window] unless params[:preferred_backup_window].right_blank?
278
+ request_hash['AllocatedStorage'] = params[:allocated_storage] unless params[:allocated_storage].right_blank?
279
+ request_hash['MultiAZ'] = params[:multi_az].to_s unless params[:multi_az].nil?
280
+ request_hash['EngineVersion'] = params[:engine_version] unless params[:engine_version].right_blank?
281
+ request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade].to_s unless params[:auto_minor_version_upgrade].nil?
282
+ request_hash['AllowMajorVersionUpgrade'] = params[:allow_major_version_upgrade].to_s unless params[:allow_major_version_upgrade].nil?
283
+ request_hash['ApplyImmediately'] = params[:apply_immediately].to_s unless params[:apply_immediately].right_blank?
233
284
  request_hash.merge!(amazonize_list('DBSecurityGroups.member', params[:db_security_groups]))
234
- # request_hash.merge!(amazonize_list('DBParameterGroups.member', params[:db_parameter_groups]))
235
- request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].blank?
285
+ request_hash['DBParameterGroupName'] = params[:db_parameter_group] unless params[:db_parameter_group].right_blank?
236
286
  link = generate_request('ModifyDBInstance', request_hash)
237
287
  request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
238
288
  end
@@ -271,11 +321,11 @@ module RightAws
271
321
  request_hash = {}
272
322
  request_hash['DBInstanceIdentifier'] = aws_id
273
323
  request_hash['SkipFinalSnapshot'] = params.has_key?(:skip_final_snapshot) ? params[:skip_final_snapshot].to_s : 'false'
274
- if request_hash['SkipFinalSnapshot'] == 'false' && params[:snapshot_aws_id].blank?
324
+ if request_hash['SkipFinalSnapshot'] == 'false' && params[:snapshot_aws_id].right_blank?
275
325
  params = params.dup
276
326
  params[:snapshot_aws_id] = "#{aws_id}-final-snapshot-#{Time.now.utc.strftime('%Y%m%d%H%M%S')}"
277
327
  end
278
- request_hash['FinalDBSnapshotIdentifier'] = params[:snapshot_aws_id] unless params[:snapshot_aws_id].blank?
328
+ request_hash['FinalDBSnapshotIdentifier'] = params[:snapshot_aws_id] unless params[:snapshot_aws_id].right_blank?
279
329
  link = generate_request('DeleteDBInstance', request_hash)
280
330
  request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
281
331
  end
@@ -317,7 +367,7 @@ module RightAws
317
367
  #
318
368
  def describe_db_security_groups(*db_security_group_name, &block)
319
369
  items, params = AwsUtils::split_items_and_params(db_security_group_name)
320
- params['DBSecurityGroupName'] = items.first unless items.blank?
370
+ params['DBSecurityGroupName'] = items.first unless items.right_blank?
321
371
  result = []
322
372
  incrementally_list_items('DescribeDBSecurityGroups', DescribeDbSecurityGroupsParser, params) do |response|
323
373
  result += response[:db_security_groups]
@@ -344,9 +394,9 @@ module RightAws
344
394
 
345
395
  def modify_db_security_group_ingress(action, db_security_group_name, params={}) # :nodoc:
346
396
  request_hash = { 'DBSecurityGroupName' => db_security_group_name}
347
- request_hash['CIDRIP'] = params[:cidrip] unless params[:cidrip].blank?
348
- request_hash['EC2SecurityGroupName'] = params[:ec2_security_group_name] unless params[:ec2_security_group_name].blank?
349
- request_hash['EC2SecurityGroupOwnerId'] = params[:ec2_security_group_owner] unless params[:ec2_security_group_owner].blank?
397
+ request_hash['CIDRIP'] = params[:cidrip] unless params[:cidrip].right_blank?
398
+ request_hash['EC2SecurityGroupName'] = params[:ec2_security_group_name] unless params[:ec2_security_group_name].right_blank?
399
+ request_hash['EC2SecurityGroupOwnerId'] = params[:ec2_security_group_owner] unless params[:ec2_security_group_owner].right_blank?
350
400
  link = generate_request(action, request_hash)
351
401
  request_info(link, DescribeDbSecurityGroupsParser.new(:logger => @logger))[:db_security_groups].first
352
402
  end
@@ -434,7 +484,7 @@ module RightAws
434
484
  #
435
485
  def describe_db_parameter_groups(*db_parameter_group_name, &block)
436
486
  items, params = AwsUtils::split_items_and_params(db_parameter_group_name)
437
- params['DBParameterGroupName'] = items.first unless items.blank?
487
+ params['DBParameterGroupName'] = items.first unless items.right_blank?
438
488
  result = []
439
489
  incrementally_list_items('DescribeDBParameterGroups', DescribeDbParameterGroupsParser, params) do |response|
440
490
  result += response[:db_parameter_groups]
@@ -449,15 +499,14 @@ module RightAws
449
499
  #
450
500
  # TODO: this call returns an empty hash, but should be a parameter group data - ask Amazon guys.
451
501
  #
452
- def create_db_parameter_group(db_parameter_group_name, db_parameter_group_description, engine='MySQL5.1', params={})
453
- params['DBParameterGroupName'] = db_parameter_group_name
454
- params['Description'] = db_parameter_group_description
455
- params['Engine'] = engine
502
+ def create_db_parameter_group(db_parameter_group_name, db_parameter_group_description, db_parameter_group_family='mysql5.1', params={})
503
+ params['DBParameterGroupName'] = db_parameter_group_name
504
+ params['Description'] = db_parameter_group_description
505
+ params['DBParameterGroupFamily'] = db_parameter_group_family
456
506
  link = generate_request('CreateDBParameterGroup', params )
457
507
  request_info(link, DescribeDbParameterGroupsParser.new(:logger => @logger))[:db_parameter_groups].first
458
508
  end
459
509
 
460
-
461
510
  # Modify DBParameterGroup paramaters. Up to 20 params can be midified at once.
462
511
  #
463
512
  # rds.modify_db_parameter_group('kd1', 'max_allowed_packet' => 2048) #=> true
@@ -470,7 +519,7 @@ module RightAws
470
519
  params.each do |key, value|
471
520
  method = 'pending-reboot'
472
521
  if value.is_a?(Hash)
473
- method = value[:method] unless value[:method].blank?
522
+ method = value[:method] unless value[:method].right_blank?
474
523
  value = value[:value]
475
524
  end
476
525
  parameters << [key, value, method]
@@ -557,7 +606,7 @@ module RightAws
557
606
  result
558
607
  end
559
608
 
560
- # Describe a default parameters for the engine.
609
+ # Describe a default parameters for the parameter group family.
561
610
  #
562
611
  # rds.describe_engine_default_parameters('MySQL5.1') #=>
563
612
  # [{:is_modifiable=>true,
@@ -575,10 +624,10 @@ module RightAws
575
624
  # :name=>"auto_increment_increment",
576
625
  # :data_type=>"integer"}, ... ]
577
626
  #
578
- def describe_engine_default_parameters(*engine, &block)
579
- engine = ['MySQL5.1'] if engine.blank?
580
- item, params = AwsUtils::split_items_and_params(engine)
581
- params['Engine'] = item if item
627
+ def describe_engine_default_parameters(*db_parameter_group_family, &block)
628
+ db_parameter_group_family = ['MySQL5.1'] if db_parameter_group_family.right_blank?
629
+ item, params = AwsUtils::split_items_and_params(db_parameter_group_family)
630
+ params['DBParameterGroupFamily'] = item if item
582
631
  result = []
583
632
  incrementally_list_items('DescribeEngineDefaultParameters', DescribeDbParametersParser, params) do |response|
584
633
  result += response[:parameters]
@@ -636,7 +685,7 @@ module RightAws
636
685
  def describe_db_snapshots(params={}, &block)
637
686
  item, params = AwsUtils::split_items_and_params(params)
638
687
  params['DBSnapshotIdentifier'] = item if item
639
- params['DBInstanceIdentifier'] = params.delete(:instance_aws_id) unless params[:instance_aws_id].blank?
688
+ params['DBInstanceIdentifier'] = params.delete(:instance_aws_id) unless params[:instance_aws_id].right_blank?
640
689
  result = []
641
690
  incrementally_list_items('DescribeDBSnapshots', DescribeDbSnapshotsParser, params) do |response|
642
691
  result += response[:db_snapshots]
@@ -667,7 +716,8 @@ module RightAws
667
716
  # Create a new RDS instance from a DBSnapshot. The source DBSnapshot must be
668
717
  # in the "Available" state. The new RDS instance is created with the Default security group.
669
718
  #
670
- # Optional params: +:instance_class+, +:endpoint_port+, +:availability_zone+
719
+ # Optional params: +:instance_class+, +:endpoint_port+, +:availability_zone+, +:multi_az+,
720
+ # +:auto_minor_version_upgrade+
671
721
  #
672
722
  # rds.restore_db_instance_from_db_snapshot('ahahahaha-final-snapshot-20090828081159', 'q1') #=>
673
723
  # {:status=>"creating",
@@ -680,14 +730,17 @@ module RightAws
680
730
  # :create_time=>"2009-08-29T18:07:01.510Z",
681
731
  # :instance_class=>"Medium",
682
732
  # :preferred_maintenance_window=>"Sun:05:00-Sun:09:00",
683
- # :engine=>"MySQL5.1"}
733
+ # :engine=>"MySQL",
734
+ # :engine_version=>"5.1.49"}
684
735
  #
685
736
  def restore_db_instance_from_db_snapshot(snapshot_aws_id, instance_aws_id, params={})
686
737
  request_hash = { 'DBSnapshotIdentifier' => snapshot_aws_id,
687
738
  'DBInstanceIdentifier' => instance_aws_id }
688
- request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].blank?
689
- request_hash['EndpointPort'] = params[:endpoint_port] unless params[:endpoint_port].blank?
690
- request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].blank?
739
+ request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].right_blank?
740
+ request_hash['Port'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
741
+ request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
742
+ request_hash['MultiAZ'] = params[:multi_az] unless params[:multi_az].nil?
743
+ request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade] unless params[:auto_minor_version_upgrade].nil?
691
744
  link = generate_request('RestoreDBInstanceFromDBSnapshot', request_hash)
692
745
  request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
693
746
  end
@@ -696,10 +749,20 @@ module RightAws
696
749
  # database is created from the source database restore point with the same configuration as
697
750
  # the original source database, except that the new RDS instance is created with the default
698
751
  # security group.
699
- def restore_db_instance_to_point_in_time(instance_aws_id, new_instance_aws_id, restore_time)
752
+ #
753
+ # Optional params: +:instance_class+, +:endpoint_port+, +:availability_zone+, +:multi_az+, +:restore_time+,
754
+ # +:auto_minor_version_upgrade+, +:use_latest_restorable_time+
755
+ #
756
+ def restore_db_instance_to_point_in_time(instance_aws_id, new_instance_aws_id, params={})
700
757
  request_hash = { 'SourceDBInstanceIdentifier' => instance_aws_id,
701
- 'TargetDBInstanceIdentifier' => new_instance_aws_id,
702
- 'RestoreTime' => restore_time}
758
+ 'TargetDBInstanceIdentifier' => new_instance_aws_id}
759
+ request_hash['UseLatestRestorableTime'] = params[:use_latest_restorable_time].to_s unless params[:use_latest_restorable_time].nil?
760
+ request_hash['RestoreTime'] = params[:restore_time] unless params[:restore_time].right_blank?
761
+ request_hash['DBInstanceClass'] = params[:instance_class] unless params[:instance_class].right_blank?
762
+ request_hash['MultiAZ'] = params[:multi_az] unless params[:multi_az].nil?
763
+ request_hash['Port'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
764
+ request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
765
+ request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade] unless params[:auto_minor_version_upgrade].nil?
703
766
  link = generate_request('RestoreDBInstanceToPointInTime', request_hash)
704
767
  request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
705
768
  end
@@ -754,11 +817,11 @@ module RightAws
754
817
  #
755
818
  def describe_events(params={}, &block)
756
819
  params = params.dup
757
- params['SourceIdentifier'] = params.delete(:aws_id) unless params[:aws_id].blank?
758
- params['SourceType'] = params.delete(:source_type) unless params[:source_type].blank?
759
- params['Duration'] = params.delete(:duration) unless params[:duration].blank?
760
- params['StartDate'] = fix_date(params.delete(:start_date)) unless params[:start_date].blank?
761
- params['EndDate'] = fix_date(params.delete(:end_date)) unless params[:end_date].blank?
820
+ params['SourceIdentifier'] = params.delete(:aws_id) unless params[:aws_id].right_blank?
821
+ params['SourceType'] = params.delete(:source_type) unless params[:source_type].right_blank?
822
+ params['Duration'] = params.delete(:duration) unless params[:duration].right_blank?
823
+ params['StartDate'] = fix_date(params.delete(:start_date)) unless params[:start_date].right_blank?
824
+ params['EndDate'] = fix_date(params.delete(:end_date)) unless params[:end_date].right_blank?
762
825
  result = []
763
826
  incrementally_list_items('DescribeEvents', DescribeEventsParser, params) do |response|
764
827
  result += response[:events]
@@ -773,6 +836,170 @@ module RightAws
773
836
  date
774
837
  end
775
838
 
839
+ # --------------------------------------------
840
+ # DB Engine Versions
841
+ # --------------------------------------------
842
+
843
+ # Get a list of the available DB engines.
844
+ # Optional params: +:db_parameter_group_family+, +:default_only+, +:engine+, +:engine_version+
845
+ #
846
+ # rds.describe_db_engine_versions #=>
847
+ # [{:engine=>"mysql",
848
+ # :db_parameter_group_family=>"mysql5.1",
849
+ # :engine_version=>"5.1.45"},
850
+ # {:engine=>"mysql",
851
+ # :db_parameter_group_family=>"mysql5.1",
852
+ # :engine_version=>"5.1.49"},
853
+ # {:engine=>"mysql",
854
+ # :db_parameter_group_family=>"mysql5.1",
855
+ # :engine_version=>"5.1.50"}]
856
+ #
857
+ def describe_db_engine_versions(params={}, &block)
858
+ params = params.dup
859
+ params['DBParameterGroupFamily'] = params.delete(:db_parameter_group_family) unless params[:db_parameter_group_family].right_blank?
860
+ params['DefaultOnly'] = params.delete(:default_only).to_s unless params[:default_only].nil?
861
+ params['Engine'] = params.delete(:engine) unless params[:engine].right_blank?
862
+ params['EngineVersion'] = params.delete(:engine_version) unless params[:engine_version].right_blank?
863
+ result = []
864
+ incrementally_list_items('DescribeDBEngineVersions', DescribeDBEngineVersionsParser, params) do |response|
865
+ result += response[:db_engine_versions]
866
+ block ? block.call(response) : true
867
+ end
868
+ result
869
+ end
870
+
871
+ # --------------------------------------------
872
+ # DB Replicas
873
+ # --------------------------------------------
874
+
875
+ # Create a DB Instance that acts as a Read Replica of a source DB Instance.
876
+ #
877
+ # Optional params: +:endpoint_port+, +:availability_zone+, +:db_instance_class+, +:auto_minor_version_upgrade+
878
+ #
879
+ # rds.create_db_instance_read_replica('kd-delete-me-01-replica-01', 'kd-delete-me-01',
880
+ # :db_instance_class => 'db.m1.small',
881
+ # :endpoint_port => '11000',
882
+ # :auto_minor_version_upgrade => false ) #=>
883
+ # {:auto_minor_version_upgrade=>false,
884
+ # :read_replica_source_db_instance_identifier=>"kd-delete-me-01",
885
+ # :status=>"creating",
886
+ # :backup_retention_period=>0,
887
+ # :allocated_storage=>30,
888
+ # :read_replica_db_instance_identifiers=>[],
889
+ # :engine_version=>"5.1.50",
890
+ # :aws_id=>"kd-delete-me-01-replica-01",
891
+ # :multi_az=>false,
892
+ # :preferred_maintenance_window=>"sun:06:00-sun:10:00",
893
+ # :master_username=>"username",
894
+ # :preferred_backup_window=>"02:00-04:00",
895
+ # :db_parameter_group=>{:status=>"in-sync", :name=>"default.mysql5.1"},
896
+ # :engine=>"mysql",
897
+ # :db_security_groups=>[{:status=>"active", :name=>"default"}],
898
+ # :instance_class=>"db.m1.small",
899
+ # :pending_modified_values=>{}}
900
+ #
901
+ def create_db_instance_read_replica(aws_id, source_db_instance_identifier, params={})
902
+ request_hash = { 'DBInstanceIdentifier' => aws_id,
903
+ 'SourceDBInstanceIdentifier' => source_db_instance_identifier}
904
+ request_hash['Port'] = params[:endpoint_port] unless params[:endpoint_port].right_blank?
905
+ request_hash['AvailabilityZone'] = params[:availability_zone] unless params[:availability_zone].right_blank?
906
+ request_hash['DBInstanceClass'] = params[:db_instance_class] unless params[:db_instance_class].right_blank?
907
+ request_hash['AutoMinorVersionUpgrade'] = params[:auto_minor_version_upgrade].to_s unless params[:auto_minor_version_upgrade].nil?
908
+ link = generate_request('CreateDBInstanceReadReplica', request_hash)
909
+ request_info(link, DescribeDbInstancesParser.new(:logger => @logger))[:db_instances].first
910
+ end
911
+
912
+
913
+ #---------------------------------------------
914
+ # Reserved Instances
915
+ #---------------------------------------------
916
+
917
+ # Lists available reserved DB Instance offerings.
918
+ # Options: :aws_id, :instance_class, :duration, :product_description, :multi_az
919
+ #
920
+ # rds.describe_reserved_db_instances_offerings #=>
921
+ # [{:multi_az=>false,
922
+ # :duration=>31536000,
923
+ # :fixed_price=>1325.0,
924
+ # :usage_price=>0.262,
925
+ # :aws_id=>"248e7b75-2451-4381-9025-b5553d421c7b",
926
+ # :instance_class=>"db.m2.xlarge",
927
+ # :product_description=>"mysql"},
928
+ # {:multi_az=>true,
929
+ # :duration=>94608000,
930
+ # :fixed_price=>700.0,
931
+ # :usage_price=>0.092,
932
+ # :aws_id=>"248e7b75-49a7-4cd7-9a9b-354f4906a9b1",
933
+ # :instance_class=>"db.m1.small",
934
+ # :product_description=>"mysql"}, ... ]
935
+ #
936
+ # rds.describe_reserved_db_instances_offerings(:aws_id => "248e7b75-49a7-4cd7-9a9b-354f4906a9b1") #=>
937
+ # [{:duration=>94608000,
938
+ # :multi_az=>true,
939
+ # :fixed_price=>700.0,
940
+ # :usage_price=>0.092,
941
+ # :aws_id=>"248e7b75-49a7-4cd7-9a9b-354f4906a9b1",
942
+ # :instance_class=>"db.m1.small",
943
+ # :product_description=>"mysql"}]
944
+ #
945
+ # rds.describe_reserved_db_instances_offerings(:instance_class => "db.m1.small")
946
+ # rds.describe_reserved_db_instances_offerings(:duration => 31536000)
947
+ # rds.describe_reserved_db_instances_offerings(:product_description => 'mysql')
948
+ # rds.describe_reserved_db_instances_offerings(:multi_az => true)
949
+ #
950
+ def describe_reserved_db_instances_offerings(params={}, &block)
951
+ params = params.dup
952
+ params['ReservedDBInstancesOfferingId'] = params.delete(:aws_id) unless params[:aws_id].right_blank?
953
+ params['DBInstanceClass'] = params.delete(:instance_class) unless params[:instance_class].right_blank?
954
+ params['Duration'] = params.delete(:duration) unless params[:duration].right_blank?
955
+ params['ProductDescription'] = params.delete(:product_description) unless params[:product_description].right_blank?
956
+ params['MultiAZ'] = params.delete(:multi_az).to_s unless params[:multi_az].nil?
957
+ result = []
958
+ incrementally_list_items('DescribeReservedDBInstancesOfferings', DescribeReservedDBInstancesOfferingsParser, params) do |response|
959
+ result += response[:reserved_db_instances_offerings]
960
+ block ? block.call(response) : true
961
+ end
962
+ result
963
+ end
964
+
965
+ # Returns information about reserved DB Instances for this account, or about
966
+ # a specified reserved DB Instance.
967
+ # Options: :aws_id, :offering_aws_id, :instance_class, :duration, :product_description, :multi_az
968
+ #
969
+ # rds.describe_reserved_db_instances
970
+ # rds.describe_reserved_db_instances(:aws_id => "myreservedinstance")
971
+ # rds.describe_reserved_db_instances(:offering_aws_id => "248e7b75-49a7-4cd7-9a9b-354f4906a9b1")
972
+ # rds.describe_reserved_db_instances(:instance_class => "db.m1.small")
973
+ # rds.describe_reserved_db_instances(:duration => 31536000)
974
+ # rds.describe_reserved_db_instances(:product_description => 'mysql')
975
+ # rds.describe_reserved_db_instances_offerings(:multi_az => true)
976
+ #
977
+ def describe_reserved_db_instances(params={}, &block)
978
+ params = params.dup
979
+ params['ReservedDBInstancesId'] = params.delete(:aws_id) unless params[:aws_id].right_blank?
980
+ params['ReservedDBInstancesOfferingId'] = params.delete(:offering_aws_id) unless params[:offering_aws_id].right_blank?
981
+ params['DBInstanceClass'] = params.delete(:instance_class) unless params[:instance_class].right_blank?
982
+ params['Duration'] = params.delete(:duration) unless params[:duration].right_blank?
983
+ params['ProductDescription'] = params.delete(:product_description) unless params[:product_description].right_blank?
984
+ params['MultiAZ'] = params.delete(:multi_az).to_s unless params[:multi_az].nil?
985
+ result = []
986
+ incrementally_list_items('DescribeReservedDBInstances', DescribeReservedDBInstancesParser, params) do |response|
987
+ result += response[:reserved_db_instances]
988
+ block ? block.call(response) : true
989
+ end
990
+ result
991
+ end
992
+
993
+ # Purchases a reserved DB Instance offering.
994
+ # Options: :aws_id, :count
995
+ def purchase_reserved_db_instances_offering(offering_aws_id, params={})
996
+ request_hash = { 'ReservedDBInstancesOfferingId' => offering_aws_id }
997
+ request_hash['ReservedDBInstanceId'] = params[:aws_id] unless params[:aws_id].right_blank?
998
+ request_hash['DBInstanceCount'] = params[:count] unless params[:count].right_blank?
999
+ link = generate_request('PurchaseReservedDBInstancesOffering', request_hash)
1000
+ request_info(link, DescribeReservedDBInstancesParser.new(:logger => @logger))[:reserved_db_instances].first
1001
+ end
1002
+
776
1003
  # --------------------------------------------
777
1004
  # Parsers
778
1005
  # --------------------------------------------
@@ -783,54 +1010,61 @@ module RightAws
783
1010
 
784
1011
  class DescribeDbInstancesParser < RightAWSParser # :nodoc:
785
1012
  def reset
786
- @m = [ 'DBInstance',
787
- 'CreateDBInstanceResult',
788
- 'DeleteDBInstanceResult',
789
- 'ModifyDBInstanceResult',
790
- 'RebootDBInstanceResult',
791
- 'RestoreDBInstanceToPointInTimeResponse',
792
- 'RestoreDBInstanceFromDBSnapshotResult' ]
793
1013
  @result = { :db_instances => [] }
794
1014
  end
795
1015
  def tagstart(name, attributes)
796
1016
  case name
797
- when *@m then @db_instance = { :db_security_groups => [],
798
- :pending_modified_values => {} }
799
- when 'DBSecurityGroup' then @db_security_group = {}
800
- when 'DBParameterGroup', 'DBParameterGroupStatus' then @db_parameter_group = {}
1017
+ when 'DBInstance' then @item = { :db_security_groups => [], :pending_modified_values => {}, :read_replica_db_instance_identifiers => [] }
1018
+ when 'DBSecurityGroup' then @db_security_group = {}
1019
+ when 'DBParameterGroup',
1020
+ 'DBParameterGroupStatus' then @db_parameter_group = {}
801
1021
  end
802
1022
  end
803
1023
  def tagend(name)
804
1024
  case name
805
- when 'Marker' then @result[:marker] = @text
806
- when 'MaxRecords' then @result[:max_records] = @text.to_i
807
- when 'DBInstanceIdentifier' then @db_instance[:aws_id] = @text
808
- when 'DBName' then @db_instance[:name] = @text # ? is this one used?
809
- when 'InstanceCreateTime' then @db_instance[:create_time] = @text
810
- when 'Engine' then @db_instance[:engine] = @text
811
- when 'DBInstanceStatus' then @db_instance[:status] = @text
812
- when 'AllocatedStorage' then @db_instance[:allocated_storage] = @text.to_i
813
- when 'Port' then @db_instance[:endpoint_port] = @text.to_i
814
- when 'Address' then @db_instance[:endpoint_address] = @text
815
- when 'MasterUsername' then @db_instance[:master_username] = @text
816
- when 'AvailabilityZone' then @db_instance[:availability_zone] = @text
817
- when 'PreferredMaintenanceWindow' then @db_instance[:preferred_maintenance_window] = @text
818
- when 'BackupRetentionPeriod' then @db_instance[:backup_retention_period] = @text
819
- when 'PreferredBackupWindow' then @db_instance[:preferred_backup_window] = @text
820
- when 'DBInstanceClass'
821
- case @xmlpath
822
- when /PendingModifiedValues$/ then @db_instance[:pending_modified_values][:instance_class] = @text
823
- else @db_instance[:instance_class] = @text
1025
+ when 'Marker' then @result[:marker] = @text
1026
+ when 'MaxRecords' then @result[:max_records] = @text.to_i
1027
+ when 'DBInstanceIdentifier' then @item[:aws_id] = @text
1028
+ when 'InstanceCreateTime' then @item[:create_time] = @text
1029
+ when 'Engine' then @item[:engine] = @text
1030
+ when 'DBInstanceStatus' then @item[:status] = @text
1031
+ when 'Address' then @item[:endpoint_address] = @text
1032
+ when 'Port' then @item[:endpoint_port] = @text.to_i
1033
+ when 'MasterUsername' then @item[:master_username] = @text
1034
+ when 'AvailabilityZone' then @item[:availability_zone] = @text
1035
+ when 'LatestRestorableTime' then @item[:latest_restorable_time] = @text
1036
+ when 'ReadReplicaSourceDBInstanceIdentifier' then @item[:read_replica_source_db_instance_identifier] = @text
1037
+ when 'ReadReplicaDBInstanceIdentifier' then @item[:read_replica_db_instance_identifiers] << @text
1038
+ when 'DBSecurityGroupName' then @db_security_group[:name] = @text
1039
+ when 'Status' then @db_security_group[:status] = @text
1040
+ when 'DBParameterGroupName' then @db_parameter_group[:name] = @text
1041
+ when 'ParameterApplyStatus' then @db_parameter_group[:status] = @text
1042
+ when 'DBSecurityGroup' then @item[:db_security_groups] << @db_security_group
1043
+ when 'DBParameterGroup',
1044
+ 'DBParameterGroupStatus' then @item[:db_parameter_group] = @db_parameter_group
1045
+ when 'DBInstance' then @result[:db_instances] << @item
1046
+ else
1047
+ case full_tag_name
1048
+ when %r{DBInstance/DBInstanceClass$} then @item[:instance_class] = @text
1049
+ when %r{DBInstance/AllocatedStorage$} then @item[:allocated_storage] = @text.to_i
1050
+ when %r{DBInstance/MultiAZ$} then @item[:multi_az] = (@text == 'true')
1051
+ when %r{DBInstance/BackupRetentionPeriod$} then @item[:backup_retention_period] = @text.to_i
1052
+ when %r{DBInstance/PreferredMaintenanceWindow$} then @item[:preferred_maintenance_window] = @text
1053
+ when %r{DBInstance/PreferredBackupWindow$} then @item[:preferred_backup_window] = @text
1054
+ when %r{DBInstance/EngineVersion$} then @item[:engine_version] = @text
1055
+ when %r{DBInstance/AutoMinorVersionUpgrade$} then @item[:auto_minor_version_upgrade] = (@text == 'true')
1056
+ when %r{DBInstance/AllowMajorVersionUpgrade$} then @item[:allow_major_version_upgrade] = (@text == 'true')
1057
+ when %r{PendingModifiedValues/DBInstanceClass$} then @item[:pending_modified_values][:instance_class] = @text
1058
+ when %r{PendingModifiedValues/AllocatedStorage$} then @item[:pending_modified_values][:allocated_storage] = @text.to_i
1059
+ when %r{PendingModifiedValues/MasterUserPassword$} then @item[:pending_modified_values][:master_user_password] = @text
1060
+ when %r{PendingModifiedValues/MultiAZ$} then @item[:pending_modified_values][:multi_az] = (@text == 'true')
1061
+ when %r{PendingModifiedValues/BackupRetentionPeriod$} then @item[:pending_modified_values][:backup_retention_period] = @text.to_i
1062
+ when %r{PendingModifiedValues/PreferredMaintenanceWindow$} then @item[:pending_modified_values][:preferred_maintenance_window] = @text
1063
+ when %r{PendingModifiedValues/PreferredBackupWindow$} then @item[:pending_modified_values][:preferred_backup_window] = @text
1064
+ when %r{PendingModifiedValues/EngineVersion$} then @item[:pending_modified_values][:engine_version] = @text
1065
+ when %r{PendingModifiedValues/AutoMinorVersionUpgrade$} then @item[:pending_modified_values][:auto_minor_version_upgrade] = (@text == 'true')
1066
+ when %r{PendingModifiedValues/AllowMajorVersionUpgrade$} then @item[:pending_modified_values][:allow_major_version_upgrade] = (@text == 'true')
824
1067
  end
825
- when 'MasterUserPassword' then @db_instance[:pending_modified_values][:master_user_password] = @text
826
- when 'DBSecurityGroupName' then @db_security_group[:name] = @text
827
- when 'Status' then @db_security_group[:status] = @text
828
- when 'DBParameterGroupName' then @db_parameter_group[:name] = @text
829
- when 'ParameterApplyStatus' then @db_parameter_group[:status] = @text
830
- when 'DBSecurityGroup' then @db_instance[:db_security_groups] << @db_security_group
831
- when 'DBParameterGroup','DBParameterGroupStatus'
832
- @db_instance[:db_parameter_group] = @db_parameter_group
833
- when *@m then @result[:db_instances] << @db_instance
834
1068
  end
835
1069
  end
836
1070
  end
@@ -841,41 +1075,37 @@ module RightAws
841
1075
 
842
1076
  class DescribeDbSecurityGroupsParser < RightAWSParser # :nodoc:
843
1077
  def reset
844
- @m = [ 'DBSecurityGroup',
845
- 'CreateDBSecurityGroupResult',
846
- 'AuthorizeDBSecurityGroupIngressResult',
847
- 'RevokeDBSecurityGroupIngressResult' ]
848
1078
  @result = { :db_security_groups => [] }
849
1079
  end
850
1080
  def tagstart(name, attributes)
851
1081
  case name
852
- when *@m then @item = { :ec2_security_groups => [], :ip_ranges => [] }
853
- when 'IPRange' then @ip_range = {}
854
- when 'EC2SecurityGroup' then @ec2_security_group = {}
1082
+ when 'DBSecurityGroup' then @item = { :ec2_security_groups => [], :ip_ranges => [] }
1083
+ when 'IPRange' then @ip_range = {}
1084
+ when 'EC2SecurityGroup' then @ec2_security_group = {}
855
1085
  end
856
1086
  end
857
1087
  def tagend(name)
858
1088
  case name
859
- when 'Marker' then @result[:marker] = @text
860
- when 'MaxRecords' then @result[:max_records] = @text.to_i
861
- when 'DBSecurityGroupDescription' then @item[:description] = @text
862
- when 'OwnerId' then @item[:owner_id] = @text
863
- when 'DBSecurityGroupName' then @item[:name] = @text
864
- when 'Status'
865
- case @xmlpath
866
- when /IPRange$/ then @ip_range[:status] = @text
867
- when /EC2SecurityGroup$/ then @ec2_security_group[:status] = @text
868
- end
869
- when 'EC2SecurityGroupName' then @ec2_security_group[:name] = @text
870
- when 'EC2SecurityGroupOwnerId' then @ec2_security_group[:owner_id] = @text
871
- when 'CIDRIP' then @ip_range[:cidrip] = @text
872
- when 'IPRange' then @item[:ip_ranges] << @ip_range
873
- when 'EC2SecurityGroup' then @item[:ec2_security_groups] << @ec2_security_group
874
- when *@m
1089
+ when 'Marker' then @result[:marker] = @text
1090
+ when 'MaxRecords' then @result[:max_records] = @text.to_i
1091
+ when 'DBSecurityGroupDescription' then @item[:description ] = @text
1092
+ when 'OwnerId' then @item[:owner_id] = @text
1093
+ when 'DBSecurityGroupName' then @item[:name] = @text
1094
+ when 'EC2SecurityGroupName' then @ec2_security_group[:name] = @text
1095
+ when 'EC2SecurityGroupOwnerId' then @ec2_security_group[:owner_id] = @text
1096
+ when 'CIDRIP' then @ip_range[:cidrip] = @text
1097
+ when 'IPRange' then @item[:ip_ranges] << @ip_range
1098
+ when 'EC2SecurityGroup' then @item[:ec2_security_groups] << @ec2_security_group
1099
+ when 'DBSecurityGroup'
875
1100
  # Sort the ip_ranges and ec2_security_groups
876
1101
  @item[:ip_ranges].sort!{ |i1,i2| "#{i1[:cidrip]}" <=> "#{i2[:cidrip]}" }
877
1102
  @item[:ec2_security_groups].sort!{ |i1,i2| "#{i1[:owner_id]}#{i1[:name]}" <=> "#{i2[:owner_id]}#{i2[:name]}" }
878
1103
  @result[:db_security_groups] << @item
1104
+ else
1105
+ case full_tag_name
1106
+ when %r{IPRange/Status$} then @ip_range[:status] = @text
1107
+ when %r{EC2SecurityGroup/Status$} then @ec2_security_group[:status] = @text
1108
+ end
879
1109
  end
880
1110
  end
881
1111
  end
@@ -886,22 +1116,23 @@ module RightAws
886
1116
 
887
1117
  class DescribeDbParameterGroupsParser < RightAWSParser # :nodoc:
888
1118
  def reset
889
- @m = [ 'DBParameterGroup', 'CreateDBParameterGroupResult', 'ModifyDBParameterGroupResult' ]
890
1119
  @result = { :db_parameter_groups => [] }
891
1120
  end
892
1121
  def tagstart(name, attributes)
893
1122
  case name
894
- when *@m then @item = { }
1123
+ when 'DBParameterGroup',
1124
+ 'ModifyDBParameterGroupResult' then @item = { }
895
1125
  end
896
1126
  end
897
1127
  def tagend(name)
898
1128
  case name
899
- when 'Marker' then @result[:marker] = @text
900
- when 'MaxRecords' then @result[:max_records] = @text.to_i
901
- when 'DBParameterGroupName' then @item[:name] = @text
902
- when 'Description' then @item[:description] = @text
903
- when 'Engine' then @item[:engine] = @text
904
- when *@m then @result[:db_parameter_groups] << @item
1129
+ when 'Marker' then @result[:marker] = @text
1130
+ when 'MaxRecords' then @result[:max_records] = @text.to_i
1131
+ when 'DBParameterGroupName' then @item[:name] = @text
1132
+ when 'Description' then @item[:description] = @text
1133
+ when 'DBParameterGroupFamily' then @item[:db_parameter_group_family] = @text
1134
+ when 'DBParameterGroup',
1135
+ 'ModifyDBParameterGroupResult' then @result[:db_parameter_groups] << @item
905
1136
  end
906
1137
  end
907
1138
  end
@@ -912,24 +1143,24 @@ module RightAws
912
1143
  end
913
1144
  def tagstart(name, attributes)
914
1145
  case name
915
- when 'Parameter' then @item = {}
1146
+ when 'Parameter' then @item = {}
916
1147
  end
917
1148
  end
918
1149
  def tagend(name)
919
1150
  case name
920
1151
  when 'Marker' then @result[:marker] = @text
921
1152
  when 'MaxRecords' then @result[:max_records] = @text.to_i
922
- when 'DBParameterGroupName' then @result[:group_name] = @text # DescribeDbParametersResponse
923
- when 'Engine' then @result[:engine] = @text # DescribeDBEngineDefaultParametersResponse
924
- when 'DataType' then @item[:data_type] = @text
925
- when 'Source' then @item[:source] = @text
926
- when 'Description' then @item[:description] = @text
927
- when 'IsModifiable' then @item[:is_modifiable] = @text[/true/] ? true : false
928
- when 'ApplyType' then @item[:apply_type] = @text
929
- when 'AllowedValues' then @item[:allowed_values] = @text
930
- when 'ParameterName' then @item[:name] = @text
931
- when 'ParameterValue' then @item[:value] = @text
932
- when 'Parameter' then @result[:parameters] << @item
1153
+ when 'DBParameterGroupName' then @result[:group_name] = @text # DescribeDbParametersResponse
1154
+ when 'DBParameterGroupFamily' then @result[:db_parameter_group_family] = @text # DescribeDBEngineDefaultParametersResponse
1155
+ when 'DataType' then @item[:data_type] = @text
1156
+ when 'Source' then @item[:source] = @text
1157
+ when 'Description' then @item[:description] = @text
1158
+ when 'IsModifiable' then @item[:is_modifiable] = (@text == 'true')
1159
+ when 'ApplyType' then @item[:apply_type] = @text
1160
+ when 'AllowedValues' then @item[:allowed_values] = @text
1161
+ when 'ParameterName' then @item[:name] = @text
1162
+ when 'ParameterValue' then @item[:value] = @text
1163
+ when 'Parameter' then @result[:parameters] << @item
933
1164
  end
934
1165
  end
935
1166
  end
@@ -940,30 +1171,29 @@ module RightAws
940
1171
 
941
1172
  class DescribeDbSnapshotsParser < RightAWSParser # :nodoc:
942
1173
  def reset
943
- @m = ['DBSnapshot', 'CreateDBSnapshotResult', 'DeleteDBSnapshotResult']
944
1174
  @result = { :db_snapshots => [] }
945
1175
  end
946
1176
  def tagstart(name, attributes)
947
1177
  case name
948
- when *@m
949
- @db_snapshot = {}
1178
+ when 'DBSnapshot' then @item = {}
950
1179
  end
951
1180
  end
952
1181
  def tagend(name)
953
1182
  case name
954
- when 'Marker' then @result[:marker] = @text
955
- when 'MaxRecords' then @result[:max_records] = @text.to_i # ?
956
- when 'Engine' then @db_snapshot[:engine] = @text
957
- when 'InstanceCreateTime' then @db_snapshot[:instance_create_time] = @text
958
- when 'EndpointPort' then @db_snapshot[:endpoint_port] = @text.to_i
959
- when 'Status' then @db_snapshot[:status] = @text
960
- when 'AvailabilityZone' then @db_snapshot[:availability_zone] = @text
961
- when 'MasterUsername' then @db_snapshot[:master_username] = @text
962
- when 'AllocatedStorage' then @db_snapshot[:allocated_storage] = @text.to_i
963
- when 'SnapshotCreateTime' then @db_snapshot[:create_time] = @text
964
- when 'DBInstanceIdentifier' then @db_snapshot[:instance_aws_id] = @text
965
- when 'DBSnapshotIdentifier' then @db_snapshot[:aws_id] = @text
966
- when *@m then @result[:db_snapshots] << @db_snapshot
1183
+ when 'Marker' then @result[:marker] = @text
1184
+ when 'MaxRecords' then @result[:max_records] = @text.to_i # ?
1185
+ when 'Engine' then @item[:engine] = @text
1186
+ when 'EngineVersion' then @item[:engine_version] = @text
1187
+ when 'InstanceCreateTime' then @item[:instance_create_time] = @text
1188
+ when 'Port' then @item[:endpoint_port] = @text.to_i
1189
+ when 'Status' then @item[:status] = @text
1190
+ when 'AvailabilityZone' then @item[:availability_zone] = @text
1191
+ when 'MasterUsername' then @item[:master_username] = @text
1192
+ when 'AllocatedStorage' then @item[:allocated_storage] = @text.to_i
1193
+ when 'SnapshotCreateTime' then @item[:create_time] = @text
1194
+ when 'DBInstanceIdentifier' then @item[:instance_aws_id] = @text
1195
+ when 'DBSnapshotIdentifier' then @item[:aws_id] = @text
1196
+ when 'DBSnapshot' then @result[:db_snapshots] << @item
967
1197
  end
968
1198
  end
969
1199
  end
@@ -978,18 +1208,99 @@ module RightAws
978
1208
  end
979
1209
  def tagstart(name, attributes)
980
1210
  case name
981
- when 'Event' then @event = {}
1211
+ when 'Event' then @item = {}
982
1212
  end
983
1213
  end
984
1214
  def tagend(name)
985
1215
  case name
986
1216
  when 'Marker' then @result[:marker] = @text
987
1217
  when 'MaxRecords' then @result[:max_records] = @text.to_i # ?
988
- when 'Date' then @event[:date] = @text
989
- when 'SourceIdentifier' then @event[:aws_id] = @text
990
- when 'SourceType' then @event[:source_type] = @text
991
- when 'Message' then @event[:message] = @text
992
- when 'Event' then @result[:events] << @event
1218
+ when 'Date' then @item[:date] = @text
1219
+ when 'SourceIdentifier' then @item[:aws_id] = @text
1220
+ when 'SourceType' then @item[:source_type] = @text
1221
+ when 'Message' then @item[:message] = @text
1222
+ when 'Event' then @result[:events] << @item
1223
+ end
1224
+ end
1225
+ end
1226
+
1227
+ # --------------------------------------------
1228
+ # DB Events
1229
+ # --------------------------------------------
1230
+
1231
+ class DescribeDBEngineVersionsParser < RightAWSParser # :nodoc:
1232
+ def reset
1233
+ @result = { :db_engine_versions => [] }
1234
+ end
1235
+ def tagstart(name, attributes)
1236
+ case name
1237
+ when 'DBEngineVersion' then @item = {}
1238
+ end
1239
+ end
1240
+ def tagend(name)
1241
+ case name
1242
+ when 'Marker' then @result[:marker] = @text
1243
+ when 'MaxRecords' then @result[:max_records] = @text.to_i
1244
+ when 'DBParameterGroupFamily' then @item[:db_parameter_group_family] = @text
1245
+ when 'Engine' then @item[:engine] = @text
1246
+ when 'EngineVersion' then @item[:engine_version] = @text
1247
+ when 'DBEngineVersion' then @result[:db_engine_versions] << @item
1248
+ end
1249
+ end
1250
+ end
1251
+
1252
+ # --------------------------------------------
1253
+ # DB Reserved Instances
1254
+ # --------------------------------------------
1255
+
1256
+ class DescribeReservedDBInstancesOfferingsParser < RightAWSParser # :nodoc:
1257
+ def reset
1258
+ @result = { :reserved_db_instances_offerings => [] }
1259
+ end
1260
+ def tagstart(name, attributes)
1261
+ case name
1262
+ when 'ReservedDBInstancesOffering' then @item = {}
1263
+ end
1264
+ end
1265
+ def tagend(name)
1266
+ case name
1267
+ when 'Marker' then @result[:marker] = @text
1268
+ when 'MaxRecords' then @result[:max_records] = @text.to_i
1269
+ when 'DBInstanceClass' then @item[:instance_class] = @text
1270
+ when 'Duration' then @item[:duration] = @text.to_i
1271
+ when 'FixedPrice' then @item[:fixed_price] = @text.to_f
1272
+ when 'UsagePrice' then @item[:usage_price] = @text.to_f
1273
+ when 'MultiAZ' then @item[:multi_az] = (@text == 'true')
1274
+ when 'ProductDescription' then @item[:product_description] = @text
1275
+ when 'ReservedDBInstancesOfferingId' then @item[:aws_id] = @text
1276
+ when 'ReservedDBInstancesOffering' then @result[:reserved_db_instances_offerings] << @item
1277
+ end
1278
+ end
1279
+ end
1280
+
1281
+ class DescribeReservedDBInstancesParser < RightAWSParser # :nodoc:
1282
+ def reset
1283
+ @result = { :reserved_db_instances => [] }
1284
+ end
1285
+ def tagstart(name, attributes)
1286
+ case name
1287
+ when 'ReservedDBInstance' then @item = {}
1288
+ end
1289
+ end
1290
+ def tagend(name)
1291
+ case name
1292
+ when 'Marker' then @result[:marker] = @text
1293
+ when 'MaxRecords' then @result[:max_records] = @text.to_i
1294
+ when 'DBInstanceClass' then @item[:instance_class] = @text
1295
+ when 'Duration' then @item[:duration] = @text.to_i
1296
+ when 'FixedPrice' then @item[:fixed_price] = @text.to_f
1297
+ when 'UsagePrice' then @item[:usage_price] = @text.to_f
1298
+ when 'MultiAZ' then @item[:multi_az] = (@text == 'true')
1299
+ when 'ProductDescription' then @item[:product_description] = @text
1300
+ when 'ReservedDBInstancesOfferingId' then @item[:offering_aws_id] = @text
1301
+ when 'ReservedDBInstanceId' then @item[:aws_id] = @text
1302
+ when 'State' then @item[:state] = @text
1303
+ when 'ReservedDBInstance' then @result[:reserved_db_instances] << @item
993
1304
  end
994
1305
  end
995
1306
  end