maleo-foundation 0.3.11__py3-none-any.whl → 0.3.13__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.
@@ -63,7 +63,7 @@ class MaleoClientManager(ClientManager):
63
63
  key,
64
64
  name,
65
65
  service_manager.log_config,
66
- service_manager.configs.service.key
66
+ service_manager.configurations.service.key
67
67
  )
68
68
 
69
69
  @property
@@ -72,31 +72,43 @@ class ServiceManager:
72
72
  @property
73
73
  def settings(self) -> Settings:
74
74
  return self._settings
75
-
75
+
76
76
  @property
77
77
  def log_config(self) -> SimpleConfig:
78
78
  return self._log_config
79
-
79
+
80
80
  @property
81
81
  def google_credentials(self) -> Credentials:
82
82
  return self._credential_manager.google_credentials
83
-
83
+
84
84
  @property
85
85
  def secret_manager(self) -> GoogleSecretManager:
86
86
  return self._credential_manager.secret_manager
87
-
87
+
88
88
  @property
89
89
  def maleo_credentials(self) -> MaleoCredentials:
90
90
  return self._credential_manager.maleo_credentials
91
-
91
+
92
92
  @property
93
93
  def configurations(self) -> Configurations:
94
94
  return self._configuration_manager.configurations
95
95
 
96
96
  def _load_keys(self) -> None:
