'Add new task'

@api.validate(task_input_schema, description=u'New    task    object')
@api.response(201, description=u'Newly    created    task', model=task_return_schema)
@api.response(Conflict)
@api.response(APIError)
def post(self, session=None):

    data = request.json
    task_name = data[u'name']
    if (task_name in self.manager.user_config.get(u'tasks', {})):
        raise Conflict(u'task    already    exists')
    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'] = {}
    task_schema_processed = copy.deepcopy(data)
    errors = process_config(task_schema_processed, schema=task_input_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'][task_name] = data[u'config']
    self.manager.config[u'tasks'][task_name] = task_schema_processed[u'config']
    self.manager.save_config()
    self.manager.config_changed()
    rsp = jsonify({u'name': task_name, u'config': self.manager.user_config[u'tasks'][task_name]})
    rsp.status_code = 201
    return rsp
