diff --git a/inventory_provider/routes/ims_data.py b/inventory_provider/routes/ims_data.py new file mode 100644 index 0000000000000000000000000000000000000000..4f70c3f681b99ed31e31f83d19365e660b8b2ebb --- /dev/null +++ b/inventory_provider/routes/ims_data.py @@ -0,0 +1,26 @@ +from flask import Blueprint, Response + +from inventory_provider.routes import common + +routes = Blueprint("ims-inventory-data-query-routes", __name__) + + +@routes.after_request +def after_request(resp): + return common.after_request(resp) + + +@routes.route("/pop/<equipment_name>", methods=['GET', 'POST']) +@common.require_accepts_json +@common.ims_hostname_decorator('equipment_name') +def equipment_location(equipment_name): + redis = common.get_current_redis() + result = redis.get(f'ims:location:{equipment_name}') + + if not result: + return Response( + response="no available info for {}".format(equipment_name), + status=404, + mimetype="text/html") + + return Response(result, mimetype="application/json")