infisicalsdk 1.0.7__tar.gz → 1.0.8__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 infisicalsdk might be problematic. Click here for more details.
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/PKG-INFO +1 -1
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/infisical_requests.py +59 -1
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisicalsdk.egg-info/PKG-INFO +1 -1
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/setup.py +1 -1
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/README.md +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/__init__.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/api_types.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/client.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/__init__.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/auth.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/auth_methods/__init__.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/auth_methods/aws_auth.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/auth_methods/universal_auth.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/kms.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/secrets.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/util/__init__.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/util/secrets_cache.py +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisicalsdk.egg-info/SOURCES.txt +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisicalsdk.egg-info/dependency_links.txt +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisicalsdk.egg-info/requires.txt +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisicalsdk.egg-info/top_level.txt +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/pyproject.toml +0 -0
- {infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/setup.cfg +0 -0
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
from typing import Any, Dict, Generic, Optional, TypeVar, Type
|
|
1
|
+
from typing import Any, Dict, Generic, Optional, TypeVar, Type, Callable, List
|
|
2
|
+
import socket
|
|
2
3
|
import requests
|
|
4
|
+
import functools
|
|
3
5
|
from dataclasses import dataclass
|
|
6
|
+
import time
|
|
7
|
+
import random
|
|
4
8
|
|
|
5
9
|
T = TypeVar("T")
|
|
6
10
|
|
|
11
|
+
# List of network-related exceptions that should trigger retries
|
|
12
|
+
NETWORK_ERRORS = [
|
|
13
|
+
requests.exceptions.ConnectionError,
|
|
14
|
+
requests.exceptions.ChunkedEncodingError,
|
|
15
|
+
requests.exceptions.ReadTimeout,
|
|
16
|
+
requests.exceptions.ConnectTimeout,
|
|
17
|
+
socket.gaierror,
|
|
18
|
+
socket.timeout,
|
|
19
|
+
ConnectionResetError,
|
|
20
|
+
ConnectionRefusedError,
|
|
21
|
+
ConnectionError,
|
|
22
|
+
ConnectionAbortedError,
|
|
23
|
+
]
|
|
24
|
+
|
|
7
25
|
def join_url(base: str, path: str) -> str:
|
|
8
26
|
"""
|
|
9
27
|
Join base URL and path properly, handling slashes appropriately.
|
|
@@ -49,6 +67,42 @@ class APIResponse(Generic[T]):
|
|
|
49
67
|
headers=data['headers']
|
|
50
68
|
)
|
|
51
69
|
|
|
70
|
+
def with_retry(
|
|
71
|
+
max_retries: int = 3,
|
|
72
|
+
base_delay: float = 1.0,
|
|
73
|
+
network_errors: Optional[List[Type[Exception]]] = None
|
|
74
|
+
) -> Callable:
|
|
75
|
+
"""
|
|
76
|
+
Decorator to add retry logic with exponential backoff to requests methods.
|
|
77
|
+
"""
|
|
78
|
+
if network_errors is None:
|
|
79
|
+
network_errors = NETWORK_ERRORS
|
|
80
|
+
|
|
81
|
+
def decorator(func: Callable) -> Callable:
|
|
82
|
+
@functools.wraps(func)
|
|
83
|
+
def wrapper(*args, **kwargs):
|
|
84
|
+
retry_count = 0
|
|
85
|
+
|
|
86
|
+
while True:
|
|
87
|
+
try:
|
|
88
|
+
return func(*args, **kwargs)
|
|
89
|
+
except tuple(network_errors) as error:
|
|
90
|
+
retry_count += 1
|
|
91
|
+
if retry_count > max_retries:
|
|
92
|
+
raise
|
|
93
|
+
|
|
94
|
+
base_delay_with_backoff = base_delay * (2 ** (retry_count - 1))
|
|
95
|
+
|
|
96
|
+
# +/-20% jitter
|
|
97
|
+
jitter = random.uniform(-0.2, 0.2) * base_delay_with_backoff
|
|
98
|
+
delay = base_delay_with_backoff + jitter
|
|
99
|
+
|
|
100
|
+
time.sleep(delay)
|
|
101
|
+
|
|
102
|
+
return wrapper
|
|
103
|
+
|
|
104
|
+
return decorator
|
|
105
|
+
|
|
52
106
|
|
|
53
107
|
class InfisicalRequests:
|
|
54
108
|
def __init__(self, host: str, token: Optional[str] = None):
|
|
@@ -93,6 +147,7 @@ class InfisicalRequests:
|
|
|
93
147
|
except ValueError:
|
|
94
148
|
raise InfisicalError("Invalid JSON response")
|
|
95
149
|
|
|
150
|
+
@with_retry(max_retries=4, base_delay=1.0)
|
|
96
151
|
def get(
|
|
97
152
|
self,
|
|
98
153
|
path: str,
|
|
@@ -119,6 +174,7 @@ class InfisicalRequests:
|
|
|
119
174
|
headers=dict(response.headers)
|
|
120
175
|
)
|
|
121
176
|
|
|
177
|
+
@with_retry(max_retries=4, base_delay=1.0)
|
|
122
178
|
def post(
|
|
123
179
|
self,
|
|
124
180
|
path: str,
|
|
@@ -143,6 +199,7 @@ class InfisicalRequests:
|
|
|
143
199
|
headers=dict(response.headers)
|
|
144
200
|
)
|
|
145
201
|
|
|
202
|
+
@with_retry(max_retries=4, base_delay=1.0)
|
|
146
203
|
def patch(
|
|
147
204
|
self,
|
|
148
205
|
path: str,
|
|
@@ -167,6 +224,7 @@ class InfisicalRequests:
|
|
|
167
224
|
headers=dict(response.headers)
|
|
168
225
|
)
|
|
169
226
|
|
|
227
|
+
@with_retry(max_retries=4, base_delay=1.0)
|
|
170
228
|
def delete(
|
|
171
229
|
self,
|
|
172
230
|
path: str,
|
|
@@ -15,7 +15,7 @@ from setuptools import setup, find_packages # noqa: H301
|
|
|
15
15
|
# prerequisite: setuptools
|
|
16
16
|
# http://pypi.python.org/pypi/setuptools
|
|
17
17
|
NAME = "infisicalsdk"
|
|
18
|
-
VERSION = "1.0.
|
|
18
|
+
VERSION = "1.0.8"
|
|
19
19
|
PYTHON_REQUIRES = ">=3.8"
|
|
20
20
|
REQUIRES = [
|
|
21
21
|
"python-dateutil",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{infisicalsdk-1.0.7 → infisicalsdk-1.0.8}/infisical_sdk/resources/auth_methods/universal_auth.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
|