'Add a field to script_fields'

def add_field(self, name, script, lang=None, params=None, ignore_failure=False):

    data = {}
    if lang:
        data['lang'] = lang
    if script:
        data['script'] = script
    else:
        raise ScriptFieldsError('Script    is    required    for    script_fields    definition')
    if params:
        if isinstance(params, dict):
            if len(params):
                data['params'] = params
        else:
            raise ScriptFieldsError('Parameters    should    be    a    valid    dictionary')
    if ignore_failure:
        data['ignore_failure'] = ignore_failure
    self.fields[name] = data
