nexo-schemas 0.0.16__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.
- nexo/schemas/__init__.py +0 -0
- nexo/schemas/application.py +292 -0
- nexo/schemas/connection.py +134 -0
- nexo/schemas/data.py +27 -0
- nexo/schemas/document.py +237 -0
- nexo/schemas/error/__init__.py +476 -0
- nexo/schemas/error/constants.py +50 -0
- nexo/schemas/error/descriptor.py +354 -0
- nexo/schemas/error/enums.py +40 -0
- nexo/schemas/error/metadata.py +15 -0
- nexo/schemas/error/spec.py +312 -0
- nexo/schemas/exception/__init__.py +0 -0
- nexo/schemas/exception/exc.py +911 -0
- nexo/schemas/exception/factory.py +1928 -0
- nexo/schemas/exception/handlers.py +110 -0
- nexo/schemas/google.py +14 -0
- nexo/schemas/key/__init__.py +0 -0
- nexo/schemas/key/rsa.py +131 -0
- nexo/schemas/metadata.py +21 -0
- nexo/schemas/mixins/__init__.py +0 -0
- nexo/schemas/mixins/filter.py +140 -0
- nexo/schemas/mixins/general.py +65 -0
- nexo/schemas/mixins/hierarchy.py +19 -0
- nexo/schemas/mixins/identity.py +387 -0
- nexo/schemas/mixins/parameter.py +50 -0
- nexo/schemas/mixins/service.py +40 -0
- nexo/schemas/mixins/sort.py +111 -0
- nexo/schemas/mixins/timestamp.py +192 -0
- nexo/schemas/model.py +240 -0
- nexo/schemas/operation/__init__.py +0 -0
- nexo/schemas/operation/action/__init__.py +9 -0
- nexo/schemas/operation/action/base.py +14 -0
- nexo/schemas/operation/action/resource.py +371 -0
- nexo/schemas/operation/action/status.py +8 -0
- nexo/schemas/operation/action/system.py +6 -0
- nexo/schemas/operation/action/websocket.py +6 -0
- nexo/schemas/operation/base.py +289 -0
- nexo/schemas/operation/constants.py +18 -0
- nexo/schemas/operation/context.py +68 -0
- nexo/schemas/operation/dependency.py +26 -0
- nexo/schemas/operation/enums.py +168 -0
- nexo/schemas/operation/extractor.py +36 -0
- nexo/schemas/operation/mixins.py +53 -0
- nexo/schemas/operation/request.py +1066 -0
- nexo/schemas/operation/resource.py +839 -0
- nexo/schemas/operation/system.py +55 -0
- nexo/schemas/operation/websocket.py +55 -0
- nexo/schemas/pagination.py +67 -0
- nexo/schemas/parameter.py +60 -0
- nexo/schemas/payload.py +116 -0
- nexo/schemas/resource.py +64 -0
- nexo/schemas/response.py +1041 -0
- nexo/schemas/security/__init__.py +0 -0
- nexo/schemas/security/api_key.py +63 -0
- nexo/schemas/security/authentication.py +848 -0
- nexo/schemas/security/authorization.py +922 -0
- nexo/schemas/security/enums.py +32 -0
- nexo/schemas/security/impersonation.py +179 -0
- nexo/schemas/security/token.py +402 -0
- nexo/schemas/security/types.py +17 -0
- nexo/schemas/success/__init__.py +0 -0
- nexo/schemas/success/descriptor.py +100 -0
- nexo/schemas/success/enums.py +23 -0
- nexo/schemas/user_agent.py +46 -0
- nexo_schemas-0.0.16.dist-info/METADATA +87 -0
- nexo_schemas-0.0.16.dist-info/RECORD +69 -0
- nexo_schemas-0.0.16.dist-info/WHEEL +5 -0
- nexo_schemas-0.0.16.dist-info/licenses/LICENSE +21 -0
- nexo_schemas-0.0.16.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Generic, Literal, Type, TypeVar, overload
|
|
3
|
+
from typing_extensions import Annotated
|
|
4
|
+
from nexo.types.string import OptStr
|
|
5
|
+
from ..mixins.general import Descriptor
|
|
6
|
+
from .enums import ErrorCode
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ErrorDescriptor(Descriptor[ErrorCode]):
|
|
10
|
+
code: Annotated[
|
|
11
|
+
ErrorCode, Field(ErrorCode.INTERNAL_SERVER_ERROR, description="Error's code")
|
|
12
|
+
] = ErrorCode.INTERNAL_SERVER_ERROR
|
|
13
|
+
message: Annotated[str, Field("Error", description="Error's message")] = "Error"
|
|
14
|
+
description: Annotated[
|
|
15
|
+
str, Field("An error occurred", description="Error's description")
|
|
16
|
+
] = "An error occurred"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
ErrorDescriptorT = TypeVar("ErrorDescriptorT", bound=ErrorDescriptor)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ErrorDescriptorMixin(BaseModel, Generic[ErrorDescriptorT]):
|
|
23
|
+
descriptor: ErrorDescriptorT = Field(..., description="Error's Descriptor")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class BadRequestErrorDescriptor(ErrorDescriptor):
|
|
27
|
+
code: ErrorCode = ErrorCode.BAD_REQUEST
|
|
28
|
+
message: str = "Bad Request"
|
|
29
|
+
description: str = "Bad/Unexpected parameters given"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UnauthorizedErrorDescriptor(ErrorDescriptor):
|
|
33
|
+
code: ErrorCode = ErrorCode.UNAUTHORIZED
|
|
34
|
+
message: str = "Unauthorized"
|
|
35
|
+
description: str = "Authentication is required or invalid"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ForbiddenErrorDescriptor(ErrorDescriptor):
|
|
39
|
+
code: ErrorCode = ErrorCode.FORBIDDEN
|
|
40
|
+
message: str = "Forbidden"
|
|
41
|
+
description: str = "Insufficient permission found"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class NotFoundErrorDescriptor(ErrorDescriptor):
|
|
45
|
+
code: ErrorCode = ErrorCode.NOT_FOUND
|
|
46
|
+
message: str = "Not Found"
|
|
47
|
+
description: str = "The requested resource could not be found"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class MethodNotAllowedErrorDescriptor(ErrorDescriptor):
|
|
51
|
+
code: ErrorCode = ErrorCode.METHOD_NOT_ALLOWED
|
|
52
|
+
message: str = "Method Not Allowed"
|
|
53
|
+
description: str = "The HTTP method is not supported for this resource"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ConflictErrorDescriptor(ErrorDescriptor):
|
|
57
|
+
code: ErrorCode = ErrorCode.CONFLICT
|
|
58
|
+
message: str = "Conflict"
|
|
59
|
+
description: str = "Failed processing request due to conflicting state"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class UnprocessableEntityErrorDescriptor(ErrorDescriptor):
|
|
63
|
+
code: ErrorCode = ErrorCode.UNPROCESSABLE_ENTITY
|
|
64
|
+
message: str = "Unprocessable Entity"
|
|
65
|
+
description: str = "The request was well-formed but could not be processed"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class TooManyRequestsErrorDescriptor(ErrorDescriptor):
|
|
69
|
+
code: ErrorCode = ErrorCode.TOO_MANY_REQUESTS
|
|
70
|
+
message: str = "Too Many Requests"
|
|
71
|
+
description: str = "You have sent too many requests in a given time frame"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class InternalServerErrorDescriptor(ErrorDescriptor):
|
|
75
|
+
code: ErrorCode = ErrorCode.INTERNAL_SERVER_ERROR
|
|
76
|
+
message: str = "Internal Server Error"
|
|
77
|
+
description: str = "An unexpected error occurred on the server"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class NotImplementedErrorDescriptor(ErrorDescriptor):
|
|
81
|
+
code: ErrorCode = ErrorCode.NOT_IMPLEMENTED
|
|
82
|
+
message: str = "Not Implemented"
|
|
83
|
+
description: str = "This functionality is not supported by the server"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class BadGatewayErrorDescriptor(ErrorDescriptor):
|
|
87
|
+
code: ErrorCode = ErrorCode.BAD_GATEWAY
|
|
88
|
+
message: str = "Bad Gateway"
|
|
89
|
+
description: str = "The server received an invalid response from an upstream server"
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ServiceUnavailableErrorDescriptor(ErrorDescriptor):
|
|
93
|
+
code: ErrorCode = ErrorCode.SERVICE_UNAVAILABLE
|
|
94
|
+
message: str = "Service Unavailable"
|
|
95
|
+
description: str = "The server is temporarily unable to handle the request"
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
AnyErrorDescriptorType = (
|
|
99
|
+
Type[BadRequestErrorDescriptor]
|
|
100
|
+
| Type[UnauthorizedErrorDescriptor]
|
|
101
|
+
| Type[ForbiddenErrorDescriptor]
|
|
102
|
+
| Type[NotFoundErrorDescriptor]
|
|
103
|
+
| Type[MethodNotAllowedErrorDescriptor]
|
|
104
|
+
| Type[ConflictErrorDescriptor]
|
|
105
|
+
| Type[UnprocessableEntityErrorDescriptor]
|
|
106
|
+
| Type[TooManyRequestsErrorDescriptor]
|
|
107
|
+
| Type[InternalServerErrorDescriptor]
|
|
108
|
+
| Type[NotImplementedErrorDescriptor]
|
|
109
|
+
| Type[BadGatewayErrorDescriptor]
|
|
110
|
+
| Type[ServiceUnavailableErrorDescriptor]
|
|
111
|
+
)
|
|
112
|
+
AnyErrorDescriptor = (
|
|
113
|
+
BadRequestErrorDescriptor
|
|
114
|
+
| UnauthorizedErrorDescriptor
|
|
115
|
+
| ForbiddenErrorDescriptor
|
|
116
|
+
| NotFoundErrorDescriptor
|
|
117
|
+
| MethodNotAllowedErrorDescriptor
|
|
118
|
+
| ConflictErrorDescriptor
|
|
119
|
+
| UnprocessableEntityErrorDescriptor
|
|
120
|
+
| TooManyRequestsErrorDescriptor
|
|
121
|
+
| InternalServerErrorDescriptor
|
|
122
|
+
| NotImplementedErrorDescriptor
|
|
123
|
+
| BadGatewayErrorDescriptor
|
|
124
|
+
| ServiceUnavailableErrorDescriptor
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class ErrorDescriptorFactory:
|
|
129
|
+
@overload
|
|
130
|
+
@staticmethod
|
|
131
|
+
def cls_from_code(
|
|
132
|
+
code: Literal[ErrorCode.BAD_REQUEST, 400],
|
|
133
|
+
/,
|
|
134
|
+
) -> Type[BadRequestErrorDescriptor]: ...
|
|
135
|
+
@overload
|
|
136
|
+
@staticmethod
|
|
137
|
+
def cls_from_code(
|
|
138
|
+
code: Literal[ErrorCode.UNAUTHORIZED, 401],
|
|
139
|
+
/,
|
|
140
|
+
) -> Type[UnauthorizedErrorDescriptor]: ...
|
|
141
|
+
@overload
|
|
142
|
+
@staticmethod
|
|
143
|
+
def cls_from_code(
|
|
144
|
+
code: Literal[ErrorCode.FORBIDDEN, 403],
|
|
145
|
+
/,
|
|
146
|
+
) -> Type[ForbiddenErrorDescriptor]: ...
|
|
147
|
+
@overload
|
|
148
|
+
@staticmethod
|
|
149
|
+
def cls_from_code(
|
|
150
|
+
code: Literal[ErrorCode.NOT_FOUND, 404],
|
|
151
|
+
/,
|
|
152
|
+
) -> Type[NotFoundErrorDescriptor]: ...
|
|
153
|
+
@overload
|
|
154
|
+
@staticmethod
|
|
155
|
+
def cls_from_code(
|
|
156
|
+
code: Literal[ErrorCode.METHOD_NOT_ALLOWED, 405],
|
|
157
|
+
/,
|
|
158
|
+
) -> Type[MethodNotAllowedErrorDescriptor]: ...
|
|
159
|
+
@overload
|
|
160
|
+
@staticmethod
|
|
161
|
+
def cls_from_code(
|
|
162
|
+
code: Literal[ErrorCode.CONFLICT, 409],
|
|
163
|
+
/,
|
|
164
|
+
) -> Type[ConflictErrorDescriptor]: ...
|
|
165
|
+
@overload
|
|
166
|
+
@staticmethod
|
|
167
|
+
def cls_from_code(
|
|
168
|
+
code: Literal[ErrorCode.UNPROCESSABLE_ENTITY, 422],
|
|
169
|
+
/,
|
|
170
|
+
) -> Type[UnprocessableEntityErrorDescriptor]: ...
|
|
171
|
+
@overload
|
|
172
|
+
@staticmethod
|
|
173
|
+
def cls_from_code(
|
|
174
|
+
code: Literal[ErrorCode.TOO_MANY_REQUESTS, 429],
|
|
175
|
+
/,
|
|
176
|
+
) -> Type[TooManyRequestsErrorDescriptor]: ...
|
|
177
|
+
@overload
|
|
178
|
+
@staticmethod
|
|
179
|
+
def cls_from_code(
|
|
180
|
+
code: Literal[ErrorCode.INTERNAL_SERVER_ERROR, 500],
|
|
181
|
+
/,
|
|
182
|
+
) -> Type[InternalServerErrorDescriptor]: ...
|
|
183
|
+
@overload
|
|
184
|
+
@staticmethod
|
|
185
|
+
def cls_from_code(
|
|
186
|
+
code: Literal[ErrorCode.NOT_IMPLEMENTED, 501],
|
|
187
|
+
/,
|
|
188
|
+
) -> Type[NotImplementedErrorDescriptor]: ...
|
|
189
|
+
@overload
|
|
190
|
+
@staticmethod
|
|
191
|
+
def cls_from_code(
|
|
192
|
+
code: Literal[ErrorCode.BAD_GATEWAY, 502],
|
|
193
|
+
/,
|
|
194
|
+
) -> Type[BadGatewayErrorDescriptor]: ...
|
|
195
|
+
@overload
|
|
196
|
+
@staticmethod
|
|
197
|
+
def cls_from_code(
|
|
198
|
+
code: Literal[ErrorCode.SERVICE_UNAVAILABLE, 503],
|
|
199
|
+
/,
|
|
200
|
+
) -> Type[ServiceUnavailableErrorDescriptor]: ...
|
|
201
|
+
@overload
|
|
202
|
+
@staticmethod
|
|
203
|
+
def cls_from_code(
|
|
204
|
+
code: ErrorCode | int,
|
|
205
|
+
/,
|
|
206
|
+
) -> AnyErrorDescriptorType: ...
|
|
207
|
+
@staticmethod
|
|
208
|
+
def cls_from_code(
|
|
209
|
+
code: ErrorCode | int,
|
|
210
|
+
/,
|
|
211
|
+
) -> AnyErrorDescriptorType:
|
|
212
|
+
if code is ErrorCode.BAD_REQUEST or code == 400:
|
|
213
|
+
return BadRequestErrorDescriptor
|
|
214
|
+
elif code is ErrorCode.UNAUTHORIZED or code == 401:
|
|
215
|
+
return UnauthorizedErrorDescriptor
|
|
216
|
+
elif code is ErrorCode.FORBIDDEN or code == 403:
|
|
217
|
+
return ForbiddenErrorDescriptor
|
|
218
|
+
elif code is ErrorCode.NOT_FOUND or code == 404:
|
|
219
|
+
return NotFoundErrorDescriptor
|
|
220
|
+
elif code is ErrorCode.METHOD_NOT_ALLOWED or code == 405:
|
|
221
|
+
return MethodNotAllowedErrorDescriptor
|
|
222
|
+
elif code is ErrorCode.CONFLICT or code == 409:
|
|
223
|
+
return ConflictErrorDescriptor
|
|
224
|
+
elif code is ErrorCode.UNPROCESSABLE_ENTITY or code == 422:
|
|
225
|
+
return UnprocessableEntityErrorDescriptor
|
|
226
|
+
elif code is ErrorCode.TOO_MANY_REQUESTS or code == 429:
|
|
227
|
+
return TooManyRequestsErrorDescriptor
|
|
228
|
+
elif code is ErrorCode.INTERNAL_SERVER_ERROR or code == 500:
|
|
229
|
+
return InternalServerErrorDescriptor
|
|
230
|
+
elif code is ErrorCode.NOT_IMPLEMENTED or code == 501:
|
|
231
|
+
return NotImplementedErrorDescriptor
|
|
232
|
+
elif code is ErrorCode.BAD_GATEWAY or code == 502:
|
|
233
|
+
return BadGatewayErrorDescriptor
|
|
234
|
+
elif code is ErrorCode.SERVICE_UNAVAILABLE or code == 503:
|
|
235
|
+
return ServiceUnavailableErrorDescriptor
|
|
236
|
+
raise ValueError(f"Unable to determine error descriptor class for code: {code}")
|
|
237
|
+
|
|
238
|
+
@overload
|
|
239
|
+
@staticmethod
|
|
240
|
+
def from_code(
|
|
241
|
+
code: Literal[ErrorCode.BAD_REQUEST, 400],
|
|
242
|
+
*,
|
|
243
|
+
message: OptStr = None,
|
|
244
|
+
description: OptStr = None,
|
|
245
|
+
) -> BadRequestErrorDescriptor: ...
|
|
246
|
+
@overload
|
|
247
|
+
@staticmethod
|
|
248
|
+
def from_code(
|
|
249
|
+
code: Literal[ErrorCode.UNAUTHORIZED, 401],
|
|
250
|
+
*,
|
|
251
|
+
message: OptStr = None,
|
|
252
|
+
description: OptStr = None,
|
|
253
|
+
) -> UnauthorizedErrorDescriptor: ...
|
|
254
|
+
@overload
|
|
255
|
+
@staticmethod
|
|
256
|
+
def from_code(
|
|
257
|
+
code: Literal[ErrorCode.FORBIDDEN, 403],
|
|
258
|
+
*,
|
|
259
|
+
message: OptStr = None,
|
|
260
|
+
description: OptStr = None,
|
|
261
|
+
) -> ForbiddenErrorDescriptor: ...
|
|
262
|
+
@overload
|
|
263
|
+
@staticmethod
|
|
264
|
+
def from_code(
|
|
265
|
+
code: Literal[ErrorCode.NOT_FOUND, 404],
|
|
266
|
+
*,
|
|
267
|
+
message: OptStr = None,
|
|
268
|
+
description: OptStr = None,
|
|
269
|
+
) -> NotFoundErrorDescriptor: ...
|
|
270
|
+
@overload
|
|
271
|
+
@staticmethod
|
|
272
|
+
def from_code(
|
|
273
|
+
code: Literal[ErrorCode.METHOD_NOT_ALLOWED, 405],
|
|
274
|
+
*,
|
|
275
|
+
message: OptStr = None,
|
|
276
|
+
description: OptStr = None,
|
|
277
|
+
) -> MethodNotAllowedErrorDescriptor: ...
|
|
278
|
+
@overload
|
|
279
|
+
@staticmethod
|
|
280
|
+
def from_code(
|
|
281
|
+
code: Literal[ErrorCode.CONFLICT, 409],
|
|
282
|
+
*,
|
|
283
|
+
message: OptStr = None,
|
|
284
|
+
description: OptStr = None,
|
|
285
|
+
) -> ConflictErrorDescriptor: ...
|
|
286
|
+
@overload
|
|
287
|
+
@staticmethod
|
|
288
|
+
def from_code(
|
|
289
|
+
code: Literal[ErrorCode.UNPROCESSABLE_ENTITY, 422],
|
|
290
|
+
*,
|
|
291
|
+
message: OptStr = None,
|
|
292
|
+
description: OptStr = None,
|
|
293
|
+
) -> UnprocessableEntityErrorDescriptor: ...
|
|
294
|
+
@overload
|
|
295
|
+
@staticmethod
|
|
296
|
+
def from_code(
|
|
297
|
+
code: Literal[ErrorCode.TOO_MANY_REQUESTS, 429],
|
|
298
|
+
*,
|
|
299
|
+
message: OptStr = None,
|
|
300
|
+
description: OptStr = None,
|
|
301
|
+
) -> TooManyRequestsErrorDescriptor: ...
|
|
302
|
+
@overload
|
|
303
|
+
@staticmethod
|
|
304
|
+
def from_code(
|
|
305
|
+
code: Literal[ErrorCode.INTERNAL_SERVER_ERROR, 500],
|
|
306
|
+
*,
|
|
307
|
+
message: OptStr = None,
|
|
308
|
+
description: OptStr = None,
|
|
309
|
+
) -> InternalServerErrorDescriptor: ...
|
|
310
|
+
@overload
|
|
311
|
+
@staticmethod
|
|
312
|
+
def from_code(
|
|
313
|
+
code: Literal[ErrorCode.NOT_IMPLEMENTED, 501],
|
|
314
|
+
*,
|
|
315
|
+
message: OptStr = None,
|
|
316
|
+
description: OptStr = None,
|
|
317
|
+
) -> NotImplementedErrorDescriptor: ...
|
|
318
|
+
@overload
|
|
319
|
+
@staticmethod
|
|
320
|
+
def from_code(
|
|
321
|
+
code: Literal[ErrorCode.BAD_GATEWAY, 502],
|
|
322
|
+
*,
|
|
323
|
+
message: OptStr = None,
|
|
324
|
+
description: OptStr = None,
|
|
325
|
+
) -> BadGatewayErrorDescriptor: ...
|
|
326
|
+
@overload
|
|
327
|
+
@staticmethod
|
|
328
|
+
def from_code(
|
|
329
|
+
code: Literal[ErrorCode.SERVICE_UNAVAILABLE, 503],
|
|
330
|
+
*,
|
|
331
|
+
message: OptStr = None,
|
|
332
|
+
description: OptStr = None,
|
|
333
|
+
) -> ServiceUnavailableErrorDescriptor: ...
|
|
334
|
+
@overload
|
|
335
|
+
@staticmethod
|
|
336
|
+
def from_code(
|
|
337
|
+
code: ErrorCode | int,
|
|
338
|
+
*,
|
|
339
|
+
message: OptStr = None,
|
|
340
|
+
description: OptStr = None,
|
|
341
|
+
) -> AnyErrorDescriptor: ...
|
|
342
|
+
@staticmethod
|
|
343
|
+
def from_code(
|
|
344
|
+
code: ErrorCode | int,
|
|
345
|
+
*,
|
|
346
|
+
message: OptStr = None,
|
|
347
|
+
description: OptStr = None,
|
|
348
|
+
) -> AnyErrorDescriptor:
|
|
349
|
+
obj = {}
|
|
350
|
+
if message is not None:
|
|
351
|
+
obj["message"] = message
|
|
352
|
+
if description is not None:
|
|
353
|
+
obj["description"] = description
|
|
354
|
+
return ErrorDescriptorFactory.cls_from_code(code).model_validate(obj)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from nexo.types.string import ListOfStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ErrorType(StrEnum):
|
|
6
|
+
BAD_REQUEST = "client.bad_request"
|
|
7
|
+
UNAUTHORIZED = "client.unauthorized"
|
|
8
|
+
FORBIDDEN = "client.forbidden"
|
|
9
|
+
NOT_FOUND = "client.not_found"
|
|
10
|
+
CONFLICT = "client.conflict"
|
|
11
|
+
METHOD_NOT_ALLOWED = "client.method_not_allowed"
|
|
12
|
+
UNPROCESSABLE_ENTITY = "client.unprocessable_entity"
|
|
13
|
+
TOO_MANY_REQUESTS = "client.too_many_requests"
|
|
14
|
+
INTERNAL_SERVER_ERROR = "server.internal_server_error"
|
|
15
|
+
NOT_IMPLEMENTED = "server.not_implemented"
|
|
16
|
+
BAD_GATEWAY = "server.bad_gateway"
|
|
17
|
+
SERVICE_UNAVAILABLE = "server.service_unavailable"
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def choices(cls) -> ListOfStrs:
|
|
21
|
+
return [e.value for e in cls]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ErrorCode(StrEnum):
|
|
25
|
+
BAD_REQUEST = "MAL-ERR-CLI-BDR-001"
|
|
26
|
+
UNAUTHORIZED = "MAL-ERR-CLI-ATH-001"
|
|
27
|
+
FORBIDDEN = "MAL-ERR-CLI-FBD-001"
|
|
28
|
+
NOT_FOUND = "MAL-ERR-CLI-NTF-001"
|
|
29
|
+
METHOD_NOT_ALLOWED = "MAL-ERR-CLI-MNA-001"
|
|
30
|
+
CONFLICT = "MAL-ERR-CLI-CFL-001"
|
|
31
|
+
UNPROCESSABLE_ENTITY = "MAL-ERR-CLI-UPE-001"
|
|
32
|
+
TOO_MANY_REQUESTS = "MAL-ERR-CLI-TMR-001"
|
|
33
|
+
INTERNAL_SERVER_ERROR = "MAL-ERR-SRV-ISE-001"
|
|
34
|
+
NOT_IMPLEMENTED = "MAL-ERR-SRV-NIM-001"
|
|
35
|
+
BAD_GATEWAY = "MAL-ERR-SRV-BDG-001"
|
|
36
|
+
SERVICE_UNAVAILABLE = "MAL-ERR-SRV-SUN-001"
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def choices(cls) -> ListOfStrs:
|
|
40
|
+
return [e.value for e in cls]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Any
|
|
3
|
+
from typing_extensions import Annotated
|
|
4
|
+
from nexo.types.string import OptListOfStrs
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ErrorMetadata(BaseModel):
|
|
8
|
+
details: Annotated[Any, Field(None, description="Details")] = None
|
|
9
|
+
traceback: Annotated[OptListOfStrs, Field(None, description="Traceback")] = None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ErrorMetadataMixin(BaseModel):
|
|
13
|
+
metadata: Annotated[
|
|
14
|
+
ErrorMetadata, Field(ErrorMetadata(), description="Error's Metadata")
|
|
15
|
+
] = ErrorMetadata()
|