maleo-foundation 0.1.85__py3-none-any.whl → 0.1.87__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
- from maleo_foundation.managers.client.base import ClientManager
2
+ from maleo_foundation.managers.client.maleo import MaleoClientManager
3
+ from maleo_foundation.managers.service import ServiceManager
3
4
  from maleo_foundation.types import BaseTypes
4
5
  from maleo_foundation.utils.logging import SimpleConfig
5
6
  from maleo_foundation.client.services.encryption import (
@@ -20,11 +21,11 @@ from maleo_foundation.client.services import (
20
21
  MaleoFoundationServices
21
22
  )
22
23
 
23
- class MaleoFoundationClientManager(ClientManager):
24
- def __init__(self, log_config:SimpleConfig, service_key:BaseTypes.OptionalString=None):
24
+ class MaleoFoundationClientManager(MaleoClientManager):
25
+ def __init__(self, service_manager:ServiceManager):
25
26
  key = "maleo-foundation"
26
27
  name = "MaleoFoundation"
27
- super().__init__(key, name, log_config, service_key)
28
+ super().__init__(key, name, service_manager)
28
29
  self._initialize_services()
29
30
  self._logger.info("Client manager initialized successfully")
30
31
 
@@ -1,4 +1,5 @@
1
- from pydantic import BaseModel, Field
1
+ from pydantic import Field
2
+ from maleo_foundation.types import BaseTypes
2
3
  from maleo_foundation.managers.client.base import ClientManager, ClientHTTPControllerManager, ClientControllerManagers, ClientHTTPController, ClientServiceControllers, ClientControllers
3
4
  from maleo_foundation.managers.service import ServiceManager
4
5
 
@@ -22,8 +23,8 @@ class MaleoClientManager(ClientManager):
22
23
  self,
23
24
  key:str,
24
25
  name:str,
25
- url:str,
26
- service_manager:ServiceManager
26
+ service_manager:ServiceManager,
27
+ url:BaseTypes.OptionalString = None
27
28
  ):
28
29
  self._url = url
29
30
  self._service_manager = service_manager
@@ -34,6 +35,8 @@ class MaleoClientManager(ClientManager):
34
35
  return self._service_manager
35
36
 
36
37
  def _initialize_controllers(self) -> None:
38
+ if self._url is None:
39
+ raise ValueError("'URL' must not be None if initializing controllers")
37
40
  #* Initialize managers
38
41
  http_controller_manager = ClientHTTPControllerManager(url=self._url)
39
42
  self._controller_managers = ClientControllerManagers(http=http_controller_manager)
@@ -47,5 +50,7 @@ class MaleoClientManager(ClientManager):
47
50
 
48
51
  async def dispose(self) -> None:
49
52
  self._logger.info("Disposing client manager")
50
- await self._controller_managers.http.dispose()
53
+ if self._controller_managers is not None:
54
+ if self._controller_managers.http is not None:
55
+ await self._controller_managers.http.dispose()
51
56
  self._logger.info("Client manager disposed successfully")
@@ -113,26 +113,6 @@ class Loggers(BaseModel):
113
113
  class Config:
114
114
  arbitrary_types_allowed=True
115
115
 
116
- class GoogleClientManagers(BaseModel):
117
- secret:GoogleSecretManager = Field(..., description="Google secret manager's client manager")
118
- storage:GoogleCloudStorage = Field(..., description="Google cloud storage's client manager")
119
-
120
- class Config:
121
- arbitrary_types_allowed=True
122
-
123
- class MaleoClientManagers(BaseModel):
124
- foundation:MaleoFoundationClientManager = Field(..., description="MaleoFoundation's client manager")
125
-
126
- class Config:
127
- arbitrary_types_allowed=True
128
-
129
- class ClientManagers(BaseModel):
130
- google:GoogleClientManagers = Field(..., description="Google's client managers")
131
- maleo:MaleoClientManagers = Field(..., description="Maleo's client managers")
132
-
133
- class Config:
134
- arbitrary_types_allowed=True
135
-
136
116
  class ServiceManager:
