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