sumo-wrapper-python 1.0.16__tar.gz → 1.0.17__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.

Files changed (46) hide show
  1. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/PKG-INFO +1 -1
  2. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/_auth_provider.py +13 -0
  3. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/_version.py +2 -2
  4. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/sumo_client.py +34 -0
  5. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
  6. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.github/workflows/build_docs.yaml +0 -0
  7. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.github/workflows/linting.yml +0 -0
  8. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.github/workflows/publish_release.yml +0 -0
  9. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.github/workflows/pytest.yml +0 -0
  10. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.gitignore +0 -0
  11. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.pre-commit-config.yaml +0 -0
  12. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/.readthedocs.yaml +0 -0
  13. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/CONTRIBUTING.md +0 -0
  14. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/LICENSE +0 -0
  15. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/README.md +0 -0
  16. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/SECURITY.md +0 -0
  17. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/Makefile +0 -0
  18. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/_static/equinor-logo.png +0 -0
  19. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/_static/equinor-logo2.jpg +0 -0
  20. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/_static/equinor_logo.jpg +0 -0
  21. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/_static/equinor_logo_only.jpg +0 -0
  22. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/_templates/layout.html +0 -0
  23. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/api.rst +0 -0
  24. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/conf.py +0 -0
  25. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/index.rst +0 -0
  26. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/make.bat +0 -0
  27. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/docs/sumo-wrapper-python.rst +0 -0
  28. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/pyproject.toml +0 -0
  29. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/setup.cfg +0 -0
  30. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/__init__.py +0 -0
  31. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/__init__.py +0 -0
  32. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/_blob_client.py +0 -0
  33. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/_decorators.py +0 -0
  34. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/_logging.py +0 -0
  35. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/_retry_strategy.py +0 -0
  36. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/config.py +0 -0
  37. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo/wrapper/login.py +0 -0
  38. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -0
  39. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
  40. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
  41. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
  42. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
  43. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/tests/conftest.py +0 -0
  44. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/tests/test_sumo_thin_client.py +0 -0
  45. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/tests/testdata/case.yml +0 -0
  46. {sumo_wrapper_python-1.0.16 → sumo_wrapper_python-1.0.17}/tests/testdata/surface.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sumo-wrapper-python
3
- Version: 1.0.16
3
+ Version: 1.0.17
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -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 + "+" + case_uuid, ".sharedkey"),
72
+ "w",
73
+ ) as f:
74
+ f.write(token)
75
+
69
76
  pass
70
77
 
71
78
 
@@ -394,6 +401,7 @@ def get_auth_provider(
394
401
  access_token=None,
395
402
  refresh_token=None,
396
403
  devicecode=False,
404
+ case_uuid=None,
397
405
  ):
398
406
  if refresh_token:
399
407
  return AuthProviderRefreshToken(
@@ -403,6 +411,11 @@ def get_auth_provider(
403
411
  if access_token:
404
412
  return AuthProviderAccessToken(access_token)
405
413
  # ELSE
414
+ if case_uuid is not None and os.path.exists(
415
+ get_token_path(resource_id + "+" + case_uuid, ".sharedkey")
416
+ ):
417
+ return AuthProviderSumoToken(resource_id + "+" + case_uuid)
418
+ # ELSE
406
419
  if os.path.exists(get_token_path(resource_id, ".sharedkey")):
407
420
  return AuthProviderSumoToken(resource_id)
408
421
  # ELSE
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.0.16'
16
- __version_tuple__ = version_tuple = (1, 0, 16)
15
+ __version__ = version = '1.0.17'
16
+ __version_tuple__ = version_tuple = (1, 0, 17)
@@ -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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sumo-wrapper-python
3
- Version: 1.0.16
3
+ Version: 1.0.17
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License