sumo-wrapper-python 1.0.13__py3-none-any.whl → 1.0.15__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/__init__.py +1 -1
- sumo/wrapper/_auth_provider.py +14 -16
- sumo/wrapper/_logging.py +9 -4
- sumo/wrapper/_retry_strategy.py +1 -1
- sumo/wrapper/_version.py +2 -2
- sumo/wrapper/login.py +2 -2
- sumo/wrapper/sumo_client.py +33 -13
- {sumo_wrapper_python-1.0.13.dist-info → sumo_wrapper_python-1.0.15.dist-info}/METADATA +4 -1
- sumo_wrapper_python-1.0.15.dist-info/RECORD +17 -0
- sumo_wrapper_python-1.0.13.dist-info/RECORD +0 -17
- {sumo_wrapper_python-1.0.13.dist-info → sumo_wrapper_python-1.0.15.dist-info}/LICENSE +0 -0
- {sumo_wrapper_python-1.0.13.dist-info → sumo_wrapper_python-1.0.15.dist-info}/WHEEL +0 -0
- {sumo_wrapper_python-1.0.13.dist-info → sumo_wrapper_python-1.0.15.dist-info}/entry_points.txt +0 -0
- {sumo_wrapper_python-1.0.13.dist-info → sumo_wrapper_python-1.0.15.dist-info}/top_level.txt +0 -0
sumo/wrapper/__init__.py
CHANGED
sumo/wrapper/_auth_provider.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import errno
|
|
2
|
+
import json
|
|
2
3
|
import os
|
|
3
|
-
from datetime import datetime, timedelta
|
|
4
4
|
import stat
|
|
5
5
|
import sys
|
|
6
|
-
import json
|
|
7
|
-
import jwt
|
|
8
6
|
import time
|
|
9
|
-
from
|
|
10
|
-
import tenacity as tn
|
|
11
|
-
from ._retry_strategy import _log_retry_info, _return_last_value
|
|
7
|
+
from datetime import datetime, timedelta
|
|
12
8
|
|
|
9
|
+
import jwt
|
|
10
|
+
import msal
|
|
11
|
+
import tenacity as tn
|
|
12
|
+
from azure.identity import ManagedIdentityCredential
|
|
13
13
|
from msal_extensions.persistence import FilePersistence
|
|
14
14
|
from msal_extensions.token_cache import PersistedTokenCache
|
|
15
|
-
import errno
|
|
16
15
|
|
|
16
|
+
from ._retry_strategy import _log_retry_info, _return_last_value
|
|
17
17
|
|
|
18
18
|
if not sys.platform.startswith("linux"):
|
|
19
19
|
from msal_extensions import build_encrypted_persistence
|
|
@@ -422,14 +422,12 @@ def get_auth_provider(
|
|
|
422
422
|
return AuthProviderDeviceCode(client_id, authority, resource_id)
|
|
423
423
|
# ELSE
|
|
424
424
|
if all(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
"AZURE_AUTHORITY_HOST",
|
|
432
|
-
]
|
|
425
|
+
os.getenv(x)
|
|
426
|
+
for x in [
|
|
427
|
+
"AZURE_FEDERATED_TOKEN_FILE",
|
|
428
|
+
"AZURE_TENANT_ID",
|
|
429
|
+
"AZURE_CLIENT_ID",
|
|
430
|
+
"AZURE_AUTHORITY_HOST",
|
|
433
431
|
]
|
|
434
432
|
):
|
|
435
433
|
return AuthProviderManaged(resource_id)
|
sumo/wrapper/_logging.py
CHANGED
|
@@ -3,14 +3,19 @@ from datetime import datetime
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class LogHandlerSumo(logging.Handler):
|
|
6
|
-
def __init__(self,
|
|
6
|
+
def __init__(self, sumo_client):
|
|
7
7
|
logging.Handler.__init__(self)
|
|
8
|
-
self._sumoClient =
|
|
8
|
+
self._sumoClient = sumo_client
|
|
9
9
|
return
|
|
10
10
|
|
|
11
11
|
def emit(self, record):
|
|
12
12
|
try:
|
|
13
|
-
dt =
|
|
13
|
+
dt = (
|
|
14
|
+
datetime.now(datetime.timezone.utc)
|
|
15
|
+
.replace(microsecond=0)
|
|
16
|
+
.isoformat()
|
|
17
|
+
+ "Z"
|
|
18
|
+
)
|
|
14
19
|
json = {
|
|
15
20
|
"severity": record.levelname,
|
|
16
21
|
"message": record.getMessage(),
|
|
@@ -20,7 +25,7 @@ class LogHandlerSumo(logging.Handler):
|
|
|
20
25
|
"funcname": record.funcName,
|
|
21
26
|
"linenumber": record.lineno,
|
|
22
27
|
}
|
|
23
|
-
if "objectUuid" in record.__dict__
|
|
28
|
+
if "objectUuid" in record.__dict__:
|
|
24
29
|
json["objectUuid"] = record.__dict__.get("objectUuid")
|
|
25
30
|
|
|
26
31
|
self._sumoClient.post("/message-log/new", json=json)
|
sumo/wrapper/_retry_strategy.py
CHANGED
sumo/wrapper/_version.py
CHANGED
sumo/wrapper/login.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import platform
|
|
3
|
-
from pathlib import Path
|
|
4
3
|
from argparse import ArgumentParser
|
|
5
|
-
from
|
|
4
|
+
from pathlib import Path
|
|
6
5
|
|
|
6
|
+
from sumo.wrapper import SumoClient
|
|
7
7
|
|
|
8
8
|
logger = logging.getLogger("sumo.wrapper")
|
|
9
9
|
logger.setLevel(level="CRITICAL")
|
sumo/wrapper/sumo_client.py
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import logging
|
|
2
1
|
import asyncio
|
|
2
|
+
import contextlib
|
|
3
|
+
import logging
|
|
4
|
+
import re
|
|
5
|
+
|
|
3
6
|
import httpx
|
|
4
7
|
import jwt
|
|
5
8
|
|
|
6
|
-
from ._blob_client import BlobClient
|
|
7
|
-
from ._logging import LogHandlerSumo
|
|
8
9
|
from ._auth_provider import get_auth_provider
|
|
9
|
-
from .
|
|
10
|
-
|
|
10
|
+
from ._blob_client import BlobClient
|
|
11
11
|
from ._decorators import (
|
|
12
12
|
raise_for_status,
|
|
13
13
|
raise_for_status_async,
|
|
14
14
|
)
|
|
15
|
-
|
|
15
|
+
from ._logging import LogHandlerSumo
|
|
16
16
|
from ._retry_strategy import RetryStrategy
|
|
17
|
+
from .config import APP_REGISTRATION, AUTHORITY_HOST_URI, TENANT_ID
|
|
17
18
|
|
|
18
19
|
logger = logging.getLogger("sumo.wrapper")
|
|
19
20
|
|
|
@@ -49,8 +50,8 @@ class SumoClient:
|
|
|
49
50
|
raise ValueError(f"Invalid environment: {env}")
|
|
50
51
|
|
|
51
52
|
self._retry_strategy = retry_strategy
|
|
52
|
-
self._client = httpx.Client(
|
|
53
|
-
self._async_client = httpx.AsyncClient(
|
|
53
|
+
self._client = httpx.Client()
|
|
54
|
+
self._async_client = httpx.AsyncClient()
|
|
54
55
|
|
|
55
56
|
self._timeout = timeout
|
|
56
57
|
|
|
@@ -60,12 +61,10 @@ class SumoClient:
|
|
|
60
61
|
logger.debug("Token provided")
|
|
61
62
|
|
|
62
63
|
payload = None
|
|
63
|
-
|
|
64
|
+
with contextlib.suppress(jwt.InvalidTokenError):
|
|
64
65
|
payload = jwt.decode(
|
|
65
66
|
token, options={"verify_signature": False}
|
|
66
67
|
)
|
|
67
|
-
except jwt.InvalidTokenError:
|
|
68
|
-
pass
|
|
69
68
|
|
|
70
69
|
if payload:
|
|
71
70
|
logger.debug(f"Token decoded as JWT, payload: {payload}")
|
|
@@ -197,12 +196,22 @@ class SumoClient:
|
|
|
197
196
|
|
|
198
197
|
headers.update(self.auth.get_authorization())
|
|
199
198
|
|
|
199
|
+
follow_redirects = False
|
|
200
|
+
if (
|
|
201
|
+
re.match(
|
|
202
|
+
r"^/objects\('[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}'\)/blob$", # noqa: E501
|
|
203
|
+
path,
|
|
204
|
+
)
|
|
205
|
+
is not None
|
|
206
|
+
):
|
|
207
|
+
follow_redirects = True
|
|
208
|
+
|
|
200
209
|
def _get():
|
|
201
210
|
return self._client.get(
|
|
202
211
|
f"{self.base_url}{path}",
|
|
203
212
|
params=params,
|
|
204
213
|
headers=headers,
|
|
205
|
-
follow_redirects=
|
|
214
|
+
follow_redirects=follow_redirects,
|
|
206
215
|
timeout=self._timeout,
|
|
207
216
|
)
|
|
208
217
|
|
|
@@ -369,7 +378,7 @@ class SumoClient:
|
|
|
369
378
|
|
|
370
379
|
return retryer(_delete)
|
|
371
380
|
|
|
372
|
-
def
|
|
381
|
+
def get_logger(self, name):
|
|
373
382
|
"""Gets a logger object that sends log objects into the message_log
|
|
374
383
|
index for the Sumo instance.
|
|
375
384
|
|
|
@@ -424,11 +433,22 @@ class SumoClient:
|
|
|
424
433
|
|
|
425
434
|
headers.update(self.auth.get_authorization())
|
|
426
435
|
|
|
436
|
+
follow_redirects = False
|
|
437
|
+
if (
|
|
438
|
+
re.match(
|
|
439
|
+
r"^/objects\('[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}'\)/blob$", # noqa: E501
|
|
440
|
+
path,
|
|
441
|
+
)
|
|
442
|
+
is not None
|
|
443
|
+
):
|
|
444
|
+
follow_redirects = True
|
|
445
|
+
|
|
427
446
|
async def _get():
|
|
428
447
|
return await self._async_client.get(
|
|
429
448
|
f"{self.base_url}{path}",
|
|
430
449
|
params=params,
|
|
431
450
|
headers=headers,
|
|
451
|
+
follow_redirects=follow_redirects,
|
|
432
452
|
timeout=self._timeout,
|
|
433
453
|
)
|
|
434
454
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sumo-wrapper-python
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.15
|
|
4
4
|
Summary: Python wrapper for the Sumo API
|
|
5
5
|
Author: Equinor
|
|
6
6
|
License: Apache License
|
|
@@ -217,6 +217,9 @@ Requires-Dist: pyjwt>=2.4.0
|
|
|
217
217
|
Requires-Dist: httpx>=0.24.1
|
|
218
218
|
Requires-Dist: tenacity!=8.4.0,>=8.2.2
|
|
219
219
|
Requires-Dist: azure-identity>=1.13.0
|
|
220
|
+
Provides-Extra: dev
|
|
221
|
+
Requires-Dist: ruff; extra == "dev"
|
|
222
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
220
223
|
Provides-Extra: docs
|
|
221
224
|
Requires-Dist: sphinx==7.1.2; extra == "docs"
|
|
222
225
|
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
sumo/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
|
|
2
|
+
sumo/wrapper/__init__.py,sha256=JK6iMAy2Fdrc7iaIHTn60fHPdRvsgNjZwWD6DJtGUYQ,235
|
|
3
|
+
sumo/wrapper/_auth_provider.py,sha256=ZPwqapMRnzSySq9uXT4cavWaIQcff4IPbxb3sHbxhQg,13661
|
|
4
|
+
sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,1623
|
|
5
|
+
sumo/wrapper/_decorators.py,sha256=3IEi6GXVkkDACHoo8dOeDoBtZh5TlJ6Tw0qlpOVHqLQ,806
|
|
6
|
+
sumo/wrapper/_logging.py,sha256=jOtMpiVJcF38QBM4ER1VDdHom777L5MkfomtOVHXgu8,1060
|
|
7
|
+
sumo/wrapper/_retry_strategy.py,sha256=qDgl_FLec94fzZaCG__BT8tO4O-D5cZ2_JRYw1zjVTI,2495
|
|
8
|
+
sumo/wrapper/_version.py,sha256=jEnaeEof2ggMD0wz8kIGv1b-OQvXJDcVBOnxoO7WWV0,413
|
|
9
|
+
sumo/wrapper/config.py,sha256=6t7qqjrrmd11m4VMlRryiMYw2JDU_R51305woAP1TAs,865
|
|
10
|
+
sumo/wrapper/login.py,sha256=PGYhKnrwV4NorNbwnWj-5LDvCCIKgn-pnvCTeCDvqXA,2375
|
|
11
|
+
sumo/wrapper/sumo_client.py,sha256=pOx2ahRe1rXonH2PAnQWZ_S3XFv1n3P9qU5Pt-oe1Oc,16424
|
|
12
|
+
sumo_wrapper_python-1.0.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
13
|
+
sumo_wrapper_python-1.0.15.dist-info/METADATA,sha256=a2p1BGlGPdahGCkc55MnQ9VzPAsPkNsgdCN0w0Fu6_I,14560
|
|
14
|
+
sumo_wrapper_python-1.0.15.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
15
|
+
sumo_wrapper_python-1.0.15.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
|
|
16
|
+
sumo_wrapper_python-1.0.15.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
|
|
17
|
+
sumo_wrapper_python-1.0.15.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
sumo/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
|
|
2
|
-
sumo/wrapper/__init__.py,sha256=wW7Bjl0btCgK9_exGVrfJsnFmTOybIdyeCudz0LueQM,235
|
|
3
|
-
sumo/wrapper/_auth_provider.py,sha256=O7Yqw4xfEWCJXF_jAX0zosT4bSPUtbDLYZ46aQWJ4k4,13709
|
|
4
|
-
sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,1623
|
|
5
|
-
sumo/wrapper/_decorators.py,sha256=3IEi6GXVkkDACHoo8dOeDoBtZh5TlJ6Tw0qlpOVHqLQ,806
|
|
6
|
-
sumo/wrapper/_logging.py,sha256=lnhjn6oQna33jZpzeZ7IeBya2uKNfrzXr_C3nw7txo0,965
|
|
7
|
-
sumo/wrapper/_retry_strategy.py,sha256=_V-KzAyP1nAeHf1lhc_syxlaKj5CQz-tIsCYs2DONe0,2495
|
|
8
|
-
sumo/wrapper/_version.py,sha256=CZ8Zo1p2pk-2aVQ1p1ONwv-G7Nuh-enuBbQWiK4K-Fs,413
|
|
9
|
-
sumo/wrapper/config.py,sha256=6t7qqjrrmd11m4VMlRryiMYw2JDU_R51305woAP1TAs,865
|
|
10
|
-
sumo/wrapper/login.py,sha256=IlENRNdSc2UPmGdrcxjziovMVYpV40qQSnAuDy5LKh4,2375
|
|
11
|
-
sumo/wrapper/sumo_client.py,sha256=itx4zZBMA7JmgPOEVRI37_QNpJPpBvK7UokeLMRgnvE,15770
|
|
12
|
-
sumo_wrapper_python-1.0.13.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
13
|
-
sumo_wrapper_python-1.0.13.dist-info/METADATA,sha256=1Pa2-GVAakpaspTypl2boMl4BxAfv_uxezUldnEWs68,14462
|
|
14
|
-
sumo_wrapper_python-1.0.13.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
15
|
-
sumo_wrapper_python-1.0.13.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
|
|
16
|
-
sumo_wrapper_python-1.0.13.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
|
|
17
|
-
sumo_wrapper_python-1.0.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{sumo_wrapper_python-1.0.13.dist-info → sumo_wrapper_python-1.0.15.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|