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.
- maleo/identity/constants/api_key.py +13 -0
- maleo/identity/constants/organization.py +3 -10
- maleo/identity/constants/organization_registration_code.py +5 -17
- maleo/identity/constants/organization_relation.py +13 -0
- maleo/identity/constants/patient.py +7 -0
- maleo/identity/constants/user.py +3 -20
- maleo/identity/constants/user_medical_role.py +13 -0
- maleo/identity/constants/user_organization_role.py +5 -39
- maleo/identity/constants/user_profile.py +3 -21
- maleo/identity/constants/user_system_role.py +9 -8
- maleo/identity/enums/api_key.py +25 -0
- maleo/identity/enums/organization.py +16 -3
- maleo/identity/enums/organization_registration_code.py +9 -0
- maleo/identity/enums/organization_relation.py +22 -0
- maleo/identity/enums/patient.py +29 -0
- maleo/identity/enums/user.py +16 -7
- maleo/identity/enums/user_medical_role.py +22 -0
- maleo/identity/enums/user_organization_role.py +19 -12
- maleo/identity/enums/user_profile.py +7 -9
- maleo/identity/enums/user_system_role.py +30 -0
- maleo/identity/mixins/api_key.py +72 -0
- maleo/identity/mixins/common.py +29 -0
- maleo/identity/mixins/organization.py +68 -8
- maleo/identity/mixins/organization_registration_code.py +126 -9
- maleo/identity/mixins/organization_relation.py +80 -0
- maleo/identity/mixins/patient.py +65 -0
- maleo/identity/mixins/user.py +86 -24
- maleo/identity/mixins/user_medical_role.py +68 -0
- maleo/identity/mixins/user_organization_role.py +68 -4
- maleo/identity/mixins/user_profile.py +84 -53
- maleo/identity/mixins/user_system_role.py +72 -4
- maleo/identity/schemas/api_key.py +171 -0
- maleo/identity/schemas/common.py +335 -0
- maleo/identity/schemas/organization.py +311 -0
- maleo/identity/schemas/organization_registration_code.py +314 -0
- maleo/identity/schemas/organization_relation.py +315 -0
- maleo/identity/schemas/patient.py +349 -0
- maleo/identity/schemas/user.py +318 -0
- maleo/identity/schemas/user_medical_role.py +316 -0
- maleo/identity/schemas/user_organization_role.py +317 -0
- maleo/identity/schemas/user_profile.py +362 -0
- maleo/identity/schemas/user_system_role.py +339 -0
- maleo/identity/types/api_key.py +7 -0
- maleo/identity/types/organization.py +4 -0
- maleo/identity/types/organization_registration_code.py +4 -0
- maleo/identity/types/organization_relation.py +7 -0
- maleo/identity/types/patient.py +4 -0
- maleo/identity/types/user.py +4 -0
- maleo/identity/types/user_medical_role.py +7 -0
- maleo/identity/types/user_organization_role.py +7 -0
- maleo/identity/types/user_profile.py +4 -0
- maleo/identity/types/user_system_role.py +8 -0
- maleo/identity/utils/organization.py +32 -0
- maleo/identity/utils/user.py +32 -0
- maleo_identity-0.1.24.dist-info/METADATA +119 -0
- maleo_identity-0.1.24.dist-info/RECORD +66 -0
- maleo_identity-0.1.24.dist-info/licenses/LICENSE +57 -0
- maleo/identity/client/manager.py +0 -157
- maleo/identity/client/services/__init__.py +0 -0
- maleo/identity/client/services/organization.py +0 -1944
- maleo/identity/client/services/organization_registration_code.py +0 -470
- maleo/identity/client/services/organization_role.py +0 -276
- maleo/identity/client/services/user.py +0 -1559
- maleo/identity/client/services/user_organization.py +0 -276
- maleo/identity/client/services/user_organization_role.py +0 -278
- maleo/identity/client/services/user_profile.py +0 -276
- maleo/identity/client/services/user_system_role.py +0 -276
- maleo/identity/constants/organization_role.py +0 -35
- maleo/identity/constants/user_organization.py +0 -58
- maleo/identity/db.py +0 -4
- maleo/identity/dtos/__init__.py +0 -0
- maleo/identity/dtos/configuration.py +0 -15
- maleo/identity/dtos/data/__init__.py +0 -0
- maleo/identity/dtos/data/organization_registration_code.py +0 -15
- maleo/identity/dtos/data/user_profile.py +0 -29
- maleo/identity/dtos/settings.py +0 -17
- maleo/identity/enums/general.py +0 -5
- maleo/identity/enums/organization_role.py +0 -7
- maleo/identity/enums/user_organization.py +0 -14
- maleo/identity/mixins/organization_role.py +0 -15
- maleo/identity/mixins/user_organization.py +0 -6
- maleo/identity/models/__init__.py +0 -0
- maleo/identity/models/organization.py +0 -62
- maleo/identity/models/organization_registration_code.py +0 -33
- maleo/identity/models/organization_role.py +0 -37
- maleo/identity/models/user.py +0 -39
- maleo/identity/models/user_organization.py +0 -48
- maleo/identity/models/user_organization_role.py +0 -61
- maleo/identity/models/user_profile.py +0 -33
- maleo/identity/models/user_system_role.py +0 -26
- maleo/identity/schemas/data/__init__.py +0 -0
- maleo/identity/schemas/data/organization.py +0 -36
- maleo/identity/schemas/data/organization_registration_code.py +0 -27
- maleo/identity/schemas/data/organization_role.py +0 -32
- maleo/identity/schemas/data/user.py +0 -33
- maleo/identity/schemas/data/user_organization.py +0 -23
- maleo/identity/schemas/data/user_organization_role.py +0 -13
- maleo/identity/schemas/data/user_profile.py +0 -59
- maleo/identity/schemas/data/user_system_role.py +0 -25
- maleo/identity/schemas/metadata/__init__.py +0 -0
- maleo/identity/schemas/metadata/user.py +0 -6
- maleo/identity/schemas/parameter/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/organization.py +0 -74
- maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
- maleo/identity/schemas/parameter/client/organization_role.py +0 -42
- maleo/identity/schemas/parameter/client/user.py +0 -44
- maleo/identity/schemas/parameter/client/user_organization.py +0 -62
- maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
- maleo/identity/schemas/parameter/client/user_profile.py +0 -28
- maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
- maleo/identity/schemas/parameter/general/__init__.py +0 -0
- maleo/identity/schemas/parameter/general/organization.py +0 -43
- maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -54
- maleo/identity/schemas/parameter/general/organization_role.py +0 -14
- maleo/identity/schemas/parameter/general/user.py +0 -101
- maleo/identity/schemas/parameter/general/user_organization.py +0 -18
- maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
- maleo/identity/schemas/parameter/general/user_profile.py +0 -70
- maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
- maleo/identity/schemas/parameter/service/__init__.py +0 -0
- maleo/identity/schemas/parameter/service/organization.py +0 -60
- maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
- maleo/identity/schemas/parameter/service/organization_role.py +0 -35
- maleo/identity/schemas/parameter/service/user.py +0 -47
- maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
- maleo/identity/schemas/parameter/service/user_profile.py +0 -28
- maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
- maleo/identity/types/base/__init__.py +0 -0
- maleo/identity/types/base/organization.py +0 -5
- maleo/identity/types/base/organization_registration_code.py +0 -4
- maleo/identity/types/base/user.py +0 -5
- maleo/identity/types/base/user_profile.py +0 -5
- maleo_identity-0.0.85.dist-info/METADATA +0 -40
- maleo_identity-0.0.85.dist-info/RECORD +0 -105
- /maleo/identity/{client → utils}/__init__.py +0 -0
- {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
- {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
from datetime import date
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
from typing import Annotated, Generic, TypeVar, Type
|
|
4
|
+
from maleo.enums.identity import OptRhesus, RhesusMixin
|
|
5
|
+
from maleo.enums.status import DataStatus as DataStatusEnum, SimpleDataStatusMixin
|
|
6
|
+
from maleo.metadata.schemas.blood_type import (
|
|
7
|
+
OptKeyOrStandardSchema as BloodTypeOptKeyOrStandardSchema,
|
|
8
|
+
FullBloodTypeMixin,
|
|
9
|
+
)
|
|
10
|
+
from maleo.metadata.schemas.gender import (
|
|
11
|
+
OptKeyOrStandardSchema as GenderOptKeyOrStandardSchema,
|
|
12
|
+
KeyOrStandardSchema as GenderKeyOrStandardSchema,
|
|
13
|
+
FullGenderMixin,
|
|
14
|
+
)
|
|
15
|
+
from maleo.metadata.schemas.medical_role import (
|
|
16
|
+
KeyOrStandardSchema as MedicalRoleKeyOrStandardSchema,
|
|
17
|
+
FullMedicalRoleMixin,
|
|
18
|
+
)
|
|
19
|
+
from maleo.metadata.schemas.organization_role import (
|
|
20
|
+
KeyOrStandardSchema as OrganizationRoleKeyOrStandardSchema,
|
|
21
|
+
FullOrganizationRoleMixin,
|
|
22
|
+
)
|
|
23
|
+
from maleo.metadata.schemas.organization_type import (
|
|
24
|
+
KeyOrStandardSchema as OrganizationTypeKeyOrStandardSchema,
|
|
25
|
+
FullOrganizationTypeMixin,
|
|
26
|
+
)
|
|
27
|
+
from maleo.metadata.schemas.system_role import (
|
|
28
|
+
KeyOrStandardSchema as SystemRoleKeyOrStandardSchema,
|
|
29
|
+
FullSystemRoleMixin,
|
|
30
|
+
)
|
|
31
|
+
from maleo.metadata.schemas.user_type import (
|
|
32
|
+
KeyOrStandardSchema as UserTypeKeyOrStandardSchema,
|
|
33
|
+
FullUserTypeMixin,
|
|
34
|
+
)
|
|
35
|
+
from maleo.schemas.mixins.identity import (
|
|
36
|
+
DataIdentifier,
|
|
37
|
+
IntOrganizationId,
|
|
38
|
+
IntUserId,
|
|
39
|
+
BirthDate,
|
|
40
|
+
DateOfBirth,
|
|
41
|
+
)
|
|
42
|
+
from maleo.schemas.mixins.timestamp import LifecycleTimestamp
|
|
43
|
+
from maleo.types.datetime import OptDate
|
|
44
|
+
from maleo.types.integer import OptInt
|
|
45
|
+
from maleo.types.string import OptStr
|
|
46
|
+
from ..mixins.common import IdCard, FullName, BirthPlace, PlaceOfBirth
|
|
47
|
+
from ..mixins.api_key import APIKey
|
|
48
|
+
from ..mixins.organization_registration_code import Code, CurrentUses
|
|
49
|
+
from ..mixins.organization_relation import IsBidirectional, Meta
|
|
50
|
+
from ..mixins.organization import Key as OrganizationKey, Name as OrganizationName
|
|
51
|
+
from ..mixins.patient import PatientIdentity
|
|
52
|
+
from ..mixins.user_profile import (
|
|
53
|
+
LeadingTitle,
|
|
54
|
+
FirstName,
|
|
55
|
+
MiddleName,
|
|
56
|
+
LastName,
|
|
57
|
+
EndingTitle,
|
|
58
|
+
AvatarName,
|
|
59
|
+
AvatarUrl,
|
|
60
|
+
)
|
|
61
|
+
from ..mixins.user import Username, Email, Phone
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class APIKeySchema(
|
|
65
|
+
APIKey,
|
|
66
|
+
IntOrganizationId[OptInt],
|
|
67
|
+
IntUserId[int],
|
|
68
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
69
|
+
LifecycleTimestamp,
|
|
70
|
+
DataIdentifier,
|
|
71
|
+
):
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class PatientSchema(
|
|
76
|
+
RhesusMixin[OptRhesus],
|
|
77
|
+
FullBloodTypeMixin[BloodTypeOptKeyOrStandardSchema],
|
|
78
|
+
FullGenderMixin[GenderKeyOrStandardSchema],
|
|
79
|
+
DateOfBirth[date],
|
|
80
|
+
PlaceOfBirth[OptStr],
|
|
81
|
+
FullName[str],
|
|
82
|
+
PatientIdentity,
|
|
83
|
+
IntOrganizationId[int],
|
|
84
|
+
IntUserId[int],
|
|
85
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
86
|
+
LifecycleTimestamp,
|
|
87
|
+
DataIdentifier,
|
|
88
|
+
):
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class OrganizationRegistrationCodeSchema(
|
|
93
|
+
CurrentUses,
|
|
94
|
+
Code[str],
|
|
95
|
+
IntOrganizationId[int],
|
|
96
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
97
|
+
LifecycleTimestamp,
|
|
98
|
+
DataIdentifier,
|
|
99
|
+
):
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
OptOrganizationRegistrationCodeSchema = OrganizationRegistrationCodeSchema | None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class OrganizationRegistrationCodeSchemaMixin(BaseModel):
|
|
107
|
+
registration_code: Annotated[
|
|
108
|
+
OptOrganizationRegistrationCodeSchema,
|
|
109
|
+
Field(None, description="Organization's registration code"),
|
|
110
|
+
] = None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class StandardOrganizationSchema(
|
|
114
|
+
OrganizationName[str],
|
|
115
|
+
OrganizationKey[str],
|
|
116
|
+
FullOrganizationTypeMixin[OrganizationTypeKeyOrStandardSchema],
|
|
117
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
118
|
+
LifecycleTimestamp,
|
|
119
|
+
DataIdentifier,
|
|
120
|
+
):
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class SourceOrganizationSchemaMixin(BaseModel):
|
|
125
|
+
source: Annotated[
|
|
126
|
+
StandardOrganizationSchema, Field(..., description="Source organization")
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class SourceOrganizationRelationSchema(
|
|
131
|
+
Meta,
|
|
132
|
+
IsBidirectional[bool],
|
|
133
|
+
SourceOrganizationSchemaMixin,
|
|
134
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
135
|
+
LifecycleTimestamp,
|
|
136
|
+
DataIdentifier,
|
|
137
|
+
):
|
|
138
|
+
pass
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class SourceOrganizationRelationsSchemaMixin(BaseModel):
|
|
142
|
+
sources: Annotated[
|
|
143
|
+
list[SourceOrganizationRelationSchema],
|
|
144
|
+
Field(list[SourceOrganizationRelationSchema](), description="Sources"),
|
|
145
|
+
] = list[SourceOrganizationRelationSchema]()
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class TargetOrganizationSchemaMixin(BaseModel):
|
|
149
|
+
target: Annotated[
|
|
150
|
+
StandardOrganizationSchema, Field(..., description="Target organization")
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class TargetOrganizationRelationSchema(
|
|
155
|
+
Meta,
|
|
156
|
+
IsBidirectional[bool],
|
|
157
|
+
TargetOrganizationSchemaMixin,
|
|
158
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
159
|
+
LifecycleTimestamp,
|
|
160
|
+
DataIdentifier,
|
|
161
|
+
):
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class TargetOrganizationRelationsSchemaMixin(BaseModel):
|
|
166
|
+
targets: Annotated[
|
|
167
|
+
list[TargetOrganizationRelationSchema],
|
|
168
|
+
Field(list[TargetOrganizationRelationSchema](), description="Targets"),
|
|
169
|
+
] = list[TargetOrganizationRelationSchema]()
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class FullOrganizationSchema(
|
|
173
|
+
TargetOrganizationRelationsSchemaMixin,
|
|
174
|
+
SourceOrganizationRelationsSchemaMixin,
|
|
175
|
+
OrganizationRegistrationCodeSchemaMixin,
|
|
176
|
+
StandardOrganizationSchema,
|
|
177
|
+
):
|
|
178
|
+
pass
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
AnyOrganizationSchemaType = (
|
|
182
|
+
Type[StandardOrganizationSchema] | Type[FullOrganizationSchema]
|
|
183
|
+
)
|
|
184
|
+
AnyOrganizationSchema = StandardOrganizationSchema | FullOrganizationSchema
|
|
185
|
+
AnyOrganizationSchemaT = TypeVar("AnyOrganizationSchemaT", bound=AnyOrganizationSchema)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class OrganizationSchemaMixin(BaseModel, Generic[AnyOrganizationSchemaT]):
|
|
189
|
+
organization: Annotated[
|
|
190
|
+
AnyOrganizationSchemaT, Field(..., description="Organization")
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class UserMedicalRoleSchema(
|
|
195
|
+
FullMedicalRoleMixin[MedicalRoleKeyOrStandardSchema],
|
|
196
|
+
IntOrganizationId[int],
|
|
197
|
+
IntUserId[int],
|
|
198
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
199
|
+
LifecycleTimestamp,
|
|
200
|
+
DataIdentifier,
|
|
201
|
+
):
|
|
202
|
+
pass
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class UserMedicalRolesSchemaMixin(BaseModel):
|
|
206
|
+
medical_roles: Annotated[
|
|
207
|
+
list[UserMedicalRoleSchema],
|
|
208
|
+
Field(list[UserMedicalRoleSchema](), description="Medical roles"),
|
|
209
|
+
] = list[UserMedicalRoleSchema]()
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class UserOrganizationRoleSchema(
|
|
213
|
+
FullOrganizationRoleMixin[OrganizationRoleKeyOrStandardSchema],
|
|
214
|
+
IntOrganizationId[int],
|
|
215
|
+
IntUserId[int],
|
|
216
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
217
|
+
LifecycleTimestamp,
|
|
218
|
+
DataIdentifier,
|
|
219
|
+
):
|
|
220
|
+
pass
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class UserOrganizationRolesSchemaMixin(BaseModel):
|
|
224
|
+
organization_roles: Annotated[
|
|
225
|
+
list[UserOrganizationRoleSchema],
|
|
226
|
+
Field(list[UserOrganizationRoleSchema](), description="Organization roles"),
|
|
227
|
+
] = list[UserOrganizationRoleSchema]()
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class UserProfileSchema(
|
|
231
|
+
AvatarUrl[OptStr],
|
|
232
|
+
AvatarName[str],
|
|
233
|
+
FullBloodTypeMixin[BloodTypeOptKeyOrStandardSchema],
|
|
234
|
+
FullGenderMixin[GenderOptKeyOrStandardSchema],
|
|
235
|
+
BirthDate[OptDate],
|
|
236
|
+
BirthPlace[OptStr],
|
|
237
|
+
FullName[str],
|
|
238
|
+
EndingTitle[OptStr],
|
|
239
|
+
LastName[str],
|
|
240
|
+
MiddleName[OptStr],
|
|
241
|
+
FirstName[str],
|
|
242
|
+
LeadingTitle[OptStr],
|
|
243
|
+
IdCard[OptStr],
|
|
244
|
+
IntUserId[int],
|
|
245
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
246
|
+
LifecycleTimestamp,
|
|
247
|
+
DataIdentifier,
|
|
248
|
+
):
|
|
249
|
+
pass
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
OptUserProfileSchema = UserProfileSchema | None
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class UserProfileSchemaMixin(BaseModel):
|
|
256
|
+
profile: Annotated[
|
|
257
|
+
OptUserProfileSchema, Field(None, description="User's Profile")
|
|
258
|
+
] = None
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class UserSystemRoleSchema(
|
|
262
|
+
FullSystemRoleMixin[SystemRoleKeyOrStandardSchema],
|
|
263
|
+
IntUserId[int],
|
|
264
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
265
|
+
LifecycleTimestamp,
|
|
266
|
+
DataIdentifier,
|
|
267
|
+
):
|
|
268
|
+
pass
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class UserSystemRolesSchemaMixin(BaseModel):
|
|
272
|
+
system_roles: Annotated[
|
|
273
|
+
list[UserSystemRoleSchema],
|
|
274
|
+
Field(
|
|
275
|
+
list[UserSystemRoleSchema](),
|
|
276
|
+
description="User's system roles",
|
|
277
|
+
min_length=1,
|
|
278
|
+
),
|
|
279
|
+
] = list[UserSystemRoleSchema]()
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class StandardUserSchema(
|
|
283
|
+
UserProfileSchemaMixin,
|
|
284
|
+
Phone[str],
|
|
285
|
+
Email[str],
|
|
286
|
+
Username[str],
|
|
287
|
+
FullUserTypeMixin[UserTypeKeyOrStandardSchema],
|
|
288
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
289
|
+
LifecycleTimestamp,
|
|
290
|
+
DataIdentifier,
|
|
291
|
+
):
|
|
292
|
+
pass
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class UserOrganizationSchema(
|
|
296
|
+
UserMedicalRolesSchemaMixin,
|
|
297
|
+
UserOrganizationRolesSchemaMixin,
|
|
298
|
+
OrganizationSchemaMixin[StandardOrganizationSchema],
|
|
299
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
300
|
+
LifecycleTimestamp,
|
|
301
|
+
DataIdentifier,
|
|
302
|
+
):
|
|
303
|
+
pass
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class UserOrganizationsSchemaMixin(BaseModel):
|
|
307
|
+
organizations: Annotated[
|
|
308
|
+
list[UserOrganizationSchema],
|
|
309
|
+
Field(list[UserOrganizationSchema](), description="Organizations"),
|
|
310
|
+
] = list[UserOrganizationSchema]()
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
class FullUserSchema(UserSystemRolesSchemaMixin, StandardUserSchema):
|
|
314
|
+
pass
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
AnyUserSchemaType = Type[StandardUserSchema] | Type[FullUserSchema]
|
|
318
|
+
AnyUserSchema = StandardUserSchema | FullUserSchema
|
|
319
|
+
AnyUserSchemaT = TypeVar("AnyUserSchemaT", bound=AnyUserSchema)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class UserSchemaMixin(BaseModel, Generic[AnyUserSchemaT]):
|
|
323
|
+
user: Annotated[AnyUserSchemaT, Field(..., description="User")]
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
class UserAndOrganizationSchema(
|
|
327
|
+
UserMedicalRolesSchemaMixin,
|
|
328
|
+
UserOrganizationRolesSchemaMixin,
|
|
329
|
+
OrganizationSchemaMixin[StandardOrganizationSchema],
|
|
330
|
+
UserSchemaMixin[StandardUserSchema],
|
|
331
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
332
|
+
LifecycleTimestamp,
|
|
333
|
+
DataIdentifier,
|
|
334
|
+
):
|
|
335
|
+
pass
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.organization import (
|
|
5
|
+
OptOrganizationRelation,
|
|
6
|
+
OrganizationType,
|
|
7
|
+
OptOrganizationType,
|
|
8
|
+
FullOrganizationTypeMixin,
|
|
9
|
+
OptListOfOrganizationTypes,
|
|
10
|
+
FullOrganizationTypesMixin,
|
|
11
|
+
)
|
|
12
|
+
from maleo.enums.status import (
|
|
13
|
+
ListOfDataStatuses,
|
|
14
|
+
FULL_DATA_STATUSES,
|
|
15
|
+
)
|
|
16
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
17
|
+
from maleo.schemas.mixins.identity import (
|
|
18
|
+
IdentifierMixin,
|
|
19
|
+
Ids,
|
|
20
|
+
UUIDs,
|
|
21
|
+
Keys,
|
|
22
|
+
Names,
|
|
23
|
+
)
|
|
24
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
25
|
+
from maleo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
26
|
+
from maleo.schemas.parameter import (
|
|
27
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
28
|
+
ReadPaginatedMultipleParameter,
|
|
29
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
30
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
31
|
+
)
|
|
32
|
+
from maleo.types.dict import StrToAnyDict
|
|
33
|
+
from maleo.types.integer import OptInt, OptListOfInts
|
|
34
|
+
from maleo.types.string import OptStr, OptListOfStrs
|
|
35
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
36
|
+
from ..enums.organization import IdentifierType
|
|
37
|
+
from ..mixins.organization import Key, Name, OrganizationIdentifier
|
|
38
|
+
from ..types.organization import IdentifierValueType
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class InsertData(Name[str], Key[str], FullOrganizationTypeMixin[OrganizationType]):
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CreateParameter(InsertData):
|
|
46
|
+
related_to: Annotated[OptInt, Field(None, description="Related to", ge=1)] = None
|
|
47
|
+
relation: Annotated[
|
|
48
|
+
OptOrganizationRelation, Field(None, description="Relation")
|
|
49
|
+
] = None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ReadMultipleParameter(
|
|
53
|
+
ReadPaginatedMultipleParameter,
|
|
54
|
+
Names[OptListOfStrs],
|
|
55
|
+
Keys[OptListOfStrs],
|
|
56
|
+
FullOrganizationTypesMixin[OptListOfOrganizationTypes],
|
|
57
|
+
UUIDs[OptListOfUUIDs],
|
|
58
|
+
Ids[OptListOfInts],
|
|
59
|
+
):
|
|
60
|
+
ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
|
|
61
|
+
uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
|
|
62
|
+
organization_types: Annotated[
|
|
63
|
+
OptListOfOrganizationTypes, Field(None, description="Organization Types")
|
|
64
|
+
] = None
|
|
65
|
+
keys: Annotated[OptListOfStrs, Field(None, description="Keys")] = None
|
|
66
|
+
names: Annotated[OptListOfStrs, Field(None, description="Names")] = None
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def _query_param_fields(self) -> set[str]:
|
|
70
|
+
return {
|
|
71
|
+
"ids",
|
|
72
|
+
"uuids",
|
|
73
|
+
"statuses",
|
|
74
|
+
"organization_types",
|
|
75
|
+
"keys",
|
|
76
|
+
"names",
|
|
77
|
+
"search",
|
|
78
|
+
"page",
|
|
79
|
+
"limit",
|
|
80
|
+
"use_cache",
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
84
|
+
params = self.model_dump(
|
|
85
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
86
|
+
)
|
|
87
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
88
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
89
|
+
params = {k: v for k, v in params.items()}
|
|
90
|
+
return params
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
94
|
+
@classmethod
|
|
95
|
+
def from_identifier(
|
|
96
|
+
cls,
|
|
97
|
+
identifier: OrganizationIdentifier,
|
|
98
|
+
statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
|
|
99
|
+
use_cache: bool = True,
|
|
100
|
+
) -> "ReadSingleParameter":
|
|
101
|
+
return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
|
|
102
|
+
|
|
103
|
+
@overload
|
|
104
|
+
@classmethod
|
|
105
|
+
def new(
|
|
106
|
+
cls,
|
|
107
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
108
|
+
identifier_value: int,
|
|
109
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
110
|
+
use_cache: bool = True,
|
|
111
|
+
) -> "ReadSingleParameter": ...
|
|
112
|
+
@overload
|
|
113
|
+
@classmethod
|
|
114
|
+
def new(
|
|
115
|
+
cls,
|
|
116
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
117
|
+
identifier_value: UUID,
|
|
118
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
119
|
+
use_cache: bool = True,
|
|
120
|
+
) -> "ReadSingleParameter": ...
|
|
121
|
+
@overload
|
|
122
|
+
@classmethod
|
|
123
|
+
def new(
|
|
124
|
+
cls,
|
|
125
|
+
identifier_type: Literal[IdentifierType.KEY],
|
|
126
|
+
identifier_value: str,
|
|
127
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
128
|
+
use_cache: bool = True,
|
|
129
|
+
) -> "ReadSingleParameter": ...
|
|
130
|
+
@overload
|
|
131
|
+
@classmethod
|
|
132
|
+
def new(
|
|
133
|
+
cls,
|
|
134
|
+
identifier_type: IdentifierType,
|
|
135
|
+
identifier_value: IdentifierValueType,
|
|
136
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
137
|
+
use_cache: bool = True,
|
|
138
|
+
) -> "ReadSingleParameter": ...
|
|
139
|
+
@classmethod
|
|
140
|
+
def new(
|
|
141
|
+
cls,
|
|
142
|
+
identifier_type: IdentifierType,
|
|
143
|
+
identifier_value: IdentifierValueType,
|
|
144
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
145
|
+
use_cache: bool = True,
|
|
146
|
+
) -> "ReadSingleParameter":
|
|
147
|
+
return cls(
|
|
148
|
+
identifier=OrganizationIdentifier(
|
|
149
|
+
type=identifier_type, value=identifier_value
|
|
150
|
+
),
|
|
151
|
+
statuses=statuses,
|
|
152
|
+
use_cache=use_cache,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
156
|
+
return self.model_dump(
|
|
157
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class FullUpdateData(Name[str], Key[str], FullOrganizationTypeMixin[OrganizationType]):
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class PartialUpdateData(
|
|
166
|
+
Name[OptStr], Key[OptStr], FullOrganizationTypeMixin[OptOrganizationType]
|
|
167
|
+
):
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
175
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class UpdateParameter(
|
|
179
|
+
UpdateDataMixin[UpdateDataT],
|
|
180
|
+
IdentifierMixin[OrganizationIdentifier],
|
|
181
|
+
Generic[UpdateDataT],
|
|
182
|
+
):
|
|
183
|
+
@overload
|
|
184
|
+
@classmethod
|
|
185
|
+
def new(
|
|
186
|
+
cls,
|
|
187
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
188
|
+
identifier_value: int,
|
|
189
|
+
data: UpdateDataT,
|
|
190
|
+
) -> "UpdateParameter": ...
|
|
191
|
+
@overload
|
|
192
|
+
@classmethod
|
|
193
|
+
def new(
|
|
194
|
+
cls,
|
|
195
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
196
|
+
identifier_value: UUID,
|
|
197
|
+
data: UpdateDataT,
|
|
198
|
+
) -> "UpdateParameter": ...
|
|
199
|
+
@overload
|
|
200
|
+
@classmethod
|
|
201
|
+
def new(
|
|
202
|
+
cls,
|
|
203
|
+
identifier_type: Literal[IdentifierType.KEY],
|
|
204
|
+
identifier_value: str,
|
|
205
|
+
data: UpdateDataT,
|
|
206
|
+
) -> "UpdateParameter": ...
|
|
207
|
+
@overload
|
|
208
|
+
@classmethod
|
|
209
|
+
def new(
|
|
210
|
+
cls,
|
|
211
|
+
identifier_type: IdentifierType,
|
|
212
|
+
identifier_value: IdentifierValueType,
|
|
213
|
+
data: UpdateDataT,
|
|
214
|
+
) -> "UpdateParameter": ...
|
|
215
|
+
@classmethod
|
|
216
|
+
def new(
|
|
217
|
+
cls,
|
|
218
|
+
identifier_type: IdentifierType,
|
|
219
|
+
identifier_value: IdentifierValueType,
|
|
220
|
+
data: UpdateDataT,
|
|
221
|
+
) -> "UpdateParameter":
|
|
222
|
+
return cls(
|
|
223
|
+
identifier=OrganizationIdentifier(
|
|
224
|
+
type=identifier_type, value=identifier_value
|
|
225
|
+
),
|
|
226
|
+
data=data,
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class StatusUpdateParameter(
|
|
231
|
+
BaseStatusUpdateParameter[OrganizationIdentifier],
|
|
232
|
+
):
|
|
233
|
+
@overload
|
|
234
|
+
@classmethod
|
|
235
|
+
def new(
|
|
236
|
+
cls,
|
|
237
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
238
|
+
identifier_value: int,
|
|
239
|
+
type: ResourceOperationStatusUpdateType,
|
|
240
|
+
) -> "StatusUpdateParameter": ...
|
|
241
|
+
@overload
|
|
242
|
+
@classmethod
|
|
243
|
+
def new(
|
|
244
|
+
cls,
|
|
245
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
246
|
+
identifier_value: UUID,
|
|
247
|
+
type: ResourceOperationStatusUpdateType,
|
|
248
|
+
) -> "StatusUpdateParameter": ...
|
|
249
|
+
@overload
|
|
250
|
+
@classmethod
|
|
251
|
+
def new(
|
|
252
|
+
cls,
|
|
253
|
+
identifier_type: Literal[IdentifierType.KEY],
|
|
254
|
+
identifier_value: str,
|
|
255
|
+
type: ResourceOperationStatusUpdateType,
|
|
256
|
+
) -> "StatusUpdateParameter": ...
|
|
257
|
+
@overload
|
|
258
|
+
@classmethod
|
|
259
|
+
def new(
|
|
260
|
+
cls,
|
|
261
|
+
identifier_type: IdentifierType,
|
|
262
|
+
identifier_value: IdentifierValueType,
|
|
263
|
+
type: ResourceOperationStatusUpdateType,
|
|
264
|
+
) -> "StatusUpdateParameter": ...
|
|
265
|
+
@classmethod
|
|
266
|
+
def new(
|
|
267
|
+
cls,
|
|
268
|
+
identifier_type: IdentifierType,
|
|
269
|
+
identifier_value: IdentifierValueType,
|
|
270
|
+
type: ResourceOperationStatusUpdateType,
|
|
271
|
+
) -> "StatusUpdateParameter":
|
|
272
|
+
return cls(
|
|
273
|
+
identifier=OrganizationIdentifier(
|
|
274
|
+
type=identifier_type, value=identifier_value
|
|
275
|
+
),
|
|
276
|
+
type=type,
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
class DeleteSingleParameter(BaseDeleteSingleParameter[OrganizationIdentifier]):
|
|
281
|
+
@overload
|
|
282
|
+
@classmethod
|
|
283
|
+
def new(
|
|
284
|
+
cls, identifier_type: Literal[IdentifierType.ID], identifier_value: int
|
|
285
|
+
) -> "DeleteSingleParameter": ...
|
|
286
|
+
@overload
|
|
287
|
+
@classmethod
|
|
288
|
+
def new(
|
|
289
|
+
cls, identifier_type: Literal[IdentifierType.UUID], identifier_value: UUID
|
|
290
|
+
) -> "DeleteSingleParameter": ...
|
|
291
|
+
@overload
|
|
292
|
+
@classmethod
|
|
293
|
+
def new(
|
|
294
|
+
cls,
|
|
295
|
+
identifier_type: Literal[IdentifierType.KEY],
|
|
296
|
+
identifier_value: str,
|
|
297
|
+
) -> "DeleteSingleParameter": ...
|
|
298
|
+
@overload
|
|
299
|
+
@classmethod
|
|
300
|
+
def new(
|
|
301
|
+
cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
|
|
302
|
+
) -> "DeleteSingleParameter": ...
|
|
303
|
+
@classmethod
|
|
304
|
+
def new(
|
|
305
|
+
cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
|
|
306
|
+
) -> "DeleteSingleParameter":
|
|
307
|
+
return cls(
|
|
308
|
+
identifier=OrganizationIdentifier(
|
|
309
|
+
type=identifier_type, value=identifier_value
|
|
310
|
+
)
|
|
311
|
+
)
|