maleo-foundation 0.2.67__py3-none-any.whl → 0.2.69__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
  import asyncio
2
2
  from fastapi import Request, status
3
+ from fastapi.encoders import jsonable_encoder
3
4
  from fastapi.exceptions import RequestValidationError
4
5
  from fastapi.responses import JSONResponse
5
6
  from functools import wraps
@@ -24,8 +25,9 @@ class BaseExceptions:
24
25
 
25
26
  @staticmethod
26
27
  async def validation_exception_handler(request:Request, exc:RequestValidationError):
28
+ serialized_error = jsonable_encoder(exc.errors())
27
29
  return JSONResponse(
28
- content=BaseResponses.ValidationError(other=exc.errors()).model_dump(mode="json"),
30
+ content=BaseResponses.ValidationError(other=serialized_error).model_dump(mode="json"),
29
31
  status_code=status.HTTP_422_UNPROCESSABLE_ENTITY
30
32
  )
31
33
 
@@ -6,20 +6,27 @@ from typing import Optional, Union
6
6
 
7
7
  class GoogleCredentialsLoader:
8
8
  @staticmethod
9
- def load(credentials_path:Optional[Union[Path, str]] = None) -> Credentials:
9
+ def load(credentials_path: Optional[Union[Path, str]] = None) -> Credentials:
10
+ """
11
+ Load Google credentials either from a service account file or from the default credentials.
12
+ Priority:
13
+ 1. Explicit path argument
14
+ 2. GOOGLE_CREDENTIALS_PATH environment variable
15
+ 3. google.auth.default()
16
+ """
10
17
  if credentials_path is None:
11
18
  credentials_path = os.getenv("GOOGLE_CREDENTIALS_PATH")
12
- else:
13
- credentials_path = credentials_path
19
+
20
+ if credentials_path is not None:
21
+ credentials_path = Path(credentials_path)
22
+ if credentials_path.exists() and credentials_path.is_file():
23
+ try:
24
+ return Credentials.from_service_account_file(str(credentials_path))
25
+ except Exception as e:
26
+ raise ValueError(f"Failed to load credentials from file: {str(e)}")
27
+
14
28
  try:
15
- if credentials_path is not None:
16
- credentials_path = Path(credentials_path)
17
- if credentials_path.exists() or credentials_path.is_file():
18
- credentials = Credentials.from_service_account_file(
19
- filename=str(credentials_path)
20
- )
21
- else:
22
- credentials, _ = default()
29
+ credentials, _ = default()
23
30
  return credentials
24
31
  except Exception as e:
25
- raise ValueError(f"Failed to initialize credentials: {str(e)}")
32
+ raise ValueError(f"Failed to load default credentials: {str(e)}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.67
3
+ Version: 0.2.69
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -100,7 +100,7 @@ maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCu
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
102
  maleo_foundation/utils/controller.py,sha256=D8uUfqkMpPw8M8Ykn8Uxn7dfRGwxmBxSP1h9xSkYw1I,6945
103
- maleo_foundation/utils/exceptions.py,sha256=kDLTWiUauvc-fSKrEyxlGvIi2NtZIAhJ9bV3OXnpTyo,6253
103
+ maleo_foundation/utils/exceptions.py,sha256=eM__Mxo-BC5d7JmoBd-Wh-fmryUdfjNfOuY_eONK5Fk,6361
104
104
  maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
105
105
  maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
106
106
  maleo_foundation/utils/merger.py,sha256=z9GROLVtGpwx84bOiakBFphKazsI-9l3F3WauTDwQLs,597
@@ -115,10 +115,10 @@ maleo_foundation/utils/loaders/__init__.py,sha256=P_3ycGfeDXFjAi8bE4iLWHxBveqUId
115
115
  maleo_foundation/utils/loaders/json.py,sha256=8e3qe1TyL-jaJVuiQJpVHKDBS2n_CGJPGv8Ci6cK42Y,506
116
116
  maleo_foundation/utils/loaders/yaml.py,sha256=8cZWOYuDTAFNrLsUlz7IGyOrtR4oL-tk-jc7q_7nq8Q,501
117
117
  maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg7rejnG4I684FjUwh70tvhtVM,141
118
- maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
118
+ maleo_foundation/utils/loaders/credential/google.py,sha256=HUcuHD4tXHPt0eHInlFYxA_MDrGSOtbenpd0PX156OM,1255
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.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,,
121
+ maleo_foundation-0.2.69.dist-info/METADATA,sha256=X_OcNlzdstf_panCKQt8IA_7Cbx5A9-CRN_jVnwjyaI,3598
122
+ maleo_foundation-0.2.69.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
+ maleo_foundation-0.2.69.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
124
+ maleo_foundation-0.2.69.dist-info/RECORD,,