maleo-foundation 0.3.55__tar.gz → 0.3.58__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 (148) hide show
  1. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/PKG-INFO +1 -1
  2. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/enums.py +58 -18
  3. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/maleo.py +26 -2
  4. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/service.py +11 -9
  5. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/middlewares/authentication.py +2 -2
  6. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/responses.py +60 -14
  7. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/result.py +73 -8
  8. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/cache/redis.py +3 -0
  9. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/client/maleo.py +4 -0
  10. maleo_foundation-0.3.58/maleo_foundation/models/transfers/results/client/controllers/http.py +41 -0
  11. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/client/service.py +1 -8
  12. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/service/general.py +1 -8
  13. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/__init__.py +0 -2
  14. maleo_foundation-0.3.58/maleo_foundation/utils/exceptions/__init__.py +0 -0
  15. maleo_foundation-0.3.58/maleo_foundation/utils/exceptions/client.py +221 -0
  16. maleo_foundation-0.3.58/maleo_foundation/utils/exceptions/request.py +38 -0
  17. maleo_foundation-0.3.58/maleo_foundation/utils/exceptions/service.py +221 -0
  18. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation.egg-info/PKG-INFO +1 -1
  19. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation.egg-info/SOURCES.txt +4 -1
  20. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/pyproject.toml +1 -1
  21. maleo_foundation-0.3.55/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -37
  22. maleo_foundation-0.3.55/maleo_foundation/utils/exceptions.py +0 -158
  23. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/README.md +0 -0
  24. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/__init__.py +0 -0
  25. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/authentication.py +0 -0
  26. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/authorization.py +0 -0
  27. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/__init__.py +0 -0
  28. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/manager.py +0 -0
  29. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/__init__.py +0 -0
  30. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/encryption/__init__.py +0 -0
  31. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/encryption/aes.py +0 -0
  32. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/encryption/rsa.py +0 -0
  33. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/hash/__init__.py +0 -0
  34. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
  35. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/hash/hmac.py +0 -0
  36. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/hash/sha256.py +0 -0
  37. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/key.py +0 -0
  38. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/signature.py +0 -0
  39. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/client/services/token.py +0 -0
  40. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/constants.py +0 -0
  41. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/__init__.py +0 -0
  42. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/client.py +0 -0
  43. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
  44. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
  45. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
  46. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/general.py +0 -0
  47. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/hash.py +0 -0
  48. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/key.py +0 -0
  49. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/service.py +0 -0
  50. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/signature.py +0 -0
  51. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/expanded_types/token.py +0 -0
  52. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/extended_types.py +0 -0
  53. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/__init__.py +0 -0
  54. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/cache.py +0 -0
  55. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/__init__.py +0 -0
  56. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/base.py +0 -0
  57. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/google/__init__.py +0 -0
  58. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/google/base.py +0 -0
  59. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/google/parameter.py +0 -0
  60. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/google/secret.py +0 -0
  61. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/google/storage.py +0 -0
  62. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/client/google/subscription.py +0 -0
  63. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/configuration.py +0 -0
  64. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/credential.py +0 -0
  65. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/db.py +0 -0
  66. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/managers/middleware.py +0 -0
  67. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/middlewares/base.py +0 -0
  68. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/middlewares/cors.py +0 -0
  69. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/__init__.py +0 -0
  70. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/__init__.py +0 -0
  71. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/encryption.py +0 -0
  72. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/general.py +0 -0
  73. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/hash.py +0 -0
  74. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/key.py +0 -0
  75. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/parameter.py +0 -0
  76. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/signature.py +0 -0
  77. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/schemas/token.py +0 -0
  78. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/table.py +0 -0
  79. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/__init__.py +0 -0
  80. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  81. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/__init__.py +0 -0
  82. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/cache/__init__.py +0 -0
  83. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/client/__init__.py +0 -0
  84. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/database.py +0 -0
  85. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/middleware.py +0 -0
  86. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/configurations/service.py +0 -0
  87. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/credentials.py +0 -0
  88. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/data.py +0 -0
  89. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/database.py +0 -0
  90. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/key.py +0 -0
  91. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/request.py +0 -0
  92. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/settings.py +0 -0
  93. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/signature.py +0 -0
  94. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/general/token.py +0 -0
  95. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  96. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  97. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
  98. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
  99. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
  100. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  101. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
  102. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
  103. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
  104. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
  105. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/key.py +0 -0
  106. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  107. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  108. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  109. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  110. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  111. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  112. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
  113. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
  114. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
  115. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/hash.py +0 -0
  116. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/key.py +0 -0
  117. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  118. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  119. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  120. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/signature.py +0 -0
  121. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/models/transfers/results/token.py +0 -0
  122. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/rest_controller_result.py +0 -0
  123. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/types.py +0 -0
  124. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/cache.py +0 -0
  125. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/client.py +0 -0
  126. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/controller.py +0 -0
  127. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/dependencies/__init__.py +0 -0
  128. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/dependencies/auth.py +0 -0
  129. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/dependencies/context.py +0 -0
  130. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/extractor.py +0 -0
  131. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/formatter/__init__.py +0 -0
  132. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/formatter/case.py +0 -0
  133. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/__init__.py +0 -0
  134. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
  135. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/credential/google.py +0 -0
  136. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/json.py +0 -0
  137. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
  138. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
  139. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/loaders/yaml.py +0 -0
  140. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/logging.py +0 -0
  141. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/merger.py +0 -0
  142. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/query.py +0 -0
  143. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/repository.py +0 -0
  144. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation/utils/searcher.py +0 -0
  145. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  146. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation.egg-info/requires.txt +0 -0
  147. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/maleo_foundation.egg-info/top_level.txt +0 -0
  148. {maleo_foundation-0.3.55 → maleo_foundation-0.3.58}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.3.55
