def _get_entity(func, name_or_id, filters, **kwargs):
    # Sometimes in the control flow of shade, we already have an object
    # fetched. Rather than then needing to pull the name or id out of that
    # object, pass it in here and rely on caching to prevent us from making
    # an additional call, it's simple enough to test to see if we got an
    # object and just short-circuit return it.
    if hasattr(name_or_id, 'id'):
        return name_or_id
    entities = func(name_or_id, filters, **kwargs)
    if not entities:
        return None
    if len(entities) > 1:
        raise exc.OpenStackCloudException(
            "Multiple matches found for %s" % name_or_id)
    return entities[0]
Tests ``R.get_metric_history`` with daily granularity.
dataset/ETHPy150Open openstack-infra/shade/shade/_utils.py/_get_entity--crossover with--dataset/ETHPy150Open bradmontgomery/django-redis-metrics/redis_metrics/tests/test_models.py/TestR.test_get_metric_history_daily