137
117
  def __init__(
138
118
  self,
@@ -148,12 +128,12 @@ class ServiceManager:
148
128
  self._log_config.google_cloud_logging = None
149
129
  self._load_google_credentials()
150
130
  self._initialize_secret_manager()
131
+ self._initialize_cloud_storage()
151
132
  self._load_maleo_credentials()
152
133
  self._load_configs()
153
134
  self._load_keys()
154
135
  self._initialize_loggers()
155
136
  self._initialize_db()
156
- self._initialize_clients()
157
137
 
158
138
  @property
159
139
  def log_config(self) -> SimpleConfig:
@@ -174,9 +154,17 @@ class ServiceManager:
174
154
  self._secret_manager = GoogleSecretManager(log_config=self._log_config, service_key=self._settings.SERVICE_KEY, credentials=self._google_credentials)
175
155
 
176
156
  @property
177
- def secret_manager(self) -> None:
157
+ def secret_manager(self) -> GoogleSecretManager:
178
158
  return self._secret_manager
179
159
 
160
+ def _initialize_cloud_storage(self) -> None:
161
+ environment = BaseEnums.EnvironmentType.STAGING if self._settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL else self._settings.ENVIRONMENT
162
+ self._cloud_storage = GoogleCloudStorage(log_config=self._log_config, service_key=self._settings.SERVICE_KEY, bucket_name=f"maleo-suite-{environment}", credentials=self._google_credentials)
163
+
164
+ @property
165
+ def cloud_storage(self) -> GoogleCloudStorage:
166
+ return self._cloud_storage
167
+
180
168
  def _load_maleo_credentials(self) -> None:
181
169
  email = self._secret_manager.get("maleo-service-account-email")
182
170
  username = self._secret_manager.get("maleo-service-account-username")
@@ -241,27 +229,6 @@ class ServiceManager:
241
229
  def database(self) -> DatabaseManager:
242
230
  return self._database
243
231
 
244
- def _initialize_clients(self) -> None:
245
- secret = self._secret_manager
246
- environment = BaseEnums.EnvironmentType.STAGING if self._settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL else self._settings.ENVIRONMENT
247
- storage = GoogleCloudStorage(log_config=self._log_config, service_key=self._settings.SERVICE_KEY, bucket_name=f"maleo-suite-{environment}", credentials=self._google_credentials)
248
- self._google_clients = GoogleClientManagers(secret=secret, storage=storage)
249
- foundation = MaleoFoundationClientManager(log_config=self._log_config, service_key=self._settings.SERVICE_KEY)
250
- self._maleo_clients = MaleoClientManagers(foundation=foundation)
251
- self._clients = ClientManagers(google=self._google_clients, maleo=self._maleo_clients)
252
-
253
- @property
254
- def google_clients(self) -> GoogleClientManagers:
255
- self._google_clients
256
-
257
- @property
258
- def maleo_clients(self) -> MaleoClientManagers:
259
- self._maleo_clients
260
-
261
- @property
262
- def clients(self) -> ClientManagers:
263
- self._clients
264
-
265
232
  @property
266
233
  def token(self) -> str:
267
234
  payload = MaleoFoundationTokenGeneralTransfers.BaseEncodePayload(
@@ -4,6 +4,10 @@ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
4
4
  from maleo_foundation.types import BaseTypes
5
5
 
6
6
  class BaseResultSchemas:
7
+ class BaseRow(BaseModel):
8
+ class Config:
9
+ from_attributes=True
10
+
7
11
  class Base(BaseModel):
8
12
  success:bool = Field(..., description="Success status")
9
13
  code:BaseTypes.OptionalString = Field(None, description="Optional result code")
@@ -7,10 +7,9 @@ class BaseServiceQueryResultsTransfers:
7
7
  class Row(
8
8
  BaseGeneralSchemas.Status,
9
9
  BaseGeneralSchemas.Timestamps,
10
- BaseGeneralSchemas.Identifiers
11
- ):
12
- class Config:
13
- from_attributes=True
10
+ BaseGeneralSchemas.Identifiers,
11
+ BaseResultSchemas.BaseRow
12
+ ): pass
14
13
 
15
14
  class Fail(BaseResultSchemas.Fail): pass
16
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.85
3
+ Version: 0.1.87
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -5,7 +5,7 @@ maleo_foundation/enums.py,sha256=uvwl3dl2r6BoJMEbtSETiLoyJubHup9Lc7VOg7w7zQo,294
5
5
  maleo_foundation/extended_types.py,sha256=pIKt-_9tby4rmune3fmWcCW_mohaNRh_1lywBmdc-L4,301
6
6
  maleo_foundation/types.py,sha256=aKXnIgEhYGSfFqNMGLc4qIKGkINBRpkOo9R9cb2CbwI,2414
7
7
  maleo_foundation/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- maleo_foundation/client/manager.py,sha256=pFWLFYW4eE9MLyFmFS05IgnMBdqqUHbdyTkSbnBtm5E,2620
8
+ maleo_foundation/client/manager.py,sha256=5-wGZEwCocg06_cRh0dW5V5cXS2_4mnEMcIHuMvQyIk,2648
9
9
  maleo_foundation/client/services/__init__.py,sha256=uIBnAeQ9a2otQbUAbKBQfYrkEUugXjxXoV8W5QYHuic,1051
10
10
  maleo_foundation/client/services/key.py,sha256=Av8OFEJO8-Chlu-lRzR4or1qkJ0ahxtiHwkqF4ktDD4,5537
11
11
  maleo_foundation/client/services/signature.py,sha256=brEnNPrkeChx0niDgAYCI2HeANQGHpPI6a0lARGCbZ4,4498
@@ -32,10 +32,10 @@ maleo_foundation/expanded_types/encryption/rsa.py,sha256=MuhB_DGrjnsl4t96W4pKuCt
32
32
  maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  maleo_foundation/managers/db.py,sha256=Pn5EZ-c1Hy6-BihN7KokHJWmBIt3Ty96fZ0zF-srtF4,5208
34
34
  maleo_foundation/managers/middleware.py,sha256=ODIQU1Hpu-Xempjjo_VRbVtxiD5oi74mNuoWuDawRh0,4250
35
- maleo_foundation/managers/service.py,sha256=l5YoDj5mT4B6XtAP4LDF9h93VUkKVQGrgWIZ7nsaklE,16420
35
+ maleo_foundation/managers/service.py,sha256=rXAt2XNy_eeGSd8SEGiYZI9mbh-amj8oUN9iT4_uScw,15132
36
36
  maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  maleo_foundation/managers/client/base.py,sha256=5z9l2GN4QASF0-Lft8o5QQ3SRPXqeNZNT1S1CgaE764,4384
38
- maleo_foundation/managers/client/maleo.py,sha256=iCM47TLL-RSQ2FkTmHVPdsb2JCd1LebMx6OJvIr4vCQ,2035
38
+ maleo_foundation/managers/client/maleo.py,sha256=-QeJ6dwBtXCVGPk3hQOgy9-Um0v5hpp0-e5zPTzT4w0,2327
39
39
  maleo_foundation/managers/client/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  maleo_foundation/managers/client/google/base.py,sha256=eIdd6C2BFIu4EyZ1j017VZaJn_nSTPGFftBwQmVAUDA,1366
41
41
  maleo_foundation/managers/client/google/secret.py,sha256=Ski1CHYeA8vjSk2Oc2Pf4CfFrzT_RcA6NEZwza7gM7Y,4464
@@ -52,7 +52,7 @@ maleo_foundation/models/schemas/general.py,sha256=KGPP67ciKeL8cvOS3kYrVwmRx3kD33
52
52
  maleo_foundation/models/schemas/hash.py,sha256=db2uyCeUzvF2zDCcbiZMh1MxIOGOGezOMOx-M1ta4zI,441
53
53
  maleo_foundation/models/schemas/key.py,sha256=7FZxVqTL5qRK48AXL1odrMNhAwhwtCwSkBUPsJwuBII,594
54
54
  maleo_foundation/models/schemas/parameter.py,sha256=K47z2NzmTEhUiOfRiRLyRPXoQurbWsKBL7ObXAxIWRY,2100
55
- maleo_foundation/models/schemas/result.py,sha256=V3dljS2AdtWW4Pf8YsnQuiCylN1bZtEY1AtYC7okWuI,1747
55
+ maleo_foundation/models/schemas/result.py,sha256=fvS7yxqdCmBgU-zIcS0QkoFzuGRfPotFCRVk6uk1Lz8,1833
56
56
  maleo_foundation/models/schemas/signature.py,sha256=-5ldTnJsjwqPRbHw7PFcLKITqEXJ_qKDdRHShK75NVA,620
57
57
  maleo_foundation/models/schemas/token.py,sha256=oaK4XVb-2q31ooZMwPDfQhaGFLzs2QZxEgIGz8rp_Y4,562
58
58
  maleo_foundation/models/transfers/__init__.py,sha256=oJLJ3Geeme6vBw7R2Dhvdvg4ziVvzEYAGJaP-tm_90w,299
@@ -88,7 +88,7 @@ maleo_foundation/models/transfers/results/encryption/aes.py,sha256=yx3hZNhge2lfj
88
88
  maleo_foundation/models/transfers/results/encryption/rsa.py,sha256=hlCtiT1TZwmMBEn-sgGs-WocNEmJ4qxWcHS5y9m7Voc,683
89
89
  maleo_foundation/models/transfers/results/service/__init__.py,sha256=dTjHe1iGIpdulrzawQoOj003sxxObumF63YpUptKrDA,390
90
90
  maleo_foundation/models/transfers/results/service/general.py,sha256=G4x-MhQI7Km9UAcx2uJmrsqA6RBvxpH6VFAd_ynFFd4,1486
91
- maleo_foundation/models/transfers/results/service/query.py,sha256=G5A4FRkHyRRlpuGWrPV5-vqgyyBjMqu8f-Ka9BjD0lA,1828
91
+ maleo_foundation/models/transfers/results/service/query.py,sha256=9Nl_BDHf9cGMY4mMfgs0VFgMHWM0UKEjsUh9FgwOwb8,1813
92
92
  maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
93
93
  maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
94
94
  maleo_foundation/utils/__init__.py,sha256=SRPEVoqjZoO6W8rtF_Ti8VIangg6Auwm6eHbZMdOthY,520
@@ -107,7 +107,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
107
107
  maleo_foundation/utils/loaders/credential/google.py,sha256=deksZXT5wPhEsSMHbZ3x05WHXxCjLDt76Ns-1Tmhp7g,948
108
108
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
109
109
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
110
- maleo_foundation-0.1.85.dist-info/METADATA,sha256=sg3XSlU15Aog8U__kh4pcz3yctxyUpRbh9SLX8nF3-c,3419
111
- maleo_foundation-0.1.85.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
112
- maleo_foundation-0.1.85.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
113
- maleo_foundation-0.1.85.dist-info/RECORD,,
110
+ maleo_foundation-0.1.87.dist-info/METADATA,sha256=fHG1758lVh2m6laf255Ny581zX92lPSX4OSxDcDi5yc,3419
111
+ maleo_foundation-0.1.87.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
112
+ maleo_foundation-0.1.87.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
113
+ maleo_foundation-0.1.87.dist-info/RECORD,,