|
22 | 22 | from starlette.requests import Request |
23 | 23 | from starlette.responses import HTMLResponse, JSONResponse, Response |
24 | 24 |
|
| 25 | +from database.obp_utils import DEFAULT_API_VERSION |
| 26 | + |
25 | 27 | logger = logging.getLogger(__name__) |
26 | 28 |
|
27 | 29 | _START_TIME = time.time() |
@@ -66,7 +68,8 @@ async def build_status() -> dict[str, Any]: |
66 | 68 | from src.tools.glossary_index import get_glossary_index |
67 | 69 |
|
68 | 70 | obp_base_url = os.getenv("OBP_BASE_URL", "").rstrip("/") |
69 | | - obp_api_version = os.getenv("OBP_API_VERSION", "") |
| 71 | + obp_version_to_call = os.getenv("OBP_VERSION_TO_CALL", DEFAULT_API_VERSION) |
| 72 | + obp_version_of_interest = os.getenv("API_VERSION_OF_INTEREST", DEFAULT_API_VERSION) |
70 | 73 | auth_enabled = os.getenv("ENABLE_OAUTH", "false").lower() == "true" |
71 | 74 | auth_provider = os.getenv("AUTH_PROVIDER", "none") if auth_enabled else "none" |
72 | 75 | outbound_auth_via = os.getenv("OBP_AUTHORIZATION_VIA", "").lower() or None |
@@ -95,8 +98,8 @@ async def build_status() -> dict[str, Any]: |
95 | 98 | obp_check: dict[str, Any] | None = None |
96 | 99 | if obp_base_url: |
97 | 100 | root_url = ( |
98 | | - f"{obp_base_url}/obp/{obp_api_version}/root" |
99 | | - if obp_api_version |
| 101 | + f"{obp_base_url}/obp/{obp_version_to_call}/root" |
| 102 | + if obp_version_to_call |
100 | 103 | else obp_base_url |
101 | 104 | ) |
102 | 105 | obp_check = {"url": root_url, **(await _check_http(root_url))} |
@@ -125,7 +128,8 @@ async def build_status() -> dict[str, Any]: |
125 | 128 | }, |
126 | 129 | "obp_api": { |
127 | 130 | "base_url": obp_base_url or None, |
128 | | - "api_version": obp_api_version or None, |
| 131 | + "version_to_call": obp_version_to_call or None, |
| 132 | + "version_of_interest": obp_version_of_interest or None, |
129 | 133 | "check": obp_check, |
130 | 134 | }, |
131 | 135 | "auth": { |
@@ -196,7 +200,8 @@ def row(label: str, value: Any) -> str: |
196 | 200 | obp_check = obp.get("check") or {} |
197 | 201 | obp_rows = "".join([ |
198 | 202 | row("Base URL", obp.get("base_url")), |
199 | | - row("API version", obp.get("api_version")), |
| 203 | + row("Version to call", obp.get("version_to_call")), |
| 204 | + row("API version of interest", obp.get("version_of_interest")), |
200 | 205 | row("Probe URL", obp_check.get("url")), |
201 | 206 | row("Reachable", obp_check.get("reachable")), |
202 | 207 | row("HTTP status", obp_check.get("status_code")), |
@@ -333,11 +338,11 @@ async def ready_endpoint(request: Request) -> Response: |
333 | 338 | ok = False |
334 | 339 |
|
335 | 340 | obp_base_url = os.getenv("OBP_BASE_URL", "").rstrip("/") |
336 | | - obp_api_version = os.getenv("OBP_API_VERSION", "") |
| 341 | + obp_version_to_call = os.getenv("OBP_VERSION_TO_CALL", DEFAULT_API_VERSION) |
337 | 342 | if obp_base_url: |
338 | 343 | url = ( |
339 | | - f"{obp_base_url}/obp/{obp_api_version}/root" |
340 | | - if obp_api_version |
| 344 | + f"{obp_base_url}/obp/{obp_version_to_call}/root" |
| 345 | + if obp_version_to_call |
341 | 346 | else obp_base_url |
342 | 347 | ) |
343 | 348 | result = await _check_http(url, timeout=2.0) |
|
0 commit comments