Initial commit of AthonetTools
This commit is contained in:
2
services/api/cc_v1/init.py
Normal file
2
services/api/cc_v1/init.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from flask import Blueprint
|
||||
bp = Blueprint("cc_v1", __name__)
|
||||
25
services/api/cc_v1/ncm.py
Normal file
25
services/api/cc_v1/ncm.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from flask import Blueprint, request, jsonify, current_app
|
||||
from services.combocore.ncm import get_routes, derive_eth0_cidr_gw
|
||||
|
||||
bp = Blueprint("cc_ncm_v1", __name__)
|
||||
|
||||
@bp.post("/routes")
|
||||
def api_routes():
|
||||
body = request.get_json(silent=True) or {}
|
||||
host = body.get("host", "").strip()
|
||||
if not host:
|
||||
return jsonify({"ok": False, "error": "host required"}), 400
|
||||
cfg = current_app.config
|
||||
routes = get_routes(host, cfg["CORE_API_USER"], cfg["CORE_API_PASS"], cfg["VERIFY_SSL"], cfg["REQUEST_TIMEOUT"])
|
||||
return jsonify({"ok": True, "routes": routes})
|
||||
|
||||
@bp.post("/oam")
|
||||
def api_oam_eth0():
|
||||
body = request.get_json(silent=True) or {}
|
||||
host = body.get("host", "").strip()
|
||||
if not host:
|
||||
return jsonify({"ok": False, "error": "host required"}), 400
|
||||
cfg = current_app.config
|
||||
routes = get_routes(host, cfg["CORE_API_USER"], cfg["CORE_API_PASS"], cfg["VERIFY_SSL"], cfg["REQUEST_TIMEOUT"])
|
||||
cidr, gw = derive_eth0_cidr_gw(routes)
|
||||
return jsonify({"ok": True, "cidr": cidr, "gw": gw})
|
||||
24
services/api/cc_v1/pls.py
Normal file
24
services/api/cc_v1/pls.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from flask import Blueprint, request, jsonify, current_app
|
||||
from services.combocore.pls import login as pls_login, get_me
|
||||
|
||||
bp = Blueprint("cc_pls_v1", __name__)
|
||||
|
||||
@bp.post("/login")
|
||||
def api_login():
|
||||
body = request.get_json(silent=True) or {}
|
||||
host = body.get("host", "").strip()
|
||||
if not host:
|
||||
return jsonify({"ok": False, "error": "host required"}), 400
|
||||
cfg = current_app.config
|
||||
token = pls_login(host, cfg["CORE_API_USER"], cfg["CORE_API_PASS"], cfg["VERIFY_SSL"], cfg["REQUEST_TIMEOUT"])
|
||||
return jsonify({"ok": True, "access_token": token})
|
||||
|
||||
@bp.post("/me")
|
||||
def api_me():
|
||||
body = request.get_json(silent=True) or {}
|
||||
host = body.get("host", "").strip()
|
||||
if not host:
|
||||
return jsonify({"ok": False, "error": "host required"}), 400
|
||||
cfg = current_app.config
|
||||
me = get_me(host, cfg["CORE_API_USER"], cfg["CORE_API_PASS"], cfg["VERIFY_SSL"], cfg["REQUEST_TIMEOUT"])
|
||||
return jsonify({"ok": True, "me": me})
|
||||
Reference in New Issue
Block a user