maleo-foundation 0.2.34__py3-none-any.whl → 0.2.36__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.
@@ -115,21 +115,6 @@ class BaseMiddleware(BaseHTTPMiddleware):
115
115
  self._requests[client_ip].append(now)
116
116
  return False
117
117
 
118
- def _append_cors_headers(
119
- self,
120
- request:Request,
121
- response:Response
122
- ) -> Response:
123
- origin = request.headers.get("Origin")
124
-
125
- if origin in self._allow_origins:
126
- response.headers["Access-Control-Allow-Origin"] = origin
127
- response.headers["Access-Control-Allow-Methods"] = ", ".join(self._allow_methods)
128
- response.headers["Access-Control-Allow-Headers"] = ", ".join(self._allow_headers)
129
- response.headers["Access-Control-Allow-Credentials"] = "true" if self._allow_credentials else "false"
130
-
131
- return response
132
-
133
118
  def _add_response_headers(
134
119
  self,
135
120
  request:Request,
@@ -151,7 +136,6 @@ class BaseMiddleware(BaseHTTPMiddleware):
151
136
  sign_result = self._maleo_foundation.services.signature.sign(parameters=sign_parameters)
152
137
  if sign_result.success:
153
138
  response.headers["X-Signature"] = sign_result.data.signature
154
- # response = self._append_cors_headers(request=request, response=response) #* Re-append CORS headers
155
139
  if (authentication.user.is_authenticated
156
140
  and authentication.credentials.token_type == BaseEnums.TokenType.REFRESH
157
141
  and authentication.credentials.payload is not None
@@ -50,6 +50,11 @@ class BaseResponses:
50
50
  message:str = "Unexpected Server Error"
51
51
  description:str = "An unexpected error occurred while processing your request."
52
52
 
53
+ class NotImplemented(Fail):
54
+ code:str = "MAL-NIM-001"
55
+ message:str = "Not Implemented"
56
+ description:str = "This request is not yet implemented by the system."
57
+
53
58
  class NotFound(BaseResultSchemas.NotFound): pass
54
59
 
55
60
  class NoData(BaseResultSchemas.NoData): pass
@@ -0,0 +1,59 @@
1
+ from fastapi import status
2
+ from maleo_foundation.models.transfers.results.service.controllers.rest \
3
+ import BaseServiceRESTControllerResults
4
+ from maleo_foundation.models.responses import BaseResponses
5
+
6
+ class RESTControllerResultsConstants:
7
+ BAD_REQUEST = BaseServiceRESTControllerResults(
8
+ success=False,
9
+ content=BaseResponses.BadRequest().model_dump(),
10
+ status_code=status.HTTP_400_BAD_REQUEST
11
+ )
12
+
13
+ INVALID_EXPAND = BaseServiceRESTControllerResults(
14
+ success=False,
15
+ content=BaseResponses.InvalidExpand().model_dump(),
16
+ status_code=status.HTTP_400_BAD_REQUEST
17
+ )
18
+
19
+ UNAUTHORIZED = BaseServiceRESTControllerResults(
20
+ success=False,
21
+ content=BaseResponses.Unauthorized().model_dump(),
22
+ status_code=status.HTTP_401_UNAUTHORIZED
23
+ )
24
+
25
+ FORBIDDEN = BaseServiceRESTControllerResults(
26
+ success=False,
27
+ content=BaseResponses.Forbidden().model_dump(),
28
+ status_code=status.HTTP_403_FORBIDDEN
29
+ )
30
+
31
+ METHOD_NOT_ALLOWED = BaseServiceRESTControllerResults(
32
+ success=False,
33
+ content=BaseResponses.MethodNotAllowed().model_dump(),
34
+ status_code=status.HTTP_405_METHOD_NOT_ALLOWED
35
+ )
36
+
37
+ VALIDATION_ERROR = BaseServiceRESTControllerResults(
38
+ success=False,
39
+ content=BaseResponses.ValidationError().model_dump(),
40
+ status_code=status.HTTP_422_UNPROCESSABLE_ENTITY
41
+ )
42
+
43
+ RATE_LIMIT_EXCEEDED = BaseServiceRESTControllerResults(
44
+ success=False,
45
+ content=BaseResponses.RateLimitExceeded().model_dump(),
46
+ status_code=status.HTTP_429_TOO_MANY_REQUESTS
47
+ )
48
+
49
+ SERVER_ERROR = BaseServiceRESTControllerResults(
50
+ success=False,
51
+ content=BaseResponses.ServerError().model_dump(),
52
+ status_code=status.HTTP_500_INTERNAL_SERVER_ERROR
53
+ )
54
+
55
+ NOT_IMPLEMENTED = BaseServiceRESTControllerResults(
56
+ success=False,
57
+ content=BaseResponses.NotImplemented().model_dump(),
58
+ status_code=status.HTTP_501_NOT_IMPLEMENTED
59
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.34
3
+ Version: 0.2.36
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -4,6 +4,7 @@ maleo_foundation/authorization.py,sha256=euq24UEhTaimmM24Ies-kZF1zqVwM_x0Zox_6k7
4
4
  maleo_foundation/constants.py,sha256=aBmEfWlBqZxi0k-n6h2NM1YRLOjMnheEiLyQcjP-zCQ,1164
5
5
  maleo_foundation/enums.py,sha256=OLVgb0rKk2gfG19FEyq9YGrQcmovr_FgtGFUcIu23Lo,3596
6
6
  maleo_foundation/extended_types.py,sha256=pIKt-_9tby4rmune3fmWcCW_mohaNRh_1lywBmdc-L4,301
7
+ maleo_foundation/rest_controller_result.py,sha256=4KbCmk70IEHj1L1bNJfFg1Y3ifnRSnmvK6dYyVJddok,2014
7
8
  maleo_foundation/types.py,sha256=aKXnIgEhYGSfFqNMGLc4qIKGkINBRpkOo9R9cb2CbwI,2414
8
9
  maleo_foundation/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
10
  maleo_foundation/client/manager.py,sha256=pFWLFYW4eE9MLyFmFS05IgnMBdqqUHbdyTkSbnBtm5E,2620
@@ -46,10 +47,10 @@ maleo_foundation/managers/client/google/parameter.py,sha256=Lnj7mQgxWQpsQwbmDRK5
46
47
  maleo_foundation/managers/client/google/secret.py,sha256=Ski1CHYeA8vjSk2Oc2Pf4CfFrzT_RcA6NEZwza7gM7Y,4464
47
48
  maleo_foundation/managers/client/google/storage.py,sha256=ECyEBgEvvbTDVfqXey-meGnoU4qvIRU32BxbCuzcaHU,2576
48
49
  maleo_foundation/middlewares/authentication.py,sha256=y3FEvcB8I8piCQIvvDRl2F2tCmspOVJx3jrSGI6HPn4,4702
49
- maleo_foundation/middlewares/base.py,sha256=msYMZjks3BDOmQCUM9wOfzRzbBrkZutzPHdTUbRs-7o,15264
50
+ maleo_foundation/middlewares/base.py,sha256=8_ENtyB2iKejCOQofESzlAaq_zxDWtHNaq3f10dA020,14554
50
51
  maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
51
52
  maleo_foundation/models/__init__.py,sha256=AaKehO7c1HyKhoTGRmNHDddSeBXkW-_YNrpOGBu8Ms8,246
52
- maleo_foundation/models/responses.py,sha256=iKJs9EFemCuUOc-IxEUwjX9RgNnPf-mw7yGheCGyVDA,4896
53
+ maleo_foundation/models/responses.py,sha256=_9yOON2OIxFSE9KcUNCvnofO4WjdAJhI-svWep_4Q0E,5081
53
54
  maleo_foundation/models/table.py,sha256=tcOwj_Heqi6ode8rbD4eeSiixEYsAtUaUyJyqrYaMAw,1327
54
55
  maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
55
56
  maleo_foundation/models/schemas/encryption.py,sha256=KYs2P57AqWpEROuqTuSuyt1Zk-jsIUKFeRWIfSwem74,658
@@ -116,7 +117,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
116
117
  maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
117
118
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
118
119
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
119
- maleo_foundation-0.2.34.dist-info/METADATA,sha256=e6QwYGMvXouCAHON2Y8xnPGvQtmUrv6Q1oN99d5ex6o,3598
120
- maleo_foundation-0.2.34.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
121
- maleo_foundation-0.2.34.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
122
- maleo_foundation-0.2.34.dist-info/RECORD,,
120
+ maleo_foundation-0.2.36.dist-info/METADATA,sha256=KH5ZivrQHz8SmWQuS8IaxoSkusjveDBIJBrtJwQQgl8,3598
121
+ maleo_foundation-0.2.36.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
122
+ maleo_foundation-0.2.36.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
123
+ maleo_foundation-0.2.36.dist-info/RECORD,,