maleo-foundation 0.1.31__tar.gz → 0.1.33__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 (94) hide show
  1. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/PKG-INFO +1 -1
  2. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/service.py +15 -45
  3. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/middlewares/authentication.py +4 -4
  4. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation.egg-info/PKG-INFO +1 -1
  5. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/pyproject.toml +1 -1
  6. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/README.md +0 -0
  7. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/__init__.py +0 -0
  8. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/authentication.py +0 -0
  9. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/__init__.py +0 -0
  10. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/general/__init__.py +0 -0
  11. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/general/http.py +0 -0
  12. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/__init__.py +0 -0
  13. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/base.py +0 -0
  14. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/cloud/__init__.py +0 -0
  15. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/cloud/base.py +0 -0
  16. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/cloud/logging.py +0 -0
  17. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/cloud/secret.py +0 -0
  18. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/cloud/storage.py +0 -0
  19. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/secret.py +0 -0
  20. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/google/storage.py +0 -0
  21. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/utils/__init__.py +0 -0
  22. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/clients/utils/logger.py +0 -0
  23. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/constants.py +0 -0
  24. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/db/__init__.py +0 -0
  25. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/db/engine.py +0 -0
  26. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/db/manager.py +0 -0
  27. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/db/session.py +0 -0
  28. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/db/table.py +0 -0
  29. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/enums.py +0 -0
  30. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/expanded_types/__init__.py +0 -0
  31. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/expanded_types/client.py +0 -0
  32. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/expanded_types/general.py +0 -0
  33. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/expanded_types/query.py +0 -0
  34. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/expanded_types/service.py +0 -0
  35. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/expanded_types/token.py +0 -0
  36. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/extended_types.py +0 -0
  37. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/__init__.py +0 -0
  38. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/__init__.py +0 -0
  39. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/base.py +0 -0
  40. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/google/__init__.py +0 -0
  41. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/google/base.py +0 -0
  42. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/google/secret.py +0 -0
  43. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/google/storage.py +0 -0
  44. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/http.py +0 -0
  45. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/client/maleo.py +0 -0
  46. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/db.py +0 -0
  47. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/managers/middleware.py +0 -0
  48. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/middlewares/__init__.py +0 -0
  49. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/middlewares/base.py +0 -0
  50. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/middlewares/cors.py +0 -0
  51. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/__init__.py +0 -0
  52. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/responses.py +0 -0
  53. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/schemas/__init__.py +0 -0
  54. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/schemas/general.py +0 -0
  55. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/schemas/parameter.py +0 -0
  56. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/schemas/result.py +0 -0
  57. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/schemas/token.py +0 -0
  58. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/__init__.py +0 -0
  59. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  60. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/general/token.py +0 -0
  61. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  62. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  63. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  64. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  65. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  66. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  67. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  68. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  69. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  70. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  71. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  72. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  73. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  74. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  75. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/service/query.py +0 -0
  76. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/models/transfers/results/token.py +0 -0
  77. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/services/__init__.py +0 -0
  78. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/services/token.py +0 -0
  79. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/types.py +0 -0
  80. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/__init__.py +0 -0
  81. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/controller.py +0 -0
  82. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/exceptions.py +0 -0
  83. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/extractor.py +0 -0
  84. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/formatter/__init__.py +0 -0
  85. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/formatter/case.py +0 -0
  86. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/keyloader.py +0 -0
  87. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/logger.py +0 -0
  88. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/logging.py +0 -0
  89. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation/utils/query.py +0 -0
  90. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation.egg-info/SOURCES.txt +0 -0
  91. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  92. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation.egg-info/requires.txt +0 -0
  93. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/maleo_foundation.egg-info/top_level.txt +0 -0
  94. {maleo_foundation-0.1.31 → maleo_foundation-0.1.33}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.31
3
+ Version: 0.1.33
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -40,7 +40,6 @@ class Settings(BaseSettings):
40
40
  PUBLIC_KEY_PATH:str = Field("/keys/maleo-public-key.pem", description="Maleo's public key path")
41
41
  KEY_PASSWORD:str = Field(..., description="Maleo key's password")
42
42
  CONFIGURATIONS_PATH:str = Field(..., description="Service's configuration file path")
43
- GCS_BUCKET_NAME:str = Field(..., description="Google cloud storage (GCS)'s bucket name")
44
43
 
45
44
  class Keys(BaseModel):
46
45
  password:str = Field(..., description="Key's password")
@@ -90,6 +89,12 @@ class DatabaseConfigurations(BaseModel):
90
89
  def url(self) -> str:
91
90
  return f"postgresql://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}"
92
91
 
92
+ class GoogleCloudStorageConfigurations(BaseModel):
93
+ bucket_name:str = Field(..., description="Bucket's name")
94
+
95
+ class GoogleClientConfigurations(BaseModel):
96
+ storage:GoogleCloudStorageConfigurations = Field(..., description="Google cloud storage client configurations")
97
+
93
98
  class MaleoClientConfiguration(BaseModel):
94
99
  key:str = Field(..., description="Client's key")
95
100
  name:str = Field(..., description="Client's name")
@@ -113,8 +118,12 @@ class MaleoClientConfigurations(BaseModel):
113
118
  arbitrary_types_allowed=True
114
119
 
115
120
  class ClientConfigurations(BaseModel):
121
+ google:GoogleClientConfigurations = Field(..., description="Google client's configurations")
116
122
  maleo:MaleoClientConfigurations = Field(..., description="Maleo client's configurations")
117
123
 
124
+ class Config:
125
+ arbitrary_types_allowed=True
126
+
118
127
  class Configurations(BaseModel):
119
128
  service:ServiceConfigurations = Field(..., description="Service's configurations")
120
129
  middleware:MiddlewareConfigurations = Field(..., description="Middleware's configurations")
@@ -315,7 +324,7 @@ class ServiceManager:
315
324
  def _initialize_clients(self) -> None:
316
325
  #* Initialize google clients
317
326
  secret = GoogleSecretManager(**self._log_config.model_dump())
318
- storage = GoogleCloudStorage(**self._log_config.model_dump())
327
+ storage = GoogleCloudStorage(**self._log_config.model_dump(), bucket_name=self._configs.client.google.storage.bucket_name)
319
328
  self._google_clients = GoogleClientManagers(secret=secret, storage=storage)
320
329
  #* Initialize http clients
321
330
  self._http_client = HTTPClientManager
@@ -392,49 +401,6 @@ class ServiceManager:
392
401
  def app(self) -> FastAPI:
393
402
  return self._app
394
403
 
395
- def run_app(self) -> None:
396
- self._loggers.application.info("Detected environment: '%s'", self._settings.ENVIRONMENT)
397
- if self._settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL:
398
- import importlib.util
399
- import sys
400
-
401
- # Get the module path and add it to sys.path if needed
402
- self._loggers.application.info("Getting spec")
403
- spec = importlib.util.find_spec("app")
404
- self._loggers.application.info(f"Spec: {spec}, Origin: {spec.origin if spec else None}")
405
- if spec:
406
- # For namespace packages, use the first entry in submodule_search_locations
407
- if spec.origin is None and spec.submodule_search_locations:
408
- module_path = os.path.dirname(spec.submodule_search_locations[0])
409
- elif spec.origin:
410
- module_path = os.path.dirname(os.path.dirname(spec.origin))
411
- else:
412
- # Fallback to the current directory
413
- module_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
414
-
415
- if module_path not in sys.path:
416
- sys.path.insert(0, module_path)
417
-
418
- self._loggers.application.info(f"Module path: {module_path}")
419
- # Create the import string for uvicorn
420
- app_import_string = "app.main:app"
421
- self._loggers.application.info(f"Using import string: {app_import_string}")
422
-
423
- try:
424
- uvicorn.run(
425
- app_import_string,
426
- host=self._configs.service.host,
427
- port=self._configs.service.port,
428
- reload=True,
429
- log_level="debug",
430
- reload_dirs=[module_path]
431
- )
432
- except Exception as e:
433
- self._loggers.application.error(f"Error starting uvicorn: {e}")
434
- raise
435
- else:
436
- uvicorn.run(self._app, host=self._configs.service.host, port=self._configs.service.port)
437
-
438
404
  async def dispose(self) -> None:
439
405
  self._loggers.application.info("Disposing service manager")
440
406
  if self._database is not None:
@@ -450,8 +416,12 @@ class ServiceManager:
450
416
  await client_instance.dispose()
451
417
  self._loggers.application.info("Service manager disposed successfully")
452
418
  if self._loggers is not None:
419
+ self._loggers.application.info("Disposing logger")
453
420
  self._loggers.application.dispose()
421
+ self._loggers.database.info("Disposing logger")
454
422
  self._loggers.database.dispose()
423
+ self._loggers.middleware.base.info("Disposing logger")
455
424
  self._loggers.middleware.base.dispose()
425
+ self._loggers.middleware.authentication.info("Disposing logger")
456
426
  self._loggers.middleware.authentication.dispose()
457
427
  self._loggers = None
@@ -18,22 +18,22 @@ class Backend(AuthenticationBackend):
18
18
  async def authenticate(self, conn:HTTPConnection) -> Tuple[Credentials, User]:
19
19
  client_ip = extract_client_ip(conn)
20
20
  if "Authorization" not in conn.headers:
21
- self._logger.info(f"Authentication - Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Header did not contain authorization")
21
+ self._logger.info(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Header did not contain authorization")
22
22
  return Credentials(), User(authenticated=False)
23
23
 
24
24
  auth = conn.headers["Authorization"]
25
25
  scheme, token = auth.split()
26
26
  if scheme != 'Bearer':
27
- self._logger.info(f"Authentication - Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Authorization scheme is not Bearer")
27
+ self._logger.info(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Authorization scheme is not Bearer")
28
28
  return Credentials(), User(authenticated=False)
29
29
 
30
30
  decode_token_parameters = BaseTokenParametersTransfers.Decode(key=self._key, token=token)
31
31
  decode_token_result = BaseTokenService.decode(parameters=decode_token_parameters)
32
32
  if not decode_token_result.success:
33
- self._logger.error(f"Authentication - Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Failed decoding authorization token")
33
+ self._logger.error(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Failed decoding authorization token")
34
34
  return Credentials(token=token), User(authenticated=False)
35
35
 
36
- self._logger.info(f"Authentication - Request | IP: {client_ip} | URL: {conn.url.path} - Result | Username: {decode_token_result.data.u_u} | Email: {decode_token_result.data.u_e}")
36
+ self._logger.info(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | Username: {decode_token_result.data.u_u} | Email: {decode_token_result.data.u_e}")
37
37
  return Credentials(token=token), User(authenticated=True, username=decode_token_result.data.u_u, email=decode_token_result.data.u_e)
38
38
 
39
39
  def add_authentication_middleware(app:FastAPI, logger:MiddlewareLogger, key:str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.31
3
+ Version: 0.1.33
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.1.31"
7
+ version = "0.1.33"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }