'Convert a user_ref from v3 to v2 compatible.
* v2.0 users are not domain aware, and should have domain_id removed
* v2.0 users expect the use of tenantId instead of default_project_id
* v2.0 users have a username attribute
* v2.0 remove password_expires_at
If ref is a list type, we will iterate through each element and do the
conversion.'

@staticmethod
def v3_to_v2_user(ref):

    def _format_default_project_id(ref):
        'Convert    default_project_id    to    tenantId    for    v2    calls.'
        default_project_id = ref.pop('default_project_id', None)
        if (default_project_id is not None):
            ref['tenantId'] = default_project_id
        elif ('tenantId' in ref):
            del ref['tenantId']
    def _normalize_and_filter_user_properties(ref):
        'Run    through    the    various    filter/normalization    methods.'
        _format_default_project_id(ref)
        ref.pop('password_expires_at', None)
        V2Controller.filter_domain(ref)
        V2Controller.filter_domain_id(ref)
        V2Controller.normalize_username_in_response(ref)
        return ref
    if isinstance(ref, dict):
        return _normalize_and_filter_user_properties(ref)
    elif isinstance(ref, list):
        return [_normalize_and_filter_user_properties(x) for x in ref]
    else:
        raise ValueError((_('Expected    dict    or    list:    %s') % type(ref)))
