maleo-foundation 0.1.33__tar.gz → 0.1.35__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.
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/PKG-INFO +1 -1
- maleo_foundation-0.1.35/maleo_foundation/managers/client/base.py +52 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/google/base.py +15 -2
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/google/secret.py +17 -5
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/google/storage.py +18 -5
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/maleo.py +14 -4
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/service.py +17 -14
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation.egg-info/PKG-INFO +1 -1
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation.egg-info/SOURCES.txt +0 -1
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/pyproject.toml +1 -1
- maleo_foundation-0.1.33/maleo_foundation/managers/client/base.py +0 -34
- maleo_foundation-0.1.33/maleo_foundation/managers/client/http.py +0 -82
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/README.md +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/authentication.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/general/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/general/http.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/base.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/base.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/logging.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/secret.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/storage.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/secret.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/storage.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/utils/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/utils/logger.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/constants.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/db/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/db/engine.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/db/manager.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/db/session.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/db/table.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/enums.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/client.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/general.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/query.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/service.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/token.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/extended_types.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/google/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/db.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/middleware.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/middlewares/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/middlewares/authentication.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/middlewares/base.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/middlewares/cors.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/responses.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/general.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/parameter.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/result.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/token.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/general/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/general/token.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/parameters/client.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/parameters/general.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/parameters/service.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/parameters/token.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/client/service.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/service/general.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/service/query.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/results/token.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/services/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/services/token.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/types.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/controller.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/exceptions.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/extractor.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/formatter/__init__.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/formatter/case.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/keyloader.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/logger.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/logging.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/query.py +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation.egg-info/dependency_links.txt +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation.egg-info/requires.txt +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation.egg-info/top_level.txt +0 -0
- {maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/setup.cfg +0 -0
@@ -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()
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/google/base.py
RENAMED
@@ -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__(
|
8
|
-
|
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__(
|
9
|
-
self
|
10
|
-
|
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:
|
19
|
+
key = "google-secret-manager"
|
20
|
+
name = "GoogleSecretManager"
|
11
21
|
super().__init__(
|
12
|
-
key=
|
13
|
-
name=
|
22
|
+
key=key,
|
23
|
+
name=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__(
|
9
|
-
self
|
10
|
-
|
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:
|
20
|
+
key = "google-cloud-storage"
|
21
|
+
name = "GoogleCloudStorage"
|
11
22
|
super().__init__(
|
12
|
-
key=
|
13
|
-
name=
|
23
|
+
key=key,
|
24
|
+
name=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
|
)
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/maleo.py
RENAMED
@@ -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__(
|
92
|
-
|
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
|
@@ -184,7 +183,6 @@ class MaleoClientManagers(BaseModel):
|
|
184
183
|
|
185
184
|
class ClientManagers(BaseModel):
|
186
185
|
google:GoogleClientManagers = Field(..., description="Google client's managers")
|
187
|
-
http:Type[HTTPClientManager] = Field(..., description="HTTP client's manager")
|
188
186
|
maleo:MaleoClientManagers = Field(..., description="Maleo client's managers")
|
189
187
|
|
190
188
|
class Config:
|
@@ -323,30 +321,36 @@ class ServiceManager:
|
|
323
321
|
|
324
322
|
def _initialize_clients(self) -> None:
|
325
323
|
#* Initialize google clients
|
326
|
-
secret = GoogleSecretManager(
|
327
|
-
|
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
|
+
)
|
328
335
|
self._google_clients = GoogleClientManagers(secret=secret, storage=storage)
|
329
|
-
#* Initialize http clients
|
330
|
-
self._http_client = HTTPClientManager
|
331
|
-
self._http_client.initialize()
|
332
336
|
#* Initialize maleo clients
|
333
337
|
self._maleo_clients = MaleoClientManagers()
|
334
338
|
for client in self._maleo_client_manager_classes.__class__.__annotations__:
|
335
339
|
client_cls = getattr(self._maleo_client_manager_classes, client)
|
336
340
|
if client_cls is not None and issubclass(client_cls, MaleoClientManager):
|
337
341
|
cfg:MaleoClientConfiguration = getattr(self._configs.client.maleo, client)
|
338
|
-
client_instance = client_cls(
|
342
|
+
client_instance = client_cls(
|
343
|
+
**cfg.model_dump(),
|
344
|
+
**self._log_config.model_dump(),
|
345
|
+
service_key=self._configs.service.key
|
346
|
+
)
|
339
347
|
setattr(self._maleo_clients, client, client_instance)
|
340
|
-
self._clients = ClientManagers(google=self._google_clients,
|
348
|
+
self._clients = ClientManagers(google=self._google_clients, maleo=self._maleo_clients)
|
341
349
|
|
342
350
|
@property
|
343
351
|
def google_clients(self) -> GoogleClientManagers:
|
344
352
|
return self._google_clients
|
345
353
|
|
346
|
-
@property
|
347
|
-
def http_client(self) -> Type[HTTPClientManager]:
|
348
|
-
return self._http_client
|
349
|
-
|
350
354
|
@property
|
351
355
|
def maleo_clients(self) -> MaleoClientManagers:
|
352
356
|
return self._maleo_clients
|
@@ -409,7 +413,6 @@ class ServiceManager:
|
|
409
413
|
if self._clients is not None:
|
410
414
|
self._clients.google.storage.dispose()
|
411
415
|
self._clients.google.secret.dispose()
|
412
|
-
await self._clients.http.dispose()
|
413
416
|
for client in self._maleo_clients.__class__.__annotations__:
|
414
417
|
client_instance = getattr(self._maleo_clients, client)
|
415
418
|
if client_instance is not None and isinstance(client_instance, MaleoClientManager):
|
@@ -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
|
@@ -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()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/general/__init__.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/general/http.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/base.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/logging.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/secret.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/cloud/storage.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/secret.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/google/storage.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/utils/__init__.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/clients/utils/logger.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/__init__.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/client.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/general.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/query.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/service.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/expanded_types/token.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/managers/client/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/middlewares/__init__.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/middlewares/authentication.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/__init__.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/general.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/parameter.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/result.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/schemas/token.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/models/transfers/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/formatter/__init__.py
RENAMED
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation/utils/formatter/case.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{maleo_foundation-0.1.33 → maleo_foundation-0.1.35}/maleo_foundation.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|