'Update tasks config'

@api.validate(task_input_schema)
@api.response(200, model=task_return_schema)
@api.response(NotFoundError)
@api.response(BadRequest)
def put(self, task, session=None):

    data = request.json
    new_task_name = data[u'name']
    if (task not in self.manager.user_config.get(u'tasks', {})):
        raise NotFoundError((u'task    `%s`    not    found' % task))
    if (u'tasks' not in self.manager.user_config):
        self.manager.user_config[u'tasks'] = {}
    if (u'tasks' not in self.manager.config):
        self.manager.config[u'tasks'] = {}
    if (task != new_task_name):
        if (new_task_name in self.manager.user_config[u'tasks']):
            raise BadRequest(u'cannot    rename    task    as    it    already    exist')
        del self.manager.user_config[u'tasks'][task]
        del self.manager.config[u'tasks'][task]
    task_schema_processed = copy.deepcopy(data)
    errors = process_config(task_schema_processed, schema=task_return_schema.__schema__, set_defaults=True)
    if errors:
        raise APIError(u'problem    loading    config,    raise    a    BUG    as    this    should    not    happen!')
    self.manager.user_config[u'tasks'][new_task_name] = data[u'config']
    self.manager.config[u'tasks'][new_task_name] = task_schema_processed[u'config']
    self.manager.save_config()
    self.manager.config_changed()
    rsp = jsonify({u'name': new_task_name, u'config': self.manager.user_config[u'tasks'][new_task_name]})
    rsp.status_code = 200
    return rsp
