Encryptors 2.46__tar.gz → 2.48__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.
Files changed (91) hide show
  1. {encryptors-2.46 → encryptors-2.48}/PKG-INFO +1 -1
  2. {encryptors-2.46 → encryptors-2.48}/setup.py +1 -1
  3. {encryptors-2.46 → encryptors-2.48}/src/Encryptors.egg-info/PKG-INFO +1 -1
  4. {encryptors-2.46 → encryptors-2.48}/src/Encryptors.egg-info/SOURCES.txt +2 -1
  5. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Exception/ControlledException.py +9 -0
  6. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/_Helpers/_AuditHelper.py +10 -3
  7. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Helpers/AuditDispatcher.py +13 -12
  8. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Http/APIClient.py +16 -26
  9. encryptors-2.48/src/Osdental/Http/_Helpers.py +122 -0
  10. encryptors-2.48/src/Osdental/Models/ApiResponse.py +17 -0
  11. encryptors-2.48/src/Osdental/Shared/Enums/Message.py +40 -0
  12. encryptors-2.46/src/Osdental/Http/_Exceptions.py +0 -12
  13. encryptors-2.46/src/Osdental/Shared/Enums/Message.py +0 -39
  14. {encryptors-2.46 → encryptors-2.48}/README.md +0 -0
  15. {encryptors-2.46 → encryptors-2.48}/setup.cfg +0 -0
  16. {encryptors-2.46 → encryptors-2.48}/src/Encryptors.egg-info/dependency_links.txt +0 -0
  17. {encryptors-2.46 → encryptors-2.48}/src/Encryptors.egg-info/entry_points.txt +0 -0
  18. {encryptors-2.46 → encryptors-2.48}/src/Encryptors.egg-info/requires.txt +0 -0
  19. {encryptors-2.46 → encryptors-2.48}/src/Encryptors.egg-info/top_level.txt +0 -0
  20. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Cli/__init__.py +0 -0
  21. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Database/BaseRepository.py +0 -0
  22. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Database/Connection.py +0 -0
  23. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Database/__init__.py +0 -0
  24. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Decorators/Grpc.py +0 -0
  25. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Decorators/PublicResolver.py +0 -0
  26. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Decorators/Retry.py +0 -0
  27. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Decorators/SecureResolver.py +0 -0
  28. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Decorators/SqlDataNormalizer.py +0 -0
  29. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Decorators/__init__.py +0 -0
  30. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/Aes.py +0 -0
  31. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/Argon2.py +0 -0
  32. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/Bcrypt.py +0 -0
  33. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/Jwt.py +0 -0
  34. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/Rsa.py +0 -0
  35. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/Sha512.py +0 -0
  36. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Encryptor/__init__.py +0 -0
  37. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Exception/__init__.py +0 -0
  38. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/Extensions/AuditExtension.py +0 -0
  39. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/Extensions/__init__.py +0 -0
  40. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/Models/__init__.py +0 -0
  41. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/_Exceptions/__init__.py +0 -0
  42. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/_Helpers/_ExtractAuthToken.py +0 -0
  43. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/_Helpers/_TenantPolicy.py +0 -0
  44. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/_Helpers/_TokenService.py +0 -0
  45. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/_Helpers/__init__.py +0 -0
  46. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Graphql/__init__.py +0 -0
  47. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Helpers/KeyVaultService.py +0 -0
  48. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Helpers/ResponseDecryptor.py +0 -0
  49. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Helpers/__init__.py +0 -0
  50. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Http/__init__.py +0 -0
  51. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Messaging/AzureServiceBus.py +0 -0
  52. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Messaging/Kafka.py +0 -0
  53. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Messaging/RabbitMQ.py +0 -0
  54. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Messaging/__init__.py +0 -0
  55. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Models/AuditConfig.py +0 -0
  56. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Models/Response.py +0 -0
  57. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Models/Token.py +0 -0
  58. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Models/_Audit.py +0 -0
  59. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Models/__init__.py +0 -0
  60. {encryptors-2.46 → encryptors-2.48}/src/Osdental/RedisCache/Redis.py +0 -0
  61. {encryptors-2.46 → encryptors-2.48}/src/Osdental/RedisCache/__init__.py +0 -0
  62. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Rest/Context/RequestContext.py +0 -0
  63. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Rest/Context/__init__.py +0 -0
  64. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Rest/Middlewares/RequestContextMiddleware.py +0 -0
  65. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Rest/Middlewares/__init__.py +0 -0
  66. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Rest/__init__.py +0 -0
  67. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Enums/Code.py +0 -0
  68. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Enums/Constant.py +0 -0
  69. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Enums/FileType.py +0 -0
  70. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Enums/GrahpqlOperation.py +0 -0
  71. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Enums/Profile.py +0 -0
  72. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Enums/__init__.py +0 -0
  73. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Logger.py +0 -0
  74. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/CaseConverter.py +0 -0
  75. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/CodeGenerator.py +0 -0
  76. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/DataNormalizer.py +0 -0
  77. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/DataUtils.py +0 -0
  78. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/DateUtils.py +0 -0
  79. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/FileMetaData.py +0 -0
  80. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/HashValidator.py +0 -0
  81. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/Mapper.py +0 -0
  82. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/PasswordGenerator.py +0 -0
  83. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/QueryGenerator.py +0 -0
  84. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/RsaUtils.py +0 -0
  85. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/TextProcessor.py +0 -0
  86. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/Utils/__init__.py +0 -0
  87. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Shared/__init__.py +0 -0
  88. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Storage/AzureBlobStorage.py +0 -0
  89. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Storage/S3Storage.py +0 -0
  90. {encryptors-2.46 → encryptors-2.48}/src/Osdental/Storage/__init__.py +0 -0
  91. {encryptors-2.46 → encryptors-2.48}/src/Osdental/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Encryptors