3
+ Version: 0.3.58
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -67,19 +67,69 @@ class BaseEnums:
67
67
  REFRESH = "refresh"
68
68
  ACCESS = "access"
69
69
 
70
- class StatusUpdateType(StrEnum):
71
- ACTIVATE = "activate"
72
- DEACTIVATE = "deactivate"
73
- RESTORE = "restore"
74
- DELETE = "delete"
70
+ class ExceptionType(StrEnum):
71
+ TIMEOUT = "timeout"
72
+ UNAUTHORIZED = "unauthorized"
73
+ FORBIDDEN = "forbidden"
74
+ NOT_FOUND = "not_found"
75
+ VALIDATION = "validation"
76
+ INTERNAL = "internal"
77
+ UNAVAILABLE = "unavailable"
78
+
79
+ class OperationOrigin(StrEnum):
80
+ SERVICE = "service"
81
+ CLIENT = "client"
75
82
 
76
- class UpdateType(StrEnum):
77
- STATUS = "status"
78
- DATA = "data"
83
+ class ServiceOperationLayer(StrEnum):
84
+ ROUTER = "router"
85
+ CONTROLLER = "controller"
86
+ SERVICE = "service"
87
+ REPOSITORY = "repository"
88
+
89
+ class ClientOperationLayer(StrEnum):
90
+ CONTROLLER = "controller"
91
+ SERVICE = "service"
92
+
93
+ class OperationLayer(StrEnum):
94
+ ROUTER = "router"
95
+ CONTROLLER = "controller"
96
+ SERVICE = "service"
97
+ REPOSITORY = "repository"
98
+
99
+ class ServiceOperationTarget(StrEnum):
100
+ CACHE = "cache"
101
+ DATABASE = "database"
102
+ MICROSERVICE = "microservice"
103
+ THIRD_PARTY = "third_party"
104
+
105
+ class ClientOperationTarget(StrEnum):
106
+ CACHE = "cache"
107
+ CONTROLLER = "controller"
108
+
109
+ class OperationTarget(StrEnum):
110
+ CACHE = "cache"
111
+ CONTROLLER = "controller"
112
+ DATABASE = "database"
113
+ MICROSERVICE = "microservice"
114
+ THIRD_PARTY = "third_party"
79
115
 
80
116
  class OperationType(StrEnum):
81
117
  CREATE = "create"
118
+ READ = "read"
82
119
  UPDATE = "update"
120
+ DELETE = "delete"
121
+
122
+ class CreateType(StrEnum):
123
+ CREATE = "create"
124
+ RESTORE = "restore"
125
+
126
+ class UpdateType(StrEnum):
127
+ DATA = "data"
128
+ STATUS = "status"
129
+
130
+ class StatusUpdateType(StrEnum):
131
+ ACTIVATE = "activate"
132
+ DEACTIVATE = "deactivate"
83
133
  RESTORE = "restore"
84
134
  DELETE = "delete"
85
135
 
