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.
Files changed (69) hide show
  1. nexo/schemas/__init__.py +0 -0
  2. nexo/schemas/application.py +292 -0
  3. nexo/schemas/connection.py +134 -0
  4. nexo/schemas/data.py +27 -0
  5. nexo/schemas/document.py +237 -0
  6. nexo/schemas/error/__init__.py +476 -0
  7. nexo/schemas/error/constants.py +50 -0
  8. nexo/schemas/error/descriptor.py +354 -0
  9. nexo/schemas/error/enums.py +40 -0
  10. nexo/schemas/error/metadata.py +15 -0
  11. nexo/schemas/error/spec.py +312 -0
  12. nexo/schemas/exception/__init__.py +0 -0
  13. nexo/schemas/exception/exc.py +911 -0
  14. nexo/schemas/exception/factory.py +1928 -0
  15. nexo/schemas/exception/handlers.py +110 -0
  16. nexo/schemas/google.py +14 -0
  17. nexo/schemas/key/__init__.py +0 -0
  18. nexo/schemas/key/rsa.py +131 -0
  19. nexo/schemas/metadata.py +21 -0
  20. nexo/schemas/mixins/__init__.py +0 -0
  21. nexo/schemas/mixins/filter.py +140 -0
  22. nexo/schemas/mixins/general.py +65 -0
  23. nexo/schemas/mixins/hierarchy.py +19 -0
  24. nexo/schemas/mixins/identity.py +387 -0
  25. nexo/schemas/mixins/parameter.py +50 -0
  26. nexo/schemas/mixins/service.py +40 -0
  27. nexo/schemas/mixins/sort.py +111 -0
  28. nexo/schemas/mixins/timestamp.py +192 -0
  29. nexo/schemas/model.py +240 -0
  30. nexo/schemas/operation/__init__.py +0 -0
  31. nexo/schemas/operation/action/__init__.py +9 -0
  32. nexo/schemas/operation/action/base.py +14 -0
  33. nexo/schemas/operation/action/resource.py +371 -0
  34. nexo/schemas/operation/action/status.py +8 -0
  35. nexo/schemas/operation/action/system.py +6 -0
  36. nexo/schemas/operation/action/websocket.py +6 -0
  37. nexo/schemas/operation/base.py +289 -0
  38. nexo/schemas/operation/constants.py +18 -0
  39. nexo/schemas/operation/context.py +68 -0
  40. nexo/schemas/operation/dependency.py +26 -0
  41. nexo/schemas/operation/enums.py +168 -0
  42. nexo/schemas/operation/extractor.py +36 -0
  43. nexo/schemas/operation/mixins.py +53 -0
  44. nexo/schemas/operation/request.py +1066 -0
  45. nexo/schemas/operation/resource.py +839 -0
  46. nexo/schemas/operation/system.py +55 -0
  47. nexo/schemas/operation/websocket.py +55 -0
  48. nexo/schemas/pagination.py +67 -0
  49. nexo/schemas/parameter.py +60 -0
  50. nexo/schemas/payload.py +116 -0
  51. nexo/schemas/resource.py +64 -0
  52. nexo/schemas/response.py +1041 -0
  53. nexo/schemas/security/__init__.py +0 -0
  54. nexo/schemas/security/api_key.py +63 -0
  55. nexo/schemas/security/authentication.py +848 -0
  56. nexo/schemas/security/authorization.py +922 -0
  57. nexo/schemas/security/enums.py +32 -0
  58. nexo/schemas/security/impersonation.py +179 -0
  59. nexo/schemas/security/token.py +402 -0
  60. nexo/schemas/security/types.py +17 -0
  61. nexo/schemas/success/__init__.py +0 -0
  62. nexo/schemas/success/descriptor.py +100 -0
  63. nexo/schemas/success/enums.py +23 -0
  64. nexo/schemas/user_agent.py +46 -0
  65. nexo_schemas-0.0.16.dist-info/METADATA +87 -0
  66. nexo_schemas-0.0.16.dist-info/RECORD +69 -0
  67. nexo_schemas-0.0.16.dist-info/WHEEL +5 -0
  68. nexo_schemas-0.0.16.dist-info/licenses/LICENSE +21 -0
  69. nexo_schemas-0.0.16.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1066 @@