3
- Version: 2.46
3
+ Version: 2.48
4
4
  Summary: End-to-end algorithm library
5
5
  Author: OSDental LLC
6
6
  Author-email: support@osdental.ai
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
  # ANDERSON ESTO YA SE SUBIO Y ESTA ESTABLE, AUN TE QUEDA PENDIENTE LA AUDITORIA CON RSA Y AES DE ACCESSTOKEN
3
3
  setup(
4
4
  name="Encryptors",
5
- version="2.46",
5
+ version="2.48",
6
6
  author="OSDental LLC",
7
7
  author_email="support@osdental.ai",
8
8
  description="End-to-end algorithm library",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Encryptors
3
- Version: 2.46
3
+ Version: 2.48
4
4
  Summary: End-to-end algorithm library
5
5
  Author: OSDental LLC
6
6
  Author-email: support@osdental.ai
@@ -41,12 +41,13 @@ src/Osdental/Helpers/KeyVaultService.py
41
41
  src/Osdental/Helpers/ResponseDecryptor.py
42
42
  src/Osdental/Helpers/__init__.py
43
43
  src/Osdental/Http/APIClient.py
44
- src/Osdental/Http/_Exceptions.py
44
+ src/Osdental/Http/_Helpers.py
45
45
  src/Osdental/Http/__init__.py
46
46
  src/Osdental/Messaging/AzureServiceBus.py
47
47
  src/Osdental/Messaging/Kafka.py
48
48
  src/Osdental/Messaging/RabbitMQ.py
49
49
  src/Osdental/Messaging/__init__.py
50
+ src/Osdental/Models/ApiResponse.py
50
51
  src/Osdental/Models/AuditConfig.py
51
52
  src/Osdental/Models/Response.py
52
53
  src/Osdental/Models/Token.py
@@ -147,5 +147,14 @@ class InvalidFormatException(OSDException):
147
147
  message: str = Message.INVALID_FORMAT_MSG,
148
148
  error: str = None,
149
149
  status_code: str = Code.INVALID_FORMAT_CODE
150
+ ):
151
+ super().__init__(message=message, error=error, status_code=status_code)
152
+
153
+ class HttpClientException(OSDException):
154
+ def __init__(
155
+ self,
156
+ message: str = Message.EXTERNAL_API_ERROR_MESSAGE,
157
+ error: str = None,
158
+ status_code: str = Code.HTTP_ERROR_CODE
150
159
  ):
