sumo-wrapper-python 1.0.16__tar.gz → 1.0.18__tar.gz
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.
Potentially problematic release.
This version of sumo-wrapper-python might be problematic. Click here for more details.
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/PKG-INFO +1 -1
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_auth_provider.py +27 -11
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_version.py +2 -2
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/sumo_client.py +34 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.github/workflows/build_docs.yaml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.github/workflows/linting.yml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.github/workflows/publish_release.yml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.github/workflows/pytest.yml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.gitignore +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.pre-commit-config.yaml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.readthedocs.yaml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/CONTRIBUTING.md +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/LICENSE +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/README.md +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/SECURITY.md +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/Makefile +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/_static/equinor-logo.png +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/_static/equinor-logo2.jpg +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/_static/equinor_logo.jpg +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/_static/equinor_logo_only.jpg +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/_templates/layout.html +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/api.rst +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/conf.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/index.rst +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/make.bat +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/sumo-wrapper-python.rst +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/pyproject.toml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/setup.cfg +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/__init__.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/__init__.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_blob_client.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_decorators.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_logging.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_retry_strategy.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/config.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/login.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/tests/conftest.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/tests/test_sumo_thin_client.py +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/tests/testdata/case.yml +0 -0
- {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/tests/testdata/surface.yml +0 -0
{sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_auth_provider.py
RENAMED
|
@@ -66,6 +66,13 @@ class AuthProvider:
|
|
|
66
66
|
|
|
67
67
|
return {"Authorization": "Bearer " + token}
|
|
68
68
|
|
|
69
|
+
def store_shared_access_key_for_case(self, case_uuid, token):
|
|
70
|
+
with open(
|
|
71
|
+
get_token_path(self._resource_id, ".sharedkey", case_uuid),
|
|
72
|
+
"w",
|
|
73
|
+
) as f:
|
|
74
|
+
f.write(token)
|
|
75
|
+
|
|
69
76
|
pass
|
|
70
77
|
|
|
71
78
|
|
|
@@ -86,6 +93,7 @@ class AuthProviderAccessToken(AuthProvider):
|
|
|
86
93
|
self._access_token = access_token
|
|
87
94
|
payload = jwt.decode(access_token, options={"verify_signature": False})
|
|
88
95
|
self._expires = payload["exp"]
|
|
96
|
+
self._resource_id = payload["aud"]
|
|
89
97
|
return
|
|
90
98
|
|
|
91
99
|
def get_token(self):
|
|
@@ -110,10 +118,17 @@ class AuthProviderRefreshToken(AuthProvider):
|
|
|
110
118
|
pass
|
|
111
119
|
|
|
112
120
|
|
|
113
|
-
def get_token_path(resource_id, suffix):
|
|
114
|
-
|
|
115
|
-
os.path.
|
|
116
|
-
|
|
121
|
+
def get_token_path(resource_id, suffix, case_uuid=None):
|
|
122
|
+
if case_uuid is not None:
|
|
123
|
+
return os.path.join(
|
|
124
|
+
os.path.expanduser("~"),
|
|
125
|
+
".sumo",
|
|
126
|
+
str(resource_id) + "+" + str(case_uuid) + suffix,
|
|
127
|
+
)
|
|
128
|
+
else:
|
|
129
|
+
return os.path.join(
|
|
130
|
+
os.path.expanduser("~"), ".sumo", str(resource_id) + suffix
|
|
131
|
+
)
|
|
117
132
|
|
|
118
133
|
|
|
119
134
|
@tn.retry(
|
|
@@ -169,8 +184,8 @@ def get_token_cache(resource_id, suffix):
|
|
|
169
184
|
retry_error_callback=_return_last_value,
|
|
170
185
|
before_sleep=_log_retry_info,
|
|
171
186
|
)
|
|
172
|
-
def protect_token_cache(resource_id, suffix):
|
|
173
|
-
token_path = get_token_path(resource_id, suffix)
|
|
187
|
+
def protect_token_cache(resource_id, suffix, case_uuid=None):
|
|
188
|
+
token_path = get_token_path(resource_id, suffix, case_uuid)
|
|
174
189
|
|
|
175
190
|
if sys.platform.startswith("linux") or sys.platform == "darwin":
|
|
176
191
|
filemode = stat.filemode(os.stat(token_path).st_mode)
|
|
@@ -362,9 +377,9 @@ class AuthProviderSumoToken(AuthProvider):
|
|
|
362
377
|
retry_error_callback=_return_last_value,
|
|
363
378
|
before_sleep=_log_retry_info,
|
|
364
379
|
)
|
|
365
|
-
def __init__(self, resource_id):
|
|
366
|
-
protect_token_cache(resource_id, ".sharedkey")
|
|
367
|
-
token_path = get_token_path(resource_id, ".sharedkey")
|
|
380
|
+
def __init__(self, resource_id, case_uuid=None):
|
|
381
|
+
protect_token_cache(resource_id, ".sharedkey", case_uuid)
|
|
382
|
+
token_path = get_token_path(resource_id, ".sharedkey", case_uuid)
|
|
368
383
|
with open(token_path, "r") as f:
|
|
369
384
|
self._token = f.readline().strip()
|
|
370
385
|
return
|
|
@@ -394,6 +409,7 @@ def get_auth_provider(
|
|
|
394
409
|
access_token=None,
|
|
395
410
|
refresh_token=None,
|
|
396
411
|
devicecode=False,
|
|
412
|
+
case_uuid=None,
|
|
397
413
|
):
|
|
398
414
|
if refresh_token:
|
|
399
415
|
return AuthProviderRefreshToken(
|
|
@@ -403,8 +419,8 @@ def get_auth_provider(
|
|
|
403
419
|
if access_token:
|
|
404
420
|
return AuthProviderAccessToken(access_token)
|
|
405
421
|
# ELSE
|
|
406
|
-
if os.path.exists(get_token_path(resource_id, ".sharedkey")):
|
|
407
|
-
return AuthProviderSumoToken(resource_id)
|
|
422
|
+
if os.path.exists(get_token_path(resource_id, ".sharedkey", case_uuid)):
|
|
423
|
+
return AuthProviderSumoToken(resource_id, case_uuid)
|
|
408
424
|
# ELSE
|
|
409
425
|
if os.path.exists(get_token_path(resource_id, ".token")):
|
|
410
426
|
auth_silent = AuthProviderSilent(client_id, authority, resource_id)
|
|
@@ -33,6 +33,7 @@ class SumoClient:
|
|
|
33
33
|
verbosity: str = "CRITICAL",
|
|
34
34
|
retry_strategy=RetryStrategy(),
|
|
35
35
|
timeout=DEFAULT_TIMEOUT,
|
|
36
|
+
case_uuid=None,
|
|
36
37
|
):
|
|
37
38
|
"""Initialize a new Sumo object
|
|
38
39
|
|
|
@@ -49,6 +50,9 @@ class SumoClient:
|
|
|
49
50
|
if env not in APP_REGISTRATION:
|
|
50
51
|
raise ValueError(f"Invalid environment: {env}")
|
|
51
52
|
|
|
53
|
+
self.env = env
|
|
54
|
+
self._verbosity = verbosity
|
|
55
|
+
|
|
52
56
|
self._retry_strategy = retry_strategy
|
|
53
57
|
self._client = httpx.Client()
|
|
54
58
|
self._async_client = httpx.AsyncClient()
|
|
@@ -85,6 +89,7 @@ class SumoClient:
|
|
|
85
89
|
refresh_token=refresh_token,
|
|
86
90
|
access_token=access_token,
|
|
87
91
|
devicecode=devicecode,
|
|
92
|
+
case_uuid=case_uuid,
|
|
88
93
|
)
|
|
89
94
|
|
|
90
95
|
if env == "localhost":
|
|
@@ -398,6 +403,35 @@ class SumoClient:
|
|
|
398
403
|
pass
|
|
399
404
|
return logger
|
|
400
405
|
|
|
406
|
+
def create_shared_access_key_for_case(self, case_uuid):
|
|
407
|
+
"""Creates and stores a shared access key that can be used to access
|
|
408
|
+
the case identified by *case_uuid*, in the current Sumo environment.
|
|
409
|
+
|
|
410
|
+
This shared access key can then be used by instantiating
|
|
411
|
+
SumoClient with the parameter case_uuid set accordingly.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
case_uuid: the uuid for a case.
|
|
415
|
+
|
|
416
|
+
Side effects:
|
|
417
|
+
Creates a new file in ~/.sumo, named {app_id}+{case_uuid}
|
|
418
|
+
"""
|
|
419
|
+
token = self.get(
|
|
420
|
+
f"/objects('{case_uuid}')/make-shared-access-key"
|
|
421
|
+
).text
|
|
422
|
+
self.auth.store_shared_access_key_for_case(case_uuid, token)
|
|
423
|
+
|
|
424
|
+
def client_for_case(self, case_uuid):
|
|
425
|
+
"""Instantiate and return new SumoClient for accessing the
|
|
426
|
+
case identified by *case_uuid*."""
|
|
427
|
+
return SumoClient(
|
|
428
|
+
env=self.env,
|
|
429
|
+
verbosity=self._verbosity,
|
|
430
|
+
retry_strategy=self._retry_strategy,
|
|
431
|
+
timeout=self._timeout,
|
|
432
|
+
case_uuid=case_uuid,
|
|
433
|
+
)
|
|
434
|
+
|
|
401
435
|
@raise_for_status_async
|
|
402
436
|
async def get_async(self, path: str, params: dict = None):
|
|
403
437
|
"""Performs an async GET-request to the Sumo API.
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/.github/workflows/publish_release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/docs/_static/equinor_logo_only.jpg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.18}/src/sumo/wrapper/_retry_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|