'Builds a werkzeug routing map out of a given router class.'

def _BuildHttpRoutingMap(self, router_cls):

    if (not issubclass(router_cls, api_call_router.ApiCallRouter)):
        raise ValueError('Router    has    to    be    an    instance    of    ApiCallRouter.')
    routing_map = routing.Map()
    for (_, metadata) in router_cls.GetAnnotatedMethods().items():
        for (http_method, path, unused_options) in metadata.http_methods:
            routing_map.add(routing.Rule(path, methods=[http_method], endpoint=metadata))
            routing_map.add(routing.Rule(path.replace('/api/', '/api/v2/'), methods=[http_method], endpoint=metadata))
    return routing_map
