maleo-foundation 0.3.25__py3-none-any.whl → 0.3.27__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,18 +1,7 @@
1
1
  from pathlib import Path
2
- from maleo_foundation.models.transfers.general.configurations.cache.redis import (
3
- RedisCacheNamespaces,
4
- RedisCacheConfigurations
5
- )
6
- from maleo_foundation.models.transfers.general.configurations.cache \
7
- import CacheConfigurations
8
- from maleo_foundation.models.transfers.general.configurations import (
9
- RuntimeConfigurations,
10
- StaticConfigurations,
11
- Configurations
12
- )
2
+ from maleo_foundation.models.transfers.general.configurations import Configurations
13
3
  from maleo_foundation.models.transfers.general.settings import Settings
14
4
  from maleo_foundation.utils.loaders.yaml import YAMLLoader
15
- from maleo_foundation.utils.merger import deep_merge
16
5
  from .credential import CredentialManager
17
6
 
18
7
  class ConfigurationManager:
@@ -20,77 +9,28 @@ class ConfigurationManager:
20
9
  self,
21
10
  settings: Settings,
22
11
  credential_manager: CredentialManager
23
- ):
12
+ ) -> None:
24
13
  self._settings = settings
25
14
  self._credential_manager = credential_manager
26
15
 
27
- self._load_configurations()
28
-
29
- def _load_static_configurations(self) -> StaticConfigurations:
30
- use_local = self._settings.USE_LOCAL_STATIC_CONFIGURATIONS
31
- config_path = self._settings.STATIC_CONFIGURATIONS_PATH
32
-
33
- if use_local and config_path is not None and isinstance(config_path, str):
34
- config_path = Path(config_path)
35
- if config_path.exists() and config_path.is_file():
36
- data = YAMLLoader.load_from_path(config_path)
37
- return StaticConfigurations.model_validate(data)
38
-
39
- secret_data = (
40
- self
41
- ._credential_manager
42
- .secret_manager
43
- .get(f"maleo-static-configurations-{self._settings.ENVIRONMENT}")
44
- )
45
- data = YAMLLoader.load_from_string(secret_data)
46
- return StaticConfigurations.model_validate(data)
47
-
48
- def _load_runtime_configurations(self) -> RuntimeConfigurations:
49
- use_local = self._settings.USE_LOCAL_STATIC_CONFIGURATIONS
50
- config_path = self._settings.RUNTIME_CONFIGURATIONS_PATH
16
+ use_local = self._settings.USE_LOCAL_CONFIGURATIONS
17
+ config_path = self._settings.CONFIGURATIONS_PATH
51
18
 
52
19
  if use_local and config_path is not None and isinstance(config_path, str):
53
20
  config_path = Path(config_path)
54
21
  if config_path.exists() and config_path.is_file():
55
22
  data = YAMLLoader.load_from_path(config_path)
56
- return RuntimeConfigurations.model_validate(data)
23
+ self._configurations = Configurations.model_validate(data)
24
+ return
57
25
 
58
26
  secret_data = (
59
27
  self
60
28
  ._credential_manager
61
29
  .secret_manager
62
- .get(f"{self._settings.SERVICE_KEY}-runtime-configurations-{self._settings.ENVIRONMENT}")
30
+ .get(f"/configurations/{self._settings.SERVICE_KEY}-configurations-{self._settings.ENVIRONMENT}")
63
31
  )
64
32
  data = YAMLLoader.load_from_string(secret_data)
65
- return RuntimeConfigurations.model_validate(data)
66
-
67
- def _load_cache_configurations(self) -> CacheConfigurations:
68
- namespaces = RedisCacheNamespaces(base=self._settings.SERVICE_KEY)
69
- host = self._credential_manager.secret_manager.get(
70
- f"maleo-redis-host-{self._settings.ENVIRONMENT}"
71
- )
72
- password = self._credential_manager.secret_manager.get(
73
- f"maleo-redis-password-{self._settings.ENVIRONMENT}"
74
- )
75
- redis = RedisCacheConfigurations(
76
- namespaces=namespaces,
77
- host=host,
78
- password=password
79
- )
80
- return CacheConfigurations(redis=redis)
81
-
82
- def _load_configurations(self) -> None:
83
- static_configurations = self._load_static_configurations()
84
- runtime_configurations = self._load_runtime_configurations()
85
- cache_configurations = self._load_cache_configurations()
86
-
87
- merged_configurations = deep_merge(
88
- static_configurations.model_dump(),
89
- runtime_configurations.model_dump(),
90
- {"cache": cache_configurations.model_dump()}
91
- )
92
-
93
- self._configurations = Configurations.model_validate(merged_configurations)
33
+ self._configurations = Configurations.model_validate(data)
94
34
 
