Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__pycache__/
*.py[cod]
.DS_Store
.idea*
*~
_venv
venv
Expand Down
35 changes: 25 additions & 10 deletions src/sumo/wrapper/sumo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SumoClient:

def __init__(
self,
env: str,
env: str = "prod",
token: Optional[str] = None,
interactive: bool = True,
devicecode: bool = False,
Expand All @@ -45,15 +45,28 @@ def __init__(
case_uuid=None,
http_client=None,
async_http_client=None,
client_id: Optional[str] = None,
):
"""Initialize a new Sumo object

Args:
env: Sumo environment
token: Access token or refresh token.
interactive: Enable interactive authentication (in browser).
If not enabled, code grant flow will be used.
verbosity: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
env (str): Sumo environment. Defaults to "prod".
token (Optional[str]): Access token or refresh token. Defaults to None.
interactive (bool): Enable interactive authentication (in browser).
If not enabled, code grant flow will be used. Defaults to True.
devicecode (bool): Enable device code flow. Defaults to False.
verbosity (str): Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
Defaults to "CRITICAL".
retry_strategy (RetryStrategy): Retry strategy for HTTP requests.
Defaults to RetryStrategy().
timeout (int): Timeout for HTTP requests. Defaults to DEFAULT_TIMEOUT.
case_uuid (Optional[str]): Case UUID for authentication. Defaults to None.
http_client (Optional[httpx.Client]): HTTP client for synchronous requests.
Defaults to None.
async_http_client (Optional[httpx.AsyncClient]): HTTP client for asynchronous requests.
Defaults to None.
client_id (Optional[str]): Client ID for authentication. If None, will use
AZURE_CLIENT_ID from environment variables or the config. Defaults to None.
"""

logger.setLevel(verbosity)
Expand All @@ -65,10 +78,13 @@ def __init__(
tenant_id = well_known["tenant_id"]
authority_host = well_known["authority"]
config = well_known["envs"][env]
client_id = config["client_id"]
Comment thread
atadj marked this conversation as resolved.
resource_id = config["resource_id"]
base_url = config["base_url"]

Comment thread
atadj marked this conversation as resolved.
self.client_id = (
client_id
or os.environ.get("AZURE_CLIENT_ID")
or config["client_id"]
)
self.env = env
self._verbosity = verbosity

Expand Down Expand Up @@ -113,9 +129,8 @@ def __init__(
pass

cleanup_shared_keys()

self.auth = get_auth_provider(
client_id=client_id,
client_id=self.client_id,
authority=f"{authority_host}{tenant_id}",
resource_id=resource_id,
interactive=interactive,
Expand Down