sumo-wrapper-python 1.3.0__tar.gz → 1.4.0__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.
Files changed (46) hide show
  1. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.gitignore +1 -0
  2. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/PKG-INFO +1 -1
  3. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/_version.py +3 -3
  4. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/sumo_client.py +40 -20
  5. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo_wrapper_python.egg-info/PKG-INFO +1 -1
  6. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo_wrapper_python.egg-info/SOURCES.txt +0 -1
  7. sumo_wrapper_python-1.3.0/src/sumo/wrapper/config.py +0 -26
  8. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.github/workflows/build_docs.yaml +0 -0
  9. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.github/workflows/linting.yml +0 -0
  10. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.github/workflows/publish_release.yml +0 -0
  11. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.github/workflows/pytest.yml +0 -0
  12. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.pre-commit-config.yaml +0 -0
  13. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/.readthedocs.yaml +0 -0
  14. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/CONTRIBUTING.md +0 -0
  15. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/LICENSE +0 -0
  16. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/README.md +0 -0
  17. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/SECURITY.md +0 -0
  18. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/Makefile +0 -0
  19. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/_static/equinor-logo.png +0 -0
  20. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/_static/equinor-logo2.jpg +0 -0
  21. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/_static/equinor_logo.jpg +0 -0
  22. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/_static/equinor_logo_only.jpg +0 -0
  23. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/_templates/layout.html +0 -0
  24. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/api.rst +0 -0
  25. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/conf.py +0 -0
  26. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/index.rst +0 -0
  27. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/make.bat +0 -0
  28. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/docs/sumo-wrapper-python.rst +0 -0
  29. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/pyproject.toml +0 -0
  30. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/setup.cfg +0 -0
  31. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/__init__.py +0 -0
  32. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/__init__.py +0 -0
  33. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/_auth_provider.py +0 -0
  34. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/_blob_client.py +0 -0
  35. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/_decorators.py +0 -0
  36. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/_logging.py +0 -0
  37. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/_retry_strategy.py +0 -0
  38. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo/wrapper/login.py +0 -0
  39. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo_wrapper_python.egg-info/dependency_links.txt +0 -0
  40. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo_wrapper_python.egg-info/entry_points.txt +0 -0
  41. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo_wrapper_python.egg-info/requires.txt +0 -0
  42. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/src/sumo_wrapper_python.egg-info/top_level.txt +0 -0
  43. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/tests/conftest.py +0 -0
  44. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/tests/test_sumo_thin_client.py +0 -0
  45. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/tests/testdata/case.yml +0 -0
  46. {sumo_wrapper_python-1.3.0 → sumo_wrapper_python-1.4.0}/tests/testdata/surface.yml +0 -0
@@ -1,6 +1,7 @@
1
1
  __pycache__/
2
2
  *.py[cod]
3
3
  .DS_Store
4
+ .idea*
4
5
  *~
5
6
  _venv
6
7
  venv
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumo-wrapper-python
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -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.3.0'
32
- __version_tuple__ = version_tuple = (1, 3, 0)
31
+ __version__ = version = '1.4.0'
32
+ __version_tuple__ = version_tuple = (1, 4, 0)
33
33
 
34
- __commit_id__ = commit_id = 'g650a0d132'
34
+ __commit_id__ = commit_id = 'g8c4d4a4f8'
@@ -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
- verbosity: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
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
- if env not in APP_REGISTRATION:
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=APP_REGISTRATION[env]["CLIENT_ID"],
107
- authority=f"{AUTHORITY_HOST_URI}/{TENANT_ID}",
108
- resource_id=APP_REGISTRATION[env]["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
- if env == "prod":
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sumo-wrapper-python
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Python wrapper for the Sumo API
5
5
  Author: Equinor
6
6
  License: Apache License
@@ -29,7 +29,6 @@ src/sumo/wrapper/_decorators.py
29
29
  src/sumo/wrapper/_logging.py
30
30
  src/sumo/wrapper/_retry_strategy.py
31
31
  src/sumo/wrapper/_version.py
32
- src/sumo/wrapper/config.py
33
32
  src/sumo/wrapper/login.py
34
33
  src/sumo/wrapper/sumo_client.py
35
34
  src/sumo_wrapper_python.egg-info/PKG-INFO
@@ -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"