151
160
  super().__init__(message=message, error=error, status_code=status_code)
@@ -48,13 +48,20 @@ class AuditHelper:
48
48
  @staticmethod
49
49
  def build_final_payload(
50
50
  _type: Literal["RESPONSE", "ERROR"],
51
- status_code: Any,
51
+ status_code: int,
52
52
  result: Optional[Any] = None,
53
- error: Optional[Any] = "*"
53
+ error: Optional[Any] = None
54
54
  ) -> Dict[str, Any]:
55
+
56
+ result = "*" if result is None else result
57
+ error = "*" if error is None else error
58
+
59
+ if isinstance(result, (dict, list)):
60
+ result = json.dumps(result)
61
+
55
62
  return {
56
63
  "type": _type,
57
64
  "httpResponseCode": status_code,
58
- "messageOut": json.dumps(result) if isinstance(result, dict) else "*",
65
+ "messageOut": result,
59
66
  "errorProducer": error
60
67
  }
@@ -1,5 +1,5 @@
1
1
  import asyncio
2
- from typing import Dict, Any
2
+ from typing import Dict, Any, Optional
3
3
  from fastapi import Request
4
4
  from Osdental.Models.AuditConfig import AuditConfig
5
5
  from Osdental.Messaging import IMessageQueue
@@ -7,6 +7,7 @@ from Osdental.Graphql._Helpers._AuditHelper import AuditHelper
7
7
  from Osdental.Helpers.ResponseDecryptor import decryptor_data, VALID_TYPES
8
8
  from Osdental.Models._Audit import Audit
9
9
  from Osdental.Models.Response import Response
10
+ from Osdental.Models.ApiResponse import ApiResponse
10
11
  from Osdental.Shared.Enums.Constant import Constant
11
12
  from Osdental.Shared.Logger import logger
12
13
 
@@ -39,8 +40,8 @@ class AuditDispatcher:
39
40
  self,
40
41
  request: Request,
41
42
  request_payload: Dict[str, Any],
42
- result: Response,
43
- metadata: Dict[str, Any],
43
+ result: Response | ApiResponse,
44
+ metadata: Optional[Dict[str, Any]] = None,
44
45
  audit_type: str = None
45
46
  ):
46
47
  try:
@@ -77,10 +78,9 @@ class AuditDispatcher:
77
78
  async def _process(self, payload: Dict[str, Any]) -> None:
78
79
  request = payload["request"]
79
80
  request_payload = payload["request_payload"]
80
- result: Response = payload["result"]
81
+ result: Response | ApiResponse = payload["result"]
81
82
  audit_type = payload["audit_type"]
82
- metadata = payload["metadata"]
83
-
83
+
84
84
  operation_name = request_payload.get("operation_name")
85
85
  if operation_name == 'UnknownOperation':
86
86
  logger.info("Skipping audit: no data in GraphQL response")
@@ -101,10 +101,6 @@ class AuditDispatcher:
101
101
  data = result.data
102
102
  error = result.error if result.error else message
103
103
 
104
- # Obtencion de campos adicionales cuando es otro tipo de encriptacion o clave
105
- encryption_type = result.encryption_type
106
- decrypted_key = metadata.get("decrypted_key")
107
-
108
104
  if audit_type == Constant.MESSAGE_LOG_INTERNAL:
109
105
 
110
106
  ERROR_PREFIXES = ("DB_ERROR", "DB_WARNING")
@@ -128,8 +124,13 @@ class AuditDispatcher:
128
124
  audit_message = request_audit_payload | payload
129
125
 
130
126
  else:
131
- if encryption_type in VALID_TYPES and decrypted_key and data:
132
- data = decryptor_data(encryption_type, decrypted_key, data)
127
+ if isinstance(result, Response):
128
+ metadata = payload["metadata"]
129
+ encryption_type = result.encryption_type
130
+ decrypted_key = metadata.get("decrypted_key")
131
+
132
+ if encryption_type in VALID_TYPES and decrypted_key and data:
133
+ data = decryptor_data(encryption_type, decrypted_key, data)
133
134
 