1
+ from copy import deepcopy
2
+ from pydantic import Field
3
+ from typing import Annotated, Any, Generic, Literal, Type, overload
4
+ from uuid import UUID
5
+ from nexo.types.boolean import BoolT
6
+ from ..application import OptApplicationContext
7
+ from ..connection import ConnectionContext
8
+ from ..error import OptAnyErrorT, AnyErrorT
9
+ from ..pagination import OptAnyPagination
10
+ from ..response import (
11
+ ResponseContext,
12
+ ResponseT,
13
+ ErrorResponseT,
14
+ AnyDataResponse,
15
+ )
16
+ from ..security.authentication import OptAnyAuthentication
17
+ from ..security.authorization import OptAnyAuthorization
18
+ from ..security.impersonation import OptImpersonation
19
+ from .action.resource import (
20
+ AnyResourceOperationActionT,
21
+ CreateResourceOperationAction,
22
+ ReadResourceOperationAction,
23
+ UpdateResourceOperationAction,
24
+ DeleteResourceOperationAction,
25
+ ResourceOperationActions,
26
+ AnyResourceOperationAction,
27
+ OptAnyResourceOperationAction,
28
+ ResourceOperationActionFactory,
29
+ )
30
+ from .base import BaseOperation
31
+ from .context import Context as OperationContext
32
+ from .enums import (
33
+ OperationType,
34
+ ResourceOperationType,
35
+ OptResourceOperationType,
36
+ OptResourceOperationUpdateType,
37
+ OptResourceOperationDataUpdateType,
38
+ OptResourceOperationStatusUpdateType,
39
+ )
40
+ from .mixins import Timestamp
41
+
42
+
43
+ class RequestOperation(
44
+ BaseOperation[
45
+ AnyResourceOperationActionT,
46
+ None,
47
+ BoolT,
48
+ OptAnyErrorT,
49
+ ConnectionContext,
50
+ ResponseT,
51
+ ResponseContext,
52
+ ],
53
+ Generic[
54
+ AnyResourceOperationActionT,
55
+ BoolT,
56
+ OptAnyErrorT,
57
+ ResponseT,
58
+ ],
59
+ ):
60
+ type: OperationType = OperationType.REQUEST
61
+ resource: None = None
62
+
63
+
64
+ class FailedRequestOperation(
65
+ RequestOperation[
66
+ AnyResourceOperationActionT,
67
+ Literal[False],
68
+ AnyErrorT,
69
+ ErrorResponseT,
70
+ ],
71
+ Generic[
72
+ AnyResourceOperationActionT,
73
+ AnyErrorT,
74
+ ErrorResponseT,
75
+ ],
76
+ ):
77
+ success: Literal[False] = False
78
+ summary: str = "Failed processing request"
79
+
80
+
81
+ class CreateFailedRequestOperation(
82
+ FailedRequestOperation[
83
+ CreateResourceOperationAction,
84
+ AnyErrorT,
85
+ ErrorResponseT,
86
+ ],
87
+ Generic[
88
+ AnyErrorT,
89
+ ErrorResponseT,
90
+ ],
91
+ ):
92
+ action: Annotated[
93
+ CreateResourceOperationAction,
94
+ Field(CreateResourceOperationAction(), description="Action"),
95
+ ] = CreateResourceOperationAction()
96
+
97
+
98
+ class ReadFailedRequestOperation(
99
+ FailedRequestOperation[
100
+ ReadResourceOperationAction,
101
+ AnyErrorT,
102
+ ErrorResponseT,
103
+ ],
104
+ Generic[
105
+ AnyErrorT,
106
+ ErrorResponseT,
107
+ ],
108
+ ):
109
+ action: Annotated[
110
+ ReadResourceOperationAction,
111
+ Field(ReadResourceOperationAction(), description="Action"),
112
+ ] = ReadResourceOperationAction()
113
+
114
+
115
+ class UpdateFailedRequestOperation(
116
+ FailedRequestOperation[
117
+ UpdateResourceOperationAction,
118
+ AnyErrorT,
119
+ ErrorResponseT,
120
+ ],
121
+ Generic[
122
+ AnyErrorT,
123
+ ErrorResponseT,
124
+ ],
125
+ ):
126
+ action: Annotated[
127
+ UpdateResourceOperationAction,
128
+ Field(UpdateResourceOperationAction(), description="Action"),
129
+ ] = UpdateResourceOperationAction()
130
+
131
+
132
+ class DeleteFailedRequestOperation(
133
+ FailedRequestOperation[
134
+ DeleteResourceOperationAction,
135
+ AnyErrorT,
136
+ ErrorResponseT,
137
+ ],
138
+ Generic[
139
+ AnyErrorT,
140
+ ErrorResponseT,
141
+ ],
142
+ ):
143
+ action: Annotated[
144
+ DeleteResourceOperationAction,
145
+ Field(DeleteResourceOperationAction(), description="Action"),
146
+ ] = DeleteResourceOperationAction()
147
+
148
+
149
+ class SuccessfulRequestOperation(
150
+ RequestOperation[
151
+ AnyResourceOperationActionT,
152
+ Literal[True],
153
+ None,
154
+ AnyDataResponse[Any, OptAnyPagination, Any],
155
+ ],
156
+ Generic[AnyResourceOperationActionT],
157
+ ):
158
+ success: Literal[True] = True
159
+ error: None = None
160
+ summary: str = "Successfully processed request"
161
+
162
+
163
+ class CreateSuccessfulRequestOperation(
164
+ SuccessfulRequestOperation[CreateResourceOperationAction]
165
+ ):
166
+ action: Annotated[
167
+ CreateResourceOperationAction,
168
+ Field(CreateResourceOperationAction(), description="Action"),
169
+ ] = CreateResourceOperationAction()
170
+
171
+
172
+ class ReadSuccessfulRequestOperation(
173
+ SuccessfulRequestOperation[ReadResourceOperationAction]
174
+ ):
175
+ action: Annotated[
176
+ ReadResourceOperationAction,
177
+ Field(ReadResourceOperationAction(), description="Action"),
178
+ ] = ReadResourceOperationAction()
179
+
180
+
181
+ class UpdateSuccessfulRequestOperation(
182
+ SuccessfulRequestOperation[UpdateResourceOperationAction]
183
+ ):
184
+ action: Annotated[
185
+ UpdateResourceOperationAction,
186
+ Field(UpdateResourceOperationAction(), description="Action"),
187
+ ] = UpdateResourceOperationAction()
188
+
189
+
190
+ class DeleteSuccessfulRequestOperation(
191
+ SuccessfulRequestOperation[DeleteResourceOperationAction]
192
+ ):
193
+ action: Annotated[
194
+ DeleteResourceOperationAction,
195
+ Field(DeleteResourceOperationAction(), description="Action"),
196
+ ] = DeleteResourceOperationAction()
197
+
198
+
199
+ AnySuccessfulRequestOperationType = (
200
+ Type[CreateSuccessfulRequestOperation]
201
+ | Type[ReadSuccessfulRequestOperation]
202
+ | Type[UpdateSuccessfulRequestOperation]
203
+ | Type[DeleteSuccessfulRequestOperation]
204
+ )
205
+
206
+
207
+ AnySuccessfulRequestOperation = (
208
+ CreateSuccessfulRequestOperation
209
+ | ReadSuccessfulRequestOperation
210
+ | UpdateSuccessfulRequestOperation
211
+ | DeleteSuccessfulRequestOperation
212
+ )
213
+
214
+
215
+ class FailedRequestOperationFactory(Generic[AnyErrorT, ErrorResponseT]):
216
+ @overload
217
+ @classmethod
218
+ def operation_cls_from_action(cls, action: CreateResourceOperationAction) -> Type[
219
+ CreateFailedRequestOperation[
220
+ AnyErrorT,
221
+ ErrorResponseT,
222
+ ]
223
+ ]: ...
224
+ @overload
225
+ @classmethod
226
+ def operation_cls_from_action(cls, action: ReadResourceOperationAction) -> Type[
227
+ ReadFailedRequestOperation[
228
+ AnyErrorT,
229
+ ErrorResponseT,
230
+ ]
231
+ ]: ...
232
+ @overload
233
+ @classmethod
234
+ def operation_cls_from_action(cls, action: UpdateResourceOperationAction) -> Type[
235
+ UpdateFailedRequestOperation[
236
+ AnyErrorT,
237
+ ErrorResponseT,
238
+ ]
239
+ ]: ...
240
+ @overload
241
+ @classmethod
242
+ def operation_cls_from_action(cls, action: DeleteResourceOperationAction) -> Type[
243
+ DeleteFailedRequestOperation[
244
+ AnyErrorT,
245
+ ErrorResponseT,
246
+ ]
247
+ ]: ...
248
+ @overload
249
+ @classmethod
250
+ def operation_cls_from_action(cls, action: AnyResourceOperationAction) -> (
251
+ Type[
252
+ CreateFailedRequestOperation[
253
+ AnyErrorT,
254
+ ErrorResponseT,
255
+ ]
256
+ ]
257
+ | Type[
258
+ ReadFailedRequestOperation[
259
+ AnyErrorT,
260
+ ErrorResponseT,
261
+ ]
262
+ ]
263
+ | Type[
264
+ UpdateFailedRequestOperation[
265
+ AnyErrorT,
266
+ ErrorResponseT,
267
+ ]
268
+ ]
269
+ | Type[
270
+ DeleteFailedRequestOperation[
271
+ AnyErrorT,
272
+ ErrorResponseT,
273
+ ]
274
+ ]
275
+ ): ...
276
+ @classmethod
277
+ def operation_cls_from_action(cls, action: AnyResourceOperationAction) -> (
278
+ Type[
279
+ CreateFailedRequestOperation[
280
+ AnyErrorT,
281
+ ErrorResponseT,
282
+ ]
283
+ ]
284
+ | Type[
285
+ ReadFailedRequestOperation[
286
+ AnyErrorT,
287
+ ErrorResponseT,
288
+ ]
289
+ ]
290
+ | Type[
291
+ UpdateFailedRequestOperation[
292
+ AnyErrorT,
293
+ ErrorResponseT,
294
+ ]
295
+ ]
296
+ | Type[
297
+ DeleteFailedRequestOperation[
298
+ AnyErrorT,
299
+ ErrorResponseT,
300
+ ]
301
+ ]
302
+ ):
303
+ if isinstance(action, CreateResourceOperationAction):
304
+ operation_cls = CreateFailedRequestOperation[
305
+ AnyErrorT,
306
+ ErrorResponseT,
307
+ ]
308
+ elif isinstance(action, ReadResourceOperationAction):
309
+ operation_cls = ReadFailedRequestOperation[
310
+ AnyErrorT,
311
+ ErrorResponseT,
312
+ ]
313
+ elif isinstance(action, UpdateResourceOperationAction):
314
+ operation_cls = UpdateFailedRequestOperation[
315
+ AnyErrorT,
316
+ ErrorResponseT,
317
+ ]
318
+ elif isinstance(action, DeleteResourceOperationAction):
319
+ operation_cls = DeleteFailedRequestOperation[
320
+ AnyErrorT,
321
+ ErrorResponseT,
322
+ ]
323
+ return operation_cls
324
+
325
+ @overload
326
+ @classmethod
327
+ def operation_cls_from_type(
328
+ cls,
329
+ type_: Literal[ResourceOperationType.CREATE],
330
+ ) -> Type[
331
+ CreateFailedRequestOperation[
332
+ AnyErrorT,
333
+ ErrorResponseT,
334
+ ]
335
+ ]: ...
336
+ @overload
337
+ @classmethod
338
+ def operation_cls_from_type(
339
+ cls,
340
+ type_: Literal[ResourceOperationType.READ],
341
+ ) -> Type[
342
+ ReadFailedRequestOperation[
343
+ AnyErrorT,
344
+ ErrorResponseT,
345
+ ]
346
+ ]: ...
347
+ @overload
348
+ @classmethod
349
+ def operation_cls_from_type(
350
+ cls,
351
+ type_: Literal[ResourceOperationType.UPDATE],
352
+ ) -> Type[
353
+ UpdateFailedRequestOperation[
354
+ AnyErrorT,
355
+ ErrorResponseT,
356
+ ]
357
+ ]: ...
358
+ @overload
359
+ @classmethod
360
+ def operation_cls_from_type(
361
+ cls,
362
+ type_: Literal[ResourceOperationType.DELETE],
363
+ ) -> Type[
364
+ DeleteFailedRequestOperation[
365
+ AnyErrorT,
366
+ ErrorResponseT,
367
+ ]
368
+ ]: ...
369
+ @classmethod
370
+ def operation_cls_from_type(
371
+ cls,
372
+ type_: ResourceOperationType,
373
+ ) -> (
374
+ Type[
375
+ CreateFailedRequestOperation[
376
+ AnyErrorT,
377
+ ErrorResponseT,
378
+ ]
379
+ ]
380
+ | Type[
381
+ ReadFailedRequestOperation[
382
+ AnyErrorT,
383
+ ErrorResponseT,
384
+ ]
385
+ ]
386
+ | Type[
387
+ UpdateFailedRequestOperation[
388
+ AnyErrorT,
389
+ ErrorResponseT,
390
+ ]
391
+ ]
392
+ | Type[
393
+ DeleteFailedRequestOperation[
394
+ AnyErrorT,
395
+ ErrorResponseT,
396
+ ]
397
+ ]
398
+ ):
399
+ if type_ is ResourceOperationType.CREATE:
400
+ operation_cls = CreateFailedRequestOperation[
401
+ AnyErrorT,
402
+ ErrorResponseT,
403
+ ]
404
+ elif type_ is ResourceOperationType.READ:
405
+ operation_cls = ReadFailedRequestOperation[
406
+ AnyErrorT,
407
+ ErrorResponseT,
408
+ ]
409
+ elif type_ is ResourceOperationType.UPDATE:
410
+ operation_cls = UpdateFailedRequestOperation[
411
+ AnyErrorT,
412
+ ErrorResponseT,
413
+ ]
414
+ elif type_ is ResourceOperationType.DELETE:
415
+ operation_cls = DeleteFailedRequestOperation[
416
+ AnyErrorT,
417
+ ErrorResponseT,
418
+ ]
419
+ return operation_cls
420
+
421
+ @overload
422
+ @classmethod
423
+ def generate(
424
+ cls,
425
+ action: CreateResourceOperationAction,
426
+ *,
427
+ application_context: OptApplicationContext = None,
428
+ id: UUID,
429
+ context: OperationContext,
430
+ timestamp: Timestamp,
431
+ summary: str,
432
+ error: AnyErrorT,
433
+ connection_context: ConnectionContext,
434
+ authentication: OptAnyAuthentication = None,
435
+ authorization: OptAnyAuthorization = None,
436
+ impersonation: OptImpersonation = None,
437
+ response: ErrorResponseT,
438
+ response_context: ResponseContext,
439
+ ) -> CreateFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
440
+ @overload
441
+ @classmethod
442
+ def generate(
443
+ cls,
444
+ action: ReadResourceOperationAction,
445
+ *,
446
+ application_context: OptApplicationContext = None,
447
+ id: UUID,
448
+ context: OperationContext,
449
+ timestamp: Timestamp,
450
+ summary: str,
451
+ error: AnyErrorT,
452
+ connection_context: ConnectionContext,
453
+ authentication: OptAnyAuthentication = None,
454
+ authorization: OptAnyAuthorization = None,
455
+ impersonation: OptImpersonation = None,
456
+ response: ErrorResponseT,
457
+ response_context: ResponseContext,
458
+ ) -> ReadFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
459
+ @overload
460
+ @classmethod
461
+ def generate(
462
+ cls,
463
+ action: UpdateResourceOperationAction,
464
+ *,
465
+ application_context: OptApplicationContext = None,
466
+ id: UUID,
467
+ context: OperationContext,
468
+ timestamp: Timestamp,
469
+ summary: str,
470
+ error: AnyErrorT,
471
+ connection_context: ConnectionContext,
472
+ authentication: OptAnyAuthentication = None,
473
+ authorization: OptAnyAuthorization = None,
474
+ impersonation: OptImpersonation = None,
475
+ response: ErrorResponseT,
476
+ response_context: ResponseContext,
477
+ ) -> UpdateFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
478
+ @overload
479
+ @classmethod
480
+ def generate(
481
+ cls,
482
+ action: DeleteResourceOperationAction,
483
+ *,
484
+ application_context: OptApplicationContext = None,
485
+ id: UUID,
486
+ context: OperationContext,
487
+ timestamp: Timestamp,
488
+ summary: str,
489
+ error: AnyErrorT,
490
+ connection_context: ConnectionContext,
491
+ authentication: OptAnyAuthentication = None,
492
+ authorization: OptAnyAuthorization = None,
493
+ impersonation: OptImpersonation = None,
494
+ response: ErrorResponseT,
495
+ response_context: ResponseContext,
496
+ ) -> DeleteFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
497
+ @overload
498
+ @classmethod
499
+ def generate(
500
+ cls,
501
+ action: AnyResourceOperationAction,
502
+ *,
503
+ application_context: OptApplicationContext = None,
504
+ id: UUID,
505
+ context: OperationContext,
506
+ timestamp: Timestamp,
507
+ summary: str,
508
+ error: AnyErrorT,
509
+ connection_context: ConnectionContext,
510
+ authentication: OptAnyAuthentication = None,
511
+ authorization: OptAnyAuthorization = None,
512
+ impersonation: OptImpersonation = None,
513
+ response: ErrorResponseT,
514
+ response_context: ResponseContext,
515
+ ) -> (
516
+ CreateFailedRequestOperation[
517
+ AnyErrorT,
518
+ ErrorResponseT,
519
+ ]
520
+ | ReadFailedRequestOperation[
521
+ AnyErrorT,
522
+ ErrorResponseT,
523
+ ]
524
+ | UpdateFailedRequestOperation[
525
+ AnyErrorT,
526
+ ErrorResponseT,
527
+ ]
528
+ | DeleteFailedRequestOperation[
529
+ AnyErrorT,
530
+ ErrorResponseT,
531
+ ]
532
+ ): ...
533
+ @overload
534
+ @classmethod
535
+ def generate(
536
+ cls,
537
+ *,
538
+ type_: Literal[ResourceOperationType.CREATE],
539
+ application_context: OptApplicationContext = None,
540
+ id: UUID,
541
+ context: OperationContext,
542
+ timestamp: Timestamp,
543
+ summary: str,
544
+ error: AnyErrorT,
545
+ connection_context: ConnectionContext,
546
+ authentication: OptAnyAuthentication = None,
547
+ authorization: OptAnyAuthorization = None,
548
+ impersonation: OptImpersonation = None,
549
+ response: ErrorResponseT,
550
+ response_context: ResponseContext,
551
+ ) -> CreateFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
552
+ @overload
553
+ @classmethod
554
+ def generate(
555
+ cls,
556
+ *,
557
+ type_: Literal[ResourceOperationType.READ],
558
+ application_context: OptApplicationContext = None,
559
+ id: UUID,
560
+ context: OperationContext,
561
+ timestamp: Timestamp,
562
+ summary: str,
563
+ error: AnyErrorT,
564
+ connection_context: ConnectionContext,
565
+ authentication: OptAnyAuthentication = None,
566
+ authorization: OptAnyAuthorization = None,
567
+ impersonation: OptImpersonation = None,
568
+ response: ErrorResponseT,
569
+ response_context: ResponseContext,
570
+ ) -> ReadFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
571
+ @overload
572
+ @classmethod
573
+ def generate(
574
+ cls,
575
+ *,
576
+ type_: Literal[ResourceOperationType.UPDATE],
577
+ update_type: OptResourceOperationUpdateType = ...,
578
+ data_update_type: OptResourceOperationDataUpdateType = ...,
579
+ status_update_type: OptResourceOperationStatusUpdateType = ...,
580
+ application_context: OptApplicationContext = None,
581
+ id: UUID,
582
+ context: OperationContext,
583
+ timestamp: Timestamp,
584
+ summary: str,
585
+ error: AnyErrorT,
586
+ connection_context: ConnectionContext,
587
+ authentication: OptAnyAuthentication = None,
588
+ authorization: OptAnyAuthorization = None,
589
+ impersonation: OptImpersonation = None,
590
+ response: ErrorResponseT,
591
+ response_context: ResponseContext,
592
+ ) -> UpdateFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
593
+ @overload
594
+ @classmethod
595
+ def generate(
596
+ cls,
597
+ *,
598
+ type_: Literal[ResourceOperationType.DELETE],
599
+ application_context: OptApplicationContext = None,
600
+ id: UUID,
601
+ context: OperationContext,
602
+ timestamp: Timestamp,
603
+ summary: str,
604
+ error: AnyErrorT,
605
+ connection_context: ConnectionContext,
606
+ authentication: OptAnyAuthentication = None,
607
+ authorization: OptAnyAuthorization = None,
608
+ impersonation: OptImpersonation = None,
609
+ response: ErrorResponseT,
610
+ response_context: ResponseContext,
611
+ ) -> DeleteFailedRequestOperation[AnyErrorT, ErrorResponseT]: ...
612
+ @overload
613
+ @classmethod
614
+ def generate(
615
+ cls,
616
+ *,
617
+ type_: ResourceOperationType,
618
+ update_type: OptResourceOperationUpdateType = None,
619
+ data_update_type: OptResourceOperationDataUpdateType = None,
620
+ status_update_type: OptResourceOperationStatusUpdateType = None,
621
+ application_context: OptApplicationContext = None,
622
+ id: UUID,
623
+ context: OperationContext,
624
+ timestamp: Timestamp,
625
+ summary: str,
626
+ error: AnyErrorT,
627
+ connection_context: ConnectionContext,
628
+ authentication: OptAnyAuthentication = None,
629
+ authorization: OptAnyAuthorization = None,
630
+ impersonation: OptImpersonation = None,
631
+ response: ErrorResponseT,
632
+ response_context: ResponseContext,
633
+ ) -> (
634
+ CreateFailedRequestOperation[
635
+ AnyErrorT,
636
+ ErrorResponseT,
637
+ ]
638
+ | ReadFailedRequestOperation[
639
+ AnyErrorT,
640
+ ErrorResponseT,
641
+ ]
642
+ | UpdateFailedRequestOperation[
643
+ AnyErrorT,
644
+ ErrorResponseT,
645
+ ]
646
+ | DeleteFailedRequestOperation[
647
+ AnyErrorT,
648
+ ErrorResponseT,
649
+ ]
650
+ ): ...
651
+ @classmethod
652
+ def generate(
653
+ cls,
654
+ action: OptAnyResourceOperationAction = None,
655
+ *,
656
+ type_: OptResourceOperationType = None,
657
+ update_type: OptResourceOperationUpdateType = None,
658
+ data_update_type: OptResourceOperationDataUpdateType = None,
659
+ status_update_type: OptResourceOperationStatusUpdateType = None,
660
+ application_context: OptApplicationContext = None,
661
+ id: UUID,
662
+ context: OperationContext,
663
+ timestamp: Timestamp,
664
+ summary: str,
665
+ error: AnyErrorT,
666
+ connection_context: ConnectionContext,
667
+ authentication: OptAnyAuthentication = None,
668
+ authorization: OptAnyAuthorization = None,
669
+ impersonation: OptImpersonation = None,
670
+ response: ErrorResponseT,
671
+ response_context: ResponseContext,
672
+ ) -> (
673
+ CreateFailedRequestOperation[
674
+ AnyErrorT,
675
+ ErrorResponseT,
676
+ ]
677
+ | ReadFailedRequestOperation[
678
+ AnyErrorT,
679
+ ErrorResponseT,
680
+ ]
681
+ | UpdateFailedRequestOperation[
682
+ AnyErrorT,
683
+ ErrorResponseT,
684
+ ]
685
+ | DeleteFailedRequestOperation[
686
+ AnyErrorT,
687
+ ErrorResponseT,
688
+ ]
689
+ ):
690
+ if (action is None and type_ is None) or (
691
+ action is not None and type_ is not None
692
+ ):
693
+ raise ValueError("Only either 'action' or 'type' must be given")
694
+
695
+ common_kwargs = {
696
+ "id": id,
697
+ "context": context,
698
+ "timestamp": timestamp,
699
+ "summary": summary,
700
+ "error": error,
701
+ "connection_context": connection_context,
702
+ "authentication": authentication,
703
+ "authorization": authorization,
704
+ "impersonation": impersonation,
705
+ "response": response,
706
+ "response_context": response_context,
707
+ }
708
+
709
+ if application_context is not None:
710
+ common_kwargs["application_context"] = application_context
711
+
712
+ if action is not None:
713
+ if not isinstance(action, ResourceOperationActions):
714
+ raise ValueError(f"Invalid 'action' type: '{type(action)}'")
715
+
716
+ kwargs = deepcopy(common_kwargs)
717
+ kwargs["action"] = action
718
+
719
+ return cls.operation_cls_from_action(action).model_validate(kwargs)
720
+
721
+ elif type_ is not None:
722
+ action = ResourceOperationActionFactory.generate(
723
+ type_,
724
+ update_type=update_type,
725
+ data_update_type=data_update_type,
726
+ status_update_type=status_update_type,
727
+ )
728
+ kwargs = deepcopy(common_kwargs)
729
+ kwargs["action"] = action
730
+ return cls.operation_cls_from_type(type_).model_validate(kwargs)
731
+
732
+ # This should never happen due to initial validation,
733
+ # but type checker needs to see all paths covered
734
+ raise ValueError("Neither 'action' nor 'type' provided")
735
+
736
+
737
+ class SuccessfulRequestOperationFactory:
738
+ @overload
739
+ @classmethod
740
+ def operation_cls_from_action(
741
+ cls, action: CreateResourceOperationAction
742
+ ) -> Type[CreateSuccessfulRequestOperation]: ...
743
+ @overload
744
+ @classmethod
745
+ def operation_cls_from_action(
746
+ cls, action: ReadResourceOperationAction
747
+ ) -> Type[ReadSuccessfulRequestOperation]: ...
748
+ @overload
749
+ @classmethod
750
+ def operation_cls_from_action(
751
+ cls, action: UpdateResourceOperationAction
752
+ ) -> Type[UpdateSuccessfulRequestOperation]: ...
753
+ @overload
754
+ @classmethod
755
+ def operation_cls_from_action(
756
+ cls, action: DeleteResourceOperationAction
757
+ ) -> Type[DeleteSuccessfulRequestOperation]: ...
758
+ @overload
759
+ @classmethod
760
+ def operation_cls_from_action(
761
+ cls, action: AnyResourceOperationAction
762
+ ) -> AnySuccessfulRequestOperationType: ...
763
+ @classmethod
764
+ def operation_cls_from_action(
765
+ cls, action: AnyResourceOperationAction
766
+ ) -> AnySuccessfulRequestOperationType:
767
+ if isinstance(action, CreateResourceOperationAction):
768
+ operation_cls = CreateSuccessfulRequestOperation
769
+ elif isinstance(action, ReadResourceOperationAction):
770
+ operation_cls = ReadSuccessfulRequestOperation
771
+ elif isinstance(action, UpdateResourceOperationAction):
772
+ operation_cls = UpdateSuccessfulRequestOperation
773
+ elif isinstance(action, DeleteResourceOperationAction):
774
+ operation_cls = DeleteSuccessfulRequestOperation
775
+ return operation_cls
776
+
777
+ @overload
778
+ @classmethod
779
+ def operation_cls_from_type(
780
+ cls,
781
+ type_: Literal[ResourceOperationType.CREATE],
782
+ ) -> Type[CreateSuccessfulRequestOperation]: ...
783
+ @overload
784
+ @classmethod
785
+ def operation_cls_from_type(
786
+ cls,
787
+ type_: Literal[ResourceOperationType.READ],
788
+ ) -> Type[ReadSuccessfulRequestOperation]: ...
789
+ @overload
790
+ @classmethod
791
+ def operation_cls_from_type(
792
+ cls,
793
+ type_: Literal[ResourceOperationType.UPDATE],
794
+ ) -> Type[UpdateSuccessfulRequestOperation]: ...
795
+ @overload
796
+ @classmethod
797
+ def operation_cls_from_type(
798
+ cls,
799
+ type_: Literal[ResourceOperationType.DELETE],
800
+ ) -> Type[DeleteSuccessfulRequestOperation]: ...
801
+ @classmethod
802
+ def operation_cls_from_type(
803
+ cls,
804
+ type_: ResourceOperationType,
805
+ ) -> AnySuccessfulRequestOperationType:
806
+ if type_ is ResourceOperationType.CREATE:
807
+ operation_cls = CreateSuccessfulRequestOperation
808
+ elif type_ is ResourceOperationType.READ:
809
+ operation_cls = ReadSuccessfulRequestOperation
810
+ elif type_ is ResourceOperationType.UPDATE:
811
+ operation_cls = UpdateSuccessfulRequestOperation
812
+ elif type_ is ResourceOperationType.DELETE:
813
+ operation_cls = DeleteSuccessfulRequestOperation
814
+ return operation_cls
815
+
816
+ @overload
817
+ @classmethod
818
+ def generate(
819
+ cls,
820
+ action: CreateResourceOperationAction,
821
+ *,
822
+ application_context: OptApplicationContext = None,
823
+ id: UUID,
824
+ context: OperationContext,
825
+ timestamp: Timestamp,
826
+ summary: str,
827
+ connection_context: ConnectionContext,
828
+ authentication: OptAnyAuthentication = None,
829
+ authorization: OptAnyAuthorization = None,
830
+ impersonation: OptImpersonation = None,
831
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
832
+ response_context: ResponseContext,
833
+ ) -> CreateSuccessfulRequestOperation: ...
834
+ @overload
835
+ @classmethod
836
+ def generate(
837
+ cls,
838
+ action: ReadResourceOperationAction,
839
+ *,
840
+ application_context: OptApplicationContext = None,
841
+ id: UUID,
842
+ context: OperationContext,
843
+ timestamp: Timestamp,
844
+ summary: str,
845
+ connection_context: ConnectionContext,
846
+ authentication: OptAnyAuthentication = None,
847
+ authorization: OptAnyAuthorization = None,
848
+ impersonation: OptImpersonation = None,
849
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
850
+ response_context: ResponseContext,
851
+ ) -> ReadSuccessfulRequestOperation: ...
852
+ @overload
853
+ @classmethod
854
+ def generate(
855
+ cls,
856
+ action: UpdateResourceOperationAction,
857
+ *,
858
+ application_context: OptApplicationContext = None,
859
+ id: UUID,
860
+ context: OperationContext,
861
+ timestamp: Timestamp,
862
+ summary: str,
863
+ connection_context: ConnectionContext,
864
+ authentication: OptAnyAuthentication = None,
865
+ authorization: OptAnyAuthorization = None,
866
+ impersonation: OptImpersonation = None,
867
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
868
+ response_context: ResponseContext,
869
+ ) -> UpdateSuccessfulRequestOperation: ...
870
+ @overload
871
+ @classmethod
872
+ def generate(
873
+ cls,
874
+ action: DeleteResourceOperationAction,
875
+ *,
876
+ application_context: OptApplicationContext = None,
877
+ id: UUID,
878
+ context: OperationContext,
879
+ timestamp: Timestamp,
880
+ summary: str,
881
+ connection_context: ConnectionContext,
882
+ authentication: OptAnyAuthentication = None,
883
+ authorization: OptAnyAuthorization = None,
884
+ impersonation: OptImpersonation = None,
885
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
886
+ response_context: ResponseContext,
887
+ ) -> DeleteSuccessfulRequestOperation: ...
888
+ @overload
889
+ @classmethod
890
+ def generate(
891
+ cls,
892
+ action: AnyResourceOperationAction,
893
+ *,
894
+ application_context: OptApplicationContext = None,
895
+ id: UUID,
896
+ context: OperationContext,
897
+ timestamp: Timestamp,
898
+ summary: str,
899
+ connection_context: ConnectionContext,
900
+ authentication: OptAnyAuthentication = None,
901
+ authorization: OptAnyAuthorization = None,
902
+ impersonation: OptImpersonation = None,
903
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
904
+ response_context: ResponseContext,
905
+ ) -> AnySuccessfulRequestOperation: ...
906
+ @overload
907
+ @classmethod
908
+ def generate(
909
+ cls,
910
+ *,
911
+ type_: Literal[ResourceOperationType.CREATE],
912
+ application_context: OptApplicationContext = None,
913
+ id: UUID,
914
+ context: OperationContext,
915
+ timestamp: Timestamp,
916
+ summary: str,
917
+ connection_context: ConnectionContext,
918
+ authentication: OptAnyAuthentication = None,
919
+ authorization: OptAnyAuthorization = None,
920
+ impersonation: OptImpersonation = None,
921
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
922
+ response_context: ResponseContext,
923
+ ) -> CreateSuccessfulRequestOperation: ...
924
+ @overload
925
+ @classmethod
926
+ def generate(
927
+ cls,
928
+ *,
929
+ type_: Literal[ResourceOperationType.READ],
930
+ application_context: OptApplicationContext = None,
931
+ id: UUID,
932
+ context: OperationContext,
933
+ timestamp: Timestamp,
934
+ summary: str,
935
+ connection_context: ConnectionContext,
936
+ authentication: OptAnyAuthentication = None,
937
+ authorization: OptAnyAuthorization = None,
938
+ impersonation: OptImpersonation = None,
939
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
940
+ response_context: ResponseContext,
941
+ ) -> ReadSuccessfulRequestOperation: ...
942
+ @overload
943
+ @classmethod
944
+ def generate(
945
+ cls,
946
+ *,
947
+ type_: Literal[ResourceOperationType.UPDATE],
948
+ update_type: OptResourceOperationUpdateType = ...,
949
+ data_update_type: OptResourceOperationDataUpdateType = ...,
950
+ status_update_type: OptResourceOperationStatusUpdateType = ...,
951
+ application_context: OptApplicationContext = None,
952
+ id: UUID,
953
+ context: OperationContext,
954
+ timestamp: Timestamp,
955
+ summary: str,
956
+ connection_context: ConnectionContext,
957
+ authentication: OptAnyAuthentication = None,
958
+ authorization: OptAnyAuthorization = None,
959
+ impersonation: OptImpersonation = None,
960
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
961
+ response_context: ResponseContext,
962
+ ) -> UpdateSuccessfulRequestOperation: ...
963
+ @overload
964
+ @classmethod
965
+ def generate(
966
+ cls,
967
+ *,
968
+ type_: Literal[ResourceOperationType.DELETE],
969
+ application_context: OptApplicationContext = None,
970
+ id: UUID,
971
+ context: OperationContext,
972
+ timestamp: Timestamp,
973
+ summary: str,
974
+ connection_context: ConnectionContext,
975
+ authentication: OptAnyAuthentication = None,
976
+ authorization: OptAnyAuthorization = None,
977
+ impersonation: OptImpersonation = None,
978
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
979
+ response_context: ResponseContext,
980
+ ) -> DeleteSuccessfulRequestOperation: ...
981
+ @overload
982
+ @classmethod
983
+ def generate(
984
+ cls,
985
+ *,
986
+ type_: ResourceOperationType,
987
+ update_type: OptResourceOperationUpdateType = None,
988
+ data_update_type: OptResourceOperationDataUpdateType = None,
989
+ status_update_type: OptResourceOperationStatusUpdateType = None,
990
+ application_context: OptApplicationContext = None,
991
+ id: UUID,
992
+ context: OperationContext,
993
+ timestamp: Timestamp,
994
+ summary: str,
995
+ connection_context: ConnectionContext,
996
+ authentication: OptAnyAuthentication = None,
997
+ authorization: OptAnyAuthorization = None,
998
+ impersonation: OptImpersonation = None,
999
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
1000
+ response_context: ResponseContext,
1001
+ ) -> AnySuccessfulRequestOperation: ...
1002
+ @classmethod
1003
+ def generate(
1004
+ cls,
1005
+ action: OptAnyResourceOperationAction = None,
1006
+ *,
1007
+ type_: OptResourceOperationType = None,
1008
+ update_type: OptResourceOperationUpdateType = None,
1009
+ data_update_type: OptResourceOperationDataUpdateType = None,
1010
+ status_update_type: OptResourceOperationStatusUpdateType = None,
1011
+ application_context: OptApplicationContext = None,
1012
+ id: UUID,
1013
+ context: OperationContext,
1014
+ timestamp: Timestamp,
1015
+ summary: str,
1016
+ connection_context: ConnectionContext,
1017
+ authentication: OptAnyAuthentication = None,
1018
+ authorization: OptAnyAuthorization = None,
1019
+ impersonation: OptImpersonation = None,
1020
+ response: AnyDataResponse[Any, OptAnyPagination, Any],
1021
+ response_context: ResponseContext,
1022
+ ) -> AnySuccessfulRequestOperation:
1023
+ if (action is None and type_ is None) or (
1024
+ action is not None and type_ is not None
1025
+ ):
1026
+ raise ValueError("Only either 'action' or 'type' must be given")
1027
+
1028
+ common_kwargs = {
1029
+ "id": id,
1030
+ "context": context,
1031
+ "timestamp": timestamp,
1032
+ "summary": summary,
1033
+ "connection_context": connection_context,
1034
+ "authentication": authentication,
1035
+ "authorization": authorization,
1036
+ "impersonation": impersonation,
1037
+ "response": response,
1038
+ "response_context": response_context,
1039
+ }
1040
+
1041
+ if application_context is not None:
1042
+ common_kwargs["application_context"] = application_context
1043
+
1044
+ if action is not None:
1045
+ if not isinstance(action, ResourceOperationActions):
1046
+ raise ValueError(f"Invalid 'action' type: '{type(action)}'")
1047
+
1048
+ kwargs = deepcopy(common_kwargs)
1049
+ kwargs["action"] = action
1050
+
1051
+ return cls.operation_cls_from_action(action).model_validate(kwargs)
1052
+
1053
+ if type_ is not None:
1054
+ action = ResourceOperationActionFactory.generate(
1055
+ type_,
1056
+ update_type=update_type,
1057
+ data_update_type=data_update_type,
1058
+ status_update_type=status_update_type,
1059
+ )
1060
+ kwargs = deepcopy(common_kwargs)
1061
+ kwargs["action"] = action
1062
+ return cls.operation_cls_from_type(type_).model_validate(kwargs)
1063
+
1064
+ # This should never happen due to initial validation,
1065
+ # but type checker needs to see all paths covered
1066
+ raise ValueError("Neither 'action' nor 'type' provided")