def _modify_backup_policy()

in footmark/rds/connection.py [0:0]


    def _modify_backup_policy(self, instance_id, preferred_backup_time, preferred_backup_period,
                             backup_retention_period, backup_log=None):
        """
        Modify Backup Policy

        :type instance_id: string
        :param instance_id: Id of instances to change
        :type preferred_backup_time: string
        :param preferred_backup_time: Backup time, in the format ofHH:mmZ- HH:mm Z.
        :type preferred_backup_period: string
        :param preferred_backup_period: Backup period
        :type backup_retention_period: integer
        :param backup_retention_period: Retention days of the backup (7 to 730 days
        :type backup_log: string
        :param backup_log: The default value is Enable. You can change it to Disabled
        :return:
            changed: If backup policy is modified successfully.The changed para will
             be set to True else False
            result: detailed server response
        """
        params = {}
        results = []
        changed = False

        if instance_id:
            self.build_list_params(params, instance_id, 'DBInstanceId')
        if preferred_backup_time:
            self.build_list_params(params, preferred_backup_time, 'PreferredBackupTime')
        if preferred_backup_period:
            self.build_list_params(params, preferred_backup_period, 'PreferredBackupPeriod')
        if backup_retention_period:
            self.build_list_params(params, backup_retention_period, 'BackupRetentionPeriod')
        if backup_log:
            self.build_list_params(params, backup_log, 'BackupLog')
        try:
            results = self.get_status('ModifyBackupPolicy', params)
            changed = True
        except Exception as ex:
            if (ex.args is None) or (ex.args == "need more than 2 values to unpack") \
                    or (ex.message == "need more than 2 values to unpack") or ex.error_code is None:
                results.append({"Error Message": "The API is showing None error code and error message "
                                                 "while modifying backup policy"})
            else:
                error_code = ex.error_code
                error_msg = ex.message
                results.append("Failed to modify backup policy with error code " + error_code +
                               " and message: " + error_msg)

        return changed, results