tp-common 0.0.1__py3-none-any.whl → 0.0.3__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.
@@ -0,0 +1,138 @@
1
+ """Исключения для базового HTTP клиента."""
2
+
3
+
4
+ class ClientException(Exception):
5
+ """Базовое исключение для всех ошибок клиента."""
6
+
7
+ def __init__(
8
+ self,
9
+ message: str,
10
+ url: str | None = None,
11
+ status_code: int | None = None,
12
+ response_body: str | None = None,
13
+ ) -> None:
14
+ super().__init__(message)
15
+ self.url = url
16
+ self.status_code = status_code
17
+ self.response_body = response_body
18
+
19
+
20
+
21
+ class ClientResponseErrorException(ClientException):
22
+ """Исключение при неуспешном HTTP статусе (>=400)."""
23
+
24
+ def __init__(
25
+ self,
26
+ message: str,
27
+ url: str | None = None,
28
+ status_code: int | None = None,
29
+ response_body: str | None = None,
30
+ ) -> None:
31
+ super().__init__(message, url, status_code, response_body)
32
+
33
+ class ClientConnectionException(ClientException):
34
+ """Исключение при ошибке соединения (не удалось установить соединение)."""
35
+
36
+ def __init__(
37
+ self,
38
+ message: str,
39
+ url: str | None = None,
40
+ ) -> None:
41
+ super().__init__(message, url)
42
+
43
+ class ClientTimeoutException(ClientConnectionException):
44
+ """Исключение при таймауте соединения."""
45
+
46
+ def __init__(
47
+ self,
48
+ message: str,
49
+ url: str | None = None,
50
+ ) -> None:
51
+ super().__init__(message, url)
52
+
53
+
54
+ class ClientProxyException(ClientConnectionException):
55
+ """Исключение при ошибке прокси."""
56
+
57
+ def __init__(
58
+ self,
59
+ message: str,
60
+ url: str | None = None,
61
+ proxy: str | None = None,
62
+ ) -> None:
63
+ super().__init__(message, url)
64
+ self.proxy = proxy
65
+
66
+
67
+
68
+
69
+
70
+ class ClientDNSException(ClientConnectionException):
71
+ """Исключение при ошибке DNS (не удалось разрешить доменное имя)."""
72
+
73
+ def __init__(
74
+ self,
75
+ message: str,
76
+ url: str | None = None,
77
+ ) -> None:
78
+ super().__init__(message, url)
79
+
80
+
81
+ class ClientBusinessErrorException(ClientException):
82
+ """Базовое исключение для бизнес-ошибок (400, 401, 403, 404, 422)."""
83
+
84
+ pass
85
+
86
+
87
+ class ClientServerErrorException(ClientException):
88
+ """Базовое исключение для ошибок сервера (500, 502, 503, 504)."""
89
+
90
+ pass
91
+
92
+
93
+ class BaseNetworkErrorException(ClientException):
94
+ """Базовое исключение для сетевых ошибок (таймауты, соединение, DNS)."""
95
+
96
+ pass
97
+
98
+
99
+ class ClientProxyErrorException(ClientException):
100
+ """Базовое исключение для ошибок прокси."""
101
+
102
+ pass
103
+
104
+
105
+ class ClientAuthorizationException(ClientBusinessErrorException):
106
+ """Исключение при ошибке авторизации (401, 403)."""
107
+
108
+ pass
109
+
110
+
111
+ class ClientValidationException(ClientBusinessErrorException):
112
+ """Исключение при ошибке валидации данных (400, 422)."""
113
+
114
+ pass
115
+
116
+
117
+ class ClientResourceNotFoundException(ClientBusinessErrorException):
118
+ """Исключение при отсутствии ресурса (404)."""
119
+
120
+ pass
121
+
122
+
123
+ class ClientServerException(ClientServerErrorException):
124
+ """Исключение при ошибке сервера (500, 502, 503, 504)."""
125
+
126
+ pass
127
+
128
+
129
+ class ClientTooManyRequestsException(ClientProxyErrorException):
130
+ """Исключение при превышении лимита запросов (429)."""
131
+
132
+ pass
133
+
134
+
135
+ class ClientServiceUnavailableException(ClientServerErrorException):
136
+ """Исключение при недоступности сервиса (502, 503, 504)."""
137
+
138
+ pass
@@ -1,12 +1,17 @@
1
- from pydantic import BaseModel, ConfigDict
2
- from pydantic.alias_generators import to_camel
3
-
4
-
5
- class BaseRequest(BaseModel):
6
- model_config = ConfigDict(
7
- alias_generator=to_camel,
8
- validate_by_name=True,
9
- validate_by_alias=True,
10
- serialize_by_alias=True,
11
- populate_by_name=True,
12
- )
1
+ class BaseResponse(BaseModel):
2
+ model_config = ConfigDict(
3
+ alias_generator=to_camel,
4
+ validate_by_name=True,
5
+ validate_by_alias=True,
6
+ serialize_by_alias=True,
7
+ )
8
+
9
+
10
+ class BaseRequest(BaseModel):
11
+ model_config = ConfigDict(
12
+ alias_generator=to_camel,
13
+ validate_by_name=True,
14
+ validate_by_alias=True,
15
+ serialize_by_alias=True,
16
+ populate_by_name=True,
17
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tp-common
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary:
5
5
  Author: Developer
6
6
  Author-email: front-gold@mail.ru
@@ -0,0 +1,6 @@
1
+ tp_common/base_client/client.py,sha256=uE-eYkMXGis6czGjm10euvv9j2QBjHJMHNp_qP5HDNw,24399
2
+ tp_common/base_client/exceptions.py,sha256=l5CjxkBH3bUBCDuNc3sz_ygNG4ccO1odRlDiL7EmAwg,3839
3
+ tp_common/route/shames.py,sha256=2R63rNmkuK942bCitnjonAU8aPvqCr2G52N1gefwN1U,428
4
+ tp_common-0.0.3.dist-info/METADATA,sha256=iG-RfBU4cTTP7oqWq1AtGe_G7RMmcTb7p3NzVW7lv60,6582
5
+ tp_common-0.0.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
6
+ tp_common-0.0.3.dist-info/RECORD,,
tp_common/__init__.py DELETED
@@ -1,52 +0,0 @@
1
- from tp_common.base.base_client.base_client import BaseClient
2
- from tp_common.base.base_client.base_exception import BaseInfrastructureException
3
- from tp_common.base.base_client.base_request import BaseRequest
4
- from tp_common.base.base_client.base_response import BaseResponse
5
- from tp_common.base.base_client.client_exceptions import (
6
- BaseClientException,
7
- ClientConnectionException,
8
- ClientDNSException,
9
- ClientProxyException,
10
- ClientResponseErrorException,
11
- ClientTimeoutException,
12
- )
13
- from tp_common.base.base_client.domain_exceptions import (
14
- AuthorizationException,
15
- BaseBusinessErrorException,
16
- BaseNetworkErrorException,
17
- BaseProxyErrorException,
18
- BaseServerErrorException,
19
- ResourceNotFoundException,
20
- ServerException,
21
- ServiceUnavailableException,
22
- TooManyRequestsException,
23
- ValidationException,
24
- )
25
- from tp_common.logging import Logger, TracingLogger
26
-
27
- __all__ = [
28
- # BaseClient
29
- "BaseClient",
30
- "BaseInfrastructureException",
31
- "BaseRequest",
32
- "BaseResponse",
33
- "BaseClientException",
34
- "ClientResponseErrorException",
35
- "ClientTimeoutException",
36
- "ClientProxyException",
37
- "ClientConnectionException",
38
- "ClientDNSException",
39
- "BaseBusinessErrorException",
40
- "BaseServerErrorException",
41
- "BaseNetworkErrorException",
42
- "BaseProxyErrorException",
43
- "AuthorizationException",
44
- "ValidationException",
45
- "ResourceNotFoundException",
46
- "ServerException",
47
- "TooManyRequestsException",
48
- "ServiceUnavailableException",
49
- # Logging
50
- "TracingLogger",
51
- "Logger",
52
- ]
File without changes
@@ -1,2 +0,0 @@
1
- class BaseInfrastructureException(Exception):
2
- pass
@@ -1,11 +0,0 @@
1
- from pydantic import BaseModel, ConfigDict
2
- from pydantic.alias_generators import to_camel
3
-
4
-
5
- class BaseResponse(BaseModel):
6
- model_config = ConfigDict(
7
- alias_generator=to_camel,
8
- validate_by_name=True,
9
- validate_by_alias=True,
10
- serialize_by_alias=True,
11
- )
@@ -1,76 +0,0 @@
1
- """Исключения для базового HTTP клиента."""
2
-
3
-
4
- class BaseClientException(Exception):
5
- """Базовое исключение для всех ошибок клиента."""
6
-
7
- def __init__(
8
- self,
9
- message: str,
10
- url: str | None = None,
11
- status_code: int | None = None,
12
- response_body: str | None = None,
13
- ) -> None:
14
- super().__init__(message)
15
- self.url = url
16
- self.status_code = status_code
17
- self.response_body = response_body
18
-
19
-
20
- class ClientResponseErrorException(BaseClientException):
21
- """Исключение при неуспешном HTTP статусе (>=400)."""
22
-
23
- def __init__(
24
- self,
25
- message: str,
26
- url: str | None = None,
27
- status_code: int | None = None,
28
- response_body: str | None = None,
29
- ) -> None:
30
- super().__init__(message, url, status_code, response_body)
31
-
32
-
33
- class ClientTimeoutException(BaseClientException):
34
- """Исключение при таймауте соединения."""
35
-
36
- def __init__(
37
- self,
38
- message: str,
39
- url: str | None = None,
40
- ) -> None:
41
- super().__init__(message, url)
42
-
43
-
44
- class ClientProxyException(BaseClientException):
45
- """Исключение при ошибке прокси."""
46
-
47
- def __init__(
48
- self,
49
- message: str,
50
- url: str | None = None,
51
- proxy: str | None = None,
52
- ) -> None:
53
- super().__init__(message, url)
54
- self.proxy = proxy
55
-
56
-
57
- class ClientConnectionException(BaseClientException):
58
- """Исключение при ошибке соединения (не удалось установить соединение)."""
59
-
60
- def __init__(
61
- self,
62
- message: str,
63
- url: str | None = None,
64
- ) -> None:
65
- super().__init__(message, url)
66
-
67
-
68
- class ClientDNSException(BaseClientException):
69
- """Исключение при ошибке DNS (не удалось разрешить доменное имя)."""
70
-
71
- def __init__(
72
- self,
73
- message: str,
74
- url: str | None = None,
75
- ) -> None:
76
- super().__init__(message, url)
@@ -1,63 +0,0 @@
1
- """Доменные исключения для обработки ошибок в воркерах."""
2
-
3
- from tp_common.base.base_client.client_exceptions import BaseClientException
4
-
5
-
6
- class BaseBusinessErrorException(BaseClientException):
7
- """Базовое исключение для бизнес-ошибок (400, 401, 403, 404, 422)."""
8
-
9
- pass
10
-
11
-
12
- class BaseServerErrorException(BaseClientException):
13
- """Базовое исключение для ошибок сервера (500, 502, 503, 504)."""
14
-
15
- pass
16
-
17
-
18
- class BaseNetworkErrorException(BaseClientException):
19
- """Базовое исключение для сетевых ошибок (таймауты, соединение, DNS)."""
20
-
21
- pass
22
-
23
-
24
- class BaseProxyErrorException(BaseClientException):
25
- """Базовое исключение для ошибок прокси."""
26
-
27
- pass
28
-
29
-
30
- class AuthorizationException(BaseBusinessErrorException):
31
- """Исключение при ошибке авторизации (401, 403)."""
32
-
33
- pass
34
-
35
-
36
- class ValidationException(BaseBusinessErrorException):
37
- """Исключение при ошибке валидации данных (400, 422)."""
38
-
39
- pass
40
-
41
-
42
- class ResourceNotFoundException(BaseBusinessErrorException):
43
- """Исключение при отсутствии ресурса (404)."""
44
-
45
- pass
46
-
47
-
48
- class ServerException(BaseServerErrorException):
49
- """Исключение при ошибке сервера (500, 502, 503, 504)."""
50
-
51
- pass
52
-
53
-
54
- class TooManyRequestsException(BaseProxyErrorException):
55
- """Исключение при превышении лимита запросов (429)."""
56
-
57
- pass
58
-
59
-
60
- class ServiceUnavailableException(BaseServerErrorException):
61
- """Исключение при недоступности сервиса (502, 503, 504)."""
62
-
63
- pass