v1.0.77: debug logging in api_params to trace modify flow
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ from routes.main import bp as main_bp
|
|||||||
from routes.api import bp as api_bp
|
from routes.api import bp as api_bp
|
||||||
from routes.api_test import bp as api_test_bp
|
from routes.api_test import bp as api_test_bp
|
||||||
|
|
||||||
VERSION = "1.0.76"
|
VERSION = "1.0.77"
|
||||||
|
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
|
||||||
|
|||||||
+14
-1
@@ -102,33 +102,42 @@ def api_params(op_id):
|
|||||||
try:
|
try:
|
||||||
instance_uid = request.args.get("instanceUid")
|
instance_uid = request.args.get("instanceUid")
|
||||||
op_name = request.args.get("opName")
|
op_name = request.args.get("opName")
|
||||||
|
print(f"[api_params] op_id={op_id} instanceUid={instance_uid!r} opName={op_name!r}", flush=True)
|
||||||
|
|
||||||
if instance_uid and op_name:
|
if instance_uid and op_name:
|
||||||
|
print(f"[api_params] PREVIEW branch: creating operation for instance={instance_uid}", flush=True)
|
||||||
# Создать pending-операцию чтобы прочитать ТЕКУЩИЕ значения параметров инстанса
|
# Создать pending-операцию чтобы прочитать ТЕКУЩИЕ значения параметров инстанса
|
||||||
op_payload = {"instanceUid": instance_uid, "svcOperationId": op_id, "operation": op_name}
|
op_payload = {"instanceUid": instance_uid, "svcOperationId": op_id, "operation": op_name}
|
||||||
op_resp = _client().post("/instanceOperations", op_payload)
|
op_resp = _client().post("/instanceOperations", op_payload)
|
||||||
preview_op_uid = _find_uid(op_resp) or _uid_from_location(op_resp.get("_location", ""))
|
preview_op_uid = _find_uid(op_resp) or _uid_from_location(op_resp.get("_location", ""))
|
||||||
|
print(f"[api_params] preview_op_uid={preview_op_uid!r}", flush=True)
|
||||||
if not preview_op_uid:
|
if not preview_op_uid:
|
||||||
return jsonify({"error": "Не удалось создать preview-операцию"}), 500
|
return jsonify({"error": "Не удалось создать preview-операцию"}), 500
|
||||||
|
|
||||||
op_data = _client().get(f"/instanceOperations/{preview_op_uid}")
|
op_data = _client().get(f"/instanceOperations/{preview_op_uid}")
|
||||||
cfs_params = op_data.get("instanceOperation", {}).get("cfsParams", [])
|
cfs_params = op_data.get("instanceOperation", {}).get("cfsParams", [])
|
||||||
|
print(f"[api_params] cfsParams count={len(cfs_params)}", flush=True)
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for p in cfs_params:
|
for p in cfs_params:
|
||||||
dd = p.get("dataDescriptor")
|
dd = p.get("dataDescriptor")
|
||||||
|
pv = p.get("paramValue")
|
||||||
|
dv = p.get("defaultValue")
|
||||||
|
print(f"[api_params] {p.get('svcOperationCfsParam')}: paramValue={pv!r} defaultValue={dv!r}", flush=True)
|
||||||
result.append({
|
result.append({
|
||||||
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
|
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
|
||||||
"name": p.get("svcOperationCfsParam", ""),
|
"name": p.get("svcOperationCfsParam", ""),
|
||||||
"dataType": p.get("dataType", ""),
|
"dataType": p.get("dataType", ""),
|
||||||
"isRequired": p.get("isRequired", False),
|
"isRequired": p.get("isRequired", False),
|
||||||
"defaultValue": p.get("paramValue"), # текущее значение из инстанса
|
"defaultValue": pv, # текущее значение из инстанса
|
||||||
"valueList": p.get("valueList"),
|
"valueList": p.get("valueList"),
|
||||||
"dataDescriptor": {k: {"dataType": v.get("dataType",""), "valueList": v.get("valueList",""), "isRequired": v.get("isRequired", False)} for k, v in dd.items()} if isinstance(dd, dict) else None,
|
"dataDescriptor": {k: {"dataType": v.get("dataType",""), "valueList": v.get("valueList",""), "isRequired": v.get("isRequired", False)} for k, v in dd.items()} if isinstance(dd, dict) else None,
|
||||||
})
|
})
|
||||||
|
print(f"[api_params] PREVIEW returning {len(result)} params", flush=True)
|
||||||
return jsonify({"params": result, "previewOpUid": preview_op_uid})
|
return jsonify({"params": result, "previewOpUid": preview_op_uid})
|
||||||
|
|
||||||
# Без instanceUid — шаблонные значения по умолчанию
|
# Без instanceUid — шаблонные значения по умолчанию
|
||||||
|
print(f"[api_params] DEFAULT branch: template defaults", flush=True)
|
||||||
data = _client().get(f"/instanceOperations/default/{op_id}")
|
data = _client().get(f"/instanceOperations/default/{op_id}")
|
||||||
params = data["svcOperation"]["cfsParams"]
|
params = data["svcOperation"]["cfsParams"]
|
||||||
result = []
|
result = []
|
||||||
@@ -143,8 +152,12 @@ def api_params(op_id):
|
|||||||
"valueList": p.get("valueList"),
|
"valueList": p.get("valueList"),
|
||||||
"dataDescriptor": {k: {"dataType": v.get("dataType",""), "valueList": v.get("valueList",""), "isRequired": v.get("isRequired", False)} for k, v in dd.items()} if isinstance(dd, dict) else None,
|
"dataDescriptor": {k: {"dataType": v.get("dataType",""), "valueList": v.get("valueList",""), "isRequired": v.get("isRequired", False)} for k, v in dd.items()} if isinstance(dd, dict) else None,
|
||||||
})
|
})
|
||||||
|
print(f"[api_params] DEFAULT returning {len(result)} params", flush=True)
|
||||||
return jsonify({"params": result})
|
return jsonify({"params": result})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
print(f"[api_params] EXCEPTION: {e}", flush=True)
|
||||||
|
traceback.print_exc()
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user