@@ -167,13 +217,3 @@ class BaseEnums:
167
217
  EXP_1WK = int(1 * 7 * 24 * 60 * 60)
168
218
  EXP_2WK = int(2 * 7 * 24 * 60 * 60)
169
219
  EXP_1MO = int(1 * 30 * 24 * 60 * 60)
170
-
171
- class ServiceDataSource(StrEnum):
172
- CACHE = "cache"
173
- DATABASE = "database"
174
- MICROSERVICE = "microservice"
175
- THIRD_PARTY = "third_party"
176
-
177
- class ClientDataSource(StrEnum):
178
- CACHE = "cache"
179
- REQUEST = "request"
@@ -1,4 +1,5 @@
1
1
  from pydantic import ConfigDict, Field
2
+ from maleo_foundation.enums import BaseEnums
2
3
  from maleo_foundation.managers.client.base import (
3
4
  ClientManager,
4
5
  ClientHTTPControllerManager,
@@ -33,11 +34,22 @@ class MaleoClientServiceControllers(ClientServiceControllers):
33
34
 
34
35
 
35
36
  class MaleoClientService(ClientService):
36
- def __init__(self, key: str, logger: ClientLogger, service_manager: ServiceManager):
37
+ def __init__(
38
+ self,
39
+ environment: BaseEnums.EnvironmentType,
40
+ key: str,
41
+ logger: ClientLogger,
42
+ service_manager: ServiceManager,
43
+ ):
37
44
  super().__init__(logger)
45
+ self._environment = environment
38
46
  self._key = key
39
47
  self._service_manager = service_manager
40
48
 
49
+ @property
50
+ def environment(self) -> BaseEnums.EnvironmentType:
51
+ return self._environment
52
+
41
53
  @property
42
54
  def key(self) -> str:
43
55
  return self._key
@@ -48,7 +60,14 @@ class MaleoClientService(ClientService):
48
60
 
49
61
 
50
62
  class MaleoClientManager(ClientManager):
51
- def __init__(self, key: str, name: str, url: str, service_manager: ServiceManager):
63
+ def __init__(
64
+ self,
65
+ environment: BaseEnums.EnvironmentType,
66
+ key: str,
67
+ name: str,
68
+ url: str,
69
+ service_manager: ServiceManager,
70
+ ):
52
71
  self._url = url
53
72
  self._service_manager = service_manager
54
73
  super().__init__(
@@ -57,11 +76,16 @@ class MaleoClientManager(ClientManager):
57
76
  service_manager.log_config,
58
77
  service_manager.configurations.service.key,
59
78
  )
79
+ self._environment = environment
60
80
 
61
81
  @property
62
82
  def service_manager(self) -> ServiceManager:
63
83
  return self._service_manager
64
84
 
85
+ @property
86
+ def environment(self) -> BaseEnums.EnvironmentType:
87
+ return self._environment
88
+
65
89
  def _initialize_controllers(self) -> None:
66
90
  # * Initialize managers
67
91
  http_controller_manager = ClientHTTPControllerManager(url=self._url)
@@ -28,7 +28,7 @@ from maleo_foundation.managers.client.google.storage import GoogleCloudStorage
28
28
  from maleo_foundation.managers.client.google.secret import GoogleSecretManager
29
29
  from maleo_foundation.managers.middleware import MiddlewareManager
30
30
  from maleo_foundation.types import BaseTypes
31
- from maleo_foundation.utils.exceptions import BaseExceptions
31
+ from maleo_foundation.utils.exceptions.request import BaseRequestExceptions
32
32
  from maleo_foundation.utils.logging import (
33
33
  SimpleConfig,
34
34
  ApplicationLogger,
@@ -52,7 +52,7 @@ class ServiceManager:
52
52
  self._db_metadata = db_metadata # * Declare DB Metadata
53
53
  self._log_config = log_config # * Declare log config
54
54
  self._settings = (
55
- settings if settings is not None else Settings()
55
+ settings if settings is not None else Settings() # type: ignore
56
56
  ) # * Initialize settings
57
57
 
58
58
  # * Disable google cloud logging if environment is local
@@ -244,13 +244,18 @@ class ServiceManager:
244
244
  u_u=self.maleo_credentials.username,
245
245
  u_e=self.maleo_credentials.email,
246
246
  u_ut="service",
247
+ o_i=None,
248
+ o_uu=None,
249
+ o_k=None,
250
+ o_ot=None,
251
+ uor=None,
247
252
  exp_in=1,
248
253
  )
249
254
  parameters = MaleoFoundationTokenParametersTransfers.Encode(
250
255
  key=self._keys.private, password=self._keys.password, payload=payload
251
256
  )
252
257
  result = self._foundation.services.token.encode(parameters=parameters)
253
- return result.data.token if result.success else None
258
+ return result.data.token if result.success and result.data is not None else None
254
259
 
255
260
  def create_app(
256
261
  self,
@@ -263,7 +268,7 @@ class ServiceManager:
263
268
  self._app = FastAPI(
264
269
  title=self.configurations.service.name,
265
270
  version=version,
266
- lifespan=lifespan,
271
+ lifespan=lifespan, # type: ignore
267
272
  root_path=root_path,
268
273
  )
269
274
  self._loggers.application.info("FastAPI application created successfully")
@@ -284,11 +289,11 @@ class ServiceManager:
284
289
  self._loggers.application.info("Adding exception handlers")
285
290
  self._app.add_exception_handler(
286
291
  exc_class_or_status_code=RequestValidationError,
287
- handler=BaseExceptions.validation_exception_handler,
292
+ handler=BaseRequestExceptions.validation_exception_handler, # type: ignore
288
293
  )
289
294
  self._app.add_exception_handler(
290
295
  exc_class_or_status_code=HTTPException,
291
- handler=BaseExceptions.http_exception_handler,
296
+ handler=BaseRequestExceptions.http_exception_handler, # type: ignore
292
297
  )
293
298
  self._loggers.application.info("Exception handlers added successfully")
294
299
 
@@ -307,10 +312,8 @@ class ServiceManager:
307
312
  self._loggers.application.info("Disposing service manager")
308
313
  if self._redis is not None:
309
314
  await self._redis.close()
310
- self._redis = None
311
315
  if self._database is not None:
312
316
  self._database.dispose()
313
- self._database = None
314
317
  self._loggers.application.info("Service manager disposed successfully")
315
318
  if self._loggers is not None:
316
319
  self._loggers.application.info("Disposing logger")
@@ -319,4 +322,3 @@ class ServiceManager:
319
322
  self._loggers.database.dispose()
320
323
  self._loggers.middleware.info("Disposing logger")
321
324
  self._loggers.middleware.dispose()
322
- self._loggers = None
@@ -10,7 +10,7 @@ from maleo_foundation.models.schemas import BaseGeneralSchemas
10
10
  from maleo_foundation.models.transfers.parameters.token import (
11
11
  MaleoFoundationTokenParametersTransfers,
12
12
  )
13
- from maleo_foundation.utils.exceptions import BaseExceptions
13
+ from maleo_foundation.utils.exceptions.request import BaseRequestExceptions
14
14
 
15
15
 
16
16
  class Backend(AuthenticationBackend):
@@ -100,5 +100,5 @@ def add_authentication_middleware(
100
100
  app.add_middleware(
101
101
  AuthenticationMiddleware,
102
102
  backend=Backend(keys, maleo_foundation),
103
- on_error=BaseExceptions.authentication_error_handler, # type: ignore
103
+ on_error=BaseRequestExceptions.authentication_error_handler, # type: ignore
104
104
  )
@@ -1,18 +1,48 @@
1
1
  from __future__ import annotations
2
2
  from fastapi import status
3
- from pydantic import Field, model_validator
4
- from typing import Dict, Type, Union
5
- from maleo_foundation.models.schemas.result import BaseResultSchemas
3
+ from pydantic import BaseModel, Field, model_validator
4
+ from typing import Any, Dict, Optional, Type, Union
5
+ from maleo_foundation.models.schemas.result import BaseResultSchemas, ResultMetadata
6
6
  from maleo_foundation.types import BaseTypes
7
7
 
8
8
 
9
9
  class BaseResponses:
10
- class Fail(BaseResultSchemas.Fail):
10
+ # * ----- ----- ----- Base ----- ----- ----- *#
11
+ class Base(BaseModel):
12
+ success: bool = Field(..., description="Success status")
13
+ code: BaseTypes.OptionalString = Field(None, description="Optional result code")
14
+ message: BaseTypes.OptionalString = Field(None, description="Optional message")
15
+ description: BaseTypes.OptionalString = Field(
16
+ None, description="Optional description"
17
+ )
18
+ data: Any = Field(..., description="Data")
19
+ metadata: Optional[ResultMetadata] = Field(
20
+ None, description="Optional metadata"
21
+ )
22
+ other: BaseTypes.OptionalAny = Field(
23
+ None, description="Optional other information"
24
+ )
25
+
26
+ # * ----- ----- ----- Intermediary ----- ----- ----- *#
27
+ class Fail(Base):
28
+ success: BaseTypes.LiteralFalse = Field(False, description="Success status") # type: ignore
29
+ code: str = "MAL-FAI-001" # type: ignore
30
+ message: str = "Fail result" # type: ignore
31
+ description: str = "Operation failed." # type: ignore
32
+ data: None = Field(None, description="No data")
11
33
  other: BaseTypes.OptionalAny = Field(
12
34
  "Please try again later or contact administrator.",
13
35
  description="Response's other information",
14
36
  )
15
37
 
38
+ class Success(Base):
39
+ success: BaseTypes.LiteralTrue = Field(True, description="Success status") # type: ignore
40
+ code: str = "MAL-SCS-001" # type: ignore
41
+ message: str = "Success result" # type: ignore
42
+ description: str = "Operation succeeded." # type: ignore
43
+ data: Any = Field(..., description="Data")
44
+
45
+ # * ----- ----- ----- Derived ----- ----- ----- *#
16
46
  class BadRequest(Fail):
17
47
  code: str = "MAL-BDR-001"
18
48
  message: str = "Bad Request"
@@ -83,16 +113,32 @@ class BaseResponses:
83
113
  message: str = "Resource not found"
84
114
  description: str = "The requested resource can not be found."
85
115
 
86
- class NoData(BaseResultSchemas.NoData):
87
- pass
88
-
89
- class SingleData(BaseResultSchemas.SingleData):
90
- pass
91
-
92
- class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
93
- pass
94
-
95
- class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
116
+ class NoData(Success):
117
+ code: str = "MAL-NDT-001"
118
+ message: str = "No data found"
119
+ description: str = "No data found in the requested resource."
120
+ data: None = Field(None, description="No data")
121
+
122
+ class SingleData(Success):
123
+ code: str = "MAL-SGD-001"
124
+ message: str = "Single data found"
125
+ description: str = "Requested data found in database."
126
+ data: Any = Field(..., description="Fetched single data")
127
+
128
+ class UnpaginatedMultipleData(Success):
129
+ code: str = "MAL-MTD-001"
130
+ message: str = "Multiple unpaginated data found"
131
+ description: str = "Requested unpaginated data found in database."
132
+ data: BaseTypes.ListOfAny = Field(..., description="Unpaginated multiple data")
133
+
134
+ class PaginatedMultipleData(Success):
135
+ code: str = "MAL-MTD-002"
136
+ message: str = "Multiple paginated data found"
137
+ description: str = "Requested paginated data found in database."
138
+ total_data: int = Field(..., ge=0, description="Total data count")
139
+ pagination: BaseResultSchemas.ExtendedPagination = Field(
140
+ ..., description="Pagination metadata"
141
+ )
96
142
  page: int = Field(
97
143
  1, ge=1, description="Page number, must be >= 1.", exclude=True
98
144
  )
@@ -1,5 +1,7 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Dict, Optional, Union, Any
1
+ from datetime import datetime, timezone
2
+ from pydantic import BaseModel, Field, model_validator
3
+ from typing import Any, Dict, Optional, Self, Union
4
+ from maleo_foundation.enums import BaseEnums
3
5
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
4
6
  from maleo_foundation.types import BaseTypes
5
7
 
@@ -29,6 +31,29 @@ class BaseResultSchemas:
29
31
  # * ----- ----- ----- Base ----- ----- ----- *#
30
32
  class Base(BaseModel):
31
33
  success: bool = Field(..., description="Success status")
34
+ exception: Optional[BaseEnums.ExceptionType] = Field(
35
+ None, description="Exception type (optional)"
36
+ )
37
+ timestamp: datetime = Field(datetime.now(timezone.utc), description="Timestamp")
38
+ origin: BaseEnums.OperationOrigin = Field(..., description="Operation origin")
39
+ layer: BaseEnums.OperationLayer = Field(..., description="Operation layer")
40
+ target: Optional[BaseEnums.OperationTarget] = Field(
41
+ None, description="Operation target (optional)"
42
+ )
43
+ environment: Optional[BaseEnums.EnvironmentType] = Field(
44
+ None, description="Operation target environment (optional)"
45
+ )
46
+ resource: str = Field(..., description="Resource name")
47
+ operation: BaseEnums.OperationType = Field(..., description="Operation type")
48
+ create_type: Optional[BaseEnums.CreateType] = Field(
49
+ None, description="Create type (optional)"
50
+ )
51
+ update_type: Optional[BaseEnums.UpdateType] = Field(
52
+ None, description="Update type (optional)"
53
+ )
54
+ status_update_type: Optional[BaseEnums.StatusUpdateType] = Field(
55
+ None, description="Status update type (optional)"
56
+ )
32
57
  code: BaseTypes.OptionalString = Field(None, description="Optional result code")
33
58
  message: BaseTypes.OptionalString = Field(None, description="Optional message")
34
59
  description: BaseTypes.OptionalString = Field(
@@ -42,9 +67,52 @@ class BaseResultSchemas:
42
67
  None, description="Optional other information"
43
68
  )
44
69
 
70
+ @model_validator(mode="after")
71
+ def verify_fields(self) -> Self:
72
+ """Verify that the required fields are set."""
73
+ if self.origin is BaseEnums.OperationOrigin.SERVICE:
74
+ if self.layer not in BaseEnums.ServiceOperationLayer:
75
+ raise ValueError(
76
+ f"Invalid layer '{self.layer}' for service operation."
77
+ )
78
+ if self.target and self.target not in BaseEnums.ServiceOperationTarget:
79
+ raise ValueError(
80
+ f"Invalid target '{self.target}' for service operation."
81
+ )
82
+ elif self.origin is BaseEnums.OperationOrigin.CLIENT:
83
+ if self.layer not in BaseEnums.ClientOperationLayer:
84
+ raise ValueError(
85
+ f"Invalid layer '{self.layer}' for client operation."
86
+ )
87
+ if self.target and self.target not in BaseEnums.ClientOperationTarget:
88
+ raise ValueError(
89
+ f"Invalid target '{self.target}' for client operation."
90
+ )
91
+ else:
92
+ raise ValueError(
93
+ f"Invalid operation origin '{self.origin}'. Must be 'service' or 'client'."
94
+ )
95
+
96
+ if self.operation is BaseEnums.OperationType.CREATE:
97
+ if self.create_type is None:
98
+ raise ValueError("Create type must be set for create operations.")
99
+ elif self.operation is BaseEnums.OperationType.UPDATE:
100
+ if self.update_type is None:
101
+ raise ValueError("Update type must be set for update operations.")
102
+ if self.update_type is BaseEnums.UpdateType.STATUS:
103
+ if self.status_update_type is None:
104
+ raise ValueError(
105
+ "Status update type must be set for status update operations."
106
+ )
107
+
108
+ return self
109
+
45
110
  # * ----- ----- ----- Intermediary ----- ----- ----- *#
46
111
  class Fail(Base):
47
112
  success: BaseTypes.LiteralFalse = Field(False, description="Success status") # type: ignore
113
+ exception: BaseEnums.ExceptionType = Field( # type: ignore
114
+ ..., description="Exception type"
115
+ )
48
116
  code: str = "MAL-FAI-001" # type: ignore
49
117
  message: str = "Fail result" # type: ignore
50
118
  description: str = "Operation failed." # type: ignore
@@ -60,9 +128,11 @@ class BaseResultSchemas:
60
128
  # * ----- ----- ----- Derived ----- ----- ----- *#
61
129
  class NotFound(Fail):
62
130
  code: str = "MAL-NTF-001"
131
+ exception: BaseEnums.ExceptionType = Field(
132
+ BaseEnums.ExceptionType.NOT_FOUND, description="Exception type"
133
+ )
63
134
  message: str = "Resource not found"
64
135
  description: str = "The requested resource can not be found."
65
- data: None = Field(None, description="No data")
66
136
 
67
137
  class NoData(Success):
68
138
  code: str = "MAL-NDT-001"
@@ -93,10 +163,5 @@ class BaseResultSchemas:
93
163
  ..., description="Pagination metadata"
94
164
  )
95
165
 
96
- class Get(BaseModel):
97
- accessed_at: BaseTypes.OptionalDatetime = Field(
98
- None, description="Accessed at timestamp"
99
- )
100
-
101
166
 
102
167
  BaseResultSchemas.PaginatedMultipleData.model_rebuild()
@@ -19,6 +19,9 @@ class RedisCacheNamespaces(BaseModel):
19
19
 
20
20
 
21
21
  class RedisCacheConfigurations(BaseModel):
22
+ environment: BaseEnums.EnvironmentType = Field(
23
+ ..., description="Redis cache's environment"
24
+ )
22
25
  ttl: Union[int, float] = Field(
23
26
  BaseEnums.Expiration.EXP_5MN, description="Default TTL"
24
27
  )
@@ -1,8 +1,12 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
2
  from typing import Optional
3
+ from maleo_foundation.enums import BaseEnums
3
4
 
4
5
 
5
6
  class MaleoClientConfigurations(BaseModel):
7
+ environment: BaseEnums.EnvironmentType = Field(
8
+ ..., description="Client's environment"
9
+ )
6
10
  key: str = Field(..., description="Client's key")
7
11
  name: str = Field(..., description="Client's name")
8
12
  url: str = Field(..., description="Client's URL")
@@ -0,0 +1,41 @@
1
+ from __future__ import annotations
2
+ from httpx import Response
3
+ from pydantic import BaseModel, ConfigDict, Field, model_validator
4
+ from typing import Any, Self
5
+
6
+
7
+ class BaseClientHTTPControllerResults(BaseModel):
8
+ model_config = ConfigDict(arbitrary_types_allowed=True)
9
+
10
+ response: Response = Field(..., description="Client's HTTP Controller response")
11
+
12
+ @model_validator(mode="after")
13
+ def verify_response(self) -> Self:
14
+ """Verify that the response is an instance of httpx.Response."""
15
+ if not isinstance(self.response, Response):
16
+ raise TypeError("Response must be an instance of httpx.Response")
17
+ return self
18
+
19
+ @property
20
+ def status_code(self) -> int:
21
+ """Get the status code of the response."""
22
+ return self.response.status_code
23
+
24
+ @property
25
+ def success(self) -> bool:
26
+ """Get the success status of the response."""
27
+ return self.response.is_success
28
+
29
+ @property
30
+ def content(self) -> Any:
31
+ """Get the content of the response."""
32
+ # * Determine content type and parse accordingly
33
+ content_type: str = self.response.headers.get("content-type", "")
34
+ content_type = content_type.lower()
35
+ if "application/json" in content_type:
36
+ content = self.response.json()
37
+ elif "text/" in content_type or "application/xml" in content_type:
38
+ content = self.response.text
39
+ else:
40
+ content = self.response.content # * Raw bytes for unknown types
41
+ return content
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
- from pydantic import Field, model_validator
3
- from typing import Optional
4
- from maleo_foundation.enums import BaseEnums
2
+ from pydantic import model_validator
5
3
  from maleo_foundation.models.schemas.result import BaseResultSchemas
6
4
 
7
5
 
@@ -35,8 +33,3 @@ class BaseClientServiceResultsTransfers:
35
33
  values["total_data"] = pagination.total_data
36
34
 
37
35
  return values
38
-
39
- class Get(BaseResultSchemas.Get):
40
- source: Optional[BaseEnums.ClientDataSource] = Field(
41
- None, description="Data source"
42
- )
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
- from pydantic import Field, model_validator
3
- from typing import Optional
4
- from maleo_foundation.enums import BaseEnums
2
+ from pydantic import model_validator
5
3
  from maleo_foundation.models.schemas.result import BaseResultSchemas
6
4
 
7
5
 
@@ -45,8 +43,3 @@ class BaseServiceGeneralResultsTransfers:
45
43
  total_pages=total_pages,
46
44
  )
47
45
  return values
48
-
49
- class Get(BaseResultSchemas.Get):
50
- source: Optional[BaseEnums.ServiceDataSource] = Field(
51
- None, description="Data source"
52
- )
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
  from .formatter import BaseFormatter
3
- from .exceptions import BaseExceptions
4
3
  from .loaders import BaseLoaders
5
4
  from .controller import BaseControllerUtils
6
5
  from .query import BaseQueryUtils
@@ -8,7 +7,6 @@ from .query import BaseQueryUtils
8
7
 
9
8
  class BaseUtils:
10
9
  Formatter = BaseFormatter
11
- Exceptions = BaseExceptions
12
10
  Loaders = BaseLoaders
13
11
  Controller = BaseControllerUtils
14
12
  Query = BaseQueryUtils