maleo-identity 0.1.27__py3-none-any.whl → 0.1.59__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.
- maleo/identity/constants/api_key.py +1 -1
- maleo/identity/constants/organization.py +1 -1
- maleo/identity/constants/organization_registration_code.py +1 -1
- maleo/identity/constants/organization_relation.py +1 -1
- maleo/identity/constants/patient.py +1 -1
- maleo/identity/constants/user.py +1 -1
- maleo/identity/constants/user_medical_role.py +1 -1
- maleo/identity/constants/user_organization.py +13 -0
- maleo/identity/constants/user_organization_role.py +1 -1
- maleo/identity/constants/user_profile.py +16 -1
- maleo/identity/constants/user_system_role.py +2 -2
- maleo/identity/enums/api_key.py +1 -1
- maleo/identity/enums/organization.py +14 -10
- maleo/identity/enums/organization_registration_code.py +1 -1
- maleo/identity/enums/organization_relation.py +14 -1
- maleo/identity/enums/patient.py +1 -1
- maleo/identity/enums/user.py +16 -1
- maleo/identity/enums/user_medical_role.py +14 -1
- maleo/identity/enums/user_organization.py +40 -0
- maleo/identity/enums/user_organization_role.py +14 -1
- maleo/identity/enums/user_profile.py +1 -1
- maleo/identity/enums/user_system_role.py +1 -1
- maleo/identity/mixins/api_key.py +19 -3
- maleo/identity/mixins/common.py +2 -2
- maleo/identity/mixins/organization.py +10 -4
- maleo/identity/mixins/organization_registration_code.py +4 -4
- maleo/identity/mixins/organization_relation.py +12 -6
- maleo/identity/mixins/patient.py +2 -2
- maleo/identity/mixins/user.py +9 -3
- maleo/identity/mixins/user_medical_role.py +11 -5
- maleo/identity/mixins/user_organization.py +76 -0
- maleo/identity/mixins/user_organization_role.py +11 -5
- maleo/identity/mixins/user_profile.py +3 -5
- maleo/identity/mixins/user_system_role.py +3 -3
- maleo/identity/schemas/api_key.py +22 -8
- maleo/identity/schemas/common.py +33 -77
- maleo/identity/schemas/organization.py +59 -25
- maleo/identity/schemas/organization_registration_code.py +11 -11
- maleo/identity/schemas/organization_relation.py +81 -21
- maleo/identity/schemas/patient.py +12 -12
- maleo/identity/schemas/user.py +104 -22
- maleo/identity/schemas/user_medical_role.py +66 -16
- maleo/identity/schemas/user_organization.py +334 -0
- maleo/identity/schemas/user_organization_role.py +68 -16
- maleo/identity/schemas/user_profile.py +15 -26
- maleo/identity/schemas/user_system_role.py +10 -10
- maleo/identity/types/api_key.py +3 -2
- maleo/identity/types/organization.py +1 -1
- maleo/identity/types/organization_registration_code.py +1 -1
- maleo/identity/types/organization_relation.py +3 -3
- maleo/identity/types/user.py +1 -1
- maleo/identity/types/user_medical_role.py +3 -2
- maleo/identity/types/user_organization.py +7 -0
- maleo/identity/types/user_organization_role.py +3 -2
- maleo/identity/types/user_profile.py +1 -1
- maleo/identity/types/user_system_role.py +1 -1
- {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/METADATA +10 -9
- maleo_identity-0.1.59.dist-info/RECORD +68 -0
- maleo/identity/utils/__init__.py +0 -0
- maleo/identity/utils/organization.py +0 -32
- maleo/identity/utils/user.py +0 -32
- maleo_identity-0.1.27.dist-info/RECORD +0 -66
- {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/WHEEL +0 -0
- {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/licenses/LICENSE +0 -0
- {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/top_level.txt +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
4
|
+
from nexo.enums.organization import (
|
|
5
5
|
OrganizationRelation,
|
|
6
6
|
SimpleOrganizationRelationMixin,
|
|
7
7
|
OptListOfOrganizationRelations,
|
|
8
8
|
SimpleOrganizationRelationsMixin,
|
|
9
9
|
)
|
|
10
|
-
from
|
|
10
|
+
from nexo.enums.status import (
|
|
11
11
|
ListOfDataStatuses,
|
|
12
12
|
FULL_DATA_STATUSES,
|
|
13
13
|
)
|
|
14
|
-
from
|
|
15
|
-
from
|
|
14
|
+
from nexo.schemas.mixins.filter import convert as convert_filter
|
|
15
|
+
from nexo.schemas.mixins.identity import (
|
|
16
16
|
IdentifierMixin,
|
|
17
17
|
Ids,
|
|
18
18
|
UUIDs,
|
|
@@ -21,41 +21,69 @@ from maleo.schemas.mixins.identity import (
|
|
|
21
21
|
IntTargetId,
|
|
22
22
|
IntTargetIds,
|
|
23
23
|
)
|
|
24
|
-
from
|
|
25
|
-
from
|
|
26
|
-
from
|
|
24
|
+
from nexo.schemas.mixins.sort import convert as convert_sort
|
|
25
|
+
from nexo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
26
|
+
from nexo.schemas.parameter import (
|
|
27
27
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
28
28
|
ReadPaginatedMultipleParameter,
|
|
29
29
|
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
30
30
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
31
31
|
)
|
|
32
|
-
from
|
|
33
|
-
from
|
|
34
|
-
from
|
|
35
|
-
from
|
|
36
|
-
from ..enums.organization_relation import IdentifierType
|
|
32
|
+
from nexo.types.boolean import OptBool
|
|
33
|
+
from nexo.types.dict import StrToAnyDict
|
|
34
|
+
from nexo.types.integer import OptListOfInts
|
|
35
|
+
from nexo.types.uuid import OptListOfUUIDs
|
|
36
|
+
from ..enums.organization_relation import IdentifierType, OptListOfExpandableFields
|
|
37
37
|
from ..mixins.organization_relation import (
|
|
38
38
|
IsBidirectional,
|
|
39
39
|
Meta,
|
|
40
40
|
OrganizationRelationIdentifier,
|
|
41
|
+
Expand,
|
|
41
42
|
)
|
|
42
43
|
from ..types.organization_relation import CompositeIdentifierType, IdentifierValueType
|
|
43
44
|
|
|
44
45
|
|
|
45
|
-
class
|
|
46
|
+
class BareCreateData(
|
|
46
47
|
Meta,
|
|
47
48
|
IsBidirectional[bool],
|
|
48
|
-
SimpleOrganizationRelationMixin[OrganizationRelation],
|
|
49
|
-
IntTargetId[int],
|
|
50
|
-
IntSourceId[int],
|
|
51
49
|
):
|
|
52
50
|
is_bidirectional: Annotated[bool, Field(False, description="Is Bidirectional")] = (
|
|
53
51
|
False
|
|
54
52
|
)
|
|
55
53
|
|
|
56
54
|
|
|
55
|
+
class BaseCreateData(
|
|
56
|
+
BareCreateData,
|
|
57
|
+
SimpleOrganizationRelationMixin[OrganizationRelation],
|
|
58
|
+
):
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class SimpleCreateData(
|
|
63
|
+
BaseCreateData,
|
|
64
|
+
IntTargetId[int],
|
|
65
|
+
):
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class FullCreateData(
|
|
70
|
+
SimpleCreateData,
|
|
71
|
+
IntSourceId[int],
|
|
72
|
+
):
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class CreateParameter(
|
|
77
|
+
Expand,
|
|
78
|
+
FullCreateData,
|
|
79
|
+
):
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
|
|
57
83
|
class ReadMultipleParameter(
|
|
84
|
+
Expand,
|
|
58
85
|
ReadPaginatedMultipleParameter,
|
|
86
|
+
IsBidirectional[OptBool],
|
|
59
87
|
SimpleOrganizationRelationsMixin[OptListOfOrganizationRelations],
|
|
60
88
|
IntTargetIds[OptListOfInts],
|
|
61
89
|
IntSourceIds[OptListOfInts],
|
|
@@ -70,6 +98,9 @@ class ReadMultipleParameter(
|
|
|
70
98
|
OptListOfOrganizationRelations,
|
|
71
99
|
Field(None, description="Organization Relations"),
|
|
72
100
|
] = None
|
|
101
|
+
is_bidirectional: Annotated[
|
|
102
|
+
OptBool, Field(None, description="Whether is bidirectional")
|
|
103
|
+
] = None
|
|
73
104
|
|
|
74
105
|
@property
|
|
75
106
|
def _query_param_fields(self) -> set[str]:
|
|
@@ -79,11 +110,13 @@ class ReadMultipleParameter(
|
|
|
79
110
|
"statuses",
|
|
80
111
|
"source_ids",
|
|
81
112
|
"target_ids",
|
|
113
|
+
"is_bidirectional",
|
|
82
114
|
"relations",
|
|
83
115
|
"search",
|
|
84
116
|
"page",
|
|
85
117
|
"limit",
|
|
86
118
|
"use_cache",
|
|
119
|
+
"expand",
|
|
87
120
|
}
|
|
88
121
|
|
|
89
122
|
def to_query_params(self) -> StrToAnyDict:
|
|
@@ -96,15 +129,20 @@ class ReadMultipleParameter(
|
|
|
96
129
|
return params
|
|
97
130
|
|
|
98
131
|
|
|
99
|
-
class ReadSingleParameter(
|
|
132
|
+
class ReadSingleParameter(
|
|
133
|
+
Expand, BaseReadSingleParameter[OrganizationRelationIdentifier]
|
|
134
|
+
):
|
|
100
135
|
@classmethod
|
|
101
136
|
def from_identifier(
|
|
102
137
|
cls,
|
|
103
138
|
identifier: OrganizationRelationIdentifier,
|
|
104
139
|
statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
|
|
105
140
|
use_cache: bool = True,
|
|
141
|
+
expand: OptListOfExpandableFields = None,
|
|
106
142
|
) -> "ReadSingleParameter":
|
|
107
|
-
return cls(
|
|
143
|
+
return cls(
|
|
144
|
+
identifier=identifier, statuses=statuses, use_cache=use_cache, expand=expand
|
|
145
|
+
)
|
|
108
146
|
|
|
109
147
|
@overload
|
|
110
148
|
@classmethod
|
|
@@ -114,6 +152,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
|
|
|
114
152
|
identifier_value: int,
|
|
115
153
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
116
154
|
use_cache: bool = True,
|
|
155
|
+
expand: OptListOfExpandableFields = None,
|
|
117
156
|
) -> "ReadSingleParameter": ...
|
|
118
157
|
@overload
|
|
119
158
|
@classmethod
|
|
@@ -123,6 +162,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
|
|
|
123
162
|
identifier_value: UUID,
|
|
124
163
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
125
164
|
use_cache: bool = True,
|
|
165
|
+
expand: OptListOfExpandableFields = None,
|
|
126
166
|
) -> "ReadSingleParameter": ...
|
|
127
167
|
@overload
|
|
128
168
|
@classmethod
|
|
@@ -132,6 +172,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
|
|
|
132
172
|
identifier_value: CompositeIdentifierType,
|
|
133
173
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
134
174
|
use_cache: bool = True,
|
|
175
|
+
expand: OptListOfExpandableFields = None,
|
|
135
176
|
) -> "ReadSingleParameter": ...
|
|
136
177
|
@overload
|
|
137
178
|
@classmethod
|
|
@@ -141,6 +182,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
|
|
|
141
182
|
identifier_value: IdentifierValueType,
|
|
142
183
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
143
184
|
use_cache: bool = True,
|
|
185
|
+
expand: OptListOfExpandableFields = None,
|
|
144
186
|
) -> "ReadSingleParameter": ...
|
|
145
187
|
@classmethod
|
|
146
188
|
def new(
|
|
@@ -149,6 +191,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
|
|
|
149
191
|
identifier_value: IdentifierValueType,
|
|
150
192
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
151
193
|
use_cache: bool = True,
|
|
194
|
+
expand: OptListOfExpandableFields = None,
|
|
152
195
|
) -> "ReadSingleParameter":
|
|
153
196
|
return cls(
|
|
154
197
|
identifier=OrganizationRelationIdentifier(
|
|
@@ -156,20 +199,23 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
|
|
|
156
199
|
),
|
|
157
200
|
statuses=statuses,
|
|
158
201
|
use_cache=use_cache,
|
|
202
|
+
expand=expand,
|
|
159
203
|
)
|
|
160
204
|
|
|
161
205
|
def to_query_params(self) -> StrToAnyDict:
|
|
162
206
|
return self.model_dump(
|
|
163
|
-
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
207
|
+
mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
|
|
164
208
|
)
|
|
165
209
|
|
|
166
210
|
|
|
167
211
|
class FullUpdateData(Meta, IsBidirectional[bool]):
|
|
168
|
-
|
|
212
|
+
is_bidirectional: Annotated[bool, Field(..., description="Is Bidirectional")]
|
|
169
213
|
|
|
170
214
|
|
|
171
215
|
class PartialUpdateData(Meta, IsBidirectional[OptBool]):
|
|
172
|
-
|
|
216
|
+
is_bidirectional: Annotated[
|
|
217
|
+
OptBool, Field(None, description="Is Bidirectional")
|
|
218
|
+
] = None
|
|
173
219
|
|
|
174
220
|
|
|
175
221
|
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
@@ -180,6 +226,7 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
|
180
226
|
|
|
181
227
|
|
|
182
228
|
class UpdateParameter(
|
|
229
|
+
Expand,
|
|
183
230
|
UpdateDataMixin[UpdateDataT],
|
|
184
231
|
IdentifierMixin[OrganizationRelationIdentifier],
|
|
185
232
|
Generic[UpdateDataT],
|
|
@@ -191,6 +238,7 @@ class UpdateParameter(
|
|
|
191
238
|
identifier_type: Literal[IdentifierType.ID],
|
|
192
239
|
identifier_value: int,
|
|
193
240
|
data: UpdateDataT,
|
|
241
|
+
expand: OptListOfExpandableFields = None,
|
|
194
242
|
) -> "UpdateParameter": ...
|
|
195
243
|
@overload
|
|
196
244
|
@classmethod
|
|
@@ -199,6 +247,7 @@ class UpdateParameter(
|
|
|
199
247
|
identifier_type: Literal[IdentifierType.UUID],
|
|
200
248
|
identifier_value: UUID,
|
|
201
249
|
data: UpdateDataT,
|
|
250
|
+
expand: OptListOfExpandableFields = None,
|
|
202
251
|
) -> "UpdateParameter": ...
|
|
203
252
|
@overload
|
|
204
253
|
@classmethod
|
|
@@ -207,6 +256,7 @@ class UpdateParameter(
|
|
|
207
256
|
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
208
257
|
identifier_value: CompositeIdentifierType,
|
|
209
258
|
data: UpdateDataT,
|
|
259
|
+
expand: OptListOfExpandableFields = None,
|
|
210
260
|
) -> "UpdateParameter": ...
|
|
211
261
|
@overload
|
|
212
262
|
@classmethod
|
|
@@ -215,6 +265,7 @@ class UpdateParameter(
|
|
|
215
265
|
identifier_type: IdentifierType,
|
|
216
266
|
identifier_value: IdentifierValueType,
|
|
217
267
|
data: UpdateDataT,
|
|
268
|
+
expand: OptListOfExpandableFields = None,
|
|
218
269
|
) -> "UpdateParameter": ...
|
|
219
270
|
@classmethod
|
|
220
271
|
def new(
|
|
@@ -222,16 +273,19 @@ class UpdateParameter(
|
|
|
222
273
|
identifier_type: IdentifierType,
|
|
223
274
|
identifier_value: IdentifierValueType,
|
|
224
275
|
data: UpdateDataT,
|
|
276
|
+
expand: OptListOfExpandableFields = None,
|
|
225
277
|
) -> "UpdateParameter":
|
|
226
278
|
return cls(
|
|
227
279
|
identifier=OrganizationRelationIdentifier(
|
|
228
280
|
type=identifier_type, value=identifier_value
|
|
229
281
|
),
|
|
230
282
|
data=data,
|
|
283
|
+
expand=expand,
|
|
231
284
|
)
|
|
232
285
|
|
|
233
286
|
|
|
234
287
|
class StatusUpdateParameter(
|
|
288
|
+
Expand,
|
|
235
289
|
BaseStatusUpdateParameter[OrganizationRelationIdentifier],
|
|
236
290
|
):
|
|
237
291
|
@overload
|
|
@@ -241,6 +295,7 @@ class StatusUpdateParameter(
|
|
|
241
295
|
identifier_type: Literal[IdentifierType.ID],
|
|
242
296
|
identifier_value: int,
|
|
243
297
|
type: ResourceOperationStatusUpdateType,
|
|
298
|
+
expand: OptListOfExpandableFields = None,
|
|
244
299
|
) -> "StatusUpdateParameter": ...
|
|
245
300
|
@overload
|
|
246
301
|
@classmethod
|
|
@@ -249,6 +304,7 @@ class StatusUpdateParameter(
|
|
|
249
304
|
identifier_type: Literal[IdentifierType.UUID],
|
|
250
305
|
identifier_value: UUID,
|
|
251
306
|
type: ResourceOperationStatusUpdateType,
|
|
307
|
+
expand: OptListOfExpandableFields = None,
|
|
252
308
|
) -> "StatusUpdateParameter": ...
|
|
253
309
|
@overload
|
|
254
310
|
@classmethod
|
|
@@ -257,6 +313,7 @@ class StatusUpdateParameter(
|
|
|
257
313
|
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
258
314
|
identifier_value: CompositeIdentifierType,
|
|
259
315
|
type: ResourceOperationStatusUpdateType,
|
|
316
|
+
expand: OptListOfExpandableFields = None,
|
|
260
317
|
) -> "StatusUpdateParameter": ...
|
|
261
318
|
@overload
|
|
262
319
|
@classmethod
|
|
@@ -265,6 +322,7 @@ class StatusUpdateParameter(
|
|
|
265
322
|
identifier_type: IdentifierType,
|
|
266
323
|
identifier_value: IdentifierValueType,
|
|
267
324
|
type: ResourceOperationStatusUpdateType,
|
|
325
|
+
expand: OptListOfExpandableFields = None,
|
|
268
326
|
) -> "StatusUpdateParameter": ...
|
|
269
327
|
@classmethod
|
|
270
328
|
def new(
|
|
@@ -272,12 +330,14 @@ class StatusUpdateParameter(
|
|
|
272
330
|
identifier_type: IdentifierType,
|
|
273
331
|
identifier_value: IdentifierValueType,
|
|
274
332
|
type: ResourceOperationStatusUpdateType,
|
|
333
|
+
expand: OptListOfExpandableFields = None,
|
|
275
334
|
) -> "StatusUpdateParameter":
|
|
276
335
|
return cls(
|
|
277
336
|
identifier=OrganizationRelationIdentifier(
|
|
278
337
|
type=identifier_type, value=identifier_value
|
|
279
338
|
),
|
|
280
339
|
type=type,
|
|
340
|
+
expand=expand,
|
|
281
341
|
)
|
|
282
342
|
|
|
283
343
|
|
|
@@ -2,7 +2,7 @@ from datetime import date
|
|
|
2
2
|
from pydantic import BaseModel, Field
|
|
3
3
|
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
4
4
|
from uuid import UUID
|
|
5
|
-
from
|
|
5
|
+
from nexo.enums.identity import (
|
|
6
6
|
OptBloodType,
|
|
7
7
|
BloodTypeMixin,
|
|
8
8
|
OptListOfBloodTypes,
|
|
@@ -17,12 +17,12 @@ from maleo.enums.identity import (
|
|
|
17
17
|
OptListOfGenders,
|
|
18
18
|
GendersMixin,
|
|
19
19
|
)
|
|
20
|
-
from
|
|
20
|
+
from nexo.enums.status import (
|
|
21
21
|
ListOfDataStatuses,
|
|
22
22
|
FULL_DATA_STATUSES,
|
|
23
23
|
)
|
|
24
|
-
from
|
|
25
|
-
from
|
|
24
|
+
from nexo.schemas.mixins.filter import convert as convert_filter
|
|
25
|
+
from nexo.schemas.mixins.identity import (
|
|
26
26
|
IdentifierMixin,
|
|
27
27
|
Ids,
|
|
28
28
|
UUIDs,
|
|
@@ -33,19 +33,19 @@ from maleo.schemas.mixins.identity import (
|
|
|
33
33
|
IntOrganizationId,
|
|
34
34
|
IntOrganizationIds,
|
|
35
35
|
)
|
|
36
|
-
from
|
|
37
|
-
from
|
|
38
|
-
from
|
|
36
|
+
from nexo.schemas.mixins.sort import convert as convert_sort
|
|
37
|
+
from nexo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
38
|
+
from nexo.schemas.parameter import (
|
|
39
39
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
40
40
|
ReadPaginatedMultipleParameter,
|
|
41
41
|
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
42
42
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
43
43
|
)
|
|
44
|
-
from
|
|
45
|
-
from
|
|
46
|
-
from
|
|
47
|
-
from
|
|
48
|
-
from
|
|
44
|
+
from nexo.types.datetime import OptDate
|
|
45
|
+
from nexo.types.dict import StrToAnyDict
|
|
46
|
+
from nexo.types.integer import OptListOfInts
|
|
47
|
+
from nexo.types.string import OptStr, OptListOfStrs
|
|
48
|
+
from nexo.types.uuid import OptListOfUUIDs
|
|
49
49
|
from ..enums.patient import IdentifierType, OptListOfExpandableFields
|
|
50
50
|
from ..mixins.common import IdCard, FullName, PlaceOfBirth
|
|
51
51
|
from ..mixins.patient import PatientIdentity, PatientIdentifier, Expand
|
maleo/identity/schemas/user.py
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
from pydantic import BaseModel, Field
|
|
2
|
-
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
1
|
+
from pydantic import BaseModel, Field, model_validator
|
|
2
|
+
from typing import Annotated, Generic, Literal, Self, TypeVar, overload
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
4
|
+
from nexo.enums.status import (
|
|
5
5
|
ListOfDataStatuses,
|
|
6
6
|
FULL_DATA_STATUSES,
|
|
7
7
|
)
|
|
8
|
-
from
|
|
8
|
+
from nexo.enums.user import (
|
|
9
9
|
UserType,
|
|
10
10
|
OptUserType,
|
|
11
11
|
FullUserTypeMixin,
|
|
12
12
|
OptListOfUserTypes,
|
|
13
13
|
FullUserTypesMixin,
|
|
14
14
|
)
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from nexo.schemas.error.enums import ErrorCode
|
|
16
|
+
from nexo.schemas.mixins.filter import convert as convert_filter
|
|
17
|
+
from nexo.schemas.mixins.identity import (
|
|
17
18
|
IdentifierMixin,
|
|
18
19
|
Ids,
|
|
19
20
|
UUIDs,
|
|
20
21
|
IntOrganizationIds,
|
|
21
22
|
)
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
23
|
+
from nexo.schemas.mixins.parameter import IncludeURL
|
|
24
|
+
from nexo.schemas.mixins.sort import convert as convert_sort
|
|
25
|
+
from nexo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
26
|
+
from nexo.schemas.parameter import (
|
|
25
27
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
26
28
|
ReadPaginatedMultipleParameter,
|
|
27
29
|
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
28
30
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
29
31
|
)
|
|
30
|
-
from
|
|
31
|
-
from
|
|
32
|
-
from
|
|
33
|
-
from
|
|
34
|
-
from ..enums.user import IdentifierType
|
|
32
|
+
from nexo.types.dict import StrToAnyDict
|
|
33
|
+
from nexo.types.integer import OptListOfInts
|
|
34
|
+
from nexo.types.string import OptStr, OptListOfStrs
|
|
35
|
+
from nexo.types.uuid import OptListOfUUIDs
|
|
36
|
+
from ..enums.user import IdentifierType, OptListOfExpandableFields
|
|
35
37
|
from ..mixins.user import (
|
|
36
38
|
Username,
|
|
37
39
|
Usernames,
|
|
@@ -39,18 +41,26 @@ from ..mixins.user import (
|
|
|
39
41
|
Emails,
|
|
40
42
|
Phone,
|
|
41
43
|
Phones,
|
|
44
|
+
Password,
|
|
45
|
+
Expand,
|
|
42
46
|
UserIdentifier,
|
|
43
47
|
)
|
|
44
48
|
from ..types.user import IdentifierValueType
|
|
45
49
|
|
|
46
50
|
|
|
47
|
-
class
|
|
48
|
-
Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
|
|
51
|
+
class CreateData(
|
|
52
|
+
Password, Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
|
|
49
53
|
):
|
|
50
54
|
pass
|
|
51
55
|
|
|
52
56
|
|
|
57
|
+
class CreateParameter(Expand, CreateData):
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
|
|
53
61
|
class ReadMultipleParameter(
|
|
62
|
+
IncludeURL,
|
|
63
|
+
Expand,
|
|
54
64
|
ReadPaginatedMultipleParameter,
|
|
55
65
|
Phones[OptListOfStrs],
|
|
56
66
|
Emails[OptListOfStrs],
|
|
@@ -89,6 +99,8 @@ class ReadMultipleParameter(
|
|
|
89
99
|
"page",
|
|
90
100
|
"limit",
|
|
91
101
|
"use_cache",
|
|
102
|
+
"expand",
|
|
103
|
+
"include_url",
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
def to_query_params(self) -> StrToAnyDict:
|
|
@@ -101,15 +113,23 @@ class ReadMultipleParameter(
|
|
|
101
113
|
return params
|
|
102
114
|
|
|
103
115
|
|
|
104
|
-
class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
|
|
116
|
+
class ReadSingleParameter(IncludeURL, Expand, BaseReadSingleParameter[UserIdentifier]):
|
|
105
117
|
@classmethod
|
|
106
118
|
def from_identifier(
|
|
107
119
|
cls,
|
|
108
120
|
identifier: UserIdentifier,
|
|
109
121
|
statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
|
|
110
122
|
use_cache: bool = True,
|
|
123
|
+
expand: OptListOfExpandableFields = None,
|
|
124
|
+
include_url: bool = False,
|
|
111
125
|
) -> "ReadSingleParameter":
|
|
112
|
-
return cls(
|
|
126
|
+
return cls(
|
|
127
|
+
identifier=identifier,
|
|
128
|
+
statuses=statuses,
|
|
129
|
+
use_cache=use_cache,
|
|
130
|
+
expand=expand,
|
|
131
|
+
include_url=include_url,
|
|
132
|
+
)
|
|
113
133
|
|
|
114
134
|
@overload
|
|
115
135
|
@classmethod
|
|
@@ -119,6 +139,8 @@ class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
|
|
|
119
139
|
identifier_value: int,
|
|
120
140
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
121
141
|
use_cache: bool = True,
|
|
142
|
+
expand: OptListOfExpandableFields = None,
|
|
143
|
+
include_url: bool = False,
|
|
122
144
|
) -> "ReadSingleParameter": ...
|
|
123
145
|
@overload
|
|
124
146
|
@classmethod
|
|
@@ -128,6 +150,8 @@ class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
|
|
|
128
150
|
identifier_value: UUID,
|
|
129
151
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
130
152
|
use_cache: bool = True,
|
|
153
|
+
expand: OptListOfExpandableFields = None,
|
|
154
|
+
include_url: bool = False,
|
|
131
155
|
) -> "ReadSingleParameter": ...
|
|
132
156
|
@overload
|
|
133
157
|
@classmethod
|
|
@@ -137,7 +161,10 @@ class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
|
|
|
137
161
|
identifier_value: str,
|
|
138
162
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
139
163
|
use_cache: bool = True,
|
|
164
|
+
expand: OptListOfExpandableFields = None,
|
|
165
|
+
include_url: bool = False,
|
|
140
166
|
) -> "ReadSingleParameter": ...
|
|
167
|
+
@overload
|
|
141
168
|
@classmethod
|
|
142
169
|
def new(
|
|
143
170
|
cls,
|
|
@@ -145,6 +172,18 @@ class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
|
|
|
145
172
|
identifier_value: IdentifierValueType,
|
|
146
173
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
147
174
|
use_cache: bool = True,
|
|
175
|
+
expand: OptListOfExpandableFields = None,
|
|
176
|
+
include_url: bool = False,
|
|
177
|
+
) -> "ReadSingleParameter": ...
|
|
178
|
+
@classmethod
|
|
179
|
+
def new(
|
|
180
|
+
cls,
|
|
181
|
+
identifier_type: IdentifierType,
|
|
182
|
+
identifier_value: IdentifierValueType,
|
|
183
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
184
|
+
use_cache: bool = True,
|
|
185
|
+
expand: OptListOfExpandableFields = None,
|
|
186
|
+
include_url: bool = False,
|
|
148
187
|
) -> "ReadSingleParameter":
|
|
149
188
|
return cls(
|
|
150
189
|
identifier=UserIdentifier(
|
|
@@ -153,20 +192,33 @@ class ReadSingleParameter(BaseReadSingleParameter[UserIdentifier]):
|
|
|
153
192
|
),
|
|
154
193
|
statuses=statuses,
|
|
155
194
|
use_cache=use_cache,
|
|
195
|
+
expand=expand,
|
|
196
|
+
include_url=include_url,
|
|
156
197
|
)
|
|
157
198
|
|
|
158
199
|
def to_query_params(self) -> StrToAnyDict:
|
|
159
200
|
return self.model_dump(
|
|
160
|
-
mode="json",
|
|
201
|
+
mode="json",
|
|
202
|
+
include={"statuses", "use_cache", "expand", "include_url"},
|
|
203
|
+
exclude_none=True,
|
|
161
204
|
)
|
|
162
205
|
|
|
163
206
|
|
|
164
207
|
class PasswordUpdateData(BaseModel):
|
|
165
|
-
|
|
208
|
+
old_password: Annotated[str, Field(..., description="Old Password", max_length=255)]
|
|
166
209
|
old_confirmation: Annotated[
|
|
167
210
|
str, Field(..., description="Old Password Confirmation", max_length=255)
|
|
168
211
|
]
|
|
169
|
-
|
|
212
|
+
new_password: Annotated[str, Field(..., description="New Password", max_length=255)]
|
|
213
|
+
|
|
214
|
+
@model_validator(mode="after")
|
|
215
|
+
def validate_old_and_confirmation(self) -> Self:
|
|
216
|
+
if self.old_password != self.old_confirmation:
|
|
217
|
+
raise ValueError(
|
|
218
|
+
ErrorCode.BAD_REQUEST,
|
|
219
|
+
"Old password must be the same with the confirmation",
|
|
220
|
+
)
|
|
221
|
+
return self
|
|
170
222
|
|
|
171
223
|
|
|
172
224
|
class FullUpdateData(
|
|
@@ -181,7 +233,9 @@ class PartialUpdateData(
|
|
|
181
233
|
pass
|
|
182
234
|
|
|
183
235
|
|
|
184
|
-
UpdateDataT = TypeVar(
|
|
236
|
+
UpdateDataT = TypeVar(
|
|
237
|
+
"UpdateDataT", FullUpdateData, PartialUpdateData, PasswordUpdateData
|
|
238
|
+
)
|
|
185
239
|
|
|
186
240
|
|
|
187
241
|
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
@@ -189,6 +243,8 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
|
189
243
|
|
|
190
244
|
|
|
191
245
|
class UpdateParameter(
|
|
246
|
+
IncludeURL,
|
|
247
|
+
Expand,
|
|
192
248
|
UpdateDataMixin[UpdateDataT],
|
|
193
249
|
IdentifierMixin[UserIdentifier],
|
|
194
250
|
Generic[UpdateDataT],
|
|
@@ -200,6 +256,8 @@ class UpdateParameter(
|
|
|
200
256
|
identifier_type: Literal[IdentifierType.ID],
|
|
201
257
|
identifier_value: int,
|
|
202
258
|
data: UpdateDataT,
|
|
259
|
+
expand: OptListOfExpandableFields = None,
|
|
260
|
+
include_url: bool = False,
|
|
203
261
|
) -> "UpdateParameter": ...
|
|
204
262
|
@overload
|
|
205
263
|
@classmethod
|
|
@@ -208,6 +266,8 @@ class UpdateParameter(
|
|
|
208
266
|
identifier_type: Literal[IdentifierType.UUID],
|
|
209
267
|
identifier_value: UUID,
|
|
210
268
|
data: UpdateDataT,
|
|
269
|
+
expand: OptListOfExpandableFields = None,
|
|
270
|
+
include_url: bool = False,
|
|
211
271
|
) -> "UpdateParameter": ...
|
|
212
272
|
@overload
|
|
213
273
|
@classmethod
|
|
@@ -216,6 +276,8 @@ class UpdateParameter(
|
|
|
216
276
|
identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
|
|
217
277
|
identifier_value: str,
|
|
218
278
|
data: UpdateDataT,
|
|
279
|
+
expand: OptListOfExpandableFields = None,
|
|
280
|
+
include_url: bool = False,
|
|
219
281
|
) -> "UpdateParameter": ...
|
|
220
282
|
@overload
|
|
221
283
|
@classmethod
|
|
@@ -224,6 +286,8 @@ class UpdateParameter(
|
|
|
224
286
|
identifier_type: IdentifierType,
|
|
225
287
|
identifier_value: IdentifierValueType,
|
|
226
288
|
data: UpdateDataT,
|
|
289
|
+
expand: OptListOfExpandableFields = None,
|
|
290
|
+
include_url: bool = False,
|
|
227
291
|
) -> "UpdateParameter": ...
|
|
228
292
|
@classmethod
|
|
229
293
|
def new(
|
|
@@ -231,14 +295,20 @@ class UpdateParameter(
|
|
|
231
295
|
identifier_type: IdentifierType,
|
|
232
296
|
identifier_value: IdentifierValueType,
|
|
233
297
|
data: UpdateDataT,
|
|
298
|
+
expand: OptListOfExpandableFields = None,
|
|
299
|
+
include_url: bool = False,
|
|
234
300
|
) -> "UpdateParameter":
|
|
235
301
|
return cls(
|
|
236
302
|
identifier=UserIdentifier(type=identifier_type, value=identifier_value),
|
|
237
303
|
data=data,
|
|
304
|
+
expand=expand,
|
|
305
|
+
include_url=include_url,
|
|
238
306
|
)
|
|
239
307
|
|
|
240
308
|
|
|
241
309
|
class StatusUpdateParameter(
|
|
310
|
+
IncludeURL,
|
|
311
|
+
Expand,
|
|
242
312
|
BaseStatusUpdateParameter[UserIdentifier],
|
|
243
313
|
):
|
|
244
314
|
@overload
|
|
@@ -248,6 +318,8 @@ class StatusUpdateParameter(
|
|
|
248
318
|
identifier_type: Literal[IdentifierType.ID],
|
|
249
319
|
identifier_value: int,
|
|
250
320
|
type: ResourceOperationStatusUpdateType,
|
|
321
|
+
expand: OptListOfExpandableFields = None,
|
|
322
|
+
include_url: bool = False,
|
|
251
323
|
) -> "StatusUpdateParameter": ...
|
|
252
324
|
@overload
|
|
253
325
|
@classmethod
|
|
@@ -256,6 +328,8 @@ class StatusUpdateParameter(
|
|
|
256
328
|
identifier_type: Literal[IdentifierType.UUID],
|
|
257
329
|
identifier_value: UUID,
|
|
258
330
|
type: ResourceOperationStatusUpdateType,
|
|
331
|
+
expand: OptListOfExpandableFields = None,
|
|
332
|
+
include_url: bool = False,
|
|
259
333
|
) -> "StatusUpdateParameter": ...
|
|
260
334
|
@overload
|
|
261
335
|
@classmethod
|
|
@@ -264,6 +338,8 @@ class StatusUpdateParameter(
|
|
|
264
338
|
identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
|
|
265
339
|
identifier_value: str,
|
|
266
340
|
type: ResourceOperationStatusUpdateType,
|
|
341
|
+
expand: OptListOfExpandableFields = None,
|
|
342
|
+
include_url: bool = False,
|
|
267
343
|
) -> "StatusUpdateParameter": ...
|
|
268
344
|
@overload
|
|
269
345
|
@classmethod
|
|
@@ -272,6 +348,8 @@ class StatusUpdateParameter(
|
|
|
272
348
|
identifier_type: IdentifierType,
|
|
273
349
|
identifier_value: IdentifierValueType,
|
|
274
350
|
type: ResourceOperationStatusUpdateType,
|
|
351
|
+
expand: OptListOfExpandableFields = None,
|
|
352
|
+
include_url: bool = False,
|
|
275
353
|
) -> "StatusUpdateParameter": ...
|
|
276
354
|
@classmethod
|
|
277
355
|
def new(
|
|
@@ -279,10 +357,14 @@ class StatusUpdateParameter(
|
|
|
279
357
|
identifier_type: IdentifierType,
|
|
280
358
|
identifier_value: IdentifierValueType,
|
|
281
359
|
type: ResourceOperationStatusUpdateType,
|
|
360
|
+
expand: OptListOfExpandableFields = None,
|
|
361
|
+
include_url: bool = False,
|
|
282
362
|
) -> "StatusUpdateParameter":
|
|
283
363
|
return cls(
|
|
284
364
|
identifier=UserIdentifier(type=identifier_type, value=identifier_value),
|
|
285
365
|
type=type,
|
|
366
|
+
expand=expand,
|
|
367
|
+
include_url=include_url,
|
|
286
368
|
)
|
|
287
369
|
|
|
288
370
|
|