95
35
  @property
96
36
  def configurations(self) -> Configurations:
@@ -3,34 +3,17 @@ from maleo_foundation.utils.logging import MiddlewareLogger, ServiceLogger
3
3
  from .cache import CacheConfigurations
4
4
  from .client import ClientConfigurations
5
5
  from .database import DatabaseConfigurations
6
- from .middleware import (
7
- MiddlewareRuntimeConfigurations,
8
- MiddlewareStaticConfigurations,
9
- MiddlewareConfigurations
10
- )
6
+ from .middleware import MiddlewareConfigurations
11
7
  from .service import ServiceConfigurations
12
8
 
13
- class RuntimeConfigurations(BaseModel):
14
- model_config = ConfigDict(arbitrary_types_allowed=True)
15
-
16
- service: ServiceConfigurations = Field(..., description="Service's configurations")
17
- middleware: MiddlewareRuntimeConfigurations = Field(..., description="Middleware's runtime configurations")
18
- database: DatabaseConfigurations = Field(..., description="Database's configurations")
19
-
20
- class StaticConfigurations(BaseModel):
21
- model_config = ConfigDict(arbitrary_types_allowed=True)
22
-
23
- middleware: MiddlewareStaticConfigurations = Field(..., description="Middleware's static configurations")
24
- client: ClientConfigurations = Field(..., description="Client's configurations")
25
-
26
9
  class Configurations(BaseModel):
27
10
  model_config = ConfigDict(arbitrary_types_allowed=True)
28
11
 
29
- service: ServiceConfigurations = Field(..., description="Service's configurations")
30
- middleware: MiddlewareConfigurations = Field(..., description="Middleware's configurations")
31
12
  cache: CacheConfigurations = Field(..., description="Cache's configurations")
32
- database: DatabaseConfigurations = Field(..., description="Database's configurations")
33
13
  client: ClientConfigurations = Field(..., description="Client's configurations")
14
+ database: DatabaseConfigurations = Field(..., description="Database's configurations")
15
+ middleware: MiddlewareConfigurations = Field(..., description="Middleware's configurations")
16
+ service: ServiceConfigurations = Field(..., description="Service's configurations")
34
17
 
35
18
  class Loggers(BaseModel):
36
19
  model_config = ConfigDict(arbitrary_types_allowed=True)
@@ -4,4 +4,4 @@ from .maleo import MaleoClientsConfigurations
4
4
  class ClientConfigurations(BaseModel):
5
5
  model_config = ConfigDict(arbitrary_types_allowed=True)
6
6
 
7
- maleo: MaleoClientsConfigurations = Field(..., description="Maleo client's configurations")
7
+ maleo: MaleoClientsConfigurations = Field(default_factory=MaleoClientsConfigurations, description="Maleo client's configurations")
@@ -1,4 +1,5 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
+ from typing import Optional
2
3
 
3
4
  class MaleoClientConfigurations(BaseModel):
4
5
  key: str = Field(..., description="Client's key")
@@ -8,15 +9,15 @@ class MaleoClientConfigurations(BaseModel):
8
9
  class MaleoClientsConfigurations(BaseModel):
9
10
  model_config = ConfigDict(arbitrary_types_allowed=True)
10
11
 
11
- telemetry: MaleoClientConfigurations = Field(..., description="MaleoTelemetry client's configuration")
12
- metadata: MaleoClientConfigurations = Field(..., description="MaleoMetadata client's configuration")
13
- identity: MaleoClientConfigurations = Field(..., description="MaleoIdentity client's configuration")
14
- access: MaleoClientConfigurations = Field(..., description="MaleoAccess client's configuration")
15
- workshop: MaleoClientConfigurations = Field(..., description="MaleoWorkshop client's configuration")
16
- soapie: MaleoClientConfigurations = Field(..., description="MaleoSOAPIE client's configuration")
17
- medix: MaleoClientConfigurations = Field(..., description="MaleoMedix client's configuration")
18
- dicom: MaleoClientConfigurations = Field(..., description="MaleoDICOM client's configuration")
19
- scribe: MaleoClientConfigurations = Field(..., description="MaleoScribe client's configuration")
20
- cds: MaleoClientConfigurations = Field(..., description="MaleoCDS client's configuration")
21
- imaging: MaleoClientConfigurations = Field(..., description="MaleoImaging client's configuration")
22
- mcu: MaleoClientConfigurations = Field(..., description="MaleoMCU client's configuration")
12
+ telemetry: Optional[MaleoClientConfigurations] = Field(None, description="MaleoTelemetry client's configuration")
13
+ metadata: Optional[MaleoClientConfigurations] = Field(None, description="MaleoMetadata client's configuration")
14
+ identity: Optional[MaleoClientConfigurations] = Field(None, description="MaleoIdentity client's configuration")
15
+ access: Optional[MaleoClientConfigurations] = Field(None, description="MaleoAccess client's configuration")
16
+ workshop: Optional[MaleoClientConfigurations] = Field(None, description="MaleoWorkshop client's configuration")
17
+ soapie: Optional[MaleoClientConfigurations] = Field(None, description="MaleoSOAPIE client's configuration")
18
+ medix: Optional[MaleoClientConfigurations] = Field(None, description="MaleoMedix client's configuration")
19
+ dicom: Optional[MaleoClientConfigurations] = Field(None, description="MaleoDICOM client's configuration")
20
+ scribe: Optional[MaleoClientConfigurations] = Field(None, description="MaleoScribe client's configuration")
21
+ cds: Optional[MaleoClientConfigurations] = Field(None, description="MaleoCDS client's configuration")
22
+ imaging: Optional[MaleoClientConfigurations] = Field(None, description="MaleoImaging client's configuration")
23
+ mcu: Optional[MaleoClientConfigurations] = Field(None, description="MaleoMCU client's configuration")
@@ -1,4 +1,4 @@
1
- from pydantic import BaseModel, ConfigDict, Field
1
+ from pydantic import BaseModel, Field
2
2
  from typing import List
3
3
 
4
4
  _ALLOW_METHODS: List[str] = [
@@ -34,23 +34,12 @@ class GeneralMiddlewareConfigurations(BaseModel):
34
34
  class CORSMiddlewareConfigurations(BaseModel):
35
35
  expose_headers: List[str] = Field(_EXPOSE_HEADERS, description="Exposed headers")
36
36
 
37
- class MiddlewareStaticConfigurations(BaseModel):
38
- model_config = ConfigDict(arbitrary_types_allowed=True)
39
-
40
- general: GeneralMiddlewareConfigurations = Field(..., description="Middleware's general configurations")
41
- cors: CORSMiddlewareConfigurations = Field(..., description="CORS middleware's configurations")
42
-
43
37
  class BaseMiddlewareConfigurations(BaseModel):
44
38
  limit: int = Field(10, description="Request limit (per 'window' seconds)")
45
39
  window: int = Field(1, description="Request limit window (seconds)")
46
40
  cleanup_interval: int = Field(60, description="Interval for middleware cleanup (seconds)")
47
41
  ip_timeout: int = Field(300, description="Idle IP's timeout (seconds)")
48
42
 
49
- class MiddlewareRuntimeConfigurations(BaseModel):
50
- model_config = ConfigDict(arbitrary_types_allowed=True)
51
-
52
- base: BaseMiddlewareConfigurations = Field(..., description="Base middleware's configurations")
53
-
54
43
  class MiddlewareConfigurations(BaseModel):
55
44
  general: GeneralMiddlewareConfigurations = Field(..., description="Middleware's general configurations")
56
45
  cors: CORSMiddlewareConfigurations = Field(..., description="CORS middleware's configurations")
@@ -12,21 +12,13 @@ class Settings(BaseSettings):
12
12
  "/credentials/maleo-google-service-account.json",
13
13
  description="Internal credential's file path"
14
14
  )
15
- USE_LOCAL_STATIC_CONFIGURATIONS: bool = Field(
15
+ USE_LOCAL_CONFIGURATIONS: bool = Field(
16
16
  False,
17
- description="Whether to use local static configurations"
17
+ description="Whether to use local configurations"
18
18
  )
19
- STATIC_CONFIGURATIONS_PATH: BaseTypes.OptionalString = Field(
19
+ CONFIGURATIONS_PATH: BaseTypes.OptionalString = Field(
20
20
  None,
21
- description="Maleo's static configurations path"
22
- )
23
- USE_LOCAL_RUNTIME_CONFIGURATIONS: bool = Field(
24
- False,
25
- description="Whether to use local runtime configurations"
26
- )
27
- RUNTIME_CONFIGURATIONS_PATH: BaseTypes.OptionalString = Field(
28
- None,
29
- description="Service's runtime configurations path"
21
+ description="Configurations path"
30
22
  )
31
23
  KEY_PASSWORD: BaseTypes.OptionalString = Field(
32
24
  None,
@@ -43,20 +35,12 @@ class Settings(BaseSettings):
43
35
 
44
36
  @model_validator(mode="after")
45
37
  def validate_configurations_path(self) -> Self:
46
- if self.USE_LOCAL_STATIC_CONFIGURATIONS and self.STATIC_CONFIGURATIONS_PATH is None:
47
- self.STATIC_CONFIGURATIONS_PATH = (
48
- f"/static-configurations/maleo-static-configurations-{self.ENVIRONMENT}.yaml"
49
- )
50
-
51
- if self.USE_LOCAL_STATIC_CONFIGURATIONS and self.STATIC_CONFIGURATIONS_PATH is None:
52
- raise ValueError("Static configurations path must exist if use local static configurations is set to true")
53
-
54
- if self.USE_LOCAL_RUNTIME_CONFIGURATIONS and self.RUNTIME_CONFIGURATIONS_PATH is None:
55
- self.RUNTIME_CONFIGURATIONS_PATH = (
56
- f"/runtime-configurations/{self.SERVICE_KEY}-runtime-configurations-{self.ENVIRONMENT}.yaml"
38
+ if self.USE_LOCAL_CONFIGURATIONS and self.CONFIGURATIONS_PATH is None:
39
+ self.CONFIGURATIONS_PATH = (
40
+ f"/configurations/{self.SERVICE_KEY}-configurations-{self.ENVIRONMENT}.yaml"
57
41
  )
58
42
 
59
- if self.USE_LOCAL_RUNTIME_CONFIGURATIONS and self.RUNTIME_CONFIGURATIONS_PATH is None:
60
- raise ValueError("Runtime configurations path must exist if use local runtime configurations is set to true")
43
+ if self.USE_LOCAL_CONFIGURATIONS and self.CONFIGURATIONS_PATH is None:
44
+ raise ValueError("Configurations path must exist if use local configurations is set to true")
61
45
 
62
46
  return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.3.25
3
+ Version: 0.3.27
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -33,7 +33,7 @@ maleo_foundation/expanded_types/encryption/aes.py,sha256=1rj43qjIO0TePpr1mErT_NJ
33
33
  maleo_foundation/expanded_types/encryption/rsa.py,sha256=Esf_H8nMz2kOLAWa3M7dlD-sFdFIZylNjB_qB20Yaww,488
34
34
  maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  maleo_foundation/managers/cache.py,sha256=IgcA-NAJbW83jRyApuQPbSJdth2LUpix9o-5CMWNwdI,274
36
- maleo_foundation/managers/configuration.py,sha256=IyefI1GDDRYf5FRjxpJ2LfYiRL1fuzIOwrO1aAy5zy0,3814
36
+ maleo_foundation/managers/configuration.py,sha256=B2ho_-QkXh4KkHuiVA_GPrn2QvhoZL_KqNwQCIea_1c,1433
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
@@ -68,17 +68,17 @@ maleo_foundation/models/transfers/general/credentials.py,sha256=kLS0ymFipQmL3QaA
68
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
70
  maleo_foundation/models/transfers/general/request.py,sha256=xOeBbtXygK5P6DxPyf3C4LIH3nb262tqWsgvALB4yfQ,1792
71
- maleo_foundation/models/transfers/general/settings.py,sha256=q3ljAuvLmzXD2vE9QdYDT6VNeqM5sjm1iZMhm1xB40g,2548
71
+ maleo_foundation/models/transfers/general/settings.py,sha256=p0PSec_8y-gpYZjx4r29L5QAV68hHikWetGkI9qqeoo,1690
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
- maleo_foundation/models/transfers/general/configurations/__init__.py,sha256=DMiBLOnA4Ye2q0-n0EyUU6U8YbpyqRn1l_vl4kuMKAI,2042
74
+ maleo_foundation/models/transfers/general/configurations/__init__.py,sha256=xKU7f5V8I-pEzOXlL0CS82Zo60CqDjdB6Bnp3LUzcsg,1272
75
75
  maleo_foundation/models/transfers/general/configurations/database.py,sha256=v-IzSm8kZa1TQByCc8dpIU-8csJN_G2irWeN4EClNlo,690
76
- maleo_foundation/models/transfers/general/configurations/middleware.py,sha256=UV4vUg936Wb4xq1AMgFGcfPewAIJHswadK25jqoETB8,2254
76
+ maleo_foundation/models/transfers/general/configurations/middleware.py,sha256=-6dk6C2QBDfmTDENhsgyMHpRUGfrSxQY3BDwo_WtgAs,1710
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
79
  maleo_foundation/models/transfers/general/configurations/cache/redis.py,sha256=CFUkIgE6OyFeHcVBqShI8NBbG1G0wpJg6b2t8Ssq3OI,1161
80
- maleo_foundation/models/transfers/general/configurations/client/__init__.py,sha256=BC4KHpGte5ZSw8TH2s_zWDvFEFOGl-mfAOPhtNOREyk,292
81
- maleo_foundation/models/transfers/general/configurations/client/maleo.py,sha256=d83tJx1e_yR2YiQUwR5fSav_5beoiJSwKBLbqW52yAc,1581
80
+ maleo_foundation/models/transfers/general/configurations/client/__init__.py,sha256=2Iln1K23ad283y_PxVf4Zo25LZrGlrIIYlqm0cCFO5U,331
81
+ maleo_foundation/models/transfers/general/configurations/client/maleo.py,sha256=0ecfHUW-gkmUZBrCINdoFJN9t03VGV9a8ND1D-LpmNc,1741
82
82
  maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
83
83
  maleo_foundation/models/transfers/parameters/client.py,sha256=wI2-ML99yn5HR0AciFg2C9EQixrWjbIR8x_bDbqKeDM,4069
84
84
  maleo_foundation/models/transfers/parameters/general.py,sha256=-nSIcn0thtodk-69Uwj6qdrX8zfe-PX-gWwD-_VCVyY,779
@@ -133,7 +133,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
133
133
  maleo_foundation/utils/loaders/credential/google.py,sha256=ZglnLdW3lHmaKER4mwGe5N5ERus-bdsamfpwGmQYPIo,6344
134
134
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
135
135
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
136
- maleo_foundation-0.3.25.dist-info/METADATA,sha256=MiUXG1VvGaLcBiJqBwqmdWINhODbZYCr9t6gNLWUQk0,3740
137
- maleo_foundation-0.3.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
138
- maleo_foundation-0.3.25.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
139
- maleo_foundation-0.3.25.dist-info/RECORD,,
136
+ maleo_foundation-0.3.27.dist-info/METADATA,sha256=daIDsRpkAI2bjdV4LqhFm-p31oe6xxfPv_EdHlLj1yA,3740
137
+ maleo_foundation-0.3.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
138
+ maleo_foundation-0.3.27.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
139
+ maleo_foundation-0.3.27.dist-info/RECORD,,