v1.1.24: step 6 from REAL operation (not template) — fixes serviceInstanceUid

This commit is contained in:
2026-07-29 12:59:13 +04:00
parent 82b674d05f
commit d3164ebe76
2 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ 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
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI. # Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
VERSION = "1.1.23" VERSION = "1.1.24"
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-test.ngcloud.ru/api/v1/svc") app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc")
+9 -10
View File
@@ -205,26 +205,25 @@ def api_test():
client.post("/instanceOperationCfsParams", client.post("/instanceOperationCfsParams",
{"instanceOperationUid": op_uid, "svcOperationCfsParamId": int(pid), "paramValue": str(pval)}) {"instanceOperationUid": op_uid, "svcOperationCfsParamId": int(pid), "paramValue": str(pval)})
# Досылка required-параметров с defaultValue (шаг 6 Terraform) # Досылка required-параметров (шаг 6 Terraform)
# Берём из РЕАЛЬНОЙ операции — не из шаблона (там нет paramValue)
try: try:
tmpl = client.get(f"/instanceOperations/default/{svc_op_id}") op_det = client.get(f"/instanceOperations/{op_uid}?fields=cfsParams")
for p in tmpl.get("svcOperation", {}).get("cfsParams", []): for p in op_det.get("instanceOperation", {}).get("cfsParams", []):
pid_str = str(p["svcOperationCfsParamId"]) pid_str = str(p["svcOperationCfsParamId"])
if p.get("isRequired") and pid_str not in params: if p.get("isRequired") and pid_str not in params:
dfl = p.get("defaultValue") val = p.get("paramValue") or p.get("defaultValue")
dd = p.get("dataDescriptor") dd = p.get("dataDescriptor")
if dfl is not None and dfl != "": if val is not None and val != "":
# Есть явный default — отправляем как есть
client.post("/instanceOperationCfsParams", { client.post("/instanceOperationCfsParams", {
"instanceOperationUid": op_uid, "instanceOperationUid": op_uid,
"svcOperationCfsParamId": p["svcOperationCfsParamId"], "svcOperationCfsParamId": p["svcOperationCfsParamId"],
"paramValue": str(dfl) "paramValue": str(val)
}) })
elif isinstance(dd, dict): elif isinstance(dd, dict):
# map-fixed без явного default — собираем JSON из sub-param defaults
sub_obj = {} sub_obj = {}
for sk, sv in dd.items(): for sk, sv in dd.items():
sd = sv.get("defaultValue", "") sd = sv.get("paramValue") or sv.get("defaultValue", "")
if sv.get("isRequired") and sd: if sv.get("isRequired") and sd:
sub_obj[sk] = sd sub_obj[sk] = sd
if sub_obj: if sub_obj:
@@ -234,7 +233,7 @@ def api_test():
"paramValue": json.dumps(sub_obj) "paramValue": json.dumps(sub_obj)
}) })
except Exception: except Exception:
pass # не ронять CREATE если шаблон не загрузился pass
# Валидация перед запуском # Валидация перед запуском
try: try: