Add HydraProxy provider (aggregator): wrapper + /hydraproxy storefront + admin balance + API + MCP tool (management-only, broker-fulfilled)

This commit is contained in:
drjones
2026-09-20 18:40:25 -07:00
parent 2e238a626e
commit 16dde93ce2
6 changed files with 161 additions and 1 deletions

36
app.py
View File

@@ -13,6 +13,7 @@ from flask import (Flask, abort, flash, jsonify, redirect, render_template,
import db
import iproyal
import hydraproxy
CFG = db.CFG
app = Flask(__name__)
@@ -476,6 +477,33 @@ def poll_provisioning():
return ok, failed
# ---------- HydraProxy provider (management-only, manual broker fulfillment) ----------
HYDRA_PRODUCTS = CFG.get("hydraproxy", {}).get("products", {})
@app.route("/hydraproxy")
def hydraproxy_page():
account = None
err = None
try:
account = hydraproxy.get_account_info()
except Exception as e:
err = str(e)
return render_template("hydraproxy.html", products=HYDRA_PRODUCTS,
account=account, err=err, user=current_user())
@app.route("/api/v1/hydraproxy/info")
def api_hydraproxy_info():
try:
account = hydraproxy.get_account_info()
locations = hydraproxy.get_locations()
return jsonify({"account": account, "locations": locations,
"products": HYDRA_PRODUCTS})
except Exception as e:
return jsonify({"error": str(e)}), 502
# ---------- admin ----------
ADMIN_PASSWORD = CFG.get("admin_password", "")
@@ -507,10 +535,16 @@ def admin():
ipr_balance = iproyal.get_balance()
except Exception:
ipr_balance = "unavailable"
try:
hydra_acct = hydraproxy.get_account_info()
hydra_balance = hydra_acct.get("balance_usd", "unavailable")
except Exception:
hydra_balance = "unavailable"
low_balance = isinstance(ipr_balance, (int, float)) and \
ipr_balance < CFG.get("alerts", {}).get("low_balance_threshold", 10.0)
return render_template("admin.html", stats=stats, users=users, orders=orders,
dedicated=deds, ipr_balance=ipr_balance, low_balance=low_balance)
dedicated=deds, ipr_balance=ipr_balance, low_balance=low_balance,
hydra_balance=hydra_balance)
@app.route("/admin/credit", methods=["POST"])