'Modify an existing DBInstance.
:type id: str
:param id: Unique identifier for the new instance.
:type param_group: str or ParameterGroup object
:param param_group: Name of DBParameterGroup or ParameterGroup instance
to associate with this DBInstance.  If no groups are
specified no parameter groups will be used.
:type security_groups: list of str or list of DBSecurityGroup objects
:param security_groups: List of names of DBSecurityGroup to authorize on
this DBInstance.
:type preferred_maintenance_window: str
:param preferred_maintenance_window: The weekly time range (in UTC)
during which maintenance can
occur.
Default is Sun:05:00-Sun:09:00
:type master_password: str
:param master_password: Password of master user for the DBInstance.
Must be 4-15 alphanumeric characters.
:type allocated_storage: int
:param allocated_storage: The new allocated storage size, in GBs.
Valid values are [5-1024]
:type instance_class: str
:param instance_class: The compute and memory capacity of the
DBInstance.  Changes will be applied at
next maintenance window unless
apply_immediately is True.
Valid values are:
* db.m1.small
* db.m1.large
* db.m1.xlarge
* db.m2.xlarge
* db.m2.2xlarge
* db.m2.4xlarge
:type apply_immediately: bool
:param apply_immediately: If true, the modifications will be applied
as soon as possible rather than waiting for
the next preferred maintenance window.
:type backup_retention_period: int
:param backup_retention_period: The number of days for which automated
backups are retained.  Setting this to
zero disables automated backups.
:type preferred_backup_window: str
:param preferred_backup_window: The daily time range during which
automated backups are created (if
enabled).  Must be in h24:mi-hh24:mi
format (UTC).
:type multi_az: bool
:param multi_az: If True, specifies the DB Instance will be
deployed in multiple availability zones.
:type iops: int
:param iops:  The amount of IOPS (input/output operations per second) to Provisioned
for the DB Instance. Can be modified at a later date.
Must scale linearly. For every 1000 IOPS provision, you must allocated
100 GB of storage space. This scales up to 1 TB / 10 000 IOPS for MySQL
and Oracle. MSSQL is limited to 700 GB / 7 000 IOPS.
If you specify a value, it must be at least 1000 IOPS and you must
allocate 100 GB of storage.
:type vpc_security_groups: list of str or a VPCSecurityGroupMembership object
:param vpc_security_groups: List of VPC security group ids or a
VPCSecurityGroupMembership object this DBInstance should be a member of
:type new_instance_id: str
:param new_instance_id: New name to rename the DBInstance to.
:rtype: :class:`boto.rds.dbinstance.DBInstance`
:return: The modified db instance.'

def modify_dbinstance(self, id, param_group=None, security_groups=None, preferred_maintenance_window=None, master_password=None, allocated_storage=None, instance_class=None, backup_retention_period=None, preferred_backup_window=None, multi_az=False, apply_immediately=False, iops=None, vpc_security_groups=None, new_instance_id=None):

    params = {'DBInstanceIdentifier': id}
    if param_group:
        params['DBParameterGroupName'] = (param_group.name if isinstance(param_group, ParameterGroup) else param_group)
    if security_groups:
        l = []
        for group in security_groups:
            if isinstance(group, DBSecurityGroup):
                l.append(group.name)
            else:
                l.append(group)
        self.build_list_params(params, l, 'DBSecurityGroups.member')
    if vpc_security_groups:
        l = []
        for vpc_grp in vpc_security_groups:
            if isinstance(vpc_grp, VPCSecurityGroupMembership):
                l.append(vpc_grp.vpc_group)
            else:
                l.append(vpc_grp)
        self.build_list_params(params, l, 'VpcSecurityGroupIds.member')
    if preferred_maintenance_window:
        params['PreferredMaintenanceWindow'] = preferred_maintenance_window
    if master_password:
        params['MasterUserPassword'] = master_password
    if allocated_storage:
        params['AllocatedStorage'] = allocated_storage
    if instance_class:
        params['DBInstanceClass'] = instance_class
    if (backup_retention_period is not None):
        params['BackupRetentionPeriod'] = backup_retention_period
    if preferred_backup_window:
        params['PreferredBackupWindow'] = preferred_backup_window
    if multi_az:
        params['MultiAZ'] = 'true'
    if apply_immediately:
        params['ApplyImmediately'] = 'true'
    if iops:
        params['Iops'] = iops
    if new_instance_id:
        params['NewDBInstanceIdentifier'] = new_instance_id
    return self.get_object('ModifyDBInstance', params, DBInstance)
