sumo-wrapper-python 1.6.1__py3-none-any.whl → 1.8.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/_logging.py +3 -0
- sumo/wrapper/_retry_strategy.py +10 -3
- sumo/wrapper/_version.py +2 -2
- sumo/wrapper/sumo_client.py +60 -18
- {sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/METADATA +1 -1
- sumo_wrapper_python-1.8.0.dist-info/RECORD +16 -0
- sumo_wrapper_python-1.6.1.dist-info/RECORD +0 -16
- {sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/WHEEL +0 -0
- {sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/entry_points.txt +0 -0
- {sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/licenses/LICENSE +0 -0
- {sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/top_level.txt +0 -0
sumo/wrapper/_logging.py
CHANGED
|
@@ -28,6 +28,9 @@ class LogHandlerSumo(logging.Handler):
|
|
|
28
28
|
if "objectUuid" in record.__dict__:
|
|
29
29
|
json["objectUuid"] = record.__dict__.get("objectUuid")
|
|
30
30
|
|
|
31
|
+
if "details" in record.__dict__:
|
|
32
|
+
json["details"] = record.__dict__.get("details")
|
|
33
|
+
|
|
31
34
|
self._sumoClient.post("/message-log/new", json=json)
|
|
32
35
|
except Exception:
|
|
33
36
|
# Never fail on logging
|
sumo/wrapper/_retry_strategy.py
CHANGED
|
@@ -38,10 +38,17 @@ def _return_last_value(retry_state):
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class RetryStrategy:
|
|
41
|
-
def __init__(
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
stop_after=6,
|
|
44
|
+
multiplier=0.5,
|
|
45
|
+
exp_base=2,
|
|
46
|
+
before_sleep=_log_retry_info,
|
|
47
|
+
):
|
|
42
48
|
self._stop_after = stop_after
|
|
43
49
|
self._multiplier = multiplier
|
|
44
50
|
self._exp_base = exp_base
|
|
51
|
+
self._before_sleep = before_sleep
|
|
45
52
|
return
|
|
46
53
|
|
|
47
54
|
def make_retryer(self) -> tn.Retrying:
|
|
@@ -60,7 +67,7 @@ class RetryStrategy:
|
|
|
60
67
|
)
|
|
61
68
|
),
|
|
62
69
|
retry_error_callback=_return_last_value,
|
|
63
|
-
before_sleep=
|
|
70
|
+
before_sleep=self._before_sleep,
|
|
64
71
|
)
|
|
65
72
|
|
|
66
73
|
def make_retryer_async(self) -> tn.AsyncRetrying:
|
|
@@ -79,5 +86,5 @@ class RetryStrategy:
|
|
|
79
86
|
)
|
|
80
87
|
),
|
|
81
88
|
retry_error_callback=_return_last_value,
|
|
82
|
-
before_sleep=
|
|
89
|
+
before_sleep=self._before_sleep,
|
|
83
90
|
)
|
sumo/wrapper/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '1.
|
|
22
|
-
__version_tuple__ = version_tuple = (1,
|
|
21
|
+
__version__ = version = '1.8.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 8, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
sumo/wrapper/sumo_client.py
CHANGED
|
@@ -219,7 +219,12 @@ class SumoClient:
|
|
|
219
219
|
)
|
|
220
220
|
|
|
221
221
|
@raise_for_status
|
|
222
|
-
def get(
|
|
222
|
+
def get(
|
|
223
|
+
self,
|
|
224
|
+
path: str,
|
|
225
|
+
params: Optional[Dict] = None,
|
|
226
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
227
|
+
) -> httpx.Response:
|
|
223
228
|
"""Performs a GET-request to the Sumo API.
|
|
224
229
|
|
|
225
230
|
Args:
|
|
@@ -277,8 +282,9 @@ class SumoClient:
|
|
|
277
282
|
timeout=self._timeout,
|
|
278
283
|
)
|
|
279
284
|
|
|
280
|
-
retryer =
|
|
281
|
-
|
|
285
|
+
retryer = (
|
|
286
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
287
|
+
).make_retryer()
|
|
282
288
|
return retryer(_get)
|
|
283
289
|
|
|
284
290
|
@raise_for_status
|
|
@@ -288,6 +294,7 @@ class SumoClient:
|
|
|
288
294
|
blob: Optional[bytes] = None,
|
|
289
295
|
json: Optional[dict] = None,
|
|
290
296
|
params: Optional[dict] = None,
|
|
297
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
291
298
|
) -> httpx.Response:
|
|
292
299
|
"""Performs a POST-request to the Sumo API.
|
|
293
300
|
|
|
@@ -352,7 +359,9 @@ class SumoClient:
|
|
|
352
359
|
timeout=self._timeout,
|
|
353
360
|
)
|
|
354
361
|
|
|
355
|
-
retryer =
|
|
362
|
+
retryer = (
|
|
363
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
364
|
+
).make_retryer()
|
|
356
365
|
|
|
357
366
|
return retryer(_post)
|
|
358
367
|
|
|
@@ -362,6 +371,7 @@ class SumoClient:
|
|
|
362
371
|
path: str,
|
|
363
372
|
blob: Optional[bytes] = None,
|
|
364
373
|
json: Optional[dict] = None,
|
|
374
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
365
375
|
) -> httpx.Response:
|
|
366
376
|
"""Performs a PUT-request to the Sumo API.
|
|
367
377
|
|
|
@@ -401,13 +411,18 @@ class SumoClient:
|
|
|
401
411
|
timeout=self._timeout,
|
|
402
412
|
)
|
|
403
413
|
|
|
404
|
-
retryer =
|
|
414
|
+
retryer = (
|
|
415
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
416
|
+
).make_retryer()
|
|
405
417
|
|
|
406
418
|
return retryer(_put)
|
|
407
419
|
|
|
408
420
|
@raise_for_status
|
|
409
421
|
def delete(
|
|
410
|
-
self,
|
|
422
|
+
self,
|
|
423
|
+
path: str,
|
|
424
|
+
params: Optional[dict] = None,
|
|
425
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
411
426
|
) -> httpx.Response:
|
|
412
427
|
"""Performs a DELETE-request to the Sumo API.
|
|
413
428
|
|
|
@@ -441,7 +456,9 @@ class SumoClient:
|
|
|
441
456
|
timeout=self._timeout,
|
|
442
457
|
)
|
|
443
458
|
|
|
444
|
-
retryer =
|
|
459
|
+
retryer = (
|
|
460
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
461
|
+
).make_retryer()
|
|
445
462
|
|
|
446
463
|
return retryer(_delete)
|
|
447
464
|
|
|
@@ -460,7 +477,10 @@ class SumoClient:
|
|
|
460
477
|
return location, retry_after
|
|
461
478
|
|
|
462
479
|
def poll(
|
|
463
|
-
self,
|
|
480
|
+
self,
|
|
481
|
+
response_in: httpx.Response,
|
|
482
|
+
timeout=None,
|
|
483
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
464
484
|
) -> httpx.Response:
|
|
465
485
|
"""Poll a specific endpoint until a result is obtained.
|
|
466
486
|
|
|
@@ -474,7 +494,7 @@ class SumoClient:
|
|
|
474
494
|
expiry = time.time() + timeout if timeout is not None else None
|
|
475
495
|
while True:
|
|
476
496
|
time.sleep(retry_after)
|
|
477
|
-
response = self.get(location)
|
|
497
|
+
response = self.get(location, retry_strategy=retry_strategy)
|
|
478
498
|
if response.status_code != 202:
|
|
479
499
|
return response
|
|
480
500
|
if expiry is not None and time.time() > expiry:
|
|
@@ -522,7 +542,7 @@ class SumoClient:
|
|
|
522
542
|
).text
|
|
523
543
|
self.auth.store_shared_access_key_for_case(case_uuid, token)
|
|
524
544
|
|
|
525
|
-
def client_for_case(self, case_uuid):
|
|
545
|
+
def client_for_case(self, case_uuid, interactive=False):
|
|
526
546
|
"""Instantiate and return new SumoClient for accessing the
|
|
527
547
|
case identified by *case_uuid*."""
|
|
528
548
|
if self.auth.has_case_token(case_uuid):
|
|
@@ -532,13 +552,17 @@ class SumoClient:
|
|
|
532
552
|
retry_strategy=self._retry_strategy,
|
|
533
553
|
timeout=self._timeout,
|
|
534
554
|
case_uuid=case_uuid,
|
|
555
|
+
interactive=interactive,
|
|
535
556
|
)
|
|
536
557
|
else:
|
|
537
558
|
return self
|
|
538
559
|
|
|
539
560
|
@raise_for_status_async
|
|
540
561
|
async def get_async(
|
|
541
|
-
self,
|
|
562
|
+
self,
|
|
563
|
+
path: str,
|
|
564
|
+
params: Optional[dict] = None,
|
|
565
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
542
566
|
) -> httpx.Response:
|
|
543
567
|
"""Performs an async GET-request to the Sumo API.
|
|
544
568
|
|
|
@@ -597,7 +621,9 @@ class SumoClient:
|
|
|
597
621
|
timeout=self._timeout,
|
|
598
622
|
)
|
|
599
623
|
|
|
600
|
-
retryer =
|
|
624
|
+
retryer = (
|
|
625
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
626
|
+
).make_retryer_async()
|
|
601
627
|
|
|
602
628
|
return await retryer(_get)
|
|
603
629
|
|
|
@@ -608,6 +634,7 @@ class SumoClient:
|
|
|
608
634
|
blob: Optional[bytes] = None,
|
|
609
635
|
json: Optional[dict] = None,
|
|
610
636
|
params: Optional[dict] = None,
|
|
637
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
611
638
|
) -> httpx.Response:
|
|
612
639
|
"""Performs an async POST-request to the Sumo API.
|
|
613
640
|
|
|
@@ -673,7 +700,9 @@ class SumoClient:
|
|
|
673
700
|
timeout=self._timeout,
|
|
674
701
|
)
|
|
675
702
|
|
|
676
|
-
retryer =
|
|
703
|
+
retryer = (
|
|
704
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
705
|
+
).make_retryer_async()
|
|
677
706
|
|
|
678
707
|
return await retryer(_post)
|
|
679
708
|
|
|
@@ -683,6 +712,7 @@ class SumoClient:
|
|
|
683
712
|
path: str,
|
|
684
713
|
blob: Optional[bytes] = None,
|
|
685
714
|
json: Optional[dict] = None,
|
|
715
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
686
716
|
) -> httpx.Response:
|
|
687
717
|
"""Performs an async PUT-request to the Sumo API.
|
|
688
718
|
|
|
@@ -722,13 +752,18 @@ class SumoClient:
|
|
|
722
752
|
timeout=self._timeout,
|
|
723
753
|
)
|
|
724
754
|
|
|
725
|
-
retryer =
|
|
755
|
+
retryer = (
|
|
756
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
757
|
+
).make_retryer_async()
|
|
726
758
|
|
|
727
759
|
return await retryer(_put)
|
|
728
760
|
|
|
729
761
|
@raise_for_status_async
|
|
730
762
|
async def delete_async(
|
|
731
|
-
self,
|
|
763
|
+
self,
|
|
764
|
+
path: str,
|
|
765
|
+
params: Optional[dict] = None,
|
|
766
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
732
767
|
) -> httpx.Response:
|
|
733
768
|
"""Performs an async DELETE-request to the Sumo API.
|
|
734
769
|
|
|
@@ -762,12 +797,17 @@ class SumoClient:
|
|
|
762
797
|
timeout=self._timeout,
|
|
763
798
|
)
|
|
764
799
|
|
|
765
|
-
retryer =
|
|
800
|
+
retryer = (
|
|
801
|
+
retry_strategy if retry_strategy else self._retry_strategy
|
|
802
|
+
).make_retryer_async()
|
|
766
803
|
|
|
767
804
|
return await retryer(_delete)
|
|
768
805
|
|
|
769
806
|
async def poll_async(
|
|
770
|
-
self,
|
|
807
|
+
self,
|
|
808
|
+
response_in: httpx.Response,
|
|
809
|
+
timeout=None,
|
|
810
|
+
retry_strategy: Optional[RetryStrategy] = None,
|
|
771
811
|
) -> httpx.Response:
|
|
772
812
|
"""Poll a specific endpoint until a result is obtained.
|
|
773
813
|
|
|
@@ -781,7 +821,9 @@ class SumoClient:
|
|
|
781
821
|
expiry = time.time() + timeout if timeout is not None else None
|
|
782
822
|
while True:
|
|
783
823
|
await asyncio.sleep(retry_after)
|
|
784
|
-
response = await self.get_async(
|
|
824
|
+
response = await self.get_async(
|
|
825
|
+
location, retry_strategy=retry_strategy
|
|
826
|
+
)
|
|
785
827
|
if response.status_code != 202:
|
|
786
828
|
return response
|
|
787
829
|
if expiry is not None and time.time() > expiry:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
sumo/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
|
|
2
|
+
sumo/wrapper/__init__.py,sha256=JK6iMAy2Fdrc7iaIHTn60fHPdRvsgNjZwWD6DJtGUYQ,235
|
|
3
|
+
sumo/wrapper/_auth_provider.py,sha256=XO2WcEJjQuXsDhFZ3wplOL_plxNdAqk2yw2jzv3iLSQ,16660
|
|
4
|
+
sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,1623
|
|
5
|
+
sumo/wrapper/_decorators.py,sha256=ZwyrWkfAXiGNSgYsQSEXA13D-WIQM2XPf0v2z9N8HyQ,1002
|
|
6
|
+
sumo/wrapper/_logging.py,sha256=vm85iaarcqeM40kvv32dO1UKKCWVfeF8a3rN1-K82S0,1185
|
|
7
|
+
sumo/wrapper/_retry_strategy.py,sha256=33eY_PxgcDXJs6_NDQOOkllADePnZgge_cELtaLfJZM,2650
|
|
8
|
+
sumo/wrapper/_version.py,sha256=n6hqiGWubG62zMPv1zntf2ad8WUFfELiXM1ZL13KtJA,520
|
|
9
|
+
sumo/wrapper/login.py,sha256=PtpQ5Qi8Gm1N0hMnE79Je4QvQ8JMuKqa46TwZgjHRnM,2328
|
|
10
|
+
sumo/wrapper/sumo_client.py,sha256=fI9khiMOgpK6Vai0Sk8YD3vp0dREbdr_1WHW9nv9WWg,24430
|
|
11
|
+
sumo_wrapper_python-1.8.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
sumo_wrapper_python-1.8.0.dist-info/METADATA,sha256=q0aV31EJYFco6NYg0f7bCRUc-7ocS7CGR9zAP7inUPk,14615
|
|
13
|
+
sumo_wrapper_python-1.8.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
14
|
+
sumo_wrapper_python-1.8.0.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
|
|
15
|
+
sumo_wrapper_python-1.8.0.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
|
|
16
|
+
sumo_wrapper_python-1.8.0.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
sumo/__init__.py,sha256=ftS-xRPSH-vU7fIHlnZQaCTWbNvs4owJivNW65kzsIM,85
|
|
2
|
-
sumo/wrapper/__init__.py,sha256=JK6iMAy2Fdrc7iaIHTn60fHPdRvsgNjZwWD6DJtGUYQ,235
|
|
3
|
-
sumo/wrapper/_auth_provider.py,sha256=XO2WcEJjQuXsDhFZ3wplOL_plxNdAqk2yw2jzv3iLSQ,16660
|
|
4
|
-
sumo/wrapper/_blob_client.py,sha256=SyfyFZ1hHVWKU4lmgUqSjl5TaK_OJNQ__0wDETrp-ag,1623
|
|
5
|
-
sumo/wrapper/_decorators.py,sha256=ZwyrWkfAXiGNSgYsQSEXA13D-WIQM2XPf0v2z9N8HyQ,1002
|
|
6
|
-
sumo/wrapper/_logging.py,sha256=WAGrjPmK2_JC9w1IxT5onq1iEAreEsyzmm95pXBe0dA,1074
|
|
7
|
-
sumo/wrapper/_retry_strategy.py,sha256=JSXy-ki5vWI_N4D52LpK9EoAmPrnT3H6OG0aBLsJRMk,2525
|
|
8
|
-
sumo/wrapper/_version.py,sha256=oBVheJDDvi0mK4SCR_IERt3vP_efnZ5l5B_1mC1_E8w,520
|
|
9
|
-
sumo/wrapper/login.py,sha256=PtpQ5Qi8Gm1N0hMnE79Je4QvQ8JMuKqa46TwZgjHRnM,2328
|
|
10
|
-
sumo/wrapper/sumo_client.py,sha256=CKwl-C2YndVAaDEXUzuOnm1Ix_oNVEBKqehI7BJhQXk,23107
|
|
11
|
-
sumo_wrapper_python-1.6.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
-
sumo_wrapper_python-1.6.1.dist-info/METADATA,sha256=Uqao5pvzAgXD0PTwIuKF5uh0P2QqsYnAQ3HQB69SkNk,14615
|
|
13
|
-
sumo_wrapper_python-1.6.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
14
|
-
sumo_wrapper_python-1.6.1.dist-info/entry_points.txt,sha256=V_vGky2C3He5vohJAxnBdvpt_fqfUDFj5irUm9HtoFc,55
|
|
15
|
-
sumo_wrapper_python-1.6.1.dist-info/top_level.txt,sha256=rLbKyH9rWgCj3PoLeR7fvC5X8vCaUc5LF8-Y_GBWZL0,5
|
|
16
|
-
sumo_wrapper_python-1.6.1.dist-info/RECORD,,
|
|
File without changes
|
{sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{sumo_wrapper_python-1.6.1.dist-info → sumo_wrapper_python-1.8.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|