134
135
  payload = AuditHelper.build_final_payload(
135
136
  _type="RESPONSE",
@@ -1,10 +1,11 @@
1
1
  import httpx
2
2
  from typing import Optional, Dict, Any
3
3
  from Osdental.Decorators.Retry import rest_retry
4
- from Osdental.Rest.Context.RequestContext import current_context
5
- from Osdental.Models.Response import Response
6
- from Osdental.Http._Exceptions import HttpClientException
7
- from Osdental.Shared.Enums.Constant import Constant
4
+ from Osdental.Http._Helpers import (
5
+ audit_success, audit_http_error, audit_exception_error,
6
+ audit_unknown_error, audit_graphql_error
7
+ )
8
+ from Osdental.Exception.ControlledException import HttpClientException
8
9
  from Osdental.Shared.Logger import logger
9
10
 
10
11
  class APIClient:
@@ -37,33 +38,15 @@ class APIClient:
37
38
  **kwargs
38
39
  )
39
40
 
40
- ctx = current_context.get()
41
-
42
- if ctx and ctx.request:
43
- request = ctx.request
44
-
45
- dispatcher = request.app.state.audit_dispatcher
46
- dispatcher.dispatch(
47
- request=request,
48
- request_payload={
49
- "operation_name": "ExternalAPI",
50
- "query": url,
51
- "variables": kwargs.get("json") or kwargs.get("params")
52
- },
53
- result=Response(
54
- status=response.status_code,
55
- message="External API",
56
- data=response.text
57
- ),
58
- audit_type=Constant.MESSAGE_LOG_EXTERNAL
59
- )
60
-
61
41
  response.raise_for_status()
62
42
 
43
+ audit_success(response, method, url, kwargs)
44
+
63
45
  return response
64
46
 
65
47
  except httpx.HTTPStatusError as exc:
