'List of keypairs for a user.'

def _index(self, req, user_id=None, links=False, **keypair_filters):

    context = req.environ['nova.context']
    user_id = (user_id or context.user_id)
    context.can((kp_policies.POLICY_ROOT % 'index'), target={'user_id': user_id, 'project_id': context.project_id})
    if api_version_request.is_supported(req, min_version='2.35'):
        (limit, marker) = common.get_limit_and_marker(req)
    else:
        limit = marker = None
    try:
        key_pairs = self.api.get_key_pairs(context, user_id, limit=limit, marker=marker)
    except exception.MarkerNotFound as e:
        raise webob.exc.HTTPBadRequest(explanation=e.format_message())
    key_pairs = [self._filter_keypair(key_pair, **keypair_filters) for key_pair in key_pairs]
    keypairs_list = [{'keypair': key_pair} for key_pair in key_pairs]
    keypairs_dict = {'keypairs': keypairs_list}
    if links:
        keypairs_links = self._view_builder.get_links(req, key_pairs)
        if keypairs_links:
            keypairs_dict['keypairs_links'] = keypairs_links
    return keypairs_dict
