Ejemplo n.º 1
0
def register_api_v1():
    """ Registers version 1 of Freshmaker API. """
    for k, v in API_V1_MAPPING.items():
        view = v.as_view(k)
        for key, val in api_v1.get(k, {}).items():
            app.add_url_rule(val['url'],
                             endpoint=key,
                             view_func=view,
                             **val['options'])

    app.register_blueprint(monitor_api)
Ejemplo n.º 2
0
def register_api_v2():
    """ Registers version 2 of Freshmaker API. """

    # The API v2 has the same URL schema as v1, only semantic is different.
    for k, v in API_V1_MAPPING.items():
        view = v.as_view(k + "_v2")
        for key, val in api_v1.get(k, {}).items():
            app.add_url_rule(val['url'].replace("/api/1/", "/api/2/"),
                             endpoint=key + "_v2",
                             view_func=view,
                             **val['options'])

    app.register_blueprint(monitor_api)