maleo-foundation 0.1.32__tar.gz → 0.1.34__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 (95) hide show
  1. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/PKG-INFO +1 -1
  2. maleo_foundation-0.1.34/maleo_foundation/managers/client/base.py +52 -0
  3. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/client/google/base.py +15 -2
  4. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/client/google/secret.py +13 -1
  5. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/client/google/storage.py +14 -1
  6. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/client/maleo.py +14 -4
  7. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/service.py +27 -15
  8. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/middlewares/authentication.py +4 -4
  9. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation.egg-info/PKG-INFO +1 -1
  10. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation.egg-info/SOURCES.txt +0 -1
  11. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/pyproject.toml +1 -1
  12. maleo_foundation-0.1.32/maleo_foundation/managers/client/base.py +0 -34
  13. maleo_foundation-0.1.32/maleo_foundation/managers/client/http.py +0 -82
  14. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/README.md +0 -0
  15. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/__init__.py +0 -0
  16. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/authentication.py +0 -0
  17. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/__init__.py +0 -0
  18. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/general/__init__.py +0 -0
  19. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/general/http.py +0 -0
  20. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/__init__.py +0 -0
  21. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/base.py +0 -0
  22. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/cloud/__init__.py +0 -0
  23. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/cloud/base.py +0 -0
  24. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/cloud/logging.py +0 -0
  25. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/cloud/secret.py +0 -0
  26. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/cloud/storage.py +0 -0
  27. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/secret.py +0 -0
  28. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/google/storage.py +0 -0
  29. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/utils/__init__.py +0 -0
  30. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/clients/utils/logger.py +0 -0
  31. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/constants.py +0 -0
  32. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/db/__init__.py +0 -0
  33. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/db/engine.py +0 -0
  34. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/db/manager.py +0 -0
  35. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/db/session.py +0 -0
  36. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/db/table.py +0 -0
  37. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/enums.py +0 -0
  38. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/expanded_types/__init__.py +0 -0
  39. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/expanded_types/client.py +0 -0
  40. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/expanded_types/general.py +0 -0
  41. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/expanded_types/query.py +0 -0
  42. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/expanded_types/service.py +0 -0
  43. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/expanded_types/token.py +0 -0
  44. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/extended_types.py +0 -0
  45. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/__init__.py +0 -0
  46. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/client/__init__.py +0 -0
  47. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/client/google/__init__.py +0 -0
  48. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/db.py +0 -0
  49. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/managers/middleware.py +0 -0
  50. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/middlewares/__init__.py +0 -0
  51. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/middlewares/base.py +0 -0
  52. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/middlewares/cors.py +0 -0
  53. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/__init__.py +0 -0
  54. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/responses.py +0 -0
  55. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/schemas/__init__.py +0 -0
  56. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/schemas/general.py +0 -0
  57. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/schemas/parameter.py +0 -0
  58. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/schemas/result.py +0 -0
  59. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/schemas/token.py +0 -0
  60. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/__init__.py +0 -0
  61. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  62. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/general/token.py +0 -0
  63. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  64. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  65. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  66. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  67. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  68. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  69. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  70. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  71. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  72. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  73. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  74. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  75. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  76. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  77. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/service/query.py +0 -0
  78. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/models/transfers/results/token.py +0 -0
  79. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/services/__init__.py +0 -0
  80. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/services/token.py +0 -0
  81. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/types.py +0 -0
  82. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/__init__.py +0 -0
  83. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/controller.py +0 -0
  84. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/exceptions.py +0 -0
  85. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/extractor.py +0 -0
  86. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/formatter/__init__.py +0 -0
  87. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/formatter/case.py +0 -0
  88. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/keyloader.py +0 -0
  89. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/logger.py +0 -0
  90. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/logging.py +0 -0
  91. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation/utils/query.py +0 -0
  92. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  93. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation.egg-info/requires.txt +0 -0
  94. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/maleo_foundation.egg-info/top_level.txt +0 -0
  95. {maleo_foundation-0.1.32 → maleo_foundation-0.1.34}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.32
