maleo-foundation 0.3.71__py3-none-any.whl → 0.3.74__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.
Files changed (42) hide show
  1. maleo_foundation/authentication.py +2 -48
  2. maleo_foundation/client/manager.py +9 -3
  3. maleo_foundation/constants.py +2 -0
  4. maleo_foundation/controller_types.py +25 -0
  5. maleo_foundation/enums.py +7 -1
  6. maleo_foundation/managers/client/base.py +37 -5
  7. maleo_foundation/managers/client/google/base.py +7 -3
  8. maleo_foundation/managers/client/google/secret.py +12 -3
  9. maleo_foundation/managers/client/google/storage.py +11 -2
  10. maleo_foundation/managers/client/google/subscription.py +40 -26
  11. maleo_foundation/managers/client/maleo.py +3 -5
  12. maleo_foundation/managers/credential.py +6 -2
  13. maleo_foundation/managers/middleware.py +8 -8
  14. maleo_foundation/managers/service.py +33 -17
  15. maleo_foundation/middlewares/authentication.py +3 -2
  16. maleo_foundation/middlewares/base.py +312 -197
  17. maleo_foundation/models/schemas/general.py +1 -127
  18. maleo_foundation/models/transfers/general/authentication.py +35 -0
  19. maleo_foundation/{authorization.py → models/transfers/general/authorization.py} +0 -3
  20. maleo_foundation/models/transfers/general/configurations/__init__.py +2 -0
  21. maleo_foundation/models/transfers/general/configurations/client/maleo.py +1 -1
  22. maleo_foundation/models/transfers/general/configurations/middleware.py +6 -7
  23. maleo_foundation/models/transfers/general/configurations/pubsub/subscription.py +16 -0
  24. maleo_foundation/models/transfers/general/configurations/service.py +2 -1
  25. maleo_foundation/models/transfers/general/operation.py +192 -30
  26. maleo_foundation/models/transfers/general/request.py +13 -19
  27. maleo_foundation/models/transfers/general/response.py +14 -0
  28. maleo_foundation/models/transfers/general/service.py +9 -0
  29. maleo_foundation/models/transfers/general/settings.py +1 -1
  30. maleo_foundation/models/transfers/general/user_agent.py +34 -0
  31. maleo_foundation/utils/exceptions/client.py +26 -2
  32. maleo_foundation/utils/exceptions/service.py +26 -2
  33. maleo_foundation/utils/extractor.py +49 -19
  34. maleo_foundation/utils/logging.py +90 -21
  35. maleo_foundation/utils/parser.py +7 -0
  36. {maleo_foundation-0.3.71.dist-info → maleo_foundation-0.3.74.dist-info}/METADATA +3 -1
  37. {maleo_foundation-0.3.71.dist-info → maleo_foundation-0.3.74.dist-info}/RECORD +39 -35
  38. maleo_foundation/utils/dependencies/__init__.py +0 -6
  39. maleo_foundation/utils/dependencies/auth.py +0 -17
  40. maleo_foundation/utils/dependencies/context.py +0 -8
  41. {maleo_foundation-0.3.71.dist-info → maleo_foundation-0.3.74.dist-info}/WHEEL +0 -0
  42. {maleo_foundation-0.3.71.dist-info → maleo_foundation-0.3.74.dist-info}/top_level.txt +0 -0
@@ -40,6 +40,7 @@ from maleo_foundation.utils.logging import (
40
40
  DatabaseLogger,
41
41
  MiddlewareLogger,
42
42
  RepositoryLogger,
43
+ RouterLogger,
43
44
  ServiceLogger,
44
45
  )
45
46
  from .credential import CredentialManager
@@ -51,20 +52,14 @@ class ServiceManager:
51
52
  self,
52
53
  db_metadata: MetaData,
53
54
  log_config: SimpleConfig,
54
- settings: Optional[Settings] = None,
55
+ settings: Settings,
55
56
  additional_topics_configurations: Optional[
56
57
  AdditionalTopicsConfigurations
57
58
  ] = None,
58
59
  ):
59
60
  self._db_metadata = db_metadata # * Declare DB Metadata
60
61
  self._log_config = log_config # * Declare log config
61
- self._settings = (
62
- settings if settings is not None else Settings() # type: ignore
63
- ) # * Initialize settings
64
-
65
- # * Disable google cloud logging if environment is local
66
- if self._settings.ENVIRONMENT == "local":
67
- self._log_config.google_cloud_logging = None
62
+ self._settings = settings # * Initialize settings
68
63
 
69
64
  # * Initialize Credential Manager
70
65
  self._credential_manager = CredentialManager(
@@ -134,22 +129,39 @@ class ServiceManager:
134
129
 
135
130
  def _initialize_loggers(self) -> None:
136
131
  application = ApplicationLogger(
137
- service_key=self.configurations.service.key, **self._log_config.model_dump()
132
+ environment=self.settings.ENVIRONMENT,
133
+ service_key=self.settings.SERVICE_KEY,
134
+ **self._log_config.model_dump(),
138
135
  )
139
136
  cache = CacheLogger(
140
- service_key=self.configurations.service.key, **self._log_config.model_dump()
137
+ environment=self.settings.ENVIRONMENT,
138
+ service_key=self.settings.SERVICE_KEY,
139
+ **self._log_config.model_dump(),
141
140
  )
142
141
  database = DatabaseLogger(
143
- service_key=self.configurations.service.key, **self._log_config.model_dump()
142
+ environment=self.settings.ENVIRONMENT,
143
+ service_key=self.settings.SERVICE_KEY,
144
+ **self._log_config.model_dump(),
144
145
  )
145
146
  middleware = MiddlewareLogger(
146
- service_key=self.configurations.service.key, **self._log_config.model_dump()
147
+ environment=self.settings.ENVIRONMENT,
148
+ service_key=self.settings.SERVICE_KEY,
149
+ **self._log_config.model_dump(),
147
150
  )
148
151
  repository = RepositoryLogger(
149
- service_key=self.configurations.service.key, **self._log_config.model_dump()
152
+ environment=self.settings.ENVIRONMENT,
153
+ service_key=self.settings.SERVICE_KEY,
154
+ **self._log_config.model_dump(),
155
+ )
156
+ router = RouterLogger(
157
+ environment=self.settings.ENVIRONMENT,
158
+ service_key=self.settings.SERVICE_KEY,
159
+ **self._log_config.model_dump(),
150
160
  )
151
161
  service = ServiceLogger(
152
- service_key=self.configurations.service.key, **self._log_config.model_dump()
162
+ environment=self.settings.ENVIRONMENT,
163
+ service_key=self.settings.SERVICE_KEY,
164
+ **self._log_config.model_dump(),
153
165
  )
154
166
  self._loggers = Loggers(
155
167
  application=application,
@@ -157,6 +169,7 @@ class ServiceManager:
157
169
  database=database,
158
170
  middleware=middleware,
159
171
  repository=repository,
172
+ router=router,
160
173
  service=service,
161
174
  )
162
175
 
@@ -166,8 +179,8 @@ class ServiceManager:
166
179
 
167
180
  async def _clear_cache(self) -> None:
168
181
  prefixes = [
169
- self.configurations.service.key,
170
- f"google-cloud-storage:{self.configurations.service.key}",
182
+ self.settings.SERVICE_KEY,
183
+ f"google-cloud-storage:{self.settings.SERVICE_KEY}",
171
184
  ]
172
185
  for prefix in prefixes:
173
186
  async for key in self._redis.scan_iter(f"{prefix}*"):
@@ -243,7 +256,9 @@ class ServiceManager:
243
256
 
244
257
  def _initialize_foundation(self) -> None:
245
258
  self._foundation = MaleoFoundationClientManager(
246
- log_config=self._log_config, service_key=self._settings.SERVICE_KEY
259
+ log_config=self._log_config,
260
+ service_environment=self._settings.ENVIRONMENT,
261
+ service_key=self._settings.SERVICE_KEY,
247
262
  )
248
263
 
249
264
  @property
@@ -294,6 +309,7 @@ class ServiceManager:
294
309
  self._loggers.application.info("Configuring middlewares")
295
310
  self._middleware = MiddlewareManager(
296
311
  app=self._app,
312
+ settings=self._settings,
297
313
  configurations=self.configurations.middleware,
298
314
  keys=self._keys,
299
315
  logger=self._loggers.middleware,
@@ -3,10 +3,11 @@ from starlette.authentication import AuthenticationBackend, AuthenticationError
3
3
  from starlette.middleware.authentication import AuthenticationMiddleware
4
4
  from starlette.requests import HTTPConnection
5
5
  from typing import Tuple
6
- from maleo_foundation.authentication import Token, Credentials, User
6
+ from maleo_foundation.authentication import Credentials, User
7
7
  from maleo_foundation.enums import BaseEnums
8
8
  from maleo_foundation.client.manager import MaleoFoundationClientManager
9
9
  from maleo_foundation.models.schemas import BaseGeneralSchemas
10
+ from maleo_foundation.models.transfers.general.authentication import Token
10
11
  from maleo_foundation.models.transfers.parameters.token import (
11
12
  MaleoFoundationTokenParametersTransfers,
12
13
  )
@@ -67,7 +68,7 @@ class Backend(AuthenticationBackend):
67
68
  User(authenticated=True, username=payload.u_u, email=payload.u_e),
68
69
  )
69
70
 
70
- return Credentials(), User(authenticated=False)
71
+ return Credentials(), User()
71
72
 
72
73
 
73
74
  def add_authentication_middleware(