.. versionadded:: 2014.7.0

    Flush current nftables state

    family
        Networking family, either ipv4 or ipv6

def flush(name, family='ipv4', **kwargs):
    '''
    .. versionadded:: 2014.7.0

    Flush current nftables state

    family
        Networking family, either ipv4 or ipv6

    '''
    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    for ignore in _STATE_INTERNAL_KEYWORDS:
        if ignore in kwargs:
            del kwargs[ignore]

    if 'table' not in kwargs:
        kwargs['table'] = 'filter'

    res = __salt__['nftables.check_table'](kwargs['table'], family=family)
    if not res['result']:
        ret['result'] = False
        ret['comment'] = 'Failed to flush table {0} in family {1}, table does not exist.'.format(
            kwargs['table'],
            family
        )
        return ret

    if 'chain' not in kwargs:
        kwargs['chain'] = ''
    else:
        res = __salt__['nftables.check_chain'](kwargs['table'],
                                               kwargs['chain'],
                                               family=family)
        if not res['result']:
            ret['result'] = False
            ret['comment'] = 'Failed to flush chain {0} in table {1} in family {2}, chain does not exist.'.format(
                kwargs['chain'],
                kwargs['table'],
                family
            )
            return ret

    res = __salt__['nftables.flush'](kwargs['table'],
                                     kwargs['chain'],
                                     family)
    if res['result']:
        ret['changes'] = {'locale': name}
        ret['result'] = True
        ret['comment'] = 'Flush nftables rules in {0} table {1} chain {2} family'.format(
            kwargs['table'],
            kwargs['chain'],
            family
        )
        return ret
    else:
        ret['result'] = False
        ret['comment'] = 'Failed to flush nftables rules'
        return ret