maleo-foundation 0.3.71__tar.gz → 0.3.74__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.3.71 → maleo_foundation-0.3.74}/PKG-INFO +3 -1
- maleo_foundation-0.3.74/maleo_foundation/authentication.py +36 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/manager.py +9 -3
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/constants.py +2 -0
- maleo_foundation-0.3.74/maleo_foundation/controller_types.py +25 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/enums.py +7 -1
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/base.py +37 -5
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/base.py +7 -3
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/secret.py +12 -3
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/storage.py +11 -2
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/subscription.py +40 -26
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/maleo.py +3 -5
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/credential.py +6 -2
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/middleware.py +8 -8
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/service.py +33 -17
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/authentication.py +3 -2
- maleo_foundation-0.3.74/maleo_foundation/middlewares/base.py +589 -0
- maleo_foundation-0.3.74/maleo_foundation/models/schemas/general.py +116 -0
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/authentication.py +35 -0
- {maleo_foundation-0.3.71/maleo_foundation → maleo_foundation-0.3.74/maleo_foundation/models/transfers/general}/authorization.py +0 -3
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/__init__.py +2 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/client/maleo.py +1 -1
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/middleware.py +6 -7
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/configurations/pubsub/subscription.py +16 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/service.py +2 -1
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/operation.py +213 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/request.py +13 -19
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/response.py +14 -0
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/service.py +9 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/settings.py +1 -1
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/user_agent.py +34 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/client.py +26 -2
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/service.py +26 -2
- maleo_foundation-0.3.74/maleo_foundation/utils/extractor.py +97 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/logging.py +90 -21
- maleo_foundation-0.3.74/maleo_foundation/utils/parser.py +7 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/PKG-INFO +3 -1
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/SOURCES.txt +8 -4
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/requires.txt +2 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/pyproject.toml +3 -1
- maleo_foundation-0.3.71/maleo_foundation/authentication.py +0 -82
- maleo_foundation-0.3.71/maleo_foundation/middlewares/base.py +0 -474
- maleo_foundation-0.3.71/maleo_foundation/models/schemas/general.py +0 -242
- maleo_foundation-0.3.71/maleo_foundation/models/transfers/general/operation.py +0 -51
- maleo_foundation-0.3.71/maleo_foundation/utils/dependencies/__init__.py +0 -6
- maleo_foundation-0.3.71/maleo_foundation/utils/dependencies/auth.py +0 -17
- maleo_foundation-0.3.71/maleo_foundation/utils/dependencies/context.py +0 -8
- maleo_foundation-0.3.71/maleo_foundation/utils/extractor.py +0 -67
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/README.md +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/aes.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/hmac.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/sha256.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/key.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/signature.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/client/services/token.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/client.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/general.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/hash.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/key.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/service.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/signature.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/token.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/extended_types.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/cache.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/parameter.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/configuration.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/db.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/cors.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/responses.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/encryption.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/hash.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/key.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/parameter.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/result.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/signature.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/token.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/table.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/cache/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/cache/redis.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/client/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/database.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/publisher.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/credentials.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/data.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/database.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/key.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/signature.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/token.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/client.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/general.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/key.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/service.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/token.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/service.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/hash.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/key.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/general.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/signature.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/token.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/rest_controller_result.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/types.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/cache.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/client.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/controller.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/request.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/formatter/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/formatter/case.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/credential/google.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/json.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/yaml.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/merger.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/query.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/repository.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/utils/searcher.py +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/dependency_links.txt +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/top_level.txt +0 -0
- {maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maleo_foundation
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.74
|
4
4
|
Summary: Foundation package for Maleo
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
6
6
|
License: MIT
|
@@ -98,6 +98,8 @@ Requires-Dist: starlette>=0.46.2
|
|
98
98
|
Requires-Dist: twine>=6.1.0
|
99
99
|
Requires-Dist: typing-inspection>=0.4.0
|
100
100
|
Requires-Dist: typing_extensions>=4.13.2
|
101
|
+
Requires-Dist: ua-parser>=1.0.1
|
102
|
+
Requires-Dist: ua-parser-builtins>=0.18.0.post1
|
101
103
|
Requires-Dist: urllib3>=2.4.0
|
102
104
|
Requires-Dist: uvicorn>=0.34.2
|
103
105
|
Requires-Dist: virtualenv>=20.31.2
|
@@ -0,0 +1,36 @@
|
|
1
|
+
from starlette.authentication import AuthCredentials, BaseUser
|
2
|
+
from typing import Optional, Sequence
|
3
|
+
from maleo_foundation.models.transfers.general.authentication import Token
|
4
|
+
|
5
|
+
|
6
|
+
class Credentials(AuthCredentials):
|
7
|
+
def __init__(
|
8
|
+
self, token: Optional[Token] = None, scopes: Optional[Sequence[str]] = None
|
9
|
+
) -> None:
|
10
|
+
self._token = token
|
11
|
+
super().__init__(scopes)
|
12
|
+
|
13
|
+
@property
|
14
|
+
def token(self) -> Optional[Token]:
|
15
|
+
return self._token
|
16
|
+
|
17
|
+
|
18
|
+
class User(BaseUser):
|
19
|
+
def __init__(
|
20
|
+
self, authenticated: bool = False, username: str = "", email: str = ""
|
21
|
+
) -> None:
|
22
|
+
self._authenticated = authenticated
|
23
|
+
self._username = username
|
24
|
+
self._email = email
|
25
|
+
|
26
|
+
@property
|
27
|
+
def is_authenticated(self) -> bool:
|
28
|
+
return self._authenticated
|
29
|
+
|
30
|
+
@property
|
31
|
+
def display_name(self) -> str:
|
32
|
+
return self._username
|
33
|
+
|
34
|
+
@property
|
35
|
+
def identity(self) -> str:
|
36
|
+
return self._email
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
+
from typing import Optional
|
3
|
+
from maleo_foundation.enums import BaseEnums
|
2
4
|
from maleo_foundation.managers.client.base import ClientManager
|
3
|
-
from maleo_foundation.types import BaseTypes
|
4
5
|
from maleo_foundation.utils.logging import SimpleConfig
|
5
6
|
from maleo_foundation.client.services.encryption import (
|
6
7
|
MaleoFoundationAESEncryptionClientService,
|
@@ -23,11 +24,16 @@ from maleo_foundation.client.services import (
|
|
23
24
|
|
24
25
|
class MaleoFoundationClientManager(ClientManager):
|
25
26
|
def __init__(
|
26
|
-
self,
|
27
|
+
self,
|
28
|
+
log_config: SimpleConfig,
|
29
|
+
service_environment: Optional[BaseEnums.EnvironmentType] = None,
|
30
|
+
service_key: Optional[BaseEnums.Service] = None,
|
27
31
|
) -> None:
|
28
32
|
key = "maleo-foundation"
|
29
33
|
name = "MaleoFoundation"
|
30
|
-
super().__init__(
|
34
|
+
super().__init__(
|
35
|
+
key, name, log_config, service_environment, service_key, service_environment
|
36
|
+
)
|
31
37
|
self._initialize_services()
|
32
38
|
self._logger.info("Client manager initialized successfully")
|
33
39
|
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import re
|
2
|
+
from fastapi.security import HTTPBearer
|
2
3
|
from typing import List
|
3
4
|
from uuid import UUID
|
4
5
|
from maleo_foundation.enums import BaseEnums
|
5
6
|
from maleo_foundation.types import BaseTypes
|
6
7
|
|
8
|
+
TOKEN_SCHEME = HTTPBearer()
|
7
9
|
EMAIL_REGEX: str = r"^[^\s@]+@[^\s@]+\.[^\s@]+$"
|
8
10
|
TOKEN_COOKIE_KEY_NAME = "token"
|
9
11
|
REFRESH_TOKEN_DURATION_DAYS: int = 7
|
@@ -0,0 +1,25 @@
|
|
1
|
+
from google.cloud.pubsub_v1.subscriber.message import Message
|
2
|
+
from typing import Awaitable, Callable, Optional, Union
|
3
|
+
from maleo_foundation.models.transfers.results.service.controllers.rest import (
|
4
|
+
BaseServiceRESTControllerResults,
|
5
|
+
)
|
6
|
+
|
7
|
+
|
8
|
+
class ControllerTypes:
|
9
|
+
# * REST controller types
|
10
|
+
SyncRESTController = Callable[..., BaseServiceRESTControllerResults]
|
11
|
+
OptionalSyncRESTController = Optional[
|
12
|
+
Callable[..., BaseServiceRESTControllerResults]
|
13
|
+
]
|
14
|
+
AsyncRESTController = Callable[..., Awaitable[BaseServiceRESTControllerResults]]
|
15
|
+
OptionalAsyncRESTController = Optional[
|
16
|
+
Callable[..., Awaitable[BaseServiceRESTControllerResults]]
|
17
|
+
]
|
18
|
+
RESTController = Union[SyncRESTController, AsyncRESTController]
|
19
|
+
OptionalRESTController = Optional[RESTController]
|
20
|
+
|
21
|
+
# * Message controller types
|
22
|
+
SyncMessageController = Callable[[str, Message], bool]
|
23
|
+
AsyncMessageController = Callable[[str, Message], Awaitable[bool]]
|
24
|
+
MessageController = Union[SyncMessageController, AsyncMessageController]
|
25
|
+
OptionalMessageController = Optional[MessageController]
|
@@ -69,10 +69,12 @@ class BaseEnums:
|
|
69
69
|
|
70
70
|
class ExceptionType(StrEnum):
|
71
71
|
TIMEOUT = "timeout"
|
72
|
+
BAD = "bad"
|
72
73
|
UNAUTHORIZED = "unauthorized"
|
73
74
|
FORBIDDEN = "forbidden"
|
74
75
|
NOT_FOUND = "not_found"
|
75
76
|
VALIDATION = "validation"
|
77
|
+
RATE_LIMIT = "rate_limit"
|
76
78
|
INTERNAL = "internal"
|
77
79
|
UNAVAILABLE = "unavailable"
|
78
80
|
|
@@ -91,6 +93,7 @@ class BaseEnums:
|
|
91
93
|
SERVICE = "service"
|
92
94
|
|
93
95
|
class OperationLayer(StrEnum):
|
96
|
+
MIDDLEWARE = "middleware"
|
94
97
|
ROUTER = "router"
|
95
98
|
CONTROLLER = "controller"
|
96
99
|
SERVICE = "service"
|
@@ -122,6 +125,7 @@ class BaseEnums:
|
|
122
125
|
READ = "read"
|
123
126
|
UPDATE = "update"
|
124
127
|
DELETE = "delete"
|
128
|
+
OTHER = "other"
|
125
129
|
|
126
130
|
class CreateType(StrEnum):
|
127
131
|
CREATE = "create"
|
@@ -185,12 +189,14 @@ class BaseEnums:
|
|
185
189
|
APPLICATION = "application"
|
186
190
|
CACHE = "cache"
|
187
191
|
CLIENT = "client"
|
192
|
+
CONTROLLER = "controller"
|
188
193
|
DATABASE = "database"
|
189
194
|
MIDDLEWARE = "middleware"
|
190
195
|
REPOSITORY = "repository"
|
196
|
+
ROUTER = "router"
|
191
197
|
SERVICE = "service"
|
192
198
|
|
193
|
-
class
|
199
|
+
class LogLevel(IntEnum):
|
194
200
|
CRITICAL = logging.CRITICAL
|
195
201
|
FATAL = logging.FATAL
|
196
202
|
ERROR = logging.ERROR
|
{maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/base.py
RENAMED
@@ -1,8 +1,9 @@
|
|
1
1
|
import httpx
|
2
|
+
import os
|
2
3
|
from contextlib import asynccontextmanager
|
3
4
|
from pydantic import BaseModel, ConfigDict, Field
|
4
|
-
from typing import AsyncGenerator, Generator
|
5
|
-
from maleo_foundation.
|
5
|
+
from typing import AsyncGenerator, Generator, Optional
|
6
|
+
from maleo_foundation.enums import BaseEnums
|
6
7
|
from maleo_foundation.utils.logging import ClientLogger, SimpleConfig
|
7
8
|
|
8
9
|
|
@@ -107,18 +108,43 @@ class ClientManager:
|
|
107
108
|
key: str,
|
108
109
|
name: str,
|
109
110
|
log_config: SimpleConfig,
|
110
|
-
|
111
|
+
service_environment: Optional[BaseEnums.EnvironmentType] = None,
|
112
|
+
service_key: Optional[BaseEnums.Service] = None,
|
113
|
+
environment: Optional[BaseEnums.EnvironmentType] = None,
|
111
114
|
) -> None:
|
112
115
|
self._key = key
|
113
116
|
self._name = name
|
114
117
|
self._log_config = log_config
|
115
|
-
|
118
|
+
|
119
|
+
# Ensure environment exists
|
120
|
+
actual_service_environment = service_environment or os.getenv("ENVIRONMENT")
|
121
|
+
if actual_service_environment is None:
|
122
|
+
raise ValueError(
|
123
|
+
"ENVIRONMENT environment variable must be set if 'service_environment' is set to None"
|
124
|
+
)
|
125
|
+
else:
|
126
|
+
self._service_environment = BaseEnums.EnvironmentType(
|
127
|
+
actual_service_environment
|
128
|
+
)
|
129
|
+
|
130
|
+
# Ensure service_key exists
|
131
|
+
actual_service_key = service_key or os.getenv("SERVICE_KEY")
|
132
|
+
if actual_service_key is None:
|
133
|
+
raise ValueError(
|
134
|
+
"SERVICE_KEY environment variable must be set if 'service_key' is set to None"
|
135
|
+
)
|
136
|
+
else:
|
137
|
+
self._service_key = BaseEnums.Service(actual_service_key)
|
138
|
+
|
139
|
+
self._environment = environment
|
140
|
+
|
116
141
|
self._initialize_logger()
|
117
|
-
self._logger.info("Initializing client manager")
|
142
|
+
self._logger.info(f"Initializing {self._name} client manager")
|
118
143
|
|
119
144
|
def _initialize_logger(self) -> None:
|
120
145
|
self._logger = ClientLogger(
|
121
146
|
client_key=self._key,
|
147
|
+
environment=self._service_environment,
|
122
148
|
service_key=self._service_key,
|
123
149
|
**self._log_config.model_dump(),
|
124
150
|
)
|
@@ -131,6 +157,12 @@ class ClientManager:
|
|
131
157
|
def name(self) -> str:
|
132
158
|
return self._name
|
133
159
|
|
160
|
+
@property
|
161
|
+
def environment(self) -> BaseEnums.EnvironmentType:
|
162
|
+
if self._environment is None:
|
163
|
+
raise ValueError("Environment has not been initialized.")
|
164
|
+
return self._environment
|
165
|
+
|
134
166
|
@property
|
135
167
|
def logger(self) -> ClientLogger:
|
136
168
|
return self._logger
|
{maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/base.py
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
from google.oauth2.service_account import Credentials
|
2
2
|
from pathlib import Path
|
3
3
|
from typing import Optional, Union
|
4
|
-
from maleo_foundation.
|
4
|
+
from maleo_foundation.enums import BaseEnums
|
5
5
|
from maleo_foundation.managers.client.base import ClientManager
|
6
6
|
from maleo_foundation.utils.loaders.credential.google import GoogleCredentialsLoader
|
7
7
|
from maleo_foundation.utils.logging import SimpleConfig
|
@@ -13,11 +13,15 @@ class GoogleClientManager(ClientManager):
|
|
13
13
|
key: str,
|
14
14
|
name: str,
|
15
15
|
log_config: SimpleConfig,
|
16
|
-
|
16
|
+
service_environment: Optional[BaseEnums.EnvironmentType] = None,
|
17
|
+
service_key: Optional[BaseEnums.Service] = None,
|
18
|
+
environment: Optional[BaseEnums.EnvironmentType] = None,
|
17
19
|
credentials: Optional[Credentials] = None,
|
18
20
|
credentials_path: Optional[Union[Path, str]] = None,
|
19
21
|
) -> None:
|
20
|
-
super().__init__(
|
22
|
+
super().__init__(
|
23
|
+
key, name, log_config, service_environment, service_key, environment
|
24
|
+
)
|
21
25
|
if (credentials is not None and credentials_path is not None) or (
|
22
26
|
credentials is None and credentials_path is None
|
23
27
|
):
|
@@ -4,7 +4,7 @@ from google.cloud import secretmanager
|
|
4
4
|
from google.oauth2.service_account import Credentials
|
5
5
|
from pathlib import Path
|
6
6
|
from typing import Optional, Union
|
7
|
-
from maleo_foundation.
|
7
|
+
from maleo_foundation.enums import BaseEnums
|
8
8
|
from maleo_foundation.utils.logging import SimpleConfig
|
9
9
|
from .base import GoogleClientManager
|
10
10
|
|
@@ -13,14 +13,23 @@ class GoogleSecretManager(GoogleClientManager):
|
|
13
13
|
def __init__(
|
14
14
|
self,
|
15
15
|
log_config: SimpleConfig,
|
16
|
-
|
16
|
+
service_environment: Optional[BaseEnums.EnvironmentType] = None,
|
17
|
+
service_key: Optional[BaseEnums.Service] = None,
|
18
|
+
environment: Optional[BaseEnums.EnvironmentType] = None,
|
17
19
|
credentials: Optional[Credentials] = None,
|
18
20
|
credentials_path: Optional[Union[Path, str]] = None,
|
19
21
|
) -> None:
|
20
22
|
key = "google-secret-manager"
|
21
23
|
name = "GoogleSecretManager"
|
22
24
|
super().__init__(
|
23
|
-
key,
|
25
|
+
key,
|
26
|
+
name,
|
27
|
+
log_config,
|
28
|
+
service_environment,
|
29
|
+
service_key,
|
30
|
+
environment,
|
31
|
+
credentials,
|
32
|
+
credentials_path,
|
24
33
|
)
|
25
34
|
self._client = secretmanager.SecretManagerServiceClient(
|
26
35
|
credentials=self._credentials
|
@@ -15,7 +15,9 @@ class GoogleCloudStorage(GoogleClientManager):
|
|
15
15
|
def __init__(
|
16
16
|
self,
|
17
17
|
log_config: SimpleConfig,
|
18
|
-
|
18
|
+
service_environment: Optional[BaseEnums.EnvironmentType] = None,
|
19
|
+
service_key: Optional[BaseEnums.Service] = None,
|
20
|
+
environment: Optional[BaseEnums.EnvironmentType] = None,
|
19
21
|
credentials: Optional[Credentials] = None,
|
20
22
|
credentials_path: Optional[Union[Path, str]] = None,
|
21
23
|
bucket_name: BaseTypes.OptionalString = None,
|
@@ -24,7 +26,14 @@ class GoogleCloudStorage(GoogleClientManager):
|
|
24
26
|
key = "google-cloud-storage"
|
25
27
|
name = "GoogleCloudStorage"
|
26
28
|
super().__init__(
|
27
|
-
key,
|
29
|
+
key,
|
30
|
+
name,
|
31
|
+
log_config,
|
32
|
+
service_environment,
|
33
|
+
service_key,
|
34
|
+
environment,
|
35
|
+
credentials,
|
36
|
+
credentials_path,
|
28
37
|
)
|
29
38
|
self._client = Client(credentials=self._credentials)
|
30
39
|
self._bucket_name = bucket_name or os.getenv("GCS_BUCKET_NAME")
|
@@ -5,36 +5,37 @@ from google.cloud.pubsub_v1.subscriber.futures import StreamingPullFuture
|
|
5
5
|
from google.cloud.pubsub_v1.subscriber.message import Message
|
6
6
|
from google.oauth2.service_account import Credentials
|
7
7
|
from pathlib import Path
|
8
|
-
from
|
9
|
-
from
|
8
|
+
from typing import Dict, List, Optional, Union, cast
|
9
|
+
from maleo_foundation.controller_types import ControllerTypes
|
10
|
+
from maleo_foundation.enums import BaseEnums
|
10
11
|
from maleo_foundation.managers.client.google.base import GoogleClientManager
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Controller = Union[SyncController, AsyncController]
|
15
|
-
OptionalController = Optional[Controller]
|
16
|
-
|
17
|
-
|
18
|
-
class SubscriptionConfigurations(BaseModel):
|
19
|
-
subscription_name: str
|
20
|
-
max_messages: int = 10
|
21
|
-
ack_deadline: int = 10
|
22
|
-
controller: OptionalController = None
|
12
|
+
from maleo_foundation.models.transfers.general.configurations.pubsub.subscription import (
|
13
|
+
ExtendedSubscriptionConfigurations,
|
14
|
+
)
|
23
15
|
|
24
16
|
|
25
17
|
class SubscriptionManager(GoogleClientManager):
|
26
18
|
def __init__(
|
27
19
|
self,
|
28
|
-
subscriptions: List[
|
20
|
+
subscriptions: List[ExtendedSubscriptionConfigurations],
|
29
21
|
log_config,
|
30
|
-
|
22
|
+
service_environment: Optional[BaseEnums.EnvironmentType] = None,
|
23
|
+
service_key: Optional[BaseEnums.Service] = None,
|
24
|
+
environment: Optional[BaseEnums.EnvironmentType] = None,
|
31
25
|
credentials: Optional[Credentials] = None,
|
32
26
|
credentials_path: Optional[Union[Path, str]] = None,
|
33
27
|
):
|
34
28
|
key = "google-subscription-manager"
|
35
29
|
name = "GoogleSubscriptionManager"
|
36
30
|
super().__init__(
|
37
|
-
key,
|
31
|
+
key,
|
32
|
+
name,
|
33
|
+
log_config,
|
34
|
+
service_environment,
|
35
|
+
service_key,
|
36
|
+
environment,
|
37
|
+
credentials,
|
38
|
+
credentials_path,
|
38
39
|
)
|
39
40
|
self.subscriber = pubsub_v1.SubscriberClient(credentials=self._credentials)
|
40
41
|
self.subscriptions = subscriptions
|
@@ -42,19 +43,28 @@ class SubscriptionManager(GoogleClientManager):
|
|
42
43
|
self.loop: Optional[asyncio.AbstractEventLoop] = None
|
43
44
|
|
44
45
|
async def _handle_async_controller(
|
45
|
-
self,
|
46
|
+
self,
|
47
|
+
controller: ControllerTypes.AsyncMessageController,
|
48
|
+
subscription_name: str,
|
49
|
+
message: Message,
|
46
50
|
) -> None:
|
47
51
|
success = await controller(subscription_name, message)
|
48
52
|
message.ack() if success else message.nack()
|
49
53
|
|
50
54
|
def _handle_sync_controller(
|
51
|
-
self,
|
55
|
+
self,
|
56
|
+
controller: ControllerTypes.SyncMessageController,
|
57
|
+
subscription_name: str,
|
58
|
+
message: Message,
|
52
59
|
) -> None:
|
53
60
|
success = controller(subscription_name, message)
|
54
61
|
message.ack() if success else message.nack()
|
55
62
|
|
56
63
|
def _message_callback(
|
57
|
-
self,
|
64
|
+
self,
|
65
|
+
controller: ControllerTypes.OptionalMessageController,
|
66
|
+
subscription_name: str,
|
67
|
+
message: Message,
|
58
68
|
):
|
59
69
|
# If controller is not given, conduct default message processing
|
60
70
|
if controller is None:
|
@@ -68,13 +78,17 @@ class SubscriptionManager(GoogleClientManager):
|
|
68
78
|
raise RuntimeError("Event loop not set in SubscriptionManager")
|
69
79
|
asyncio.run_coroutine_threadsafe(
|
70
80
|
self._handle_async_controller(
|
71
|
-
cast(
|
81
|
+
cast(ControllerTypes.AsyncMessageController, controller),
|
82
|
+
subscription_name,
|
83
|
+
message,
|
72
84
|
),
|
73
85
|
self.loop,
|
74
86
|
)
|
75
87
|
else:
|
76
88
|
self._handle_sync_controller(
|
77
|
-
cast(
|
89
|
+
cast(ControllerTypes.SyncMessageController, controller),
|
90
|
+
subscription_name,
|
91
|
+
message,
|
78
92
|
)
|
79
93
|
|
80
94
|
def _default_message_processing(
|
@@ -94,18 +108,18 @@ class SubscriptionManager(GoogleClientManager):
|
|
94
108
|
message.nack()
|
95
109
|
|
96
110
|
async def _start_subscription_listener(
|
97
|
-
self, config:
|
111
|
+
self, config: ExtendedSubscriptionConfigurations
|
98
112
|
) -> None:
|
99
113
|
if self.credentials.project_id is None:
|
100
114
|
raise ValueError("Project ID must be set in credentials")
|
101
115
|
subscription_path = self.subscriber.subscription_path(
|
102
|
-
self.credentials.project_id, config.
|
116
|
+
self.credentials.project_id, config.id
|
103
117
|
)
|
104
118
|
flow_control = pubsub_v1.types.FlowControl(max_messages=config.max_messages)
|
105
119
|
future = self.subscriber.subscribe(
|
106
120
|
subscription_path,
|
107
121
|
callback=lambda message: self._message_callback(
|
108
|
-
config.controller, config.
|
122
|
+
config.controller, config.id, message
|
109
123
|
),
|
110
124
|
flow_control=flow_control,
|
111
125
|
await_callbacks_on_shutdown=True,
|
@@ -117,7 +131,7 @@ class SubscriptionManager(GoogleClientManager):
|
|
117
131
|
if not isinstance(e, asyncio.CancelledError):
|
118
132
|
self._logger.error(
|
119
133
|
"Listener error for subscription '%s': %s",
|
120
|
-
config.
|
134
|
+
config.id,
|
121
135
|
e,
|
122
136
|
exc_info=True,
|
123
137
|
)
|
{maleo_foundation-0.3.71 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/maleo.py
RENAMED
@@ -74,7 +74,9 @@ class MaleoClientManager(ClientManager):
|
|
74
74
|
key,
|
75
75
|
name,
|
76
76
|
service_manager.log_config,
|
77
|
-
service_manager.
|
77
|
+
service_manager.settings.ENVIRONMENT,
|
78
|
+
service_manager.settings.SERVICE_KEY,
|
79
|
+
environment,
|
78
80
|
)
|
79
81
|
self._environment = environment
|
80
82
|
|
@@ -82,10 +84,6 @@ class MaleoClientManager(ClientManager):
|
|
82
84
|
def service_manager(self) -> ServiceManager:
|
83
85
|
return self._service_manager
|
84
86
|
|
85
|
-
@property
|
86
|
-
def environment(self) -> BaseEnums.EnvironmentType:
|
87
|
-
return self._environment
|
88
|
-
|
89
87
|
def _initialize_controllers(self) -> None:
|
90
88
|
# * Initialize managers
|
91
89
|
http_controller_manager = ClientHTTPControllerManager(url=self._url)
|
@@ -9,9 +9,13 @@ from maleo_foundation.utils.logging import SimpleConfig
|
|
9
9
|
|
10
10
|
|
11
11
|
class CredentialManager:
|
12
|
-
def __init__(
|
13
|
-
self
|
12
|
+
def __init__(
|
13
|
+
self,
|
14
|
+
log_config: SimpleConfig,
|
15
|
+
settings: Settings,
|
16
|
+
):
|
14
17
|
self.log_config = log_config
|
18
|
+
self.settings = settings
|
15
19
|
self._initialize()
|
16
20
|
|
17
21
|
def _load_google_credentials(self) -> None:
|
@@ -4,6 +4,7 @@ from maleo_foundation.models.schemas import BaseGeneralSchemas
|
|
4
4
|
from maleo_foundation.models.transfers.general.configurations.middleware import (
|
5
5
|
MiddlewareConfigurations,
|
6
6
|
)
|
7
|
+
from maleo_foundation.models.transfers.general.settings import Settings
|
7
8
|
from maleo_foundation.middlewares.authentication import add_authentication_middleware
|
8
9
|
from maleo_foundation.middlewares.base import add_base_middleware
|
9
10
|
from maleo_foundation.middlewares.cors import add_cors_middleware
|
@@ -14,12 +15,14 @@ class MiddlewareManager:
|
|
14
15
|
def __init__(
|
15
16
|
self,
|
16
17
|
app: FastAPI,
|
18
|
+
settings: Settings,
|
17
19
|
configurations: MiddlewareConfigurations,
|
18
20
|
keys: BaseGeneralSchemas.RSAKeys,
|
19
21
|
logger: MiddlewareLogger,
|
20
22
|
maleo_foundation: MaleoFoundationClientManager,
|
21
23
|
):
|
22
24
|
self._app = app
|
25
|
+
self._settings = settings
|
23
26
|
self._configurations = configurations
|
24
27
|
self._keys = keys
|
25
28
|
self._logger = logger
|
@@ -33,23 +36,20 @@ class MiddlewareManager:
|
|
33
36
|
def add_cors(self) -> None:
|
34
37
|
add_cors_middleware(
|
35
38
|
app=self._app,
|
36
|
-
allow_origins=self._configurations.
|
37
|
-
allow_methods=self._configurations.
|
38
|
-
allow_headers=self._configurations.
|
39
|
-
allow_credentials=self._configurations.
|
39
|
+
allow_origins=self._configurations.cors.allow_origins,
|
40
|
+
allow_methods=self._configurations.cors.allow_methods,
|
41
|
+
allow_headers=self._configurations.cors.allow_headers,
|
42
|
+
allow_credentials=self._configurations.cors.allow_credentials,
|
40
43
|
expose_headers=self._configurations.cors.expose_headers,
|
41
44
|
)
|
42
45
|
|
43
46
|
def add_base(self):
|
44
47
|
add_base_middleware(
|
45
48
|
app=self._app,
|
49
|
+
settings=self._settings,
|
46
50
|
keys=self._keys,
|
47
51
|
logger=self._logger,
|
48
52
|
maleo_foundation=self._maleo_foundation,
|
49
|
-
allow_origins=self._configurations.general.allow_origins,
|
50
|
-
allow_methods=self._configurations.general.allow_methods,
|
51
|
-
allow_headers=self._configurations.general.allow_headers,
|
52
|
-
allow_credentials=self._configurations.general.allow_credentials,
|
53
53
|
limit=self._configurations.base.limit,
|
54
54
|
window=self._configurations.base.window,
|
55
55
|
cleanup_interval=self._configurations.base.cleanup_interval,
|
@@ -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:
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
170
|
-
f"google-cloud-storage:{self.
|
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,
|
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,
|