66
-
48
+
49
+ audit_http_error(exc.response, method, url, kwargs)
67
50
  raise HttpClientException(
68
51
  status_code=exc.response.status_code,
69
52
  message=exc.response.text
@@ -71,11 +54,17 @@ class APIClient:
71
54
 
72
55
  except httpx.RequestError as exc:
73
56
 
57
+ audit_exception_error(exc, method, url, kwargs)
74
58
  raise HttpClientException(
75
59
  status_code=0,
76
60
  message=str(exc)
77
61
  ) from exc
78
62
 
63
+ except Exception as exc:
64
+
65
+ audit_unknown_error(exc, method, url, kwargs)
66
+
67
+ raise
79
68
 
80
69
  async def request(
81
70
  self,
@@ -131,6 +120,7 @@ class APIClient:
131
120
  f"GraphQL error: {data['errors']}"
132
121
  )
133
122
 
123
+ audit_graphql_error(data["errors"], url, payload)
134
124
  raise HttpClientException(
135
125
  message="GraphQL execution failed",
136
126
  error=str(data["errors"])
@@ -0,0 +1,122 @@
1
+ from Osdental.Rest.Context.RequestContext import current_context
2
+ from Osdental.Models.ApiResponse import ApiResponse
3
+ from Osdental.Shared.Enums.Constant import Constant
4
+ from Osdental.Shared.Logger import logger
5
+
6
+ """
7
+ Helpers to control external API audit logging.
8
+ """
9
+
10
+ def _get_dispatcher():
11
+ try:
12
+ ctx = current_context.get()
13
+ if ctx and ctx.request:
14
+ return ctx.request, ctx.request.app.state.audit_dispatcher
15
+ except Exception:
16
+ return None, None
17
+ return None, None
18
+
19
+ def _safe_dispatch(**kwargs):
20
+ try:
21
+ _, dispatcher = _get_dispatcher()
22
+ if dispatcher:
23
+ dispatcher.dispatch(**kwargs)
24
+ except Exception as e:
25
+ logger.error(f"Audit error: {str(e)}")
26
+
27
+ def _build_payload(method, url, kwargs):
28
+ return {
29
+ "operation_name": "ExternalAPI",
30
+ "method": method,
31
+ "query": url,
32
+ "variables": kwargs.get("json") or kwargs.get("params")
33
+ }
34
+
35
+ # ✅ Success
36
+ def audit_success(response, method, url, kwargs):
37
+ request, _ = _get_dispatcher()
38
+ if not request:
39
+ return
40
+
41
+ _safe_dispatch(
42
+ request=request,
43
+ request_payload=_build_payload(method, url, kwargs),
44
+ result=ApiResponse(
45
+ status=response.status_code,
46
+ message="External API SUCCESS",
47
+ data=response.text
48
+ ),
49
+ audit_type=Constant.MESSAGE_LOG_EXTERNAL
50
+ )
51
+
52
+ # ❌ HTTP Error
53
+ def audit_http_error(response, method, url, kwargs):
54
+ request, _ = _get_dispatcher()
55
+ if not request:
56
+ return
57
+
58
+ _safe_dispatch(
59
+ request=request,
60
+ request_payload=_build_payload(method, url, kwargs),
61
+ result=ApiResponse(
62
+ status=response.status_code,
63
+ message="External API ERROR",
64
+ error=response.text
65
+ ),
66
+ audit_type=Constant.MESSAGE_LOG_EXTERNAL
67
+ )
68
+
69
+ # ❌ Network Error
70
+ def audit_exception_error(exc, method, url, kwargs):
71
+ request, _ = _get_dispatcher()
72
+ if not request:
73
+ return
74
+
75
+ _safe_dispatch(
76
+ request=request,
77
+ request_payload=_build_payload(method, url, kwargs),
78
+ result=ApiResponse(
79
+ status=0,
80
+ message="External API NETWORK ERROR",
81
+ error=str(exc)
82
+ ),
83
+ audit_type=Constant.MESSAGE_LOG_EXTERNAL
84
+ )
85
+
86
+ # ❌ Unknown Error
87
+ def audit_unknown_error(exc, method, url, kwargs):
88
+ request, _ = _get_dispatcher()
89
+ if not request:
90
+ return
91
+
92
+ _safe_dispatch(
93
+ request=request,
94
+ request_payload=_build_payload(method, url, kwargs),
95
+ result=ApiResponse(
96
+ status=0,
97
+ message="External API UNKNOWN ERROR",
98
+ error=str(exc)
99
+ ),
100
+ audit_type=Constant.MESSAGE_LOG_EXTERNAL
101
+ )
102
+
103
+ # ❌ GraphQL Error
104
+ def audit_graphql_error(errors, url, payload):
105
+ request, _ = _get_dispatcher()
106
+ if not request:
107
+ return
108
+
109
+ _safe_dispatch(
110
+ request=request,
111
+ request_payload={
112
+ "operation_name": "GraphQL",
113
+ "query": url,
114
+ "variables": payload
115
+ },
116
+ result=ApiResponse(
117
+ status=400,
118
+ message="GraphQL ERROR",
119
+ error=str(errors)
120
+ ),
121
+ audit_type=Constant.MESSAGE_LOG_EXTERNAL
122
+ )
@@ -0,0 +1,17 @@
1
+ from dataclasses import dataclass, field, asdict
2
+ from typing import Any, Optional
3
+ from Osdental.Shared.Enums.Code import Code
4
+ from Osdental.Shared.Enums.Message import Message
5
+
6
+ @dataclass
7
+ class ApiResponse:
8
+ status: Any = field(default=Code.PROCESS_SUCCESS_CODE)
9
+ message: str = field(default=Message.PROCESS_SUCCESS_MSG)
10
+ data: Optional[Any] = None
11
+ error: Optional[str] = None
12
+
13
+ def send(self):
14
+ api_response = asdict(self)
15
+
16
+ if api_response["error"] is None:
17
+ api_response.pop("error")
@@ -0,0 +1,40 @@
1
+ from enum import StrEnum
2
+
3
+ class Message(StrEnum):
4
+ ACCESS_DENIED_MSG = "You do not have the necessary privileges for this operation."
5
+ UNEXPECTED_ERROR_MSG = "Something went wrong while processing your request. Please try again later."
6
+ PORTAL_ACCESS_RESTRICTED_MSG = "You are not authorized to access this portal."
7
+ PROCESS_SUCCESS_MSG = "Process executed successfully."
8
+ NO_RESULTS_FOUND_MSG = "No records were found matching your request."
9
+ INVALID_REQUEST_PARAMS_MSG = "Please review the required fields and try again."
10
+ SERVER_NETWORK_ACCESS_ERROR_MSG = "Error making the server accessible on the network."
11
+ HEXAGONAL_SERVICE_CREATED_MSG = "The hexagonal service structure was created."
12
+ PYCACHE_CLEANUP_SUCCESS_MSG = "All __pycache__ have been removed."
13
+ NO_PASSWORD_CHARACTERS_MSG = "There are no characters available to generate the password."
14
+ INSUFFICIENT_LENGTH_MSG = "Insufficient length to meet minimum rules."
15
+ LEGACY_NAME_REQUIRED_MSG = "Legacy name cannot be empty."
16
+ REFRESH_TOKEN_EXP_REQUIRED_MSG = "Refresh token expiration time cannot be empty."
17
+ ACCESS_TOKEN_EXP_REQUIRED_MSG = "Access token expiration time cannot be empty."
18
+ PUBLIC_KEY2_REQUIRED_MSG = "Public key 2 cannot be empty."
19
+ PRIVATE_KEY1_REQUIRED_MSG = "Private key 1 cannot be empty."
20
+ PRIVATE_KEY2_REQUIRED_MSG = "Private key 2 cannot be empty."
21
+ AES_KEY_USER_REQUIRED_MSG = "AES key user cannot be empty."
22
+ AES_KEY_AUTH_REQUIRED_MSG = "AES key auth cannot be empty."
23
+ MISSING_FIELD_ERROR_MSG = "A required field is missing. Please review the data."
24
+ EXP_TIME_REQUIRED = "Expiration time (cdata integration) cannot be empty or null"
25
+ KEY_PRIVATE_REQUIRED = "Key private cannot be empty or null"
26
+ SUB_ACCOUNT_REQUIRED = "Sub account parameter is required"
27
+ CATALOG_DATA_CREDENTIALS_MISSED = "Catalog data or/and data credentials not found"
28
+ PROFILE_PERMISSION_DENIED_MSG = "Your profile does not have permission to perform this action."
29
+ INVALID_FORMAT_MSG = "The provided data format is invalid."
30
+ INVALID_AES_JSON_FORMAT_MSG = "Invalid JSON format in AES decrypted data."
31
+ UNEXPECTED_DECRYPTED_DATA_FORMAT_MSG = "Unexpected format in decrypted data."
32
+ REDIS_CLEANUP_SUCCESS_MSG = "Redis cleanup completed successfully."
33
+ REDIS_CLEANUP_ERROR_MSG = "An error occurred while attempting to clean up Redis."
34
+ DATABASE_EXECUTION_ERROR_MSG = "An unexpected error occurred while executing a database operation."
35
+ DATABASE_INTEGRITY_ERROR_MSG = "A database integrity constraint was violated during execution."
36
+ QUERY_NOT_PROVIDED_MSG = "Query not provided. Please include a valid query in your request."
37
+ FILE_PATH_NOT_PROVIDED_MSG = "File path not provided."
38
+ PROTO_FILES_GENERATED_MSG = "Proto files have been successfully generated."
39
+ ERROR_INVALID_DATA_TYPE = "Invalid data type: expected dict, str, or list."
40
+ EXTERNAL_API_ERROR_MESSAGE = "An error occurred while consuming an external API."
@@ -1,12 +0,0 @@
1
- from Osdental.Exception.ControlledException import OSDException
2
- from Osdental.Shared.Enums.Code import Code
3
- from Osdental.Shared.Enums.Message import Message
4
-
5
- class HttpClientException(OSDException):
6
- def __init__(
7
- self,
8
- message: str = Message.UNEXPECTED_ERROR_MSG,
9
- error: str = None,
10
- status_code: str = Code.HTTP_ERROR_CODE
11
- ):
12
- super().__init__(message=message, error=error, status_code=status_code)
@@ -1,39 +0,0 @@
1
- from enum import StrEnum
2
-
3
- class Message(StrEnum):
4
- ACCESS_DENIED_MSG = "You do not have the necessary privileges for this operation."
5
- UNEXPECTED_ERROR_MSG = 'Something went wrong while processing your request. Please try again later.'
6
- PORTAL_ACCESS_RESTRICTED_MSG = 'You are not authorized to access this portal.'
7
- PROCESS_SUCCESS_MSG = 'Process executed successfully.'
8
- NO_RESULTS_FOUND_MSG = 'No records were found matching your request.'
9
- INVALID_REQUEST_PARAMS_MSG = 'Please review the required fields and try again.'
10
- SERVER_NETWORK_ACCESS_ERROR_MSG = 'Error making the server accessible on the network.'
11
- HEXAGONAL_SERVICE_CREATED_MSG = 'The hexagonal service structure was created.'
12
- PYCACHE_CLEANUP_SUCCESS_MSG = 'All __pycache__ have been removed.'
13
- NO_PASSWORD_CHARACTERS_MSG = 'There are no characters available to generate the password.'
14
- INSUFFICIENT_LENGTH_MSG = 'Insufficient length to meet minimum rules.'
15
- LEGACY_NAME_REQUIRED_MSG = 'Legacy name cannot be empty.'
16
- REFRESH_TOKEN_EXP_REQUIRED_MSG = 'Refresh token expiration time cannot be empty.'
17
- ACCESS_TOKEN_EXP_REQUIRED_MSG = 'Access token expiration time cannot be empty.'
18
- PUBLIC_KEY2_REQUIRED_MSG = 'Public key 2 cannot be empty.'
19
- PRIVATE_KEY1_REQUIRED_MSG = 'Private key 1 cannot be empty.'
20
- PRIVATE_KEY2_REQUIRED_MSG = 'Private key 2 cannot be empty.'
21
- AES_KEY_USER_REQUIRED_MSG = 'AES key user cannot be empty.'
22
- AES_KEY_AUTH_REQUIRED_MSG = 'AES key auth cannot be empty.'
23
- MISSING_FIELD_ERROR_MSG = 'A required field is missing. Please review the data.'
24
- EXP_TIME_REQUIRED = 'Expiration time (cdata integration) cannot be empty or null'
25
- KEY_PRIVATE_REQUIRED = 'Key private cannot be empty or null'
26
- SUB_ACCOUNT_REQUIRED = 'Sub account parameter is required'
27
- CATALOG_DATA_CREDENTIALS_MISSED = 'Catalog data or/and data credentials not found'
28
- PROFILE_PERMISSION_DENIED_MSG = 'Your profile does not have permission to perform this action.'
29
- INVALID_FORMAT_MSG = 'The provided data format is invalid.'
30
- INVALID_AES_JSON_FORMAT_MSG = 'Invalid JSON format in AES decrypted data.'
31
- UNEXPECTED_DECRYPTED_DATA_FORMAT_MSG = 'Unexpected format in decrypted data.'
32
- REDIS_CLEANUP_SUCCESS_MSG = 'Redis cleanup completed successfully.'
33
- REDIS_CLEANUP_ERROR_MSG = 'An error occurred while attempting to clean up Redis.'
34
- DATABASE_EXECUTION_ERROR_MSG = 'An unexpected error occurred while executing a database operation.'
35
- DATABASE_INTEGRITY_ERROR_MSG = 'A database integrity constraint was violated during execution.'
36
- QUERY_NOT_PROVIDED_MSG = 'Query not provided. Please include a valid query in your request.'
37
- FILE_PATH_NOT_PROVIDED_MSG = 'File path not provided.'
38
- PROTO_FILES_GENERATED_MSG = 'Proto files have been successfully generated.'
39
- ERROR_INVALID_DATA_TYPE = 'Invalid data type: expected dict, str, or list.'
File without changes
File without changes