97
- password = self.secret_manager.get(name="maleo-key-password")
98
- private = self.secret_manager.get(name="maleo-private-key")
99
- public = self.secret_manager.get(name="maleo-public-key")
97
+ if self.settings.KEY_PASSWORD is not None:
98
+ password = self.settings.KEY_PASSWORD
99
+ else:
100
+ password = self.secret_manager.get(name="maleo-key-password")
101
+
102
+ if self.settings.PRIVATE_KEY is not None:
103
+ private = self.settings.PRIVATE_KEY
104
+ else:
105
+ private = self.secret_manager.get(name="maleo-private-key")
106
+
107
+ if self.settings.PUBLIC_KEY is not None:
108
+ public = self.settings.PUBLIC_KEY
109
+ else:
110
+ public = self.secret_manager.get(name="maleo-public-key")
111
+
100
112
  self._keys = BaseGeneralSchemas.RSAKeys(
101
113
  password=password,
102
114
  private=private,
@@ -231,12 +243,14 @@ class ServiceManager:
231
243
  def create_app(
232
244
  self,
233
245
  router: APIRouter,
234
- lifespan: Optional[Lifespan[AppType]] = None
246
+ lifespan: Optional[Lifespan[AppType]] = None,
247
+ version: str = "unknown"
235
248
  ) -> FastAPI:
236
249
  self._loggers.application.info("Creating FastAPI application")
237
- root_path = "" if self._settings.ENVIRONMENT == "local" else f"/{self.configurations.service.key.removeprefix("maleo-")}"
250
+ root_path = self._settings.ROOT_PATH
238
251
  self._app = FastAPI(
239
252
  title=self.configurations.service.name,
253
+ version=version,
240
254
  lifespan=lifespan,
241
255
  root_path=root_path
242
256
  )
@@ -21,5 +21,5 @@ class RedisCacheConfigurations(BaseModel):
21
21
  port: int = Field(6379, description="Redis instance's port")
22
22
  db: int = Field(0, description="Redis instance's db")
23
23
  password: BaseTypes.OptionalString = Field(None, description="AUTH password")
24
- decode_responses: bool = Field(False, description="Whether to decode responses")
24
+ decode_responses: bool = Field(True, description="Whether to decode responses")
25
25
  health_check_interval: int = Field(30, description="Health check interval")
@@ -18,21 +18,4 @@ class DatabaseAccess(BaseModel):
18
18
  service: BaseEnums.Service = Field(..., description="Service key")
19
19
  table: str = Field(..., description="Table name")
20
20
  data_id: int = Field(..., ge=1, description="Data Id")
21
- data: BaseTypes.StringToAnyDict = Field(..., description="Data")
22
-
23
- def to_google_pubsub_object(self) -> BaseTypes.StringToAnyDict:
24
- result = {
25
- "accessed_at": self.accessed_at.isoformat(),
26
- "request_id": str(self.request_id),
27
- "request_context": self.request_context.to_google_pubsub_object(),
28
- "organization_id": None if self.organization_id is None else {"int": self.organization_id},
29
- "user_id": self.user_id,
30
- "token_string": None if self.token_string is None else {"string": self.token_string},
31
- "token_payload": None if self.token_payload is None else {"TokenPayload": self.token_payload.to_google_pubsub_object()},
32
- "service": self.service.replace("-", "_"),
33
- "table": self.table,
34
- "data_id": self.data_id,
35
- "data": self.data
36
- }
37
-
38
- return result
21
+ data: BaseTypes.StringToAnyDict = Field(..., description="Data")
@@ -1,8 +1,6 @@
1
1
  from __future__ import annotations
2
2
  from datetime import datetime, timezone
3
- from pydantic import BaseModel, Field, field_serializer
4
- from starlette.datastructures import QueryParams
5
- from typing import Dict, Any
3
+ from pydantic import BaseModel, Field
6
4
  from uuid import UUID
7
5
  from maleo_foundation.types import BaseTypes
8
6
 
@@ -26,53 +24,4 @@ class RequestContext(BaseModel):
26
24
  language: BaseTypes.OptionalString = Field(None, description="Accepted languages from client")
27
25
 
28
26
  class Config:
29
- arbitrary_types_allowed = True
30
-
31
- @field_serializer('query_params', when_used='json')
32
- def serialize_query_params(self, qp: QueryParams, _info) -> str:
33
- return str(qp)
34
-
35
- def to_google_pubsub_object(self) -> Dict[str, Any]:
36
- result = {
37
- "request_id": str(self.request_id),
38
- "requested_at": self.requested_at.isoformat(),
39
- "method": self.method,
40
- "url": self.url,
41
- "path_params": None if self.path_params is None else {"map": self.path_params},
42
- "query_params": None if self.query_params is None else {"string": self.query_params},
43
- "ip_address": self.ip_address,
44
- "is_internal": None if self.is_internal is None else {"boolean": self.is_internal},
45
- "user_agent": None if self.user_agent is None else {"string": self.user_agent},
46
- "ua_browser": None if self.ua_browser is None else {"string": self.ua_browser},
47
- "ua_mobile": None if self.ua_mobile is None else {"string": self.ua_mobile},
48
- "platform": None if self.platform is None else {"string": self.platform},
49
- "referer": None if self.referer is None else {"array": self.referer},
50
- "origin": None if self.origin is None else {"array": self.origin},
51
- "host": None if self.host is None else {"array": self.host},
52
- "forwarded_proto": None if self.forwarded_proto is None else {"array": self.forwarded_proto},
53
- "language": None if self.language is None else {"array": self.language}
54
- }
55
-
56
- return result
57
-
58
- @classmethod
59
- def from_google_pubsub_object(cls, obj:Dict[str, Any]):
60
- return cls(
61
- request_id = UUID(obj["request_id"]),
62
- requested_at = datetime.fromisoformat(obj["requested_at"]),
63
- method = obj["method"],
64
- url = obj["url"],
65
- path_params = None if obj["path_params`"] is None else obj["path_params"]["map"],
66
- query_params = None if obj["query_params"] is None else obj["query_params"]["string"],
67
- ip_address = obj["ip_address"],
68
- is_internal = None if obj["is_internal"] is None else bool(obj["is_internal"]["boolean"]),
69
- user_agent = None if obj["user_agent"] is None else obj["user_agent"]["string"],
70
- ua_browser = None if obj["ua_browser"] is None else obj["ua_browser"]["string"],
71
- ua_mobile = None if obj["ua_mobile"] is None else obj["ua_mobile"]["string"],
72
- platform = None if obj["platform"] is None else obj["platform"]["string"],
73
- referer = None if obj["referer"] is None else obj["referer"]["string"],
74
- origin = None if obj["origin"] is None else obj["origin"]["string"],
75
- host = None if obj["host"] is None else obj["host"]["string"],
76
- forwarded_proto = None if obj["forwarded_proto"] is None else obj["forwarded_proto"]["string"],
77
- language = None if obj["language"] is None else obj["language"]["string"],
78
- )
27
+ arbitrary_types_allowed = True
@@ -7,6 +7,7 @@ from maleo_foundation.types import BaseTypes
7
7
  class Settings(BaseSettings):
8
8
  ENVIRONMENT: BaseEnums.EnvironmentType = Field(..., description="Environment")
9
9
  SERVICE_KEY: str = Field(..., description="Service's key")
10
+ ROOT_PATH: str = Field("", description="Application's root path")
10
11
  GOOGLE_CREDENTIALS_PATH: str = Field(
11
12
  "/credentials/maleo-google-service-account.json",
12
13
  description="Internal credential's file path"
@@ -27,6 +28,18 @@ class Settings(BaseSettings):
27
28
  None,
28
29
  description="Service's runtime configurations path"
29
30
  )
31
+ KEY_PASSWORD: BaseTypes.OptionalString = Field(
32
+ None,
33
+ description="Key's password"
34
+ )
35
+ PRIVATE_KEY: BaseTypes.OptionalString = Field(
36
+ None,
37
+ description="Private key"
38
+ )
39
+ PUBLIC_KEY: BaseTypes.OptionalString = Field(
40
+ None,
41
+ description="Public key"
42
+ )
30
43
 
31
44
  @classmethod
32
45
  @model_validator(mode="before")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.3.11
3
+ Version: 0.3.13
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -37,10 +37,10 @@ maleo_foundation/managers/configuration.py,sha256=IyefI1GDDRYf5FRjxpJ2LfYiRL1fuz
37
37
  maleo_foundation/managers/credential.py,sha256=i1w9bVozf7FYG8NGfLgJYRdLWBQBf35yyzVOEDgdXSA,3108
38
38
  maleo_foundation/managers/db.py,sha256=y5oP3bTXKeXYKqng-E_HZ-3wC0ZPtl5bls0AEEej6zM,6050
39
39
  maleo_foundation/managers/middleware.py,sha256=ecTNloglV67xoC_hqIEMIxhfQwzXRKHLI3ThJdd-lbY,2480
40
- maleo_foundation/managers/service.py,sha256=1rqxXMJ9E-pla0LuhKZ83JS4boTnUhiXxn1EbzYQlWA,10859
40
+ maleo_foundation/managers/service.py,sha256=UxQnWjfzqCR_e8n18-oSgM61Z9yuA93FmuqQ_vp6vmo,11168
41
41
  maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
42
  maleo_foundation/managers/client/base.py,sha256=j5_CsToA_7nn_2mP9TWWz7qKalXSWqxfKY_9gTNGJJA,4282
43
- maleo_foundation/managers/client/maleo.py,sha256=JCbuIWu5gW--o7H8xvWtSNb_Of3d05FKLRTcvDciLfE,2662
43
+ maleo_foundation/managers/client/maleo.py,sha256=DoMmRitPQkBKvi92NtW20awUQRhcaBXdBzfDyFdSM3Q,2669
44
44
  maleo_foundation/managers/client/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  maleo_foundation/managers/client/google/base.py,sha256=sxALVZIyKUUbNamMrXSlyb3ftI8wSl5YUlRY2sG-iBg,1383
46
46
  maleo_foundation/managers/client/google/parameter.py,sha256=Jy-rMz_xhepmxBI2rWPxdP8AENBbiApg04nO6cIGXN8,1429
@@ -65,10 +65,10 @@ maleo_foundation/models/schemas/token.py,sha256=Ay-ntAiKeBjCT4YYw0S3Zd4e-KvHSYvG
65
65
  maleo_foundation/models/transfers/__init__.py,sha256=oJLJ3Geeme6vBw7R2Dhvdvg4ziVvzEYAGJaP-tm_90w,299
66
66
  maleo_foundation/models/transfers/general/__init__.py,sha256=rzHpxhyNphl5RVrsAlzEvuYEonmWgb69gJ8XOLMvFDc,4686
67
67
  maleo_foundation/models/transfers/general/credentials.py,sha256=kLS0ymFipQmL3QaA2YFQepRfrQYlEm0jp1MiviAnfXM,345
68
- maleo_foundation/models/transfers/general/database.py,sha256=E3bWaMlvxIRrEGUT29AN5k42FNI5MnrmLq9rnEh0igE,2033
68
+ maleo_foundation/models/transfers/general/database.py,sha256=bFNPd-1x3jNHPscwCk0besnpwartAeLY2e5PfKVyI4M,1201
69
69
  maleo_foundation/models/transfers/general/key.py,sha256=S37SqD3qwTbgMk7785hW7Kl9d4Kouh4uPZcGoyMQ_-Q,755
70
- maleo_foundation/models/transfers/general/request.py,sha256=NTYFOmucc4bMfoocBeHGNLs6mbRdqXyVtp1_yDiv_Gg,4849
71
- maleo_foundation/models/transfers/general/settings.py,sha256=bEvsbhlFi5DO2tS3OmxL2LAG3q1cesW3ceYsT5iGNsE,3702
70
+ maleo_foundation/models/transfers/general/request.py,sha256=b-Bi8yEETtX58GiG1ROFcLGnc2LjMeccXYWqteHNwpY,1777
71
+ maleo_foundation/models/transfers/general/settings.py,sha256=aGknx8K-GWLPSn2eEkdlmZuYAtnurHeKOS2RWyPN-zI,4089
72
72
  maleo_foundation/models/transfers/general/signature.py,sha256=J9xQy2HjpCQOnES7RJqsUnDgjFPuakQ1mxyfdTdstSE,297
73
73
  maleo_foundation/models/transfers/general/token.py,sha256=PU-_wLFaY2i8pwRi9-jlk4nh7XzoTKOk0BEsUCGbD80,4979
74
74
  maleo_foundation/models/transfers/general/configurations/__init__.py,sha256=ZYXbqNkj-PHNuS8PsPtMB291s88K3wGi_PK2zJSeiX4,2010
@@ -76,7 +76,7 @@ maleo_foundation/models/transfers/general/configurations/database.py,sha256=v-Iz
76
76
  maleo_foundation/models/transfers/general/configurations/middleware.py,sha256=1BulO00lb7Xe537--rD_11GFrUKS8YxWHx2RkWfHqtg,2292
77
77
  maleo_foundation/models/transfers/general/configurations/service.py,sha256=8lag1KXkS43IwsMGWka7L-peQ9YT1-dmWeEhQ1hnnLU,304
78
78
  maleo_foundation/models/transfers/general/configurations/cache/__init__.py,sha256=a7p5LWkQJlgcfKpdJrKnCfe1LUAnwltXwTOThANlR6s,286
79
- maleo_foundation/models/transfers/general/configurations/cache/redis.py,sha256=LMxBNCmal6JjsAi7FTeN191PR1zFGw4jjfrJ9lJ_zu0,1162
79
+ maleo_foundation/models/transfers/general/configurations/cache/redis.py,sha256=CFUkIgE6OyFeHcVBqShI8NBbG1G0wpJg6b2t8Ssq3OI,1161
80
80
  maleo_foundation/models/transfers/general/configurations/client/__init__.py,sha256=XSJp-y7TzXaz_cD3AG_Cnt4YQFv3tYGfam4U0FqUrhE,275
81
81
  maleo_foundation/models/transfers/general/configurations/client/maleo.py,sha256=p6NRPWL6eKZCVU_irBCS2iuTQl-QylYuHwV8Rht30GI,1560
82
82
  maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
@@ -134,7 +134,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
134
134
  maleo_foundation/utils/loaders/credential/google.py,sha256=vmVObdAyXehb3L6ASOuUJ63mNvGPb9fiXSpdRndN-4A,6528
135
135
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
136
136
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
137
- maleo_foundation-0.3.11.dist-info/METADATA,sha256=0efeufEkkOaSp-OM15QCtvvQqXLVX_iqbyueWEBM-og,3740
138
- maleo_foundation-0.3.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
139
- maleo_foundation-0.3.11.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
140
- maleo_foundation-0.3.11.dist-info/RECORD,,
137
+ maleo_foundation-0.3.13.dist-info/METADATA,sha256=bgIumcHp68bKDu2hon7uhNTLNQz0fbHkLkTWxn-XU_I,3740
138
+ maleo_foundation-0.3.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
139
+ maleo_foundation-0.3.13.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
140
+ maleo_foundation-0.3.13.dist-info/RECORD,,