maleo-identity 0.0.85__py3-none-any.whl → 0.1.24__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 (138) hide show
  1. maleo/identity/constants/api_key.py +13 -0
  2. maleo/identity/constants/organization.py +3 -10
  3. maleo/identity/constants/organization_registration_code.py +5 -17
  4. maleo/identity/constants/organization_relation.py +13 -0
  5. maleo/identity/constants/patient.py +7 -0
  6. maleo/identity/constants/user.py +3 -20
  7. maleo/identity/constants/user_medical_role.py +13 -0
  8. maleo/identity/constants/user_organization_role.py +5 -39
  9. maleo/identity/constants/user_profile.py +3 -21
  10. maleo/identity/constants/user_system_role.py +9 -8
  11. maleo/identity/enums/api_key.py +25 -0
  12. maleo/identity/enums/organization.py +16 -3
  13. maleo/identity/enums/organization_registration_code.py +9 -0
  14. maleo/identity/enums/organization_relation.py +22 -0
  15. maleo/identity/enums/patient.py +29 -0
  16. maleo/identity/enums/user.py +16 -7
  17. maleo/identity/enums/user_medical_role.py +22 -0
  18. maleo/identity/enums/user_organization_role.py +19 -12
  19. maleo/identity/enums/user_profile.py +7 -9
  20. maleo/identity/enums/user_system_role.py +30 -0
  21. maleo/identity/mixins/api_key.py +72 -0
  22. maleo/identity/mixins/common.py +29 -0
  23. maleo/identity/mixins/organization.py +68 -8
  24. maleo/identity/mixins/organization_registration_code.py +126 -9
  25. maleo/identity/mixins/organization_relation.py +80 -0
  26. maleo/identity/mixins/patient.py +65 -0
  27. maleo/identity/mixins/user.py +86 -24
  28. maleo/identity/mixins/user_medical_role.py +68 -0
  29. maleo/identity/mixins/user_organization_role.py +68 -4
  30. maleo/identity/mixins/user_profile.py +84 -53
  31. maleo/identity/mixins/user_system_role.py +72 -4
  32. maleo/identity/schemas/api_key.py +171 -0
  33. maleo/identity/schemas/common.py +335 -0
  34. maleo/identity/schemas/organization.py +311 -0
  35. maleo/identity/schemas/organization_registration_code.py +314 -0
  36. maleo/identity/schemas/organization_relation.py +315 -0
  37. maleo/identity/schemas/patient.py +349 -0
  38. maleo/identity/schemas/user.py +318 -0
  39. maleo/identity/schemas/user_medical_role.py +316 -0
  40. maleo/identity/schemas/user_organization_role.py +317 -0
  41. maleo/identity/schemas/user_profile.py +362 -0
  42. maleo/identity/schemas/user_system_role.py +339 -0
  43. maleo/identity/types/api_key.py +7 -0
  44. maleo/identity/types/organization.py +4 -0
  45. maleo/identity/types/organization_registration_code.py +4 -0
  46. maleo/identity/types/organization_relation.py +7 -0
  47. maleo/identity/types/patient.py +4 -0
  48. maleo/identity/types/user.py +4 -0
  49. maleo/identity/types/user_medical_role.py +7 -0
  50. maleo/identity/types/user_organization_role.py +7 -0
  51. maleo/identity/types/user_profile.py +4 -0
  52. maleo/identity/types/user_system_role.py +8 -0
  53. maleo/identity/utils/organization.py +32 -0
  54. maleo/identity/utils/user.py +32 -0
  55. maleo_identity-0.1.24.dist-info/METADATA +119 -0
  56. maleo_identity-0.1.24.dist-info/RECORD +66 -0
  57. maleo_identity-0.1.24.dist-info/licenses/LICENSE +57 -0
  58. maleo/identity/client/manager.py +0 -157
  59. maleo/identity/client/services/__init__.py +0 -0
  60. maleo/identity/client/services/organization.py +0 -1944
  61. maleo/identity/client/services/organization_registration_code.py +0 -470
  62. maleo/identity/client/services/organization_role.py +0 -276
  63. maleo/identity/client/services/user.py +0 -1559
  64. maleo/identity/client/services/user_organization.py +0 -276
  65. maleo/identity/client/services/user_organization_role.py +0 -278
  66. maleo/identity/client/services/user_profile.py +0 -276
  67. maleo/identity/client/services/user_system_role.py +0 -276
  68. maleo/identity/constants/organization_role.py +0 -35
  69. maleo/identity/constants/user_organization.py +0 -58
  70. maleo/identity/db.py +0 -4
  71. maleo/identity/dtos/__init__.py +0 -0
  72. maleo/identity/dtos/configuration.py +0 -15
  73. maleo/identity/dtos/data/__init__.py +0 -0
  74. maleo/identity/dtos/data/organization_registration_code.py +0 -15
  75. maleo/identity/dtos/data/user_profile.py +0 -29
  76. maleo/identity/dtos/settings.py +0 -17
  77. maleo/identity/enums/general.py +0 -5
  78. maleo/identity/enums/organization_role.py +0 -7
  79. maleo/identity/enums/user_organization.py +0 -14
  80. maleo/identity/mixins/organization_role.py +0 -15
  81. maleo/identity/mixins/user_organization.py +0 -6
  82. maleo/identity/models/__init__.py +0 -0
  83. maleo/identity/models/organization.py +0 -62
  84. maleo/identity/models/organization_registration_code.py +0 -33
  85. maleo/identity/models/organization_role.py +0 -37
  86. maleo/identity/models/user.py +0 -39
  87. maleo/identity/models/user_organization.py +0 -48
  88. maleo/identity/models/user_organization_role.py +0 -61
  89. maleo/identity/models/user_profile.py +0 -33
  90. maleo/identity/models/user_system_role.py +0 -26
  91. maleo/identity/schemas/data/__init__.py +0 -0
  92. maleo/identity/schemas/data/organization.py +0 -36
  93. maleo/identity/schemas/data/organization_registration_code.py +0 -27
  94. maleo/identity/schemas/data/organization_role.py +0 -32
  95. maleo/identity/schemas/data/user.py +0 -33
  96. maleo/identity/schemas/data/user_organization.py +0 -23
  97. maleo/identity/schemas/data/user_organization_role.py +0 -13
  98. maleo/identity/schemas/data/user_profile.py +0 -59
  99. maleo/identity/schemas/data/user_system_role.py +0 -25
  100. maleo/identity/schemas/metadata/__init__.py +0 -0
  101. maleo/identity/schemas/metadata/user.py +0 -6
  102. maleo/identity/schemas/parameter/__init__.py +0 -0
  103. maleo/identity/schemas/parameter/client/__init__.py +0 -0
  104. maleo/identity/schemas/parameter/client/organization.py +0 -74
  105. maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
  106. maleo/identity/schemas/parameter/client/organization_role.py +0 -42
  107. maleo/identity/schemas/parameter/client/user.py +0 -44
  108. maleo/identity/schemas/parameter/client/user_organization.py +0 -62
  109. maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
  110. maleo/identity/schemas/parameter/client/user_profile.py +0 -28
  111. maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
  112. maleo/identity/schemas/parameter/general/__init__.py +0 -0
  113. maleo/identity/schemas/parameter/general/organization.py +0 -43
  114. maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -54
  115. maleo/identity/schemas/parameter/general/organization_role.py +0 -14
  116. maleo/identity/schemas/parameter/general/user.py +0 -101
  117. maleo/identity/schemas/parameter/general/user_organization.py +0 -18
  118. maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
  119. maleo/identity/schemas/parameter/general/user_profile.py +0 -70
  120. maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
  121. maleo/identity/schemas/parameter/service/__init__.py +0 -0
  122. maleo/identity/schemas/parameter/service/organization.py +0 -60
  123. maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
  124. maleo/identity/schemas/parameter/service/organization_role.py +0 -35
  125. maleo/identity/schemas/parameter/service/user.py +0 -47
  126. maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
  127. maleo/identity/schemas/parameter/service/user_profile.py +0 -28
  128. maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
  129. maleo/identity/types/base/__init__.py +0 -0
  130. maleo/identity/types/base/organization.py +0 -5
  131. maleo/identity/types/base/organization_registration_code.py +0 -4
  132. maleo/identity/types/base/user.py +0 -5
  133. maleo/identity/types/base/user_profile.py +0 -5
  134. maleo_identity-0.0.85.dist-info/METADATA +0 -40
  135. maleo_identity-0.0.85.dist-info/RECORD +0 -105
  136. /maleo/identity/{client → utils}/__init__.py +0 -0
  137. {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
  138. {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,349 @@
1
+ from datetime import date
2
+ from pydantic import BaseModel, Field
3
+ from typing import Annotated, Generic, Literal, TypeVar, overload
4
+ from uuid import UUID
5
+ from maleo.enums.identity import (
6
+ OptBloodType,
7
+ BloodTypeMixin,
8
+ OptListOfBloodTypes,
9
+ BloodTypesMixin,
10
+ OptRhesus,
11
+ RhesusMixin,
12
+ OptListOfRhesuses,
13
+ RhesusesMixin,
14
+ Gender,
15
+ OptGender,
16
+ GenderMixin,
17
+ OptListOfGenders,
18
+ GendersMixin,
19
+ )
20
+ from maleo.enums.status import (
21
+ ListOfDataStatuses,
22
+ FULL_DATA_STATUSES,
23
+ )
24
+ from maleo.schemas.mixins.filter import convert as convert_filter
25
+ from maleo.schemas.mixins.identity import (
26
+ IdentifierMixin,
27
+ Ids,
28
+ UUIDs,
29
+ FullNames,
30
+ DateOfBirth,
31
+ IntUserId,
32
+ IntUserIds,
33
+ IntOrganizationId,
34
+ IntOrganizationIds,
35
+ )
36
+ from maleo.schemas.mixins.sort import convert as convert_sort
37
+ from maleo.schemas.operation.enums import ResourceOperationStatusUpdateType
38
+ from maleo.schemas.parameter import (
39
+ ReadSingleParameter as BaseReadSingleParameter,
40
+ ReadPaginatedMultipleParameter,
41
+ StatusUpdateParameter as BaseStatusUpdateParameter,
42
+ DeleteSingleParameter as BaseDeleteSingleParameter,
43
+ )
44
+ from maleo.types.datetime import OptDate
45
+ from maleo.types.dict import StrToAnyDict
46
+ from maleo.types.integer import OptListOfInts
47
+ from maleo.types.string import OptStr, OptListOfStrs
48
+ from maleo.types.uuid import OptListOfUUIDs
49
+ from ..enums.patient import IdentifierType, OptListOfExpandableFields
50
+ from ..mixins.common import IdCard, FullName, PlaceOfBirth
51
+ from ..mixins.patient import PatientIdentity, PatientIdentifier, Expand
52
+ from ..types.patient import IdentifierValueType
53
+
54
+
55
+ class StandardCreateData(
56
+ RhesusMixin[OptRhesus],
57
+ BloodTypeMixin[OptBloodType],
58
+ GenderMixin[Gender],
59
+ DateOfBirth[date],
60
+ PlaceOfBirth[OptStr],
61
+ FullName[str],
62
+ PatientIdentity,
63
+ ):
64
+ pass
65
+
66
+
67
+ class FullCreateData(
68
+ StandardCreateData,
69
+ IntOrganizationId[int],
70
+ ):
71
+ pass
72
+
73
+
74
+ class CreateParameter(Expand, FullCreateData, IntUserId[int]):
75
+ pass
76
+
77
+
78
+ class ReadMultipleParameter(
79
+ Expand,
80
+ ReadPaginatedMultipleParameter,
81
+ RhesusesMixin[OptListOfRhesuses],
82
+ BloodTypesMixin[OptListOfBloodTypes],
83
+ GendersMixin[OptListOfGenders],
84
+ FullNames[OptListOfStrs],
85
+ IntOrganizationIds[OptListOfInts],
86
+ IntUserIds[OptListOfInts],
87
+ UUIDs[OptListOfUUIDs],
88
+ Ids[OptListOfInts],
89
+ ):
90
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
91
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
92
+ user_ids: Annotated[OptListOfInts, Field(None, description="User's IDs")] = None
93
+ organization_ids: Annotated[
94
+ OptListOfInts, Field(None, description="Organization's IDs")
95
+ ] = None
96
+ full_names: Annotated[OptListOfStrs, Field(None, description="Full Names")] = None
97
+ genders: Annotated[OptListOfGenders, Field(None, description="Genders")] = None
98
+ blood_types: Annotated[
99
+ OptListOfBloodTypes, Field(None, description="Blood Types")
100
+ ] = None
101
+ rhesuses: Annotated[OptListOfRhesuses, Field(None, description="Rhesuses")] = None
102
+
103
+ @property
104
+ def _query_param_fields(self) -> set[str]:
105
+ return {
106
+ "ids",
107
+ "uuids",
108
+ "statuses",
109
+ "user_ids",
110
+ "organization_ids",
111
+ "full_names",
112
+ "genders",
113
+ "blood_types",
114
+ "rhesuses",
115
+ "search",
116
+ "page",
117
+ "limit",
118
+ "use_cache",
119
+ "expand",
120
+ }
121
+
122
+ def to_query_params(self) -> StrToAnyDict:
123
+ params = self.model_dump(
124
+ mode="json", include=self._query_param_fields, exclude_none=True
125
+ )
126
+ params["filters"] = convert_filter(self.date_filters)
127
+ params["sorts"] = convert_sort(self.sort_columns)
128
+ params = {k: v for k, v in params.items()}
129
+ return params
130
+
131
+
132
+ class ReadSingleParameter(Expand, BaseReadSingleParameter[PatientIdentifier]):
133
+ @classmethod
134
+ def from_identifier(
135
+ cls,
136
+ identifier: PatientIdentifier,
137
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
138
+ use_cache: bool = True,
139
+ expand: OptListOfExpandableFields = None,
140
+ ) -> "ReadSingleParameter":
141
+ return cls(
142
+ identifier=identifier, statuses=statuses, use_cache=use_cache, expand=expand
143
+ )
144
+
145
+ @overload
146
+ @classmethod
147
+ def new(
148
+ cls,
149
+ identifier_type: Literal[IdentifierType.ID],
150
+ identifier_value: int,
151
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
152
+ use_cache: bool = True,
153
+ expand: OptListOfExpandableFields = None,
154
+ ) -> "ReadSingleParameter": ...
155
+ @overload
156
+ @classmethod
157
+ def new(
158
+ cls,
159
+ identifier_type: Literal[IdentifierType.UUID],
160
+ identifier_value: UUID,
161
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
162
+ use_cache: bool = True,
163
+ expand: OptListOfExpandableFields = None,
164
+ ) -> "ReadSingleParameter": ...
165
+ @overload
166
+ @classmethod
167
+ def new(
168
+ cls,
169
+ identifier_type: IdentifierType,
170
+ identifier_value: IdentifierValueType,
171
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
172
+ use_cache: bool = True,
173
+ expand: OptListOfExpandableFields = None,
174
+ ) -> "ReadSingleParameter": ...
175
+ @classmethod
176
+ def new(
177
+ cls,
178
+ identifier_type: IdentifierType,
179
+ identifier_value: IdentifierValueType,
180
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
181
+ use_cache: bool = True,
182
+ expand: OptListOfExpandableFields = None,
183
+ ) -> "ReadSingleParameter":
184
+ return cls(
185
+ identifier=PatientIdentifier(
186
+ type=identifier_type,
187
+ value=identifier_value,
188
+ ),
189
+ statuses=statuses,
190
+ use_cache=use_cache,
191
+ expand=expand,
192
+ )
193
+
194
+ def to_query_params(self) -> StrToAnyDict:
195
+ return self.model_dump(
196
+ mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
197
+ )
198
+
199
+
200
+ class FullUpdateData(
201
+ RhesusMixin[OptRhesus],
202
+ BloodTypeMixin[OptBloodType],
203
+ GenderMixin[Gender],
204
+ DateOfBirth[date],
205
+ PlaceOfBirth[OptStr],
206
+ FullName[str],
207
+ PatientIdentity,
208
+ IdCard[OptStr],
209
+ ):
210
+ pass
211
+
212
+
213
+ class PartialUpdateData(
214
+ RhesusMixin[OptRhesus],
215
+ BloodTypeMixin[OptBloodType],
216
+ GenderMixin[OptGender],
217
+ DateOfBirth[OptDate],
218
+ PlaceOfBirth[OptStr],
219
+ FullName[OptStr],
220
+ PatientIdentity,
221
+ IdCard[OptStr],
222
+ ):
223
+ pass
224
+
225
+
226
+ UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
227
+
228
+
229
+ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
230
+ data: UpdateDataT = Field(..., description="Update data")
231
+
232
+
233
+ class UpdateParameter(
234
+ Expand,
235
+ UpdateDataMixin[UpdateDataT],
236
+ IdentifierMixin[PatientIdentifier],
237
+ Generic[UpdateDataT],
238
+ ):
239
+ @overload
240
+ @classmethod
241
+ def new(
242
+ cls,
243
+ identifier_type: Literal[IdentifierType.ID],
244
+ identifier_value: int,
245
+ data: UpdateDataT,
246
+ expand: OptListOfExpandableFields = None,
247
+ ) -> "UpdateParameter": ...
248
+ @overload
249
+ @classmethod
250
+ def new(
251
+ cls,
252
+ identifier_type: Literal[IdentifierType.UUID],
253
+ identifier_value: UUID,
254
+ data: UpdateDataT,
255
+ expand: OptListOfExpandableFields = None,
256
+ ) -> "UpdateParameter": ...
257
+ @overload
258
+ @classmethod
259
+ def new(
260
+ cls,
261
+ identifier_type: IdentifierType,
262
+ identifier_value: IdentifierValueType,
263
+ data: UpdateDataT,
264
+ expand: OptListOfExpandableFields = None,
265
+ ) -> "UpdateParameter": ...
266
+ @classmethod
267
+ def new(
268
+ cls,
269
+ identifier_type: IdentifierType,
270
+ identifier_value: IdentifierValueType,
271
+ data: UpdateDataT,
272
+ expand: OptListOfExpandableFields = None,
273
+ ) -> "UpdateParameter":
274
+ return cls(
275
+ identifier=PatientIdentifier(type=identifier_type, value=identifier_value),
276
+ data=data,
277
+ expand=expand,
278
+ )
279
+
280
+
281
+ class StatusUpdateParameter(
282
+ Expand,
283
+ BaseStatusUpdateParameter[PatientIdentifier],
284
+ ):
285
+ @overload
286
+ @classmethod
287
+ def new(
288
+ cls,
289
+ identifier_type: Literal[IdentifierType.ID],
290
+ identifier_value: int,
291
+ type: ResourceOperationStatusUpdateType,
292
+ expand: OptListOfExpandableFields = None,
293
+ ) -> "StatusUpdateParameter": ...
294
+ @overload
295
+ @classmethod
296
+ def new(
297
+ cls,
298
+ identifier_type: Literal[IdentifierType.UUID],
299
+ identifier_value: UUID,
300
+ type: ResourceOperationStatusUpdateType,
301
+ expand: OptListOfExpandableFields = None,
302
+ ) -> "StatusUpdateParameter": ...
303
+ @overload
304
+ @classmethod
305
+ def new(
306
+ cls,
307
+ identifier_type: IdentifierType,
308
+ identifier_value: IdentifierValueType,
309
+ type: ResourceOperationStatusUpdateType,
310
+ expand: OptListOfExpandableFields = None,
311
+ ) -> "StatusUpdateParameter": ...
312
+ @classmethod
313
+ def new(
314
+ cls,
315
+ identifier_type: IdentifierType,
316
+ identifier_value: IdentifierValueType,
317
+ type: ResourceOperationStatusUpdateType,
318
+ expand: OptListOfExpandableFields = None,
319
+ ) -> "StatusUpdateParameter":
320
+ return cls(
321
+ identifier=PatientIdentifier(type=identifier_type, value=identifier_value),
322
+ type=type,
323
+ expand=expand,
324
+ )
325
+
326
+
327
+ class DeleteSingleParameter(BaseDeleteSingleParameter[PatientIdentifier]):
328
+ @overload
329
+ @classmethod
330
+ def new(
331
+ cls, identifier_type: Literal[IdentifierType.ID], identifier_value: int
332
+ ) -> "DeleteSingleParameter": ...
333
+ @overload
334
+ @classmethod
335
+ def new(
336
+ cls, identifier_type: Literal[IdentifierType.UUID], identifier_value: UUID
337
+ ) -> "DeleteSingleParameter": ...
338
+ @overload
339
+ @classmethod
340
+ def new(
341
+ cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
342
+ ) -> "DeleteSingleParameter": ...
343
+ @classmethod
344
+ def new(
345
+ cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
346
+ ) -> "DeleteSingleParameter":
347
+ return cls(
348
+ identifier=PatientIdentifier(type=identifier_type, value=identifier_value)
349
+ )
@@ -0,0 +1,318 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Annotated, Generic, Literal, TypeVar, overload
3
+ from uuid import UUID
4
+ from maleo.enums.status import (
5
+ ListOfDataStatuses,
6
+ FULL_DATA_STATUSES,
7
+ )
8
+ from maleo.enums.user import (
9
+ UserType,
10
+ OptUserType,
11
+ FullUserTypeMixin,
12
+ OptListOfUserTypes,
13
+ FullUserTypesMixin,
14
+ )
15
+ from maleo.schemas.mixins.filter import convert as convert_filter
16
+ from maleo.schemas.mixins.identity import (
17
+ IdentifierMixin,
18
+ Ids,
19
+ UUIDs,
20
+ IntOrganizationIds,
21
+ )
22
+ from maleo.schemas.mixins.sort import convert as convert_sort
23
+ from maleo.schemas.operation.enums import ResourceOperationStatusUpdateType
24
+ from maleo.schemas.parameter import (
25
+ ReadSingleParameter as BaseReadSingleParameter,
26
+ ReadPaginatedMultipleParameter,
27
+ StatusUpdateParameter as BaseStatusUpdateParameter,
28
+ DeleteSingleParameter as BaseDeleteSingleParameter,
29
+ )
30
+ from maleo.types.dict import StrToAnyDict
31
+ from maleo.types.integer import OptListOfInts
32
+ from maleo.types.string import OptStr, OptListOfStrs
33
+ from maleo.types.uuid import OptListOfUUIDs
34
+ from ..enums.user import IdentifierType
35
+ from ..mixins.user import (
36
+ Username,
37
+ Usernames,
38
+ Email,
39
+ Emails,
40
+ Phone,
41
+ Phones,
42
+ UserIdentifier,
43
+ )
44
+ from ..types.user import IdentifierValueType
45
+
46
+
47
+ class CreateParameter(
48
+ Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
49
+ ):
50
+ pass
51
+
52
+
53
+ class ReadMultipleParameter(
54
+ ReadPaginatedMultipleParameter,
55
+ Phones[OptListOfStrs],
56
+ Emails[OptListOfStrs],
57
+ Usernames[OptListOfStrs],
58
+ FullUserTypesMixin[OptListOfUserTypes],
59
+ UUIDs[OptListOfUUIDs],
60
+ Ids[OptListOfInts],
61
+ IntOrganizationIds[OptListOfInts],
62
+ ):
63
+ organization_ids: Annotated[
64
+ OptListOfInts, Field(None, description="Organization's IDs")
65
+ ] = None
66
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
67
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
68
+ user_types: Annotated[OptListOfUserTypes, Field(None, description="User Types")] = (
69
+ None
70
+ )
71
+ usernames: Annotated[OptListOfStrs, Field(None, description="User's Usernames")] = (
72
+ None
73
+ )
74
+ emails: Annotated[OptListOfStrs, Field(None, description="User's Emails")] = None
75
+ phones: Annotated[OptListOfStrs, Field(None, description="User's Phones")] = None
76
+
77
+ @property
78
+ def _query_param_fields(self) -> set[str]:
79
+ return {
80
+ "organization_ids",
81
+ "ids",
82
+ "uuids",
83
+ "statuses",
84
+ "user_types",
85
+ "usernames",
86
+ "emails",
87
+ "phones",
88
+ "search",
89
+ "page",
90
+ "limit",
91
+ "use_cache",
92
+ }
93
+
94
+ def to_query_params(self) -> StrToAnyDict:
95
+ params = self.model_dump(
96
+ mode="json", include=self._query_param_fields, exclude_none=True
97
+ )
98
+ params["filters"] = convert_filter(self.date_filters)
99
+ params["sorts"] = convert_sort(self.sort_columns)
100
+ params = {k: v for k, v in params.items()}
101
+ return params
102
+
103
+
104
+ class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
105
+ @classmethod
106
+ def from_identifier(
107
+ cls,
108
+ identifier: UserIdentifier,
109
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
110
+ use_cache: bool = True,
111
+ ) -> "ReadSingleParameter":
112
+ return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
113
+
114
+ @overload
115
+ @classmethod
116
+ def new(
117
+ cls,
118
+ identifier_type: Literal[IdentifierType.ID],
119
+ identifier_value: int,
120
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
121
+ use_cache: bool = True,
122
+ ) -> "ReadSingleParameter": ...
123
+ @overload
124
+ @classmethod
125
+ def new(
126
+ cls,
127
+ identifier_type: Literal[IdentifierType.UUID],
128
+ identifier_value: UUID,
129
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
130
+ use_cache: bool = True,
131
+ ) -> "ReadSingleParameter": ...
132
+ @overload
133
+ @classmethod
134
+ def new(
135
+ cls,
136
+ identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
137
+ identifier_value: str,
138
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
139
+ use_cache: bool = True,
140
+ ) -> "ReadSingleParameter": ...
141
+ @classmethod
142
+ def new(
143
+ cls,
144
+ identifier_type: IdentifierType,
145
+ identifier_value: IdentifierValueType,
146
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
147
+ use_cache: bool = True,
148
+ ) -> "ReadSingleParameter":
149
+ return cls(
150
+ identifier=UserIdentifier(
151
+ type=identifier_type,
152
+ value=identifier_value,
153
+ ),
154
+ statuses=statuses,
155
+ use_cache=use_cache,
156
+ )
157
+
158
+ def to_query_params(self) -> StrToAnyDict:
159
+ return self.model_dump(
160
+ mode="json", include={"statuses", "use_cache"}, exclude_none=True
161
+ )
162
+
163
+
164
+ class PasswordUpdateData(BaseModel):
165
+ old: Annotated[str, Field(..., description="Old Password", max_length=255)]
166
+ old_confirmation: Annotated[
167
+ str, Field(..., description="Old Password Confirmation", max_length=255)
168
+ ]
169
+ new: Annotated[str, Field(..., description="New Password", max_length=255)]
170
+
171
+
172
+ class FullUpdateData(
173
+ Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
174
+ ):
175
+ pass
176
+
177
+
178
+ class PartialUpdateData(
179
+ Phone[OptStr], Email[OptStr], Username[OptStr], FullUserTypeMixin[OptUserType]
180
+ ):
181
+ pass
182
+
183
+
184
+ UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
185
+
186
+
187
+ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
188
+ data: UpdateDataT = Field(..., description="Update data")
189
+
190
+
191
+ class UpdateParameter(
192
+ UpdateDataMixin[UpdateDataT],
193
+ IdentifierMixin[UserIdentifier],
194
+ Generic[UpdateDataT],
195
+ ):
196
+ @overload
197
+ @classmethod
198
+ def new(
199
+ cls,
200
+ identifier_type: Literal[IdentifierType.ID],
201
+ identifier_value: int,
202
+ data: UpdateDataT,
203
+ ) -> "UpdateParameter": ...
204
+ @overload
205
+ @classmethod
206
+ def new(
207
+ cls,
208
+ identifier_type: Literal[IdentifierType.UUID],
209
+ identifier_value: UUID,
210
+ data: UpdateDataT,
211
+ ) -> "UpdateParameter": ...
212
+ @overload
213
+ @classmethod
214
+ def new(
215
+ cls,
216
+ identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
217
+ identifier_value: str,
218
+ data: UpdateDataT,
219
+ ) -> "UpdateParameter": ...
220
+ @overload
221
+ @classmethod
222
+ def new(
223
+ cls,
224
+ identifier_type: IdentifierType,
225
+ identifier_value: IdentifierValueType,
226
+ data: UpdateDataT,
227
+ ) -> "UpdateParameter": ...
228
+ @classmethod
229
+ def new(
230
+ cls,
231
+ identifier_type: IdentifierType,
232
+ identifier_value: IdentifierValueType,
233
+ data: UpdateDataT,
234
+ ) -> "UpdateParameter":
235
+ return cls(
236
+ identifier=UserIdentifier(type=identifier_type, value=identifier_value),
237
+ data=data,
238
+ )
239
+
240
+
241
+ class StatusUpdateParameter(
242
+ BaseStatusUpdateParameter[UserIdentifier],
243
+ ):
244
+ @overload
245
+ @classmethod
246
+ def new(
247
+ cls,
248
+ identifier_type: Literal[IdentifierType.ID],
249
+ identifier_value: int,
250
+ type: ResourceOperationStatusUpdateType,
251
+ ) -> "StatusUpdateParameter": ...
252
+ @overload
253
+ @classmethod
254
+ def new(
255
+ cls,
256
+ identifier_type: Literal[IdentifierType.UUID],
257
+ identifier_value: UUID,
258
+ type: ResourceOperationStatusUpdateType,
259
+ ) -> "StatusUpdateParameter": ...
260
+ @overload
261
+ @classmethod
262
+ def new(
263
+ cls,
264
+ identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
265
+ identifier_value: str,
266
+ type: ResourceOperationStatusUpdateType,
267
+ ) -> "StatusUpdateParameter": ...
268
+ @overload
269
+ @classmethod
270
+ def new(
271
+ cls,
272
+ identifier_type: IdentifierType,
273
+ identifier_value: IdentifierValueType,
274
+ type: ResourceOperationStatusUpdateType,
275
+ ) -> "StatusUpdateParameter": ...
276
+ @classmethod
277
+ def new(
278
+ cls,
279
+ identifier_type: IdentifierType,
280
+ identifier_value: IdentifierValueType,
281
+ type: ResourceOperationStatusUpdateType,
282
+ ) -> "StatusUpdateParameter":
283
+ return cls(
284
+ identifier=UserIdentifier(type=identifier_type, value=identifier_value),
285
+ type=type,
286
+ )
287
+
288
+
289
+ class DeleteSingleParameter(BaseDeleteSingleParameter[UserIdentifier]):
290
+ @overload
291
+ @classmethod
292
+ def new(
293
+ cls, identifier_type: Literal[IdentifierType.ID], identifier_value: int
294
+ ) -> "DeleteSingleParameter": ...
295
+ @overload
296
+ @classmethod
297
+ def new(
298
+ cls, identifier_type: Literal[IdentifierType.UUID], identifier_value: UUID
299
+ ) -> "DeleteSingleParameter": ...
300
+ @overload
301
+ @classmethod
302
+ def new(
303
+ cls,
304
+ identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
305
+ identifier_value: str,
306
+ ) -> "DeleteSingleParameter": ...
307
+ @overload
308
+ @classmethod
309
+ def new(
310
+ cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
311
+ ) -> "DeleteSingleParameter": ...
312
+ @classmethod
313
+ def new(
314
+ cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
315
+ ) -> "DeleteSingleParameter":
316
+ return cls(
317
+ identifier=UserIdentifier(type=identifier_type, value=identifier_value)
318
+ )