From ee869002e90f9c841fe93054139a6a004b239046 Mon Sep 17 00:00:00 2001 From: Raymond Wiker Date: Fri, 13 Feb 2026 15:04:37 +0100 Subject: [PATCH 1/2] feat: get config info from well-known endpoint, rather than hard-coded in library. --- src/sumo/wrapper/config.py | 26 -------------------------- src/sumo/wrapper/sumo_client.py | 31 ++++++++++++++++++------------- 2 files changed, 18 insertions(+), 39 deletions(-) delete mode 100644 src/sumo/wrapper/config.py diff --git a/src/sumo/wrapper/config.py b/src/sumo/wrapper/config.py deleted file mode 100644 index efab82b..0000000 --- a/src/sumo/wrapper/config.py +++ /dev/null @@ -1,26 +0,0 @@ -APP_REGISTRATION = { - "prod": { - "CLIENT_ID": "d57a8f87-4e28-4391-84d6-34356d5876a2", - "RESOURCE_ID": "9e5443dd-3431-4690-9617-31eed61cb55a", - }, - "test": { - "CLIENT_ID": "d57a8f87-4e28-4391-84d6-34356d5876a2", - "RESOURCE_ID": "9e5443dd-3431-4690-9617-31eed61cb55a", - }, - "dev": { - "CLIENT_ID": "1826bd7c-582f-4838-880d-5b4da5c3eea2", - "RESOURCE_ID": "88d2b022-3539-4dda-9e66-853801334a86", - }, - "preview": { - "CLIENT_ID": "1826bd7c-582f-4838-880d-5b4da5c3eea2", - "RESOURCE_ID": "88d2b022-3539-4dda-9e66-853801334a86", - }, - "localhost": { - "CLIENT_ID": "1826bd7c-582f-4838-880d-5b4da5c3eea2", - "RESOURCE_ID": "88d2b022-3539-4dda-9e66-853801334a86", - }, -} - -TENANT_ID = "3aa4a235-b6e2-48d5-9195-7fcf05b459b0" - -AUTHORITY_HOST_URI = "https://login.microsoftonline.com" diff --git a/src/sumo/wrapper/sumo_client.py b/src/sumo/wrapper/sumo_client.py index 4f93981..fb6f1ef 100644 --- a/src/sumo/wrapper/sumo_client.py +++ b/src/sumo/wrapper/sumo_client.py @@ -1,6 +1,7 @@ import asyncio import contextlib import logging +import os import re import time from typing import Dict, Optional, Tuple @@ -16,12 +17,15 @@ ) from ._logging import LogHandlerSumo from ._retry_strategy import RetryStrategy -from .config import APP_REGISTRATION, AUTHORITY_HOST_URI, TENANT_ID logger = logging.getLogger("sumo.wrapper") DEFAULT_TIMEOUT = httpx.Timeout(30.0) +WELL_KNOWN = os.environ.get( + "SUMOCONNECTIONINFO", "https://api.sumo.equinor.com" +) + class SumoClient: """Authenticate and perform requests to the Sumo API.""" @@ -54,9 +58,17 @@ def __init__( logger.setLevel(verbosity) - if env not in APP_REGISTRATION: + well_known = httpx.get(WELL_KNOWN).json() + if env not in well_known["envs"]: raise ValueError(f"Invalid environment: {env}") + tenant_id = well_known["tenant_id"] + authority_host = well_known["authority"] + config = well_known["envs"][env] + client_id = config["client_id"] + resource_id = config["resource_id"] + base_url = config["base_url"] + self.env = env self._verbosity = verbosity @@ -103,9 +115,9 @@ def __init__( cleanup_shared_keys() self.auth = get_auth_provider( - client_id=APP_REGISTRATION[env]["CLIENT_ID"], - authority=f"{AUTHORITY_HOST_URI}/{TENANT_ID}", - resource_id=APP_REGISTRATION[env]["RESOURCE_ID"], + client_id=client_id, + authority=f"{authority_host}{tenant_id}", + resource_id=resource_id, interactive=interactive, refresh_token=refresh_token, access_token=access_token, @@ -113,14 +125,7 @@ def __init__( case_uuid=case_uuid, ) - if env == "prod": - self.base_url = "https://api.sumo.equinor.com/api/v1" - elif env == "localhost": - self.base_url = "http://localhost:8084/api/v1" - else: - self.base_url = ( - f"https://main-sumo-core-{env}.c3.radix.equinor.com/api/v1" - ) + self.base_url = base_url return def __enter__(self): From 38ecb8846d51c9e0e0e1af1fcc3983a551a3a042 Mon Sep 17 00:00:00 2001 From: Raymond Wiker Date: Mon, 16 Feb 2026 10:07:40 +0100 Subject: [PATCH 2/2] fix: correct default value for well-known endpoint. --- src/sumo/wrapper/sumo_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sumo/wrapper/sumo_client.py b/src/sumo/wrapper/sumo_client.py index fb6f1ef..349e59e 100644 --- a/src/sumo/wrapper/sumo_client.py +++ b/src/sumo/wrapper/sumo_client.py @@ -23,7 +23,7 @@ DEFAULT_TIMEOUT = httpx.Timeout(30.0) WELL_KNOWN = os.environ.get( - "SUMOCONNECTIONINFO", "https://api.sumo.equinor.com" + "SUMOCONNECTIONINFO", "https://api.sumo.equinor.com/well-known" )