v1.0.54: fix 4 audit bugs — _client auto-detect, _find_uid by key, tracker_add before params, flock LOCK_NB
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
import requests
|
||||
|
||||
STANDS = [
|
||||
"https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc",
|
||||
"https://lk-api-gateway-test.ngcloud.ru/api/v1/svc",
|
||||
]
|
||||
|
||||
|
||||
def detect_endpoint(token):
|
||||
"""Пробуем токен против dev и test стендов, возвращаем рабочий URL."""
|
||||
for ep in STANDS:
|
||||
try:
|
||||
c = HttpClient(ep, token)
|
||||
data = c.get("/instances", params={"pageSize": 1, "page": 1})
|
||||
if data.get("results") is not None:
|
||||
return ep
|
||||
except Exception:
|
||||
continue
|
||||
return None
|
||||
|
||||
|
||||
class HttpClient:
|
||||
def __init__(self, endpoint, token):
|
||||
|
||||
Reference in New Issue
Block a user