vtexpy 0.0.0b24__py3-none-any.whl → 0.0.0b26__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.
- vtex/_api/base.py +4 -4
- vtex/_config.py +18 -18
- vtex/_constants.py +4 -4
- vtex/_dto.py +5 -5
- vtex/_exceptions.py +3 -3
- vtex/_logging.py +3 -3
- {vtexpy-0.0.0b24.dist-info → vtexpy-0.0.0b26.dist-info}/METADATA +1 -1
- {vtexpy-0.0.0b24.dist-info → vtexpy-0.0.0b26.dist-info}/RECORD +10 -10
- {vtexpy-0.0.0b24.dist-info → vtexpy-0.0.0b26.dist-info}/LICENSE +0 -0
- {vtexpy-0.0.0b24.dist-info → vtexpy-0.0.0b26.dist-info}/WHEEL +0 -0
vtex/_api/base.py
CHANGED
|
@@ -134,14 +134,14 @@ class BaseAPI:
|
|
|
134
134
|
extra={
|
|
135
135
|
"method": response.request.method,
|
|
136
136
|
"url": response.request.url,
|
|
137
|
-
"
|
|
137
|
+
"status_code": response.status_code,
|
|
138
138
|
"environment": environment,
|
|
139
139
|
"endpoint": endpoint,
|
|
140
140
|
"account_name": request_config.account_name,
|
|
141
141
|
},
|
|
142
142
|
)
|
|
143
143
|
|
|
144
|
-
if response.status_code in request_config.
|
|
144
|
+
if response.status_code in request_config.retry_status_codes:
|
|
145
145
|
response.raise_for_status()
|
|
146
146
|
|
|
147
147
|
return response
|
|
@@ -172,7 +172,7 @@ class BaseAPI:
|
|
|
172
172
|
)
|
|
173
173
|
|
|
174
174
|
def _raise_from_response(self, response: Response, config: VTEXConfig) -> None:
|
|
175
|
-
if response.is_error and config.
|
|
175
|
+
if response.is_error and config.raise_for_status_code:
|
|
176
176
|
try:
|
|
177
177
|
data = to_snake_case_deep(response.json(strict=False))
|
|
178
178
|
except JSONDecodeError:
|
|
@@ -183,7 +183,7 @@ class BaseAPI:
|
|
|
183
183
|
method=str(response.request.method).upper(),
|
|
184
184
|
url=str(response.request.url),
|
|
185
185
|
request_headers=response.request.headers,
|
|
186
|
-
|
|
186
|
+
status_code=response.status_code,
|
|
187
187
|
data=data,
|
|
188
188
|
response_headers=response.headers,
|
|
189
189
|
) from None
|
vtex/_config.py
CHANGED
|
@@ -14,11 +14,11 @@ from ._constants import (
|
|
|
14
14
|
DEFAULT_LOG_4XX,
|
|
15
15
|
DEFAULT_LOG_5XX,
|
|
16
16
|
DEFAULT_LOG_RETRIES,
|
|
17
|
-
|
|
17
|
+
DEFAULT_RAISE_FOR_STATUS_CODE,
|
|
18
18
|
DEFAULT_RETRY_ATTEMPTS,
|
|
19
19
|
DEFAULT_RETRY_BACKOFF_MAX,
|
|
20
20
|
DEFAULT_RETRY_BACKOFF_MIN,
|
|
21
|
-
|
|
21
|
+
DEFAULT_RETRY_STATUS_CODES,
|
|
22
22
|
DEFAULT_TIMEOUT,
|
|
23
23
|
LOG_1XX_ENV_VAR,
|
|
24
24
|
LOG_2XX_ENV_VAR,
|
|
@@ -26,11 +26,11 @@ from ._constants import (
|
|
|
26
26
|
LOG_4XX_ENV_VAR,
|
|
27
27
|
LOG_5XX_ENV_VAR,
|
|
28
28
|
LOG_RETRIES_ENV_VAR,
|
|
29
|
-
|
|
29
|
+
RAISE_FOR_STATUS_CODE_ENV_VAR,
|
|
30
30
|
RETRY_ATTEMPTS_ENV_VAR,
|
|
31
31
|
RETRY_BACKOFF_MAX_ENV_VAR,
|
|
32
32
|
RETRY_BACKOFF_MIN_ENV_VAR,
|
|
33
|
-
|
|
33
|
+
RETRY_STATUS_CODES_ENV_VAR,
|
|
34
34
|
TIMEOUT_ENV_VAR,
|
|
35
35
|
)
|
|
36
36
|
from ._sentinels import UNDEFINED, UndefinedSentinel
|
|
@@ -51,9 +51,9 @@ class VTEXConfig(BaseModel):
|
|
|
51
51
|
retry_attempts: int = Field(UNDEFINED, validate_default=True)
|
|
52
52
|
retry_backoff_min: float = Field(UNDEFINED, validate_default=True)
|
|
53
53
|
retry_backoff_max: float = Field(UNDEFINED, validate_default=True)
|
|
54
|
-
|
|
54
|
+
retry_status_codes: List[int] = Field(UNDEFINED, validate_default=True)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
raise_for_status_code: bool = Field(UNDEFINED, validate_default=True)
|
|
57
57
|
|
|
58
58
|
log_retries: FalseOrLogLevel = Field(UNDEFINED, validate_default=True)
|
|
59
59
|
log_1xx: FalseOrLogLevel = Field(UNDEFINED, validate_default=True)
|
|
@@ -71,8 +71,8 @@ class VTEXConfig(BaseModel):
|
|
|
71
71
|
retry_attempts: Union[int, UndefinedSentinel] = UNDEFINED,
|
|
72
72
|
retry_backoff_min: Union[float, int, UndefinedSentinel] = UNDEFINED,
|
|
73
73
|
retry_backoff_max: Union[float, int, UndefinedSentinel] = UNDEFINED,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
retry_status_codes: Union[List[int], UndefinedSentinel] = UNDEFINED,
|
|
75
|
+
raise_for_status_code: Union[bool, UndefinedSentinel] = UNDEFINED,
|
|
76
76
|
log_retries: FalseOrLogLevelOrUndefined = UNDEFINED,
|
|
77
77
|
log_1xx: FalseOrLogLevelOrUndefined = UNDEFINED,
|
|
78
78
|
log_2xx: FalseOrLogLevelOrUndefined = UNDEFINED,
|
|
@@ -91,8 +91,8 @@ class VTEXConfig(BaseModel):
|
|
|
91
91
|
"retry_attempts": retry_attempts,
|
|
92
92
|
"retry_backoff_min": retry_backoff_min,
|
|
93
93
|
"retry_backoff_max": retry_backoff_max,
|
|
94
|
-
"
|
|
95
|
-
"
|
|
94
|
+
"retry_status_codes": retry_status_codes,
|
|
95
|
+
"raise_for_status_code": raise_for_status_code,
|
|
96
96
|
"log_retries": log_retries,
|
|
97
97
|
"log_1xx": log_1xx,
|
|
98
98
|
"log_2xx": log_2xx,
|
|
@@ -175,11 +175,11 @@ class VTEXConfig(BaseModel):
|
|
|
175
175
|
allow_zero=False,
|
|
176
176
|
)
|
|
177
177
|
|
|
178
|
-
@field_validator("
|
|
178
|
+
@field_validator("retry_status_codes", mode="before")
|
|
179
179
|
@classmethod
|
|
180
|
-
def
|
|
180
|
+
def validate_retry_status_codes(cls, value: Any) -> List[int]:
|
|
181
181
|
if isinstance(value, UndefinedSentinel):
|
|
182
|
-
value = getenv(
|
|
182
|
+
value = getenv(RETRY_STATUS_CODES_ENV_VAR, DEFAULT_RETRY_STATUS_CODES)
|
|
183
183
|
|
|
184
184
|
if isinstance(value, str):
|
|
185
185
|
if value == "":
|
|
@@ -199,13 +199,13 @@ class VTEXConfig(BaseModel):
|
|
|
199
199
|
):
|
|
200
200
|
return list(value)
|
|
201
201
|
|
|
202
|
-
raise cls._prepare_value_error(value,
|
|
202
|
+
raise cls._prepare_value_error(value, RETRY_STATUS_CODES_ENV_VAR)
|
|
203
203
|
|
|
204
|
-
@field_validator("
|
|
204
|
+
@field_validator("raise_for_status_code", mode="before")
|
|
205
205
|
@classmethod
|
|
206
|
-
def
|
|
206
|
+
def validate_raise_for_status_code(cls, value: Any) -> bool:
|
|
207
207
|
if isinstance(value, UndefinedSentinel):
|
|
208
|
-
value = getenv(
|
|
208
|
+
value = getenv(RAISE_FOR_STATUS_CODE_ENV_VAR, DEFAULT_RAISE_FOR_STATUS_CODE)
|
|
209
209
|
|
|
210
210
|
if isinstance(value, str):
|
|
211
211
|
try:
|
|
@@ -216,7 +216,7 @@ class VTEXConfig(BaseModel):
|
|
|
216
216
|
if isinstance(value, bool):
|
|
217
217
|
return value
|
|
218
218
|
|
|
219
|
-
raise cls._prepare_value_error(value,
|
|
219
|
+
raise cls._prepare_value_error(value, RAISE_FOR_STATUS_CODE_ENV_VAR)
|
|
220
220
|
|
|
221
221
|
@field_validator("log_retries", mode="before")
|
|
222
222
|
@classmethod
|
vtex/_constants.py
CHANGED
|
@@ -18,8 +18,8 @@ TIMEOUT_ENV_VAR = "VTEX_TIMEOUT"
|
|
|
18
18
|
RETRY_ATTEMPTS_ENV_VAR = "VTEX_RETRY_ATTEMPTS"
|
|
19
19
|
RETRY_BACKOFF_MIN_ENV_VAR = "VTEX_RETRY_BACKOFF_MIN"
|
|
20
20
|
RETRY_BACKOFF_MAX_ENV_VAR = "VTEX_RETRY_BACKOFF_MAX"
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
RETRY_STATUS_CODES_ENV_VAR = "VTEX_RETRY_STATUS_CODES"
|
|
22
|
+
RAISE_FOR_STATUS_CODE_ENV_VAR = "VTEX_RAISE_FOR_STATUS_CODE"
|
|
23
23
|
LOG_RETRIES_ENV_VAR = "VTEX_LOG_RETRIES"
|
|
24
24
|
LOG_1XX_ENV_VAR = "VTEX_LOG_1XX"
|
|
25
25
|
LOG_2XX_ENV_VAR = "VTEX_LOG_2XX"
|
|
@@ -31,7 +31,7 @@ DEFAULT_TIMEOUT = MINUTE
|
|
|
31
31
|
DEFAULT_RETRY_ATTEMPTS = 10
|
|
32
32
|
DEFAULT_RETRY_BACKOFF_MIN = SECOND
|
|
33
33
|
DEFAULT_RETRY_BACKOFF_MAX = MINUTE
|
|
34
|
-
|
|
34
|
+
DEFAULT_RETRY_STATUS_CODES = [
|
|
35
35
|
407,
|
|
36
36
|
408,
|
|
37
37
|
409,
|
|
@@ -45,7 +45,7 @@ DEFAULT_RETRY_STATUSES = [
|
|
|
45
45
|
511,
|
|
46
46
|
525,
|
|
47
47
|
]
|
|
48
|
-
|
|
48
|
+
DEFAULT_RAISE_FOR_STATUS_CODE = True
|
|
49
49
|
DEFAULT_LOG_RETRIES = WARNING
|
|
50
50
|
DEFAULT_LOG_1XX = INFO
|
|
51
51
|
DEFAULT_LOG_2XX = INFO
|
vtex/_dto.py
CHANGED
|
@@ -35,7 +35,7 @@ class VTEXResponse(BaseModel):
|
|
|
35
35
|
|
|
36
36
|
request: VTEXRequest
|
|
37
37
|
response: Response
|
|
38
|
-
|
|
38
|
+
status_code: int
|
|
39
39
|
headers: Dict[str, str]
|
|
40
40
|
|
|
41
41
|
@classmethod
|
|
@@ -43,7 +43,7 @@ class VTEXResponse(BaseModel):
|
|
|
43
43
|
return cls(
|
|
44
44
|
request=VTEXRequest.factory(response.request),
|
|
45
45
|
response=response,
|
|
46
|
-
|
|
46
|
+
status_code=int(response.status_code),
|
|
47
47
|
headers=dict(response.headers),
|
|
48
48
|
)
|
|
49
49
|
|
|
@@ -67,7 +67,7 @@ class VTEXDataResponse(VTEXResponse, Generic[DataType]):
|
|
|
67
67
|
return cls(
|
|
68
68
|
request=vtex_response.request,
|
|
69
69
|
response=vtex_response.response,
|
|
70
|
-
|
|
70
|
+
status_code=vtex_response.status_code,
|
|
71
71
|
headers=vtex_response.headers,
|
|
72
72
|
data=cls.get_original_response_data(response),
|
|
73
73
|
)
|
|
@@ -97,7 +97,7 @@ class VTEXItemsResponse(VTEXDataResponse[DataType], Generic[DataType, ItemType])
|
|
|
97
97
|
return cls(
|
|
98
98
|
request=vtex_data_response.request,
|
|
99
99
|
response=vtex_data_response.response,
|
|
100
|
-
|
|
100
|
+
status_code=vtex_data_response.status_code,
|
|
101
101
|
headers=vtex_data_response.headers,
|
|
102
102
|
data=vtex_data_response.data,
|
|
103
103
|
items=list(items),
|
|
@@ -174,7 +174,7 @@ class VTEXPaginatedItemsResponse(VTEXItemsResponse[DataType, ItemType]):
|
|
|
174
174
|
request=vtex_items_response.request,
|
|
175
175
|
response=vtex_items_response.response,
|
|
176
176
|
data=vtex_items_response.data,
|
|
177
|
-
|
|
177
|
+
status_code=vtex_items_response.status_code,
|
|
178
178
|
headers=vtex_items_response.headers,
|
|
179
179
|
items=vtex_items_response.items,
|
|
180
180
|
pagination=VTEXPagination.factory(vtex_items_response),
|
vtex/_exceptions.py
CHANGED
|
@@ -43,7 +43,7 @@ class VTEXResponseError(VTEXError):
|
|
|
43
43
|
method: Union[str, None] = None,
|
|
44
44
|
url: Union[str, None] = None,
|
|
45
45
|
request_headers: Union[Headers, Dict[str, str], None] = None,
|
|
46
|
-
|
|
46
|
+
status_code: Union[int, None] = None,
|
|
47
47
|
data: Any = None,
|
|
48
48
|
response_headers: Union[Headers, Dict[str, str], None] = None,
|
|
49
49
|
**kwargs: Any,
|
|
@@ -52,7 +52,7 @@ class VTEXResponseError(VTEXError):
|
|
|
52
52
|
self.method = method
|
|
53
53
|
self.url = url
|
|
54
54
|
self.request_headers = dict(request_headers) if request_headers else None
|
|
55
|
-
self.
|
|
55
|
+
self.status_code = status_code
|
|
56
56
|
self.data = data
|
|
57
57
|
self.response_headers = dict(response_headers) if response_headers else None
|
|
58
58
|
self.kwargs = kwargs
|
|
@@ -64,7 +64,7 @@ class VTEXResponseError(VTEXError):
|
|
|
64
64
|
"method": self.method,
|
|
65
65
|
"url": self.url,
|
|
66
66
|
"request_headers": self.request_headers,
|
|
67
|
-
"
|
|
67
|
+
"status_code": self.status_code,
|
|
68
68
|
"data": self.data,
|
|
69
69
|
"response_headers": self.response_headers,
|
|
70
70
|
}
|
vtex/_logging.py
CHANGED
|
@@ -45,20 +45,20 @@ def log_before_retry(
|
|
|
45
45
|
|
|
46
46
|
method = str(exception.request.method)
|
|
47
47
|
url = str(exception.request.url)
|
|
48
|
-
|
|
48
|
+
status_code = str(exception.response.status_code)
|
|
49
49
|
reason = str(exception.response.reason_phrase)
|
|
50
50
|
|
|
51
51
|
logger.log(
|
|
52
52
|
log_level,
|
|
53
53
|
f"Retrying {method} {url} in {retry_state.next_action.sleep}s as "
|
|
54
|
-
f"attempt {retry_state.attempt_number} failed with: {
|
|
54
|
+
f"attempt {retry_state.attempt_number} failed with: {status_code} {reason}",
|
|
55
55
|
extra={
|
|
56
56
|
"exception": exception,
|
|
57
57
|
"attempt": retry_state.attempt_number,
|
|
58
58
|
"sleep": retry_state.next_action.sleep,
|
|
59
59
|
"method": method,
|
|
60
60
|
"url": url,
|
|
61
|
-
"
|
|
61
|
+
"status_code": status_code,
|
|
62
62
|
**kwargs,
|
|
63
63
|
},
|
|
64
64
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
vtex/__init__.py,sha256=SLnqpZa19ISSQ9LDaCVLDAj-OxFlgVkQyEknydu20VU,636
|
|
2
2
|
vtex/_api/__init__.py,sha256=V4n0SQrqCcVFWtm8J7jbmwIRI9mCSURwdD_8uHGueAI,353
|
|
3
|
-
vtex/_api/base.py,sha256
|
|
3
|
+
vtex/_api/base.py,sha256=-ssrk7fdVAnBybOxFF5s68rKZvLo0Rw1eL4vp52Vgfw,6859
|
|
4
4
|
vtex/_api/catalog.py,sha256=0nYieUaEe2marzyDVpa23-XgtIXciK7n9rw8UqI9MU4,4661
|
|
5
5
|
vtex/_api/checkout.py,sha256=AMhSzyjAu5sZUpqevRorV706yXjNafqGDgbnq2wxVpg,1693
|
|
6
6
|
vtex/_api/custom.py,sha256=oW4dkHr1xuqVD7oby7ca9Qlhfzq7AeAIzcuKQ3eiUdc,2910
|
|
@@ -14,17 +14,17 @@ vtex/_api/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
14
14
|
vtex/_api/types/catalog.py,sha256=O_qLoiGMyBxRdmxPclbbPobUxJSzViqzHiKf8tgfm_I,394
|
|
15
15
|
vtex/_api/types/generic.py,sha256=m1lFTPeyBNi-K0shvK4uxE5SUyvhTTX_5Ls2VockkdI,344
|
|
16
16
|
vtex/_api/types/license_manager.py,sha256=KYISnKdQ548g6x5cNieoaN6gh9C1LQVFv4sH-II1maI,1015
|
|
17
|
-
vtex/_config.py,sha256=
|
|
18
|
-
vtex/_constants.py,sha256=
|
|
19
|
-
vtex/_dto.py,sha256=
|
|
20
|
-
vtex/_exceptions.py,sha256=
|
|
21
|
-
vtex/_logging.py,sha256=
|
|
17
|
+
vtex/_config.py,sha256=0wKEGQWiNv8WrvMqleqglZPF_eJFfAZeUt7to5HU0FI,11706
|
|
18
|
+
vtex/_constants.py,sha256=Oijo8dlWaC9m_liGlqFMWdh0HN7pPtFs75sTA2CjJOA,2047
|
|
19
|
+
vtex/_dto.py,sha256=6CSgQfQp94tA5M9rKxgWf_ftRyoZB804iABIpB5Ff6Y,6479
|
|
20
|
+
vtex/_exceptions.py,sha256=dNRhdk6k4capnsUSHPOKsvACwLfG8cwTNXltao3t344,2152
|
|
21
|
+
vtex/_logging.py,sha256=zahPJIk10YvNs6qoNqhUy7OoDG7dr634CPwiGjT0aEk,2246
|
|
22
22
|
vtex/_sentinels.py,sha256=HLkYBJVHTx9GoyACPO1SuINaGlU2YiqOPuFXUa7iG8A,1120
|
|
23
23
|
vtex/_types.py,sha256=xrqHzmrc0IhE5fc1aGf0StCm3BQbVFyk3LG4Hd7Wd2Q,631
|
|
24
24
|
vtex/_utils.py,sha256=slBhhZN3h2S_qopVLGP0MS6nTfsoOcsqaOhLwbCiFwQ,3104
|
|
25
25
|
vtex/_vtex.py,sha256=yr8ICPX0gDpPdcoSDJaokMuwFZWWEQ7Wi8z6XibYdos,2184
|
|
26
26
|
vtex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
vtexpy-0.0.
|
|
28
|
-
vtexpy-0.0.
|
|
29
|
-
vtexpy-0.0.
|
|
30
|
-
vtexpy-0.0.
|
|
27
|
+
vtexpy-0.0.0b26.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
28
|
+
vtexpy-0.0.0b26.dist-info/METADATA,sha256=c5g1NkjuqsG4hj1J7V7N_4kJ-fmswlisYtivgozA01s,3493
|
|
29
|
+
vtexpy-0.0.0b26.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
30
|
+
vtexpy-0.0.0b26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|