sumo-wrapper-python 1.3.0__py3-none-any.whl → 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sumo/wrapper/_version.py +2 -2
- sumo/wrapper/sumo_client.py +40 -20
- {sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/METADATA +1 -1
- {sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/RECORD +8 -9
- {sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/WHEEL +1 -1
- sumo/wrapper/config.py +0 -26
- {sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/entry_points.txt +0 -0
- {sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/licenses/LICENSE +0 -0
- {sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/top_level.txt +0 -0
sumo/wrapper/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '1.
|
|
32
|
-
__version_tuple__ = version_tuple = (1,
|
|
31
|
+
__version__ = version = '1.4.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 4, 0)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
sumo/wrapper/sumo_client.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import contextlib
|
|
3
3
|
import logging
|
|
4
|
+
import os
|
|
4
5
|
import re
|
|
5
6
|
import time
|
|
6
7
|
from typing import Dict, Optional, Tuple
|
|
@@ -16,12 +17,15 @@ from ._decorators import (
|
|
|
16
17
|
)
|
|
17
18
|
from ._logging import LogHandlerSumo
|
|
18
19
|
from ._retry_strategy import RetryStrategy
|
|
19
|
-
from .config import APP_REGISTRATION, AUTHORITY_HOST_URI, TENANT_ID
|
|
20
20
|
|
|
21
21
|
logger = logging.getLogger("sumo.wrapper")
|
|
22
22
|
|
|
23
23
|
DEFAULT_TIMEOUT = httpx.Timeout(30.0)
|
|
24
24
|
|
|
25
|
+
WELL_KNOWN = os.environ.get(
|
|
26
|
+
"SUMOCONNECTIONINFO", "https://api.sumo.equinor.com/well-known"
|
|
27
|
+
)
|
|
28
|
+
|
|
25
29
|
|
|
26
30
|
class SumoClient:
|
|
27
31
|
"""Authenticate and perform requests to the Sumo API."""
|
|
@@ -31,7 +35,7 @@ class SumoClient:
|
|
|
31
35
|
|
|
32
36
|
def __init__(
|
|
33
37
|
self,
|
|
34
|
-
env: str,
|
|
38
|
+
env: str = "prod",
|
|
35
39
|
token: Optional[str] = None,
|
|
36
40
|
interactive: bool = True,
|
|
37
41
|
devicecode: bool = False,
|
|
@@ -41,22 +45,46 @@ class SumoClient:
|
|
|
41
45
|
case_uuid=None,
|
|
42
46
|
http_client=None,
|
|
43
47
|
async_http_client=None,
|
|
48
|
+
client_id: Optional[str] = None,
|
|
44
49
|
):
|
|
45
50
|
"""Initialize a new Sumo object
|
|
46
51
|
|
|
47
52
|
Args:
|
|
48
|
-
env: Sumo environment
|
|
49
|
-
token: Access token or refresh token.
|
|
50
|
-
interactive: Enable interactive authentication (in browser).
|
|
51
|
-
If not enabled, code grant flow will be used.
|
|
52
|
-
|
|
53
|
+
env (str): Sumo environment. Defaults to "prod".
|
|
54
|
+
token (Optional[str]): Access token or refresh token. Defaults to None.
|
|
55
|
+
interactive (bool): Enable interactive authentication (in browser).
|
|
56
|
+
If not enabled, code grant flow will be used. Defaults to True.
|
|
57
|
+
devicecode (bool): Enable device code flow. Defaults to False.
|
|
58
|
+
verbosity (str): Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
|
|
59
|
+
Defaults to "CRITICAL".
|
|
60
|
+
retry_strategy (RetryStrategy): Retry strategy for HTTP requests.
|
|
61
|
+
Defaults to RetryStrategy().
|
|
62
|
+
timeout (int): Timeout for HTTP requests. Defaults to DEFAULT_TIMEOUT.
|
|
63
|
+
case_uuid (Optional[str]): Case UUID for authentication. Defaults to None.
|
|
64
|
+
http_client (Optional[httpx.Client]): HTTP client for synchronous requests.
|
|
65
|
+
Defaults to None.
|
|
66
|
+
async_http_client (Optional[httpx.AsyncClient]): HTTP client for asynchronous requests.
|
|
67
|
+
Defaults to None.
|
|
68
|
+
client_id (Optional[str]): Client ID for authentication. If None, will use
|
|
69
|
+
AZURE_CLIENT_ID from environment variables or the config. Defaults to None.
|
|
53
70
|
"""
|
|
54
71
|
|
|
55
72
|
logger.setLevel(verbosity)
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
well_known = httpx.get(WELL_KNOWN).json()
|
|
75
|
+
if env not in well_known["envs"]:
|
|
58
76
|
raise ValueError(f"Invalid environment: {env}")
|
|
59
77
|
|
|
78
|
+
tenant_id = well_known["tenant_id"]
|
|
79
|
+
authority_host = well_known["authority"]
|
|
80
|
+
config = well_known["envs"][env]
|
|
81
|
+
resource_id = config["resource_id"]
|
|
82
|
+
base_url = config["base_url"]
|
|
83
|
+
self.client_id = (
|
|
84
|
+
client_id
|
|
85
|
+
or os.environ.get("AZURE_CLIENT_ID")
|
|
86
|
+
or config["client_id"]
|
|
87
|
+
)
|
|
60
88
|
self.env = env
|
|
61
89
|
self._verbosity = verbosity
|
|
62
90
|
|
|
@@ -101,11 +129,10 @@ class SumoClient:
|
|
|
101
129
|
pass
|
|
102
130
|
|
|
103
131
|
cleanup_shared_keys()
|
|
104
|
-
|
|
105
132
|
self.auth = get_auth_provider(
|
|
106
|
-
client_id=
|
|
107
|
-
authority=f"{
|
|
108
|
-
resource_id=
|
|
133
|
+
client_id=self.client_id,
|
|
134
|
+
authority=f"{authority_host}{tenant_id}",
|
|
135
|
+
resource_id=resource_id,
|
|
109
136
|
interactive=interactive,
|
|
110
137
|
refresh_token=refresh_token,
|
|
111
138
|
access_token=access_token,
|
|
@@ -113,14 +140,7 @@ class SumoClient:
|
|
|
113
140
|
case_uuid=case_uuid,
|
|
114
141
|
)
|
|
115
142
|
|
|
116
|
-
|
|
117
|
-
self.base_url = "https://api.sumo.equinor.com/api/v1"
|
|
118
|
-
elif env == "localhost":
|
|
119
|
-
self.base_url = "http://localhost:8084/api/v1"
|
|
120
|
-
else:
|
|
121
|
-
self.base_url = (
|
|
122
|
-
f"https://main-sumo-core-{env}.c3.radix.equinor.com/api/v1"
|
|
123
|
-
)
|
|
143
|
+
self.base_url = base_url
|
|
124
144
|
return
|
|
125
145
|
|
|
126
146
|
def __enter__(self):
|
|
@@ -5,13 +5,12 @@ sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,
|
|
|
5
5
|
sumo/wrapper/_decorators.py,sha256=3IEi6GXVkkDACHoo8dOeDoBtZh5TlJ6Tw0qlpOVHqLQ,806
|
|
6
6
|
sumo/wrapper/_logging.py,sha256=WAGrjPmK2_JC9w1IxT5onq1iEAreEsyzmm95pXBe0dA,1074
|
|
7
7
|
sumo/wrapper/_retry_strategy.py,sha256=JSXy-ki5vWI_N4D52LpK9EoAmPrnT3H6OG0aBLsJRMk,2525
|
|
8
|
-
sumo/wrapper/_version.py,sha256=
|
|
9
|
-
sumo/wrapper/config.py,sha256=6t7qqjrrmd11m4VMlRryiMYw2JDU_R51305woAP1TAs,865
|
|
8
|
+
sumo/wrapper/_version.py,sha256=qX8_mGjWClM0QeMyVAByaVXEA4Pk87fxkFSMEQx9-KM,704
|
|
10
9
|
sumo/wrapper/login.py,sha256=Bp5IgSrsgjWcgOQIQIQ5aJrCBWdK3khS-CnTmB63Rjk,1951
|
|
11
|
-
sumo/wrapper/sumo_client.py,sha256=
|
|
12
|
-
sumo_wrapper_python-1.
|
|
13
|
-
sumo_wrapper_python-1.
|
|
14
|
-
sumo_wrapper_python-1.
|
|
15
|
-
sumo_wrapper_python-1.
|
|
16
|
-
sumo_wrapper_python-1.
|
|
17
|
-
sumo_wrapper_python-1.
|
|
10
|
+
sumo/wrapper/sumo_client.py,sha256=oGck7xvDwebdcwiygck91_oIiX6VVLjyrDK46sxGEYY,22763
|
|
11
|
+
sumo_wrapper_python-1.4.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
sumo_wrapper_python-1.4.0.dist-info/METADATA,sha256=ENzPCU_6Mr488nu2rXQzUM0eyPJjyrJ5s8RZlyZGvpU,14615
|
|
13
|
+
sumo_wrapper_python-1.4.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
14
|
+
sumo_wrapper_python-1.4.0.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
|
|
15
|
+
sumo_wrapper_python-1.4.0.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
|
|
16
|
+
sumo_wrapper_python-1.4.0.dist-info/RECORD,,
|
sumo/wrapper/config.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
APP_REGISTRATION = {
|
|
2
|
-
"prod": {
|
|
3
|
-
"CLIENT_ID": "d57a8f87-4e28-4391-84d6-34356d5876a2",
|
|
4
|
-
"RESOURCE_ID": "9e5443dd-3431-4690-9617-31eed61cb55a",
|
|
5
|
-
},
|
|
6
|
-
"test": {
|
|
7
|
-
"CLIENT_ID": "d57a8f87-4e28-4391-84d6-34356d5876a2",
|
|
8
|
-
"RESOURCE_ID": "9e5443dd-3431-4690-9617-31eed61cb55a",
|
|
9
|
-
},
|
|
10
|
-
"dev": {
|
|
11
|
-
"CLIENT_ID": "1826bd7c-582f-4838-880d-5b4da5c3eea2",
|
|
12
|
-
"RESOURCE_ID": "88d2b022-3539-4dda-9e66-853801334a86",
|
|
13
|
-
},
|
|
14
|
-
"preview": {
|
|
15
|
-
"CLIENT_ID": "1826bd7c-582f-4838-880d-5b4da5c3eea2",
|
|
16
|
-
"RESOURCE_ID": "88d2b022-3539-4dda-9e66-853801334a86",
|
|
17
|
-
},
|
|
18
|
-
"localhost": {
|
|
19
|
-
"CLIENT_ID": "1826bd7c-582f-4838-880d-5b4da5c3eea2",
|
|
20
|
-
"RESOURCE_ID": "88d2b022-3539-4dda-9e66-853801334a86",
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
TENANT_ID = "3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
|
|
25
|
-
|
|
26
|
-
AUTHORITY_HOST_URI = "https://login.microsoftonline.com"
|
{sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{sumo_wrapper_python-1.3.0.dist-info → sumo_wrapper_python-1.4.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|