comparison env/lib/python3.9/site-packages/boto/rds/__init__.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # Copyright (c) 2009-2012 Mitch Garnaat http://garnaat.org/
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions:
10 #
11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE.
21 #
22
23 import urllib
24 from boto.connection import AWSQueryConnection
25 from boto.rds.dbinstance import DBInstance
26 from boto.rds.dbsecuritygroup import DBSecurityGroup
27 from boto.rds.optiongroup import OptionGroup, OptionGroupOption
28 from boto.rds.parametergroup import ParameterGroup
29 from boto.rds.dbsnapshot import DBSnapshot
30 from boto.rds.event import Event
31 from boto.rds.regioninfo import RDSRegionInfo
32 from boto.rds.dbsubnetgroup import DBSubnetGroup
33 from boto.rds.vpcsecuritygroupmembership import VPCSecurityGroupMembership
34 from boto.regioninfo import get_regions
35 from boto.regioninfo import connect
36 from boto.rds.logfile import LogFile, LogFileObject
37
38
39 def regions():
40 """
41 Get all available regions for the RDS service.
42
43 :rtype: list
44 :return: A list of :class:`boto.rds.regioninfo.RDSRegionInfo`
45 """
46 return get_regions(
47 'rds',
48 region_cls=RDSRegionInfo,
49 connection_cls=RDSConnection
50 )
51
52
53 def connect_to_region(region_name, **kw_params):
54 """
55 Given a valid region name, return a
56 :class:`boto.rds.RDSConnection`.
57 Any additional parameters after the region_name are passed on to
58 the connect method of the region object.
59
60 :type: str
61 :param region_name: The name of the region to connect to.
62
63 :rtype: :class:`boto.rds.RDSConnection` or ``None``
64 :return: A connection to the given region, or None if an invalid region
65 name is given
66 """
67 return connect('rds', region_name, region_cls=RDSRegionInfo,
68 connection_cls=RDSConnection, **kw_params)
69
70 #boto.set_stream_logger('rds')
71
72
73 class RDSConnection(AWSQueryConnection):
74
75 DefaultRegionName = 'us-east-1'
76 DefaultRegionEndpoint = 'rds.amazonaws.com'
77 APIVersion = '2013-05-15'
78
79 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
80 is_secure=True, port=None, proxy=None, proxy_port=None,
81 proxy_user=None, proxy_pass=None, debug=0,
82 https_connection_factory=None, region=None, path='/',
83 security_token=None, validate_certs=True,
84 profile_name=None):
85 if not region:
86 region = RDSRegionInfo(self, self.DefaultRegionName,
87 self.DefaultRegionEndpoint)
88 self.region = region
89 super(RDSConnection, self).__init__(aws_access_key_id,
90 aws_secret_access_key,
91 is_secure, port, proxy, proxy_port,
92 proxy_user, proxy_pass,
93 self.region.endpoint, debug,
94 https_connection_factory, path,
95 security_token,
96 validate_certs=validate_certs,
97 profile_name=profile_name)
98
99 def _required_auth_capability(self):
100 return ['hmac-v4']
101
102 # DB Instance methods
103
104 def get_all_dbinstances(self, instance_id=None, max_records=None,
105 marker=None):
106 """
107 Retrieve all the DBInstances in your account.
108
109 :type instance_id: str
110 :param instance_id: DB Instance identifier. If supplied, only
111 information this instance will be returned.
112 Otherwise, info about all DB Instances will
113 be returned.
114
115 :type max_records: int
116 :param max_records: The maximum number of records to be returned.
117 If more results are available, a MoreToken will
118 be returned in the response that can be used to
119 retrieve additional records. Default is 100.
120
121 :type marker: str
122 :param marker: The marker provided by a previous request.
123
124 :rtype: list
125 :return: A list of :class:`boto.rds.dbinstance.DBInstance`
126 """
127 params = {}
128 if instance_id:
129 params['DBInstanceIdentifier'] = instance_id
130 if max_records:
131 params['MaxRecords'] = max_records
132 if marker:
133 params['Marker'] = marker
134 return self.get_list('DescribeDBInstances', params,
135 [('DBInstance', DBInstance)])
136
137 def create_dbinstance(self,
138 id,
139 allocated_storage,
140 instance_class,
141 master_username,
142 master_password,
143 port=3306,
144 engine='MySQL5.1',
145 db_name=None,
146 param_group=None,
147 security_groups=None,
148 availability_zone=None,
149 preferred_maintenance_window=None,
150 backup_retention_period=None,
151 preferred_backup_window=None,
152 multi_az=False,
153 engine_version=None,
154 auto_minor_version_upgrade=True,
155 character_set_name = None,
156 db_subnet_group_name = None,
157 license_model = None,
158 option_group_name = None,
159 iops=None,
160 vpc_security_groups=None,
161 ):
162 # API version: 2013-09-09
163 # Parameter notes:
164 # =================
165 # id should be db_instance_identifier according to API docs but has been left
166 # id for backwards compatibility
167 #
168 # security_groups should be db_security_groups according to API docs but has been left
169 # security_groups for backwards compatibility
170 #
171 # master_password should be master_user_password according to API docs but has been left
172 # master_password for backwards compatibility
173 #
174 # instance_class should be db_instance_class according to API docs but has been left
175 # instance_class for backwards compatibility
176 """
177 Create a new DBInstance.
178
179 :type id: str
180 :param id: Unique identifier for the new instance.
181 Must contain 1-63 alphanumeric characters.
182 First character must be a letter.
183 May not end with a hyphen or contain two consecutive hyphens
184
185 :type allocated_storage: int
186 :param allocated_storage: Initially allocated storage size, in GBs.
187 Valid values are depending on the engine value.
188
189 * MySQL = 5--3072
190 * oracle-se1 = 10--3072
191 * oracle-se = 10--3072
192 * oracle-ee = 10--3072
193 * sqlserver-ee = 200--1024
194 * sqlserver-se = 200--1024
195 * sqlserver-ex = 30--1024
196 * sqlserver-web = 30--1024
197 * postgres = 5--3072
198
199 :type instance_class: str
200 :param instance_class: The compute and memory capacity of
201 the DBInstance. Valid values are:
202
203 * db.t1.micro
204 * db.m1.small
205 * db.m1.medium
206 * db.m1.large
207 * db.m1.xlarge
208 * db.m2.xlarge
209 * db.m2.2xlarge
210 * db.m2.4xlarge
211
212 :type engine: str
213 :param engine: Name of database engine. Defaults to MySQL but can be;
214
215 * MySQL
216 * oracle-se1
217 * oracle-se
218 * oracle-ee
219 * sqlserver-ee
220 * sqlserver-se
221 * sqlserver-ex
222 * sqlserver-web
223 * postgres
224
225 :type master_username: str
226 :param master_username: Name of master user for the DBInstance.
227
228 * MySQL must be;
229 - 1--16 alphanumeric characters
230 - first character must be a letter
231 - cannot be a reserved MySQL word
232
233 * Oracle must be:
234 - 1--30 alphanumeric characters
235 - first character must be a letter
236 - cannot be a reserved Oracle word
237
238 * SQL Server must be:
239 - 1--128 alphanumeric characters
240 - first character must be a letter
241 - cannot be a reserver SQL Server word
242
243 :type master_password: str
244 :param master_password: Password of master user for the DBInstance.
245
246 * MySQL must be 8--41 alphanumeric characters
247
248 * Oracle must be 8--30 alphanumeric characters
249
250 * SQL Server must be 8--128 alphanumeric characters.
251
252 :type port: int
253 :param port: Port number on which database accepts connections.
254 Valid values [1115-65535].
255
256 * MySQL defaults to 3306
257
258 * Oracle defaults to 1521
259
260 * SQL Server defaults to 1433 and _cannot_ be 1434, 3389,
261 47001, 49152, and 49152 through 49156.
262
263 * PostgreSQL defaults to 5432
264
265 :type db_name: str
266 :param db_name: * MySQL:
267 Name of a database to create when the DBInstance
268 is created. Default is to create no databases.
269
270 Must contain 1--64 alphanumeric characters and cannot
271 be a reserved MySQL word.
272
273 * Oracle:
274 The Oracle System ID (SID) of the created DB instances.
275 Default is ORCL. Cannot be longer than 8 characters.
276
277 * SQL Server:
278 Not applicable and must be None.
279
280 * PostgreSQL:
281 Name of a database to create when the DBInstance
282 is created. Default is to create no databases.
283
284 Must contain 1--63 alphanumeric characters. Must
285 begin with a letter or an underscore. Subsequent
286 characters can be letters, underscores, or digits (0-9)
287 and cannot be a reserved PostgreSQL word.
288
289 :type param_group: str or ParameterGroup object
290 :param param_group: Name of DBParameterGroup or ParameterGroup instance
291 to associate with this DBInstance. If no groups are
292 specified no parameter groups will be used.
293
294 :type security_groups: list of str or list of DBSecurityGroup objects
295 :param security_groups: List of names of DBSecurityGroup to
296 authorize on this DBInstance.
297
298 :type availability_zone: str
299 :param availability_zone: Name of the availability zone to place
300 DBInstance into.
301
302 :type preferred_maintenance_window: str
303 :param preferred_maintenance_window: The weekly time range (in UTC)
304 during which maintenance can occur.
305 Default is Sun:05:00-Sun:09:00
306
307 :type backup_retention_period: int
308 :param backup_retention_period: The number of days for which automated
309 backups are retained. Setting this to
310 zero disables automated backups.
311
312 :type preferred_backup_window: str
313 :param preferred_backup_window: The daily time range during which
314 automated backups are created (if
315 enabled). Must be in h24:mi-hh24:mi
316 format (UTC).
317
318 :type multi_az: bool
319 :param multi_az: If True, specifies the DB Instance will be
320 deployed in multiple availability zones.
321
322 For Microsoft SQL Server, must be set to false. You cannot set
323 the AvailabilityZone parameter if the MultiAZ parameter is
324 set to true.
325
326 :type engine_version: str
327 :param engine_version: The version number of the database engine to use.
328
329 * MySQL format example: 5.1.42
330
331 * Oracle format example: 11.2.0.2.v2
332
333 * SQL Server format example: 10.50.2789.0.v1
334
335 * PostgreSQL format example: 9.3
336
337 :type auto_minor_version_upgrade: bool
338 :param auto_minor_version_upgrade: Indicates that minor engine
339 upgrades will be applied
340 automatically to the Read Replica
341 during the maintenance window.
342 Default is True.
343 :type character_set_name: str
344 :param character_set_name: For supported engines, indicates that the DB Instance
345 should be associated with the specified CharacterSet.
346
347 :type db_subnet_group_name: str
348 :param db_subnet_group_name: A DB Subnet Group to associate with this DB Instance.
349 If there is no DB Subnet Group, then it is a non-VPC DB
350 instance.
351
352 :type license_model: str
353 :param license_model: License model information for this DB Instance.
354
355 Valid values are;
356 - license-included
357 - bring-your-own-license
358 - general-public-license
359
360 All license types are not supported on all engines.
361
362 :type option_group_name: str
363 :param option_group_name: Indicates that the DB Instance should be associated
364 with the specified option group.
365
366 :type iops: int
367 :param iops: The amount of IOPS (input/output operations per second) to Provisioned
368 for the DB Instance. Can be modified at a later date.
369
370 Must scale linearly. For every 1000 IOPS provision, you must allocated
371 100 GB of storage space. This scales up to 1 TB / 10 000 IOPS for MySQL
372 and Oracle. MSSQL is limited to 700 GB / 7 000 IOPS.
373
374 If you specify a value, it must be at least 1000 IOPS and you must
375 allocate 100 GB of storage.
376
377 :type vpc_security_groups: list of str or a VPCSecurityGroupMembership object
378 :param vpc_security_groups: List of VPC security group ids or a list of
379 VPCSecurityGroupMembership objects this DBInstance should be a member of
380
381 :rtype: :class:`boto.rds.dbinstance.DBInstance`
382 :return: The new db instance.
383 """
384 # boto argument alignment with AWS API parameter names:
385 # =====================================================
386 # arg => AWS parameter
387 # allocated_storage => AllocatedStorage
388 # auto_minor_version_update => AutoMinorVersionUpgrade
389 # availability_zone => AvailabilityZone
390 # backup_retention_period => BackupRetentionPeriod
391 # character_set_name => CharacterSetName
392 # db_instance_class => DBInstanceClass
393 # db_instance_identifier => DBInstanceIdentifier
394 # db_name => DBName
395 # db_parameter_group_name => DBParameterGroupName
396 # db_security_groups => DBSecurityGroups.member.N
397 # db_subnet_group_name => DBSubnetGroupName
398 # engine => Engine
399 # engine_version => EngineVersion
400 # license_model => LicenseModel
401 # master_username => MasterUsername
402 # master_user_password => MasterUserPassword
403 # multi_az => MultiAZ
404 # option_group_name => OptionGroupName
405 # port => Port
406 # preferred_backup_window => PreferredBackupWindow
407 # preferred_maintenance_window => PreferredMaintenanceWindow
408 # vpc_security_groups => VpcSecurityGroupIds.member.N
409 params = {
410 'AllocatedStorage': allocated_storage,
411 'AutoMinorVersionUpgrade': str(auto_minor_version_upgrade).lower() if auto_minor_version_upgrade else None,
412 'AvailabilityZone': availability_zone,
413 'BackupRetentionPeriod': backup_retention_period,
414 'CharacterSetName': character_set_name,
415 'DBInstanceClass': instance_class,
416 'DBInstanceIdentifier': id,
417 'DBName': db_name,
418 'DBParameterGroupName': (param_group.name
419 if isinstance(param_group, ParameterGroup)
420 else param_group),
421 'DBSubnetGroupName': db_subnet_group_name,
422 'Engine': engine,
423 'EngineVersion': engine_version,
424 'Iops': iops,
425 'LicenseModel': license_model,
426 'MasterUsername': master_username,
427 'MasterUserPassword': master_password,
428 'MultiAZ': str(multi_az).lower() if multi_az else None,
429 'OptionGroupName': option_group_name,
430 'Port': port,
431 'PreferredBackupWindow': preferred_backup_window,
432 'PreferredMaintenanceWindow': preferred_maintenance_window,
433 }
434 if security_groups:
435 l = []
436 for group in security_groups:
437 if isinstance(group, DBSecurityGroup):
438 l.append(group.name)
439 else:
440 l.append(group)
441 self.build_list_params(params, l, 'DBSecurityGroups.member')
442
443 if vpc_security_groups:
444 l = []
445 for vpc_grp in vpc_security_groups:
446 if isinstance(vpc_grp, VPCSecurityGroupMembership):
447 l.append(vpc_grp.vpc_group)
448 else:
449 l.append(vpc_grp)
450 self.build_list_params(params, l, 'VpcSecurityGroupIds.member')
451
452 # Remove any params set to None
453 for k, v in list(params.items()):
454 if v is None: del(params[k])
455
456 return self.get_object('CreateDBInstance', params, DBInstance)
457
458 def create_dbinstance_read_replica(self, id, source_id,
459 instance_class=None,
460 port=3306,
461 availability_zone=None,
462 auto_minor_version_upgrade=None):
463 """
464 Create a new DBInstance Read Replica.
465
466 :type id: str
467 :param id: Unique identifier for the new instance.
468 Must contain 1-63 alphanumeric characters.
469 First character must be a letter.
470 May not end with a hyphen or contain two consecutive hyphens
471
472 :type source_id: str
473 :param source_id: Unique identifier for the DB Instance for which this
474 DB Instance will act as a Read Replica.
475
476 :type instance_class: str
477 :param instance_class: The compute and memory capacity of the
478 DBInstance. Default is to inherit from
479 the source DB Instance.
480
481 Valid values are:
482
483 * db.m1.small
484 * db.m1.large
485 * db.m1.xlarge
486 * db.m2.xlarge
487 * db.m2.2xlarge
488 * db.m2.4xlarge
489
490 :type port: int
491 :param port: Port number on which database accepts connections.
492 Default is to inherit from source DB Instance.
493 Valid values [1115-65535]. Defaults to 3306.
494
495 :type availability_zone: str
496 :param availability_zone: Name of the availability zone to place
497 DBInstance into.
498
499 :type auto_minor_version_upgrade: bool
500 :param auto_minor_version_upgrade: Indicates that minor engine
501 upgrades will be applied
502 automatically to the Read Replica
503 during the maintenance window.
504 Default is to inherit this value
505 from the source DB Instance.
506
507 :rtype: :class:`boto.rds.dbinstance.DBInstance`
508 :return: The new db instance.
509 """
510 params = {'DBInstanceIdentifier': id,
511 'SourceDBInstanceIdentifier': source_id}
512 if instance_class:
513 params['DBInstanceClass'] = instance_class
514 if port:
515 params['Port'] = port
516 if availability_zone:
517 params['AvailabilityZone'] = availability_zone
518 if auto_minor_version_upgrade is not None:
519 if auto_minor_version_upgrade is True:
520 params['AutoMinorVersionUpgrade'] = 'true'
521 else:
522 params['AutoMinorVersionUpgrade'] = 'false'
523
524 return self.get_object('CreateDBInstanceReadReplica',
525 params, DBInstance)
526
527
528 def promote_read_replica(self, id,
529 backup_retention_period=None,
530 preferred_backup_window=None):
531 """
532 Promote a Read Replica to a standalone DB Instance.
533
534 :type id: str
535 :param id: Unique identifier for the new instance.
536 Must contain 1-63 alphanumeric characters.
537 First character must be a letter.
538 May not end with a hyphen or contain two consecutive hyphens
539
540 :type backup_retention_period: int
541 :param backup_retention_period: The number of days for which automated
542 backups are retained. Setting this to
543 zero disables automated backups.
544
545 :type preferred_backup_window: str
546 :param preferred_backup_window: The daily time range during which
547 automated backups are created (if
548 enabled). Must be in h24:mi-hh24:mi
549 format (UTC).
550
551 :rtype: :class:`boto.rds.dbinstance.DBInstance`
552 :return: The new db instance.
553 """
554 params = {'DBInstanceIdentifier': id}
555 if backup_retention_period is not None:
556 params['BackupRetentionPeriod'] = backup_retention_period
557 if preferred_backup_window:
558 params['PreferredBackupWindow'] = preferred_backup_window
559
560 return self.get_object('PromoteReadReplica', params, DBInstance)
561
562
563 def modify_dbinstance(self, id, param_group=None, security_groups=None,
564 preferred_maintenance_window=None,
565 master_password=None, allocated_storage=None,
566 instance_class=None,
567 backup_retention_period=None,
568 preferred_backup_window=None,
569 multi_az=False,
570 apply_immediately=False,
571 iops=None,
572 vpc_security_groups=None,
573 new_instance_id=None,
574 ):
575 """
576 Modify an existing DBInstance.
577
578 :type id: str
579 :param id: Unique identifier for the new instance.
580
581 :type param_group: str or ParameterGroup object
582 :param param_group: Name of DBParameterGroup or ParameterGroup instance
583 to associate with this DBInstance. If no groups are
584 specified no parameter groups will be used.
585
586 :type security_groups: list of str or list of DBSecurityGroup objects
587 :param security_groups: List of names of DBSecurityGroup to authorize on
588 this DBInstance.
589
590 :type preferred_maintenance_window: str
591 :param preferred_maintenance_window: The weekly time range (in UTC)
592 during which maintenance can
593 occur.
594 Default is Sun:05:00-Sun:09:00
595
596 :type master_password: str
597 :param master_password: Password of master user for the DBInstance.
598 Must be 4-15 alphanumeric characters.
599
600 :type allocated_storage: int
601 :param allocated_storage: The new allocated storage size, in GBs.
602 Valid values are [5-1024]
603
604 :type instance_class: str
605 :param instance_class: The compute and memory capacity of the
606 DBInstance. Changes will be applied at
607 next maintenance window unless
608 apply_immediately is True.
609
610 Valid values are:
611
612 * db.m1.small
613 * db.m1.large
614 * db.m1.xlarge
615 * db.m2.xlarge
616 * db.m2.2xlarge
617 * db.m2.4xlarge
618
619 :type apply_immediately: bool
620 :param apply_immediately: If true, the modifications will be applied
621 as soon as possible rather than waiting for
622 the next preferred maintenance window.
623
624 :type backup_retention_period: int
625 :param backup_retention_period: The number of days for which automated
626 backups are retained. Setting this to
627 zero disables automated backups.
628
629 :type preferred_backup_window: str
630 :param preferred_backup_window: The daily time range during which
631 automated backups are created (if
632 enabled). Must be in h24:mi-hh24:mi
633 format (UTC).
634
635 :type multi_az: bool
636 :param multi_az: If True, specifies the DB Instance will be
637 deployed in multiple availability zones.
638
639 :type iops: int
640 :param iops: The amount of IOPS (input/output operations per second) to Provisioned
641 for the DB Instance. Can be modified at a later date.
642
643 Must scale linearly. For every 1000 IOPS provision, you must allocated
644 100 GB of storage space. This scales up to 1 TB / 10 000 IOPS for MySQL
645 and Oracle. MSSQL is limited to 700 GB / 7 000 IOPS.
646
647 If you specify a value, it must be at least 1000 IOPS and you must
648 allocate 100 GB of storage.
649
650 :type vpc_security_groups: list of str or a VPCSecurityGroupMembership object
651 :param vpc_security_groups: List of VPC security group ids or a
652 VPCSecurityGroupMembership object this DBInstance should be a member of
653
654 :type new_instance_id: str
655 :param new_instance_id: New name to rename the DBInstance to.
656
657 :rtype: :class:`boto.rds.dbinstance.DBInstance`
658 :return: The modified db instance.
659 """
660 params = {'DBInstanceIdentifier': id}
661 if param_group:
662 params['DBParameterGroupName'] = (param_group.name
663 if isinstance(param_group, ParameterGroup)
664 else param_group)
665 if security_groups:
666 l = []
667 for group in security_groups:
668 if isinstance(group, DBSecurityGroup):
669 l.append(group.name)
670 else:
671 l.append(group)
672 self.build_list_params(params, l, 'DBSecurityGroups.member')
673 if vpc_security_groups:
674 l = []
675 for vpc_grp in vpc_security_groups:
676 if isinstance(vpc_grp, VPCSecurityGroupMembership):
677 l.append(vpc_grp.vpc_group)
678 else:
679 l.append(vpc_grp)
680 self.build_list_params(params, l, 'VpcSecurityGroupIds.member')
681 if preferred_maintenance_window:
682 params['PreferredMaintenanceWindow'] = preferred_maintenance_window
683 if master_password:
684 params['MasterUserPassword'] = master_password
685 if allocated_storage:
686 params['AllocatedStorage'] = allocated_storage
687 if instance_class:
688 params['DBInstanceClass'] = instance_class
689 if backup_retention_period is not None:
690 params['BackupRetentionPeriod'] = backup_retention_period
691 if preferred_backup_window:
692 params['PreferredBackupWindow'] = preferred_backup_window
693 if multi_az:
694 params['MultiAZ'] = 'true'
695 if apply_immediately:
696 params['ApplyImmediately'] = 'true'
697 if iops:
698 params['Iops'] = iops
699 if new_instance_id:
700 params['NewDBInstanceIdentifier'] = new_instance_id
701
702 return self.get_object('ModifyDBInstance', params, DBInstance)
703
704 def delete_dbinstance(self, id, skip_final_snapshot=False,
705 final_snapshot_id=''):
706 """
707 Delete an existing DBInstance.
708
709 :type id: str
710 :param id: Unique identifier for the new instance.
711
712 :type skip_final_snapshot: bool
713 :param skip_final_snapshot: This parameter determines whether a final
714 db snapshot is created before the instance
715 is deleted. If True, no snapshot
716 is created. If False, a snapshot
717 is created before deleting the instance.
718
719 :type final_snapshot_id: str
720 :param final_snapshot_id: If a final snapshot is requested, this
721 is the identifier used for that snapshot.
722
723 :rtype: :class:`boto.rds.dbinstance.DBInstance`
724 :return: The deleted db instance.
725 """
726 params = {'DBInstanceIdentifier': id}
727 if skip_final_snapshot:
728 params['SkipFinalSnapshot'] = 'true'
729 else:
730 params['SkipFinalSnapshot'] = 'false'
731 params['FinalDBSnapshotIdentifier'] = final_snapshot_id
732 return self.get_object('DeleteDBInstance', params, DBInstance)
733
734 def reboot_dbinstance(self, id):
735 """
736 Reboot DBInstance.
737
738 :type id: str
739 :param id: Unique identifier of the instance.
740
741 :rtype: :class:`boto.rds.dbinstance.DBInstance`
742 :return: The rebooting db instance.
743 """
744 params = {'DBInstanceIdentifier': id}
745 return self.get_object('RebootDBInstance', params, DBInstance)
746
747 # DBParameterGroup methods
748
749 def get_all_dbparameter_groups(self, groupname=None, max_records=None,
750 marker=None):
751 """
752 Get all parameter groups associated with your account in a region.
753
754 :type groupname: str
755 :param groupname: The name of the DBParameter group to retrieve.
756 If not provided, all DBParameter groups will be returned.
757
758 :type max_records: int
759 :param max_records: The maximum number of records to be returned.
760 If more results are available, a MoreToken will
761 be returned in the response that can be used to
762 retrieve additional records. Default is 100.
763
764 :type marker: str
765 :param marker: The marker provided by a previous request.
766
767 :rtype: list
768 :return: A list of :class:`boto.ec2.parametergroup.ParameterGroup`
769 """
770 params = {}
771 if groupname:
772 params['DBParameterGroupName'] = groupname
773 if max_records:
774 params['MaxRecords'] = max_records
775 if marker:
776 params['Marker'] = marker
777 return self.get_list('DescribeDBParameterGroups', params,
778 [('DBParameterGroup', ParameterGroup)])
779
780 def get_all_dbparameters(self, groupname, source=None,
781 max_records=None, marker=None):
782 """
783 Get all parameters associated with a ParameterGroup
784
785 :type groupname: str
786 :param groupname: The name of the DBParameter group to retrieve.
787
788 :type source: str
789 :param source: Specifies which parameters to return.
790 If not specified, all parameters will be returned.
791 Valid values are: user|system|engine-default
792
793 :type max_records: int
794 :param max_records: The maximum number of records to be returned.
795 If more results are available, a MoreToken will
796 be returned in the response that can be used to
797 retrieve additional records. Default is 100.
798
799 :type marker: str
800 :param marker: The marker provided by a previous request.
801
802 :rtype: :class:`boto.ec2.parametergroup.ParameterGroup`
803 :return: The ParameterGroup
804 """
805 params = {'DBParameterGroupName': groupname}
806 if source:
807 params['Source'] = source
808 if max_records:
809 params['MaxRecords'] = max_records
810 if marker:
811 params['Marker'] = marker
812 pg = self.get_object('DescribeDBParameters', params, ParameterGroup)
813 pg.name = groupname
814 return pg
815
816 def create_parameter_group(self, name, engine='MySQL5.1', description=''):
817 """
818 Create a new dbparameter group for your account.
819
820 :type name: string
821 :param name: The name of the new dbparameter group
822
823 :type engine: str
824 :param engine: Name of database engine.
825
826 :type description: string
827 :param description: The description of the new dbparameter group
828
829 :rtype: :class:`boto.rds.parametergroup.ParameterGroup`
830 :return: The newly created ParameterGroup
831 """
832 params = {'DBParameterGroupName': name,
833 'DBParameterGroupFamily': engine,
834 'Description': description}
835 return self.get_object('CreateDBParameterGroup', params, ParameterGroup)
836
837 def modify_parameter_group(self, name, parameters=None):
838 """
839 Modify a ParameterGroup for your account.
840
841 :type name: string
842 :param name: The name of the new ParameterGroup
843
844 :type parameters: list of :class:`boto.rds.parametergroup.Parameter`
845 :param parameters: The new parameters
846
847 :rtype: :class:`boto.rds.parametergroup.ParameterGroup`
848 :return: The newly created ParameterGroup
849 """
850 params = {'DBParameterGroupName': name}
851 for i in range(0, len(parameters)):
852 parameter = parameters[i]
853 parameter.merge(params, i+1)
854 return self.get_list('ModifyDBParameterGroup', params,
855 ParameterGroup, verb='POST')
856
857 def reset_parameter_group(self, name, reset_all_params=False,
858 parameters=None):
859 """
860 Resets some or all of the parameters of a ParameterGroup to the
861 default value
862
863 :type key_name: string
864 :param key_name: The name of the ParameterGroup to reset
865
866 :type parameters: list of :class:`boto.rds.parametergroup.Parameter`
867 :param parameters: The parameters to reset. If not supplied,
868 all parameters will be reset.
869 """
870 params = {'DBParameterGroupName': name}
871 if reset_all_params:
872 params['ResetAllParameters'] = 'true'
873 else:
874 params['ResetAllParameters'] = 'false'
875 for i in range(0, len(parameters)):
876 parameter = parameters[i]
877 parameter.merge(params, i+1)
878 return self.get_status('ResetDBParameterGroup', params)
879
880 def delete_parameter_group(self, name):
881 """
882 Delete a ParameterGroup from your account.
883
884 :type key_name: string
885 :param key_name: The name of the ParameterGroup to delete
886 """
887 params = {'DBParameterGroupName': name}
888 return self.get_status('DeleteDBParameterGroup', params)
889
890 # DBSecurityGroup methods
891
892 def get_all_dbsecurity_groups(self, groupname=None, max_records=None,
893 marker=None):
894 """
895 Get all security groups associated with your account in a region.
896
897 :type groupnames: list
898 :param groupnames: A list of the names of security groups to retrieve.
899 If not provided, all security groups will
900 be returned.
901
902 :type max_records: int
903 :param max_records: The maximum number of records to be returned.
904 If more results are available, a MoreToken will
905 be returned in the response that can be used to
906 retrieve additional records. Default is 100.
907
908 :type marker: str
909 :param marker: The marker provided by a previous request.
910
911 :rtype: list
912 :return: A list of :class:`boto.rds.dbsecuritygroup.DBSecurityGroup`
913 """
914 params = {}
915 if groupname:
916 params['DBSecurityGroupName'] = groupname
917 if max_records:
918 params['MaxRecords'] = max_records
919 if marker:
920 params['Marker'] = marker
921 return self.get_list('DescribeDBSecurityGroups', params,
922 [('DBSecurityGroup', DBSecurityGroup)])
923
924 def create_dbsecurity_group(self, name, description=None):
925 """
926 Create a new security group for your account.
927 This will create the security group within the region you
928 are currently connected to.
929
930 :type name: string
931 :param name: The name of the new security group
932
933 :type description: string
934 :param description: The description of the new security group
935
936 :rtype: :class:`boto.rds.dbsecuritygroup.DBSecurityGroup`
937 :return: The newly created DBSecurityGroup
938 """
939 params = {'DBSecurityGroupName': name}
940 if description:
941 params['DBSecurityGroupDescription'] = description
942 group = self.get_object('CreateDBSecurityGroup', params,
943 DBSecurityGroup)
944 group.name = name
945 group.description = description
946 return group
947
948 def delete_dbsecurity_group(self, name):
949 """
950 Delete a DBSecurityGroup from your account.
951
952 :type key_name: string
953 :param key_name: The name of the DBSecurityGroup to delete
954 """
955 params = {'DBSecurityGroupName': name}
956 return self.get_status('DeleteDBSecurityGroup', params)
957
958 def authorize_dbsecurity_group(self, group_name, cidr_ip=None,
959 ec2_security_group_name=None,
960 ec2_security_group_owner_id=None):
961 """
962 Add a new rule to an existing security group.
963 You need to pass in either src_security_group_name and
964 src_security_group_owner_id OR a CIDR block but not both.
965
966 :type group_name: string
967 :param group_name: The name of the security group you are adding
968 the rule to.
969
970 :type ec2_security_group_name: string
971 :param ec2_security_group_name: The name of the EC2 security group
972 you are granting access to.
973
974 :type ec2_security_group_owner_id: string
975 :param ec2_security_group_owner_id: The ID of the owner of the EC2
976 security group you are granting
977 access to.
978
979 :type cidr_ip: string
980 :param cidr_ip: The CIDR block you are providing access to.
981 See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
982
983 :rtype: bool
984 :return: True if successful.
985 """
986 params = {'DBSecurityGroupName': group_name}
987 if ec2_security_group_name:
988 params['EC2SecurityGroupName'] = ec2_security_group_name
989 if ec2_security_group_owner_id:
990 params['EC2SecurityGroupOwnerId'] = ec2_security_group_owner_id
991 if cidr_ip:
992 params['CIDRIP'] = urllib.quote(cidr_ip)
993 return self.get_object('AuthorizeDBSecurityGroupIngress', params,
994 DBSecurityGroup)
995
996 def revoke_dbsecurity_group(self, group_name, ec2_security_group_name=None,
997 ec2_security_group_owner_id=None, cidr_ip=None):
998 """
999 Remove an existing rule from an existing security group.
1000 You need to pass in either ec2_security_group_name and
1001 ec2_security_group_owner_id OR a CIDR block.
1002
1003 :type group_name: string
1004 :param group_name: The name of the security group you are removing
1005 the rule from.
1006
1007 :type ec2_security_group_name: string
1008 :param ec2_security_group_name: The name of the EC2 security group
1009 from which you are removing access.
1010
1011 :type ec2_security_group_owner_id: string
1012 :param ec2_security_group_owner_id: The ID of the owner of the EC2
1013 security from which you are
1014 removing access.
1015
1016 :type cidr_ip: string
1017 :param cidr_ip: The CIDR block from which you are removing access.
1018 See http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
1019
1020 :rtype: bool
1021 :return: True if successful.
1022 """
1023 params = {'DBSecurityGroupName': group_name}
1024 if ec2_security_group_name:
1025 params['EC2SecurityGroupName'] = ec2_security_group_name
1026 if ec2_security_group_owner_id:
1027 params['EC2SecurityGroupOwnerId'] = ec2_security_group_owner_id
1028 if cidr_ip:
1029 params['CIDRIP'] = cidr_ip
1030 return self.get_object('RevokeDBSecurityGroupIngress', params,
1031 DBSecurityGroup)
1032
1033 # For backwards compatibility. This method was improperly named
1034 # in previous versions. I have renamed it to match the others.
1035 revoke_security_group = revoke_dbsecurity_group
1036
1037 # DBSnapshot methods
1038
1039 def get_all_dbsnapshots(self, snapshot_id=None, instance_id=None,
1040 max_records=None, marker=None):
1041 """
1042 Get information about DB Snapshots.
1043
1044 :type snapshot_id: str
1045 :param snapshot_id: The unique identifier of an RDS snapshot.
1046 If not provided, all RDS snapshots will be returned.
1047
1048 :type instance_id: str
1049 :param instance_id: The identifier of a DBInstance. If provided,
1050 only the DBSnapshots related to that instance will
1051 be returned.
1052 If not provided, all RDS snapshots will be returned.
1053
1054 :type max_records: int
1055 :param max_records: The maximum number of records to be returned.
1056 If more results are available, a MoreToken will
1057 be returned in the response that can be used to
1058 retrieve additional records. Default is 100.
1059
1060 :type marker: str
1061 :param marker: The marker provided by a previous request.
1062
1063 :rtype: list
1064 :return: A list of :class:`boto.rds.dbsnapshot.DBSnapshot`
1065 """
1066 params = {}
1067 if snapshot_id:
1068 params['DBSnapshotIdentifier'] = snapshot_id
1069 if instance_id:
1070 params['DBInstanceIdentifier'] = instance_id
1071 if max_records:
1072 params['MaxRecords'] = max_records
1073 if marker:
1074 params['Marker'] = marker
1075 return self.get_list('DescribeDBSnapshots', params,
1076 [('DBSnapshot', DBSnapshot)])
1077
1078 def get_all_logs(self, dbinstance_id, max_records=None, marker=None, file_size=None, filename_contains=None, file_last_written=None):
1079 """
1080 Get all log files
1081
1082 :type instance_id: str
1083 :param instance_id: The identifier of a DBInstance.
1084
1085 :type max_records: int
1086 :param max_records: Number of log file names to return.
1087
1088 :type marker: str
1089 :param marker: The marker provided by a previous request.
1090
1091 :file_size: int
1092 :param file_size: Filter results to files large than this size in bytes.
1093
1094 :filename_contains: str
1095 :param filename_contains: Filter results to files with filename containing this string
1096
1097 :file_last_written: int
1098 :param file_last_written: Filter results to files written after this time (POSIX timestamp)
1099
1100 :rtype: list
1101 :return: A list of :class:`boto.rds.logfile.LogFile`
1102 """
1103 params = {'DBInstanceIdentifier': dbinstance_id}
1104
1105 if file_size:
1106 params['FileSize'] = file_size
1107
1108 if filename_contains:
1109 params['FilenameContains'] = filename_contains
1110
1111 if file_last_written:
1112 params['FileLastWritten'] = file_last_written
1113
1114 if marker:
1115 params['Marker'] = marker
1116
1117 if max_records:
1118 params['MaxRecords'] = max_records
1119
1120 return self.get_list('DescribeDBLogFiles', params,
1121 [('DescribeDBLogFilesDetails',LogFile)])
1122
1123 def get_log_file(self, dbinstance_id, log_file_name, marker=None, number_of_lines=None, max_records=None):
1124 """
1125 Download a log file from RDS
1126
1127 :type instance_id: str
1128 :param instance_id: The identifier of a DBInstance.
1129
1130 :type log_file_name: str
1131 :param log_file_name: The name of the log file to retrieve
1132
1133 :type marker: str
1134 :param marker: A marker returned from a previous call to this method, or 0 to indicate the start of file. If
1135 no marker is specified, this will fetch log lines from the end of file instead.
1136
1137 :type number_of_lines: int
1138 :param marker: The maximium number of lines to be returned.
1139 """
1140
1141 params = {
1142 'DBInstanceIdentifier': dbinstance_id,
1143 'LogFileName': log_file_name,
1144 }
1145
1146 if marker:
1147 params['Marker'] = marker
1148
1149 if number_of_lines:
1150 params['NumberOfLines'] = number_of_lines
1151
1152 if max_records:
1153 params['MaxRecords'] = max_records
1154
1155 logfile = self.get_object('DownloadDBLogFilePortion', params, LogFileObject)
1156
1157 if logfile:
1158 logfile.log_filename = log_file_name
1159 logfile.dbinstance_id = dbinstance_id
1160
1161 return logfile
1162
1163 def create_dbsnapshot(self, snapshot_id, dbinstance_id):
1164 """
1165 Create a new DB snapshot.
1166
1167 :type snapshot_id: string
1168 :param snapshot_id: The identifier for the DBSnapshot
1169
1170 :type dbinstance_id: string
1171 :param dbinstance_id: The source identifier for the RDS instance from
1172 which the snapshot is created.
1173
1174 :rtype: :class:`boto.rds.dbsnapshot.DBSnapshot`
1175 :return: The newly created DBSnapshot
1176 """
1177 params = {'DBSnapshotIdentifier': snapshot_id,
1178 'DBInstanceIdentifier': dbinstance_id}
1179 return self.get_object('CreateDBSnapshot', params, DBSnapshot)
1180
1181 def copy_dbsnapshot(self, source_snapshot_id, target_snapshot_id):
1182 """
1183 Copies the specified DBSnapshot.
1184
1185 :type source_snapshot_id: string
1186 :param source_snapshot_id: The identifier for the source DB snapshot.
1187
1188 :type target_snapshot_id: string
1189 :param target_snapshot_id: The identifier for the copied snapshot.
1190
1191 :rtype: :class:`boto.rds.dbsnapshot.DBSnapshot`
1192 :return: The newly created DBSnapshot.
1193 """
1194 params = {'SourceDBSnapshotIdentifier': source_snapshot_id,
1195 'TargetDBSnapshotIdentifier': target_snapshot_id}
1196 return self.get_object('CopyDBSnapshot', params, DBSnapshot)
1197
1198 def delete_dbsnapshot(self, identifier):
1199 """
1200 Delete a DBSnapshot
1201
1202 :type identifier: string
1203 :param identifier: The identifier of the DBSnapshot to delete
1204 """
1205 params = {'DBSnapshotIdentifier': identifier}
1206 return self.get_object('DeleteDBSnapshot', params, DBSnapshot)
1207
1208 def restore_dbinstance_from_dbsnapshot(self, identifier, instance_id,
1209 instance_class, port=None,
1210 availability_zone=None,
1211 multi_az=None,
1212 auto_minor_version_upgrade=None,
1213 db_subnet_group_name=None):
1214 """
1215 Create a new DBInstance from a DB snapshot.
1216
1217 :type identifier: string
1218 :param identifier: The identifier for the DBSnapshot
1219
1220 :type instance_id: string
1221 :param instance_id: The source identifier for the RDS instance from
1222 which the snapshot is created.
1223
1224 :type instance_class: str
1225 :param instance_class: The compute and memory capacity of the
1226 DBInstance. Valid values are:
1227 db.m1.small | db.m1.large | db.m1.xlarge |
1228 db.m2.2xlarge | db.m2.4xlarge
1229
1230 :type port: int
1231 :param port: Port number on which database accepts connections.
1232 Valid values [1115-65535]. Defaults to 3306.
1233
1234 :type availability_zone: str
1235 :param availability_zone: Name of the availability zone to place
1236 DBInstance into.
1237
1238 :type multi_az: bool
1239 :param multi_az: If True, specifies the DB Instance will be
1240 deployed in multiple availability zones.
1241 Default is the API default.
1242
1243 :type auto_minor_version_upgrade: bool
1244 :param auto_minor_version_upgrade: Indicates that minor engine
1245 upgrades will be applied
1246 automatically to the Read Replica
1247 during the maintenance window.
1248 Default is the API default.
1249
1250 :type db_subnet_group_name: str
1251 :param db_subnet_group_name: A DB Subnet Group to associate with this DB Instance.
1252 If there is no DB Subnet Group, then it is a non-VPC DB
1253 instance.
1254
1255 :rtype: :class:`boto.rds.dbinstance.DBInstance`
1256 :return: The newly created DBInstance
1257 """
1258 params = {'DBSnapshotIdentifier': identifier,
1259 'DBInstanceIdentifier': instance_id,
1260 'DBInstanceClass': instance_class}
1261 if port:
1262 params['Port'] = port
1263 if availability_zone:
1264 params['AvailabilityZone'] = availability_zone
1265 if multi_az is not None:
1266 params['MultiAZ'] = str(multi_az).lower()
1267 if auto_minor_version_upgrade is not None:
1268 params['AutoMinorVersionUpgrade'] = str(auto_minor_version_upgrade).lower()
1269 if db_subnet_group_name is not None:
1270 params['DBSubnetGroupName'] = db_subnet_group_name
1271 return self.get_object('RestoreDBInstanceFromDBSnapshot',
1272 params, DBInstance)
1273
1274 def restore_dbinstance_from_point_in_time(self, source_instance_id,
1275 target_instance_id,
1276 use_latest=False,
1277 restore_time=None,
1278 dbinstance_class=None,
1279 port=None,
1280 availability_zone=None,
1281 db_subnet_group_name=None):
1282
1283 """
1284 Create a new DBInstance from a point in time.
1285
1286 :type source_instance_id: string
1287 :param source_instance_id: The identifier for the source DBInstance.
1288
1289 :type target_instance_id: string
1290 :param target_instance_id: The identifier of the new DBInstance.
1291
1292 :type use_latest: bool
1293 :param use_latest: If True, the latest snapshot availabile will
1294 be used.
1295
1296 :type restore_time: datetime
1297 :param restore_time: The date and time to restore from. Only
1298 used if use_latest is False.
1299
1300 :type instance_class: str
1301 :param instance_class: The compute and memory capacity of the
1302 DBInstance. Valid values are:
1303 db.m1.small | db.m1.large | db.m1.xlarge |
1304 db.m2.2xlarge | db.m2.4xlarge
1305
1306 :type port: int
1307 :param port: Port number on which database accepts connections.
1308 Valid values [1115-65535]. Defaults to 3306.
1309
1310 :type availability_zone: str
1311 :param availability_zone: Name of the availability zone to place
1312 DBInstance into.
1313
1314 :type db_subnet_group_name: str
1315 :param db_subnet_group_name: A DB Subnet Group to associate with this DB Instance.
1316 If there is no DB Subnet Group, then it is a non-VPC DB
1317 instance.
1318
1319 :rtype: :class:`boto.rds.dbinstance.DBInstance`
1320 :return: The newly created DBInstance
1321 """
1322 params = {'SourceDBInstanceIdentifier': source_instance_id,
1323 'TargetDBInstanceIdentifier': target_instance_id}
1324 if use_latest:
1325 params['UseLatestRestorableTime'] = 'true'
1326 elif restore_time:
1327 params['RestoreTime'] = restore_time.isoformat()
1328 if dbinstance_class:
1329 params['DBInstanceClass'] = dbinstance_class
1330 if port:
1331 params['Port'] = port
1332 if availability_zone:
1333 params['AvailabilityZone'] = availability_zone
1334 if db_subnet_group_name is not None:
1335 params['DBSubnetGroupName'] = db_subnet_group_name
1336 return self.get_object('RestoreDBInstanceToPointInTime',
1337 params, DBInstance)
1338
1339 # Events
1340
1341 def get_all_events(self, source_identifier=None, source_type=None,
1342 start_time=None, end_time=None,
1343 max_records=None, marker=None):
1344 """
1345 Get information about events related to your DBInstances,
1346 DBSecurityGroups and DBParameterGroups.
1347
1348 :type source_identifier: str
1349 :param source_identifier: If supplied, the events returned will be
1350 limited to those that apply to the identified
1351 source. The value of this parameter depends
1352 on the value of source_type. If neither
1353 parameter is specified, all events in the time
1354 span will be returned.
1355
1356 :type source_type: str
1357 :param source_type: Specifies how the source_identifier should
1358 be interpreted. Valid values are:
1359 b-instance | db-security-group |
1360 db-parameter-group | db-snapshot
1361
1362 :type start_time: datetime
1363 :param start_time: The beginning of the time interval for events.
1364 If not supplied, all available events will
1365 be returned.
1366
1367 :type end_time: datetime
1368 :param end_time: The ending of the time interval for events.
1369 If not supplied, all available events will
1370 be returned.
1371
1372 :type max_records: int
1373 :param max_records: The maximum number of records to be returned.
1374 If more results are available, a MoreToken will
1375 be returned in the response that can be used to
1376 retrieve additional records. Default is 100.
1377
1378 :type marker: str
1379 :param marker: The marker provided by a previous request.
1380
1381 :rtype: list
1382 :return: A list of class:`boto.rds.event.Event`
1383 """
1384 params = {}
1385 if source_identifier and source_type:
1386 params['SourceIdentifier'] = source_identifier
1387 params['SourceType'] = source_type
1388 if start_time:
1389 params['StartTime'] = start_time.isoformat()
1390 if end_time:
1391 params['EndTime'] = end_time.isoformat()
1392 if max_records:
1393 params['MaxRecords'] = max_records
1394 if marker:
1395 params['Marker'] = marker
1396 return self.get_list('DescribeEvents', params, [('Event', Event)])
1397
1398 def create_db_subnet_group(self, name, desc, subnet_ids):
1399 """
1400 Create a new Database Subnet Group.
1401
1402 :type name: string
1403 :param name: The identifier for the db_subnet_group
1404
1405 :type desc: string
1406 :param desc: A description of the db_subnet_group
1407
1408 :type subnet_ids: list
1409 :param subnets: A list of the subnet identifiers to include in the
1410 db_subnet_group
1411
1412 :rtype: :class:`boto.rds.dbsubnetgroup.DBSubnetGroup
1413 :return: the created db_subnet_group
1414 """
1415
1416 params = {'DBSubnetGroupName': name,
1417 'DBSubnetGroupDescription': desc}
1418 self.build_list_params(params, subnet_ids, 'SubnetIds.member')
1419
1420 return self.get_object('CreateDBSubnetGroup', params, DBSubnetGroup)
1421
1422 def delete_db_subnet_group(self, name):
1423 """
1424 Delete a Database Subnet Group.
1425
1426 :type name: string
1427 :param name: The identifier of the db_subnet_group to delete
1428
1429 :rtype: :class:`boto.rds.dbsubnetgroup.DBSubnetGroup`
1430 :return: The deleted db_subnet_group.
1431 """
1432
1433 params = {'DBSubnetGroupName': name}
1434
1435 return self.get_object('DeleteDBSubnetGroup', params, DBSubnetGroup)
1436
1437
1438 def get_all_db_subnet_groups(self, name=None, max_records=None, marker=None):
1439 """
1440 Retrieve all the DBSubnetGroups in your account.
1441
1442 :type name: str
1443 :param name: DBSubnetGroup name If supplied, only information about
1444 this DBSubnetGroup will be returned. Otherwise, info
1445 about all DBSubnetGroups will be returned.
1446
1447 :type max_records: int
1448 :param max_records: The maximum number of records to be returned.
1449 If more results are available, a Token will be
1450 returned in the response that can be used to
1451 retrieve additional records. Default is 100.
1452
1453 :type marker: str
1454 :param marker: The marker provided by a previous request.
1455
1456 :rtype: list
1457 :return: A list of :class:`boto.rds.dbsubnetgroup.DBSubnetGroup`
1458 """
1459 params = dict()
1460 if name is not None:
1461 params['DBSubnetGroupName'] = name
1462 if max_records is not None:
1463 params['MaxRecords'] = max_records
1464 if marker is not None:
1465 params['Marker'] = marker
1466
1467 return self.get_list('DescribeDBSubnetGroups', params, [('DBSubnetGroup',DBSubnetGroup)])
1468
1469 def modify_db_subnet_group(self, name, description=None, subnet_ids=None):
1470 """
1471 Modify a parameter group for your account.
1472
1473 :type name: string
1474 :param name: The name of the new parameter group
1475
1476 :type parameters: list of :class:`boto.rds.parametergroup.Parameter`
1477 :param parameters: The new parameters
1478
1479 :rtype: :class:`boto.rds.parametergroup.ParameterGroup`
1480 :return: The newly created ParameterGroup
1481 """
1482 params = {'DBSubnetGroupName': name}
1483 if description is not None:
1484 params['DBSubnetGroupDescription'] = description
1485 if subnet_ids is not None:
1486 self.build_list_params(params, subnet_ids, 'SubnetIds.member')
1487
1488 return self.get_object('ModifyDBSubnetGroup', params, DBSubnetGroup)
1489
1490 def create_option_group(self, name, engine_name, major_engine_version,
1491 description=None):
1492 """
1493 Create a new option group for your account.
1494 This will create the option group within the region you
1495 are currently connected to.
1496
1497 :type name: string
1498 :param name: The name of the new option group
1499
1500 :type engine_name: string
1501 :param engine_name: Specifies the name of the engine that this option
1502 group should be associated with.
1503
1504 :type major_engine_version: string
1505 :param major_engine_version: Specifies the major version of the engine
1506 that this option group should be
1507 associated with.
1508
1509 :type description: string
1510 :param description: The description of the new option group
1511
1512 :rtype: :class:`boto.rds.optiongroup.OptionGroup`
1513 :return: The newly created OptionGroup
1514 """
1515 params = {
1516 'OptionGroupName': name,
1517 'EngineName': engine_name,
1518 'MajorEngineVersion': major_engine_version,
1519 'OptionGroupDescription': description,
1520 }
1521 group = self.get_object('CreateOptionGroup', params, OptionGroup)
1522 group.name = name
1523 group.engine_name = engine_name
1524 group.major_engine_version = major_engine_version
1525 group.description = description
1526 return group
1527
1528 def delete_option_group(self, name):
1529 """
1530 Delete an OptionGroup from your account.
1531
1532 :type key_name: string
1533 :param key_name: The name of the OptionGroup to delete
1534 """
1535 params = {'OptionGroupName': name}
1536 return self.get_status('DeleteOptionGroup', params)
1537
1538 def describe_option_groups(self, name=None, engine_name=None,
1539 major_engine_version=None, max_records=100,
1540 marker=None):
1541 """
1542 Describes the available option groups.
1543
1544 :type name: str
1545 :param name: The name of the option group to describe. Cannot be
1546 supplied together with engine_name or major_engine_version.
1547
1548 :type engine_name: str
1549 :param engine_name: Filters the list of option groups to only include
1550 groups associated with a specific database engine.
1551
1552 :type major_engine_version: datetime
1553 :param major_engine_version: Filters the list of option groups to only
1554 include groups associated with a specific
1555 database engine version. If specified, then
1556 engine_name must also be specified.
1557
1558 :type max_records: int
1559 :param max_records: The maximum number of records to be returned.
1560 If more results are available, a MoreToken will
1561 be returned in the response that can be used to
1562 retrieve additional records. Default is 100.
1563
1564 :type marker: str
1565 :param marker: The marker provided by a previous request.
1566
1567 :rtype: list
1568 :return: A list of class:`boto.rds.optiongroup.OptionGroup`
1569 """
1570 params = {}
1571 if name:
1572 params['OptionGroupName'] = name
1573 elif engine_name and major_engine_version:
1574 params['EngineName'] = engine_name
1575 params['MajorEngineVersion'] = major_engine_version
1576 if max_records:
1577 params['MaxRecords'] = int(max_records)
1578 if marker:
1579 params['Marker'] = marker
1580 return self.get_list('DescribeOptionGroups', params, [
1581 ('OptionGroup', OptionGroup)
1582 ])
1583
1584 def describe_option_group_options(self, engine_name=None,
1585 major_engine_version=None, max_records=100,
1586 marker=None):
1587 """
1588 Describes the available option group options.
1589
1590 :type engine_name: str
1591 :param engine_name: Filters the list of option groups to only include
1592 groups associated with a specific database engine.
1593
1594 :type major_engine_version: datetime
1595 :param major_engine_version: Filters the list of option groups to only
1596 include groups associated with a specific
1597 database engine version. If specified, then
1598 engine_name must also be specified.
1599
1600 :type max_records: int
1601 :param max_records: The maximum number of records to be returned.
1602 If more results are available, a MoreToken will
1603 be returned in the response that can be used to
1604 retrieve additional records. Default is 100.
1605
1606 :type marker: str
1607 :param marker: The marker provided by a previous request.
1608
1609 :rtype: list
1610 :return: A list of class:`boto.rds.optiongroup.Option`
1611 """
1612 params = {}
1613 if engine_name and major_engine_version:
1614 params['EngineName'] = engine_name
1615 params['MajorEngineVersion'] = major_engine_version
1616 if max_records:
1617 params['MaxRecords'] = int(max_records)
1618 if marker:
1619 params['Marker'] = marker
1620 return self.get_list('DescribeOptionGroupOptions', params, [
1621 ('OptionGroupOptions', OptionGroupOption)
1622 ])