3
+ Version: 0.1.34
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -0,0 +1,52 @@
1
+ from typing import Optional
2
+ from maleo_foundation.enums import BaseEnums
3
+ from maleo_foundation.types import BaseTypes
4
+ from maleo_foundation.utils.logging import GoogleCloudLogging, ClientLogger
5
+
6
+ class ClientManager:
7
+ def __init__(
8
+ self,
9
+ key:str,
10
+ name:str,
11
+ logs_dir:str,
12
+ service_key:BaseTypes.OptionalString = None,
13
+ level:BaseEnums.LoggerLevel = BaseEnums.LoggerLevel.INFO,
14
+ google_cloud_logging:Optional[GoogleCloudLogging] = None
15
+ ) -> None:
16
+ self._key = key
17
+ self._name = name
18
+ self._logs_dir = logs_dir
19
+ self._service_key = service_key
20
+ self._level = level
21
+ self._google_cloud_logging = google_cloud_logging
22
+ self._initialize_logger()
23
+ self._logger.info("Initializing client manager")
24
+
25
+ def _initialize_logger(self) -> None:
26
+ self._logger = ClientLogger(
27
+ logs_dir=self._logs_dir,
28
+ client_key=self._key,
29
+ service_key=self._service_key,
30
+ level=self._level,
31
+ google_cloud_logging=self._google_cloud_logging
32
+ )
33
+
34
+ @property
35
+ def key(self) -> str:
36
+ return self._key
37
+
38
+ @property
39
+ def name(self) -> str:
40
+ return self._name
41
+
42
+ @property
43
+ def logger(self) -> ClientLogger:
44
+ return self._logger
45
+
46
+ @property
47
+ def credentials(self):
48
+ raise NotImplementedError()
49
+
50
+ @property
51
+ def client(self):
52
+ raise NotImplementedError()
@@ -1,11 +1,24 @@
1
1
  import os
2
2
  from google.auth import default
3
3
  from google.oauth2 import service_account
4
+ from typing import Optional
5
+ from maleo_foundation.enums import BaseEnums
6
+ from maleo_foundation.types import BaseTypes
4
7
  from maleo_foundation.managers.client.base import ClientManager
8
+ from maleo_foundation.utils.logging import GoogleCloudLogging
5
9
 
6
10
  class GoogleClientManager(ClientManager):
7
- def __init__(self, key, name, logs_dir, google_cloud_logging=None, credentials_path=None) -> None:
8
- super().__init__(key, name, logs_dir, google_cloud_logging)
11
+ def __init__(
12
+ self,
13
+ key:str,
14
+ name:str,
15
+ logs_dir:str,
16
+ service_key:BaseTypes.OptionalString=None,
17
+ level:BaseEnums.LoggerLevel=BaseEnums.LoggerLevel.INFO,
18
+ google_cloud_logging:Optional[GoogleCloudLogging]=None,
19
+ credentials_path:BaseTypes.OptionalString=None
20
+ ) -> None:
21
+ super().__init__(key, name, logs_dir, service_key, level, google_cloud_logging)
9
22
  credentials_path = credentials_path or os.getenv("GOOGLE_CREDENTIALS_PATH")
10
23
  try:
11
24
  if credentials_path is not None:
@@ -2,16 +2,28 @@ from google.api_core import retry
2
2
  from google.api_core.exceptions import NotFound
3
3
  from google.cloud import secretmanager
4
4
  from typing import Optional
5
+ from maleo_foundation.enums import BaseEnums
6
+ from maleo_foundation.types import BaseTypes
7
+ from maleo_foundation.utils.logging import GoogleCloudLogging
5
8
  from .base import GoogleClientManager
6
9
 
7
10
  class GoogleSecretManager(GoogleClientManager):
8
- def __init__(self, logs_dir, google_cloud_logging=None, credentials_path=None) -> None:
11
+ def __init__(
12
+ self,
13
+ logs_dir:str,
14
+ service_key:BaseTypes.OptionalString = None,
15
+ level:BaseEnums.LoggerLevel = BaseEnums.LoggerLevel.INFO,
16
+ google_cloud_logging:Optional[GoogleCloudLogging] = None,
17
+ credentials_path:BaseTypes.OptionalString=None
18
+ ) -> None:
9
19
  self._key = "google-secret-manager"
10
20
  self._name = "GoogleSecretManager"
11
21
  super().__init__(
12
22
  key=self._key,
13
23
  name=self._name,
14
24
  logs_dir=logs_dir,
25
+ service_key=service_key,
26
+ level=level,
15
27
  google_cloud_logging=google_cloud_logging,
16
28
  credentials_path=credentials_path
17
29
  )
@@ -1,17 +1,30 @@
1
1
  import os
2
2
  from datetime import timedelta
3
3
  from google.cloud.storage import Bucket, Client
4
+ from typing import Optional
5
+ from maleo_foundation.enums import BaseEnums
4
6
  from maleo_foundation.types import BaseTypes
7
+ from maleo_foundation.utils.logging import GoogleCloudLogging
5
8
  from .base import GoogleClientManager
6
9
 
7
10
  class GoogleCloudStorage(GoogleClientManager):
8
- def __init__(self, logs_dir, google_cloud_logging=None, credentials_path=None, bucket_name:BaseTypes.OptionalString=None) -> None:
11
+ def __init__(
12
+ self,
13
+ logs_dir:str,
14
+ service_key:BaseTypes.OptionalString = None,
15
+ level:BaseEnums.LoggerLevel = BaseEnums.LoggerLevel.INFO,
16
+ google_cloud_logging:Optional[GoogleCloudLogging] = None,
17
+ credentials_path:BaseTypes.OptionalString=None,
18
+ bucket_name:BaseTypes.OptionalString=None
19
+ ) -> None:
9
20
  self._key = "google-cloud-storage"
10
21
  self._name = "GoogleCloudStorage"
11
22
  super().__init__(
12
23
  key=self._key,
13
24
  name=self._name,
14
25
  logs_dir=logs_dir,
26
+ service_key=service_key,
27
+ level=level,
15
28
  google_cloud_logging=google_cloud_logging,
16
29
  credentials_path=credentials_path
17
30
  )
@@ -1,9 +1,10 @@
1
1
  import httpx
2
2
  from contextlib import asynccontextmanager
3
3
  from pydantic import BaseModel, Field
4
- from typing import AsyncGenerator
4
+ from typing import AsyncGenerator, Optional
5
+ from maleo_foundation.enums import BaseEnums
5
6
  from maleo_foundation.types import BaseTypes
6
- from maleo_foundation.utils.logging import ClientLogger
7
+ from maleo_foundation.utils.logging import GoogleCloudLogging, ClientLogger
7
8
  from maleo_foundation.managers.client.base import ClientManager
8
9
 
9
10
  class URL(BaseModel):
@@ -88,8 +89,17 @@ class ClientServices(BaseModel):
88
89
  arbitrary_types_allowed=True
89
90
 
90
91
  class MaleoClientManager(ClientManager):
91
- def __init__(self, key, name, logs_dir, google_cloud_logging = None, url:BaseTypes.OptionalString = None):
92
- super().__init__(key, name, logs_dir, google_cloud_logging)
92
+ def __init__(
93
+ self,
94
+ key:str,
95
+ name:str,
96
+ logs_dir:str,
97
+ service_key:BaseTypes.OptionalString=None,
98
+ level:BaseEnums.LoggerLevel=BaseEnums.LoggerLevel.INFO,
99
+ google_cloud_logging:Optional[GoogleCloudLogging]=None,
100
+ url:BaseTypes.OptionalString = None
101
+ ):
102
+ super().__init__(key, name, logs_dir, service_key, level, google_cloud_logging)
93
103
  self._url = url
94
104
 
95
105
  def _initialize_controllers(self) -> None:
@@ -14,7 +14,6 @@ from maleo_foundation.models.transfers.general.token import BaseTokenGeneralTran
14
14
  from maleo_foundation.models.transfers.parameters.token import BaseTokenParametersTransfers
15
15
  from maleo_foundation.managers.client.google.secret import GoogleSecretManager
16
16
  from maleo_foundation.managers.client.google.storage import GoogleCloudStorage
17
- from maleo_foundation.managers.client.http import HTTPClientManager
18
17
  from maleo_foundation.managers.client.maleo import MaleoClientManager
19
18
  from maleo_foundation.managers.db import DatabaseManager
20
19
  from maleo_foundation.managers.middleware import MiddlewareConfigurations, MiddlewareLoggers, MiddlewareManager
@@ -40,7 +39,6 @@ class Settings(BaseSettings):
40
39
  PUBLIC_KEY_PATH:str = Field("/keys/maleo-public-key.pem", description="Maleo's public key path")
41
40
  KEY_PASSWORD:str = Field(..., description="Maleo key's password")
42
41
  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
42
 
45
43
  class Keys(BaseModel):
46
44
  password:str = Field(..., description="Key's password")
@@ -90,6 +88,12 @@ class DatabaseConfigurations(BaseModel):
90
88
  def url(self) -> str:
91
89
  return f"postgresql://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}"
92
90
 
91
+ class GoogleCloudStorageConfigurations(BaseModel):
92
+ bucket_name:str = Field(..., description="Bucket's name")
93
+
94
+ class GoogleClientConfigurations(BaseModel):
95
+ storage:GoogleCloudStorageConfigurations = Field(..., description="Google cloud storage client configurations")
96
+
93
97
  class MaleoClientConfiguration(BaseModel):
94
98
  key:str = Field(..., description="Client's key")
95
99
  name:str = Field(..., description="Client's name")
@@ -113,8 +117,12 @@ class MaleoClientConfigurations(BaseModel):
113
117
  arbitrary_types_allowed=True
114
118
 
115
119
  class ClientConfigurations(BaseModel):
120
+ google:GoogleClientConfigurations = Field(..., description="Google client's configurations")
116
121
  maleo:MaleoClientConfigurations = Field(..., description="Maleo client's configurations")
117
122
 
123
+ class Config:
124
+ arbitrary_types_allowed=True
125
+
118
126
  class Configurations(BaseModel):
119
127
  service:ServiceConfigurations = Field(..., description="Service's configurations")
120
128
  middleware:MiddlewareConfigurations = Field(..., description="Middleware's configurations")
@@ -175,7 +183,6 @@ class MaleoClientManagers(BaseModel):
175
183
 
176
184
  class ClientManagers(BaseModel):
177
185
  google:GoogleClientManagers = Field(..., description="Google client's managers")
178
- http:Type[HTTPClientManager] = Field(..., description="HTTP client's manager")
179
186
  maleo:MaleoClientManagers = Field(..., description="Maleo client's managers")
180
187
 
181
188
  class Config:
@@ -314,30 +321,36 @@ class ServiceManager:
314
321
 
315
322
  def _initialize_clients(self) -> None:
316
323
  #* Initialize google clients
317
- secret = GoogleSecretManager(**self._log_config.model_dump())
318
- storage = GoogleCloudStorage(**self._log_config.model_dump())
324
+ secret = GoogleSecretManager(
325
+ **self._log_config.model_dump(),
326
+ service_key=self._configs.service.key,
327
+ credentials_path=self._settings.GOOGLE_CREDENTIALS_PATH
328
+ )
329
+ storage = GoogleCloudStorage(
330
+ **self._log_config.model_dump(),
331
+ service_key=self._configs.service.key,
332
+ credentials_path=self._settings.GOOGLE_CREDENTIALS_PATH,
333
+ bucket_name=self._configs.client.google.storage.bucket_name
334
+ )
319
335
  self._google_clients = GoogleClientManagers(secret=secret, storage=storage)
320
- #* Initialize http clients
321
- self._http_client = HTTPClientManager
322
- self._http_client.initialize()
323
336
  #* Initialize maleo clients
324
337
  self._maleo_clients = MaleoClientManagers()
325
338
  for client in self._maleo_client_manager_classes.__class__.__annotations__:
326
339
  client_cls = getattr(self._maleo_client_manager_classes, client)
327
340
  if client_cls is not None and issubclass(client_cls, MaleoClientManager):
328
341
  cfg:MaleoClientConfiguration = getattr(self._configs.client.maleo, client)
329
- client_instance = client_cls(**cfg.model_dump(), **self._log_config.model_dump())
342
+ client_instance = client_cls(
343
+ **cfg.model_dump(),
344
+ **self._log_config.model_dump(),
345
+ service_key=self._configs.service.key
346
+ )
330
347
  setattr(self._maleo_clients, client, client_instance)
331
- self._clients = ClientManagers(google=self._google_clients, http=self._http_client, maleo=self._maleo_clients)
348
+ self._clients = ClientManagers(google=self._google_clients, maleo=self._maleo_clients)
332
349
 
333
350
  @property
334
351
  def google_clients(self) -> GoogleClientManagers:
335
352
  return self._google_clients
336
353
 
337
- @property
338
- def http_client(self) -> Type[HTTPClientManager]:
339
- return self._http_client
340
-
341
354
  @property
342
355
  def maleo_clients(self) -> MaleoClientManagers:
343
356
  return self._maleo_clients
@@ -400,7 +413,6 @@ class ServiceManager:
400
413
  if self._clients is not None:
401
414
  self._clients.google.storage.dispose()
402
415
  self._clients.google.secret.dispose()
403
- await self._clients.http.dispose()
404
416
  for client in self._maleo_clients.__class__.__annotations__:
405
417
  client_instance = getattr(self._maleo_clients, client)
406
418
  if client_instance is not None and isinstance(client_instance, MaleoClientManager):
@@ -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.32
3
+ Version: 0.1.34
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -42,7 +42,6 @@ maleo_foundation/managers/middleware.py
42
42
  maleo_foundation/managers/service.py
43
43
  maleo_foundation/managers/client/__init__.py
44
44
  maleo_foundation/managers/client/base.py
45
- maleo_foundation/managers/client/http.py
46
45
  maleo_foundation/managers/client/maleo.py
47
46
  maleo_foundation/managers/client/google/__init__.py
48
47
  maleo_foundation/managers/client/google/base.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.1.32"
7
+ version = "0.1.34"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -1,34 +0,0 @@
1
- from typing import Optional
2
- from maleo_foundation.utils.logging import GoogleCloudLogging, ClientLogger
3
-
4
- class ClientManager:
5
- def __init__(self, key:str, name:str, logs_dir:str, google_cloud_logging:Optional[GoogleCloudLogging] = None) -> None:
6
- self._key = key
7
- self._name = name
8
- self._logs_dir = logs_dir
9
- self._google_cloud_logging = google_cloud_logging
10
- self._initialize_logger()
11
- self._logger.info("Initializing client manager")
12
-
13
- def _initialize_logger(self) -> None:
14
- self._logger = ClientLogger(logs_dir=self._logs_dir, client_key=self._key, google_cloud_logging=self._google_cloud_logging)
15
-
16
- @property
17
- def key(self) -> str:
18
- return self._key
19
-
20
- @property
21
- def name(self) -> str:
22
- return self._name
23
-
24
- @property
25
- def logger(self) -> ClientLogger:
26
- return self._logger
27
-
28
- @property
29
- def credentials(self):
30
- raise NotImplementedError()
31
-
32
- @property
33
- def client(self):
34
- raise NotImplementedError()
@@ -1,82 +0,0 @@
1
- import httpx
2
- from contextlib import asynccontextmanager
3
- from pydantic import BaseModel, Field
4
- from typing import AsyncGenerator, Optional
5
- from maleo_foundation.managers.client.base import ClientManager
6
-
7
- class HTTPClientManager:
8
- _client:Optional[httpx.AsyncClient] = None
9
-
10
- @classmethod
11
- def initialize(cls) -> None:
12
- """Initialize the HTTP client if not already initialized."""
13
- if cls._client is None:
14
- cls._client = httpx.AsyncClient()
15
-
16
- @classmethod
17
- async def _client_handler(cls) -> AsyncGenerator[httpx.AsyncClient, None]:
18
- """Reusable generator for client handling."""
19
- if cls._client is None:
20
- raise RuntimeError("Client has not been initialized. Call initialize first.")
21
- yield cls._client
22
-
23
- @classmethod
24
- async def inject_client(cls) -> AsyncGenerator[httpx.AsyncClient, None]:
25
- return cls._client_handler()
26
-
27
- @classmethod
28
- @asynccontextmanager
29
- async def get_client(cls) -> AsyncGenerator[httpx.AsyncClient, None]:
30
- """
31
- Async context manager for manual HTTP client handling.
32
- Supports `async with HTTPClientManager.get() as client:`
33
- """
34
- async for client in cls._client_handler():
35
- yield client
36
-
37
- @classmethod
38
- def get_base_url(cls) -> str:
39
- raise NotImplementedError()
40
-
41
- @classmethod
42
- async def dispose(cls) -> None:
43
- """Dispose of the HTTP client and release any resources."""
44
- if cls._client is not None:
45
- await cls._client.aclose()
46
- cls._client = None
47
-
48
- class URL(BaseModel):
49
- base:str = Field(..., description="Base URL")
50
-
51
- @property
52
- def api(self) -> str:
53
- return f"{self.base}/api"
54
-
55
- class HTTPClientManagerV2(ClientManager):
56
- def __init__(self, key, name, logs_dir, google_cloud_logging = None):
57
- super().__init__(key, name, logs_dir, google_cloud_logging)
58
- self._client = httpx.AsyncClient()
59
-
60
- async def _client_handler(self) -> AsyncGenerator[httpx.AsyncClient, None]:
61
- """Reusable generator for client handling."""
62
- yield self._client
63
-
64
- async def inject_client(self) -> AsyncGenerator[httpx.AsyncClient, None]:
65
- return self._client_handler()
66
-
67
- @asynccontextmanager
68
- async def get_client(self) -> AsyncGenerator[httpx.AsyncClient, None]:
69
- """
70
- Async context manager for manual HTTP client handling.
71
- Supports `async with HTTPClientManager.get() as client:`
72
- """
73
- async for client in self._client_handler():
74
- yield client
75
-
76
- @property
77
- def client(self) -> httpx.AsyncClient:
78
- return self._client
79
-
80
- @property
81
- def url(self) -> URL:
82
- raise NotImplementedError()