def parse_job_config()

in src/es_pii_tool/helpers/utils.py [0:0]


def parse_job_config(config: t.Dict, behavior: t.Literal['read', 'write']) -> t.Dict:
    """Parse raw config from the index.

    Several fields are JSON escaped, so we need to fix it to put it in a dict.

    :param config: The raw config data
    :param behavior: ``read`` or ``write``

    :type config: dict
    :type behavior: str

    :rtype: dict

    :returns: JSON-(de)sanitized configuration dict
    """
    fields = [
        'pattern',
        'query',
        'fields',
        'message',
        'expected_docs',
        'restore_settings',
        'delete',
    ]
    doc = {}
    for field in fields:
        if field in config:
            func = config_fieldmap(behavior, field)  # type: ignore
            doc[field] = func(config[field])  # type: ignore
    return doc