maleo-foundation 0.2.65__py3-none-any.whl → 0.2.67__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.
- maleo_foundation/expanded_types/general.py +22 -0
- maleo_foundation/managers/client/google/storage.py +12 -4
- maleo_foundation/models/transfers/parameters/general.py +2 -0
- maleo_foundation/utils/controller.py +62 -6
- {maleo_foundation-0.2.65.dist-info → maleo_foundation-0.2.67.dist-info}/METADATA +1 -1
- {maleo_foundation-0.2.65.dist-info → maleo_foundation-0.2.67.dist-info}/RECORD +8 -8
- {maleo_foundation-0.2.65.dist-info → maleo_foundation-0.2.67.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.2.65.dist-info → maleo_foundation-0.2.67.dist-info}/top_level.txt +0 -0
@@ -24,4 +24,26 @@ class BaseGeneralExpandedTypes:
|
|
24
24
|
BaseTypes.ListOrDictOfAny
|
25
25
|
]
|
26
26
|
]
|
27
|
+
]
|
28
|
+
|
29
|
+
#* Modification processor related types
|
30
|
+
FieldModificationProcessor = Callable[
|
31
|
+
[BaseGeneralParametersTransfers.FieldModificationProcessor],
|
32
|
+
BaseTypes.ListOrDictOfAny
|
33
|
+
]
|
34
|
+
|
35
|
+
ListOfFieldModificationProcessor = List[
|
36
|
+
Callable[
|
37
|
+
[BaseGeneralParametersTransfers.FieldModificationProcessor],
|
38
|
+
BaseTypes.ListOrDictOfAny
|
39
|
+
]
|
40
|
+
]
|
41
|
+
|
42
|
+
OptionalListOfFieldModificationProcessor = Optional[
|
43
|
+
List[
|
44
|
+
Callable[
|
45
|
+
[BaseGeneralParametersTransfers.FieldModificationProcessor],
|
46
|
+
BaseTypes.ListOrDictOfAny
|
47
|
+
]
|
48
|
+
]
|
27
49
|
]
|
@@ -53,7 +53,8 @@ class GoogleCloudStorage(GoogleClientManager):
|
|
53
53
|
location:str,
|
54
54
|
content_type:Optional[str]=None,
|
55
55
|
make_public:bool=False,
|
56
|
-
expiration:timedelta=timedelta(minutes=15)
|
56
|
+
expiration:timedelta=timedelta(minutes=15),
|
57
|
+
root_location_override:BaseTypes.OptionalString=None
|
57
58
|
) -> str:
|
58
59
|
"""
|
59
60
|
Upload a file to Google Cloud Storage.
|
@@ -67,7 +68,10 @@ class GoogleCloudStorage(GoogleClientManager):
|
|
67
68
|
Returns:
|
68
69
|
str: The public URL or blob path depending on `make_public`.
|
69
70
|
"""
|
70
|
-
|
71
|
+
if root_location_override is None or (isinstance(root_location_override, str) and len(root_location_override) <= 0):
|
72
|
+
blob = self._bucket.blob(f"{self._root_location}/{location}")
|
73
|
+
else:
|
74
|
+
blob = self._bucket.blob(f"{root_location_override}/{location}")
|
71
75
|
blob.upload_from_string(content, content_type=content_type)
|
72
76
|
|
73
77
|
if make_public:
|
@@ -84,7 +88,8 @@ class GoogleCloudStorage(GoogleClientManager):
|
|
84
88
|
def generate_signed_url(
|
85
89
|
self,
|
86
90
|
location:str,
|
87
|
-
expiration:timedelta=timedelta(minutes=15)
|
91
|
+
expiration:timedelta=timedelta(minutes=15),
|
92
|
+
root_location_override:BaseTypes.OptionalString=None
|
88
93
|
) -> str:
|
89
94
|
"""
|
90
95
|
generate signed URL of a file in the bucket based on its location.
|
@@ -99,7 +104,10 @@ class GoogleCloudStorage(GoogleClientManager):
|
|
99
104
|
Raises:
|
100
105
|
ValueError: If the file does not exist
|
101
106
|
"""
|
102
|
-
|
107
|
+
if root_location_override is None or (isinstance(root_location_override, str) and len(root_location_override) <= 0):
|
108
|
+
blob = self._bucket.blob(blob_name=f"{self._root_location}/{location}")
|
109
|
+
else:
|
110
|
+
blob = self._bucket.blob(blob_name=f"{root_location_override}/{location}")
|
103
111
|
if not blob.exists():
|
104
112
|
raise ValueError(f"File '{location}' did not exists.")
|
105
113
|
|
@@ -61,13 +61,14 @@ class BaseControllerUtils:
|
|
61
61
|
return data
|
62
62
|
elif isinstance(data, Dict):
|
63
63
|
#* Apply each processor to current dict
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
.model_validate(raw_parameters)
|
64
|
+
parameters = (
|
65
|
+
BaseGeneralParametersTransfers
|
66
|
+
.FieldExpansionProcessor(
|
67
|
+
data=data,
|
68
|
+
expand=expand
|
70
69
|
)
|
70
|
+
)
|
71
|
+
for processor in field_expansion_processors or []:
|
71
72
|
data = processor(parameters)
|
72
73
|
for key in data.keys():
|
73
74
|
if isinstance(data[key], (Dict, List)):
|
@@ -86,6 +87,61 @@ class BaseControllerUtils:
|
|
86
87
|
result.content["data"] = recursive_expand(data, expand)
|
87
88
|
result.process_response()
|
88
89
|
|
90
|
+
return result
|
91
|
+
return wrapper
|
92
|
+
return decorator
|
93
|
+
|
94
|
+
@staticmethod
|
95
|
+
def field_modification_handler(
|
96
|
+
field_modification_processors:BaseGeneralExpandedTypes.OptionalListOfFieldModificationProcessor = None
|
97
|
+
):
|
98
|
+
"""
|
99
|
+
Decorator to handle expandable fields validation and processing.
|
100
|
+
|
101
|
+
Args:
|
102
|
+
expandable_fields_dependencies_map: Dictionary where keys are dependency fields and values are lists of dependent fields
|
103
|
+
field_modification_processors: List of processor functions that handle that field's data
|
104
|
+
"""
|
105
|
+
def decorator(func:Callable[..., Awaitable[BaseServiceRESTControllerResults]]):
|
106
|
+
@wraps(func)
|
107
|
+
async def wrapper(*args, **kwargs):
|
108
|
+
#* Call the original function
|
109
|
+
result = await func(*args, **kwargs)
|
110
|
+
|
111
|
+
if not isinstance(result.content, Dict):
|
112
|
+
return result
|
113
|
+
|
114
|
+
#* Recursive function to apply modification processors
|
115
|
+
def recursive_modify(data:Union[Dict, List]):
|
116
|
+
if isinstance(data, list):
|
117
|
+
for idx, item in enumerate(data):
|
118
|
+
data[idx] = recursive_modify(item)
|
119
|
+
return data
|
120
|
+
elif isinstance(data, Dict):
|
121
|
+
#* Apply each processor to current dict
|
122
|
+
parameters = (
|
123
|
+
BaseGeneralParametersTransfers
|
124
|
+
.FieldModificationProcessor(data=data)
|
125
|
+
)
|
126
|
+
for processor in field_modification_processors or []:
|
127
|
+
data = processor(parameters)
|
128
|
+
for key in data.keys():
|
129
|
+
if isinstance(data[key], (Dict, List)):
|
130
|
+
data[key] = recursive_modify(data[key])
|
131
|
+
return data
|
132
|
+
else:
|
133
|
+
return data
|
134
|
+
|
135
|
+
#* Process modifications recursively if needed
|
136
|
+
if (
|
137
|
+
result.success
|
138
|
+
and result.content.get("data", None) is not None
|
139
|
+
and field_modification_processors is not None
|
140
|
+
):
|
141
|
+
data = result.content["data"]
|
142
|
+
result.content["data"] = recursive_modify(data)
|
143
|
+
result.process_response()
|
144
|
+
|
89
145
|
return result
|
90
146
|
return wrapper
|
91
147
|
return decorator
|
@@ -21,7 +21,7 @@ maleo_foundation/client/services/hash/hmac.py,sha256=-L0sTv5tcmfu-UyBD_InpxFJ2w7
|
|
21
21
|
maleo_foundation/client/services/hash/sha256.py,sha256=af08036kkEZ61IY_ktxwHmQnAACd6hWXYA_ZC9S1-tg,2142
|
22
22
|
maleo_foundation/expanded_types/__init__.py,sha256=Jz2NoY9609QIM84UonmJU-10CMUR9t9fkk9ZFLnU7Js,384
|
23
23
|
maleo_foundation/expanded_types/client.py,sha256=WvT911cDsfWtCCYVaDeQ90ba_eCYnzC-CRSXCHtLIuo,2414
|
24
|
-
maleo_foundation/expanded_types/general.py,sha256=
|
24
|
+
maleo_foundation/expanded_types/general.py,sha256=vPWcUI3KTsppiLx1QVmafkawmcM5B0clkj9hrLdJjkM,1463
|
25
25
|
maleo_foundation/expanded_types/hash.py,sha256=QOH_HczGY7CRUZJ5gC84RunCAiUzNSt7DYXI7uqtwkM,416
|
26
26
|
maleo_foundation/expanded_types/key.py,sha256=qopQcO6V82RxiCtixe--IBce5MRT4buOun4RSA-LLm0,573
|
27
27
|
maleo_foundation/expanded_types/repository.py,sha256=hemtQGDqSQO8N4_y7pktXqBlrcDacs4EiUZ3hFk4n2o,2482
|
@@ -45,7 +45,7 @@ maleo_foundation/managers/client/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
|
|
45
45
|
maleo_foundation/managers/client/google/base.py,sha256=eIdd6C2BFIu4EyZ1j017VZaJn_nSTPGFftBwQmVAUDA,1366
|
46
46
|
maleo_foundation/managers/client/google/parameter.py,sha256=Lnj7mQgxWQpsQwbmDRK5_bF01M1QpM5PS0eZP2q17yQ,1337
|
47
47
|
maleo_foundation/managers/client/google/secret.py,sha256=Ski1CHYeA8vjSk2Oc2Pf4CfFrzT_RcA6NEZwza7gM7Y,4464
|
48
|
-
maleo_foundation/managers/client/google/storage.py,sha256=
|
48
|
+
maleo_foundation/managers/client/google/storage.py,sha256=6pmpR44mOWhgad0ylyz0xoHCAfVo-AC3cT95tRKlNNM,4370
|
49
49
|
maleo_foundation/middlewares/authentication.py,sha256=UL6kL65SvqrzemlIDopoO9N1C05eWlYMHVR2tiRsVEA,4821
|
50
50
|
maleo_foundation/middlewares/base.py,sha256=0vHU0CJEj9s3slGE3fxCQwL0_hqXW-xvhu82WRVpkpg,14551
|
51
51
|
maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
|
@@ -68,7 +68,7 @@ maleo_foundation/models/transfers/general/signature.py,sha256=J9xQy2HjpCQOnES7RJ
|
|
68
68
|
maleo_foundation/models/transfers/general/token.py,sha256=O_U6dQS7oMScJzqufl6Pe21pTxMsYhOzKH8aFLxjblQ,2895
|
69
69
|
maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
|
70
70
|
maleo_foundation/models/transfers/parameters/client.py,sha256=wI2-ML99yn5HR0AciFg2C9EQixrWjbIR8x_bDbqKeDM,4069
|
71
|
-
maleo_foundation/models/transfers/parameters/general.py,sha256
|
71
|
+
maleo_foundation/models/transfers/parameters/general.py,sha256=-nSIcn0thtodk-69Uwj6qdrX8zfe-PX-gWwD-_VCVyY,779
|
72
72
|
maleo_foundation/models/transfers/parameters/key.py,sha256=ZhWcbPJZvl8AF_qlecG-4-9_Ym6EbU7nngRo3AtbScY,432
|
73
73
|
maleo_foundation/models/transfers/parameters/service.py,sha256=-mCGqGYTuH4tKZXwtFrETlfyVx20Yc2wUfK0Nv4-wtY,6284
|
74
74
|
maleo_foundation/models/transfers/parameters/signature.py,sha256=ysYkALwqNXn13HP8xUOnPlboL9pgFLmQ9f7OpZe9dDw,483
|
@@ -99,7 +99,7 @@ maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256
|
|
99
99
|
maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
|
100
100
|
maleo_foundation/utils/__init__.py,sha256=KoERe8U2ERGZeAKUNBPW_itk7g9YpH7v7_mD9_i050o,461
|
101
101
|
maleo_foundation/utils/client.py,sha256=F5X9TUxWQgeOHjwsMpPoSRhZANQYZ_iFv0RJDTUVhrw,2820
|
102
|
-
maleo_foundation/utils/controller.py,sha256=
|
102
|
+
maleo_foundation/utils/controller.py,sha256=D8uUfqkMpPw8M8Ykn8Uxn7dfRGwxmBxSP1h9xSkYw1I,6945
|
103
103
|
maleo_foundation/utils/exceptions.py,sha256=kDLTWiUauvc-fSKrEyxlGvIi2NtZIAhJ9bV3OXnpTyo,6253
|
104
104
|
maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
|
105
105
|
maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
|
@@ -118,7 +118,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
|
|
118
118
|
maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
|
119
119
|
maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
|
120
120
|
maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
|
121
|
-
maleo_foundation-0.2.
|
122
|
-
maleo_foundation-0.2.
|
123
|
-
maleo_foundation-0.2.
|
124
|
-
maleo_foundation-0.2.
|
121
|
+
maleo_foundation-0.2.67.dist-info/METADATA,sha256=mk2x6WyixAkvIHf_OQrP6nn9gFYyljbP9k8Ly7i-6e8,3598
|
122
|
+
maleo_foundation-0.2.67.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
123
|
+
maleo_foundation-0.2.67.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
124
|
+
maleo_foundation-0.2.67.dist-info/RECORD,,
|
File without changes
|
File without changes
|