maleo-identity 0.1.31__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 +2 -2
- 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 +1 -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 +5 -5
- 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 +2 -2
- maleo/identity/mixins/user_system_role.py +3 -3
- maleo/identity/schemas/api_key.py +22 -8
- maleo/identity/schemas/common.py +26 -82
- maleo/identity/schemas/organization.py +59 -25
- maleo/identity/schemas/organization_registration_code.py +11 -11
- maleo/identity/schemas/organization_relation.py +48 -22
- 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 +12 -12
- 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 +1 -1
- 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.31.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.31.dist-info/RECORD +0 -66
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/WHEEL +0 -0
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/licenses/LICENSE +0 -0
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
2
|
from typing import Annotated, Literal, 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
|
|
9
|
-
from
|
|
8
|
+
from nexo.schemas.mixins.filter import convert as convert_filter
|
|
9
|
+
from nexo.schemas.mixins.identity import (
|
|
10
10
|
Ids,
|
|
11
11
|
UUIDs,
|
|
12
12
|
IntUserId,
|
|
@@ -14,15 +14,15 @@ from maleo.schemas.mixins.identity import (
|
|
|
14
14
|
IntOrganizationId,
|
|
15
15
|
IntOrganizationIds,
|
|
16
16
|
)
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from nexo.schemas.mixins.sort import convert as convert_sort
|
|
18
|
+
from nexo.schemas.parameter import (
|
|
19
19
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
20
20
|
ReadPaginatedMultipleParameter,
|
|
21
21
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
22
22
|
)
|
|
23
|
-
from
|
|
24
|
-
from
|
|
25
|
-
from
|
|
23
|
+
from nexo.types.dict import StrToAnyDict
|
|
24
|
+
from nexo.types.integer import OptInt, OptListOfInts
|
|
25
|
+
from nexo.types.uuid import OptListOfUUIDs
|
|
26
26
|
from ..enums.api_key import IdentifierType
|
|
27
27
|
from ..mixins.api_key import APIKeyIdentifier
|
|
28
28
|
from ..types.api_key import CompositeIdentifierType, IdentifierValueType
|
|
@@ -103,6 +103,15 @@ class ReadSingleParameter(BaseReadSingleParameter[APIKeyIdentifier]):
|
|
|
103
103
|
) -> "ReadSingleParameter": ...
|
|
104
104
|
@overload
|
|
105
105
|
@classmethod
|
|
106
|
+
def new(
|
|
107
|
+
cls,
|
|
108
|
+
identifier_type: Literal[IdentifierType.API_KEY],
|
|
109
|
+
identifier_value: str,
|
|
110
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
111
|
+
use_cache: bool = True,
|
|
112
|
+
) -> "ReadSingleParameter": ...
|
|
113
|
+
@overload
|
|
114
|
+
@classmethod
|
|
106
115
|
def new(
|
|
107
116
|
cls,
|
|
108
117
|
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
@@ -152,6 +161,11 @@ class DeleteSingleParameter(BaseDeleteSingleParameter[APIKeyIdentifier]):
|
|
|
152
161
|
) -> "DeleteSingleParameter": ...
|
|
153
162
|
@overload
|
|
154
163
|
@classmethod
|
|
164
|
+
def new(
|
|
165
|
+
cls, identifier_type: Literal[IdentifierType.API_KEY], identifier_value: str
|
|
166
|
+
) -> "DeleteSingleParameter": ...
|
|
167
|
+
@overload
|
|
168
|
+
@classmethod
|
|
155
169
|
def new(
|
|
156
170
|
cls,
|
|
157
171
|
identifier_type: Literal[IdentifierType.COMPOSITE],
|
maleo/identity/schemas/common.py
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
from datetime import date
|
|
2
2
|
from pydantic import BaseModel, Field
|
|
3
|
-
from typing import Annotated
|
|
4
|
-
from
|
|
5
|
-
from
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
from nexo.enums.identity import OptRhesus, RhesusMixin
|
|
5
|
+
from nexo.enums.organization import (
|
|
6
|
+
OrganizationRelation,
|
|
7
|
+
SimpleOrganizationRelationMixin,
|
|
8
|
+
)
|
|
9
|
+
from nexo.enums.status import DataStatus as DataStatusEnum, SimpleDataStatusMixin
|
|
6
10
|
from maleo.metadata.schemas.blood_type import (
|
|
7
11
|
OptKeyOrStandardSchema as BloodTypeOptKeyOrStandardSchema,
|
|
8
12
|
FullBloodTypeMixin,
|
|
@@ -32,17 +36,16 @@ from maleo.metadata.schemas.user_type import (
|
|
|
32
36
|
KeyOrStandardSchema as UserTypeKeyOrStandardSchema,
|
|
33
37
|
FullUserTypeMixin,
|
|
34
38
|
)
|
|
35
|
-
from
|
|
39
|
+
from nexo.schemas.mixins.identity import (
|
|
36
40
|
DataIdentifier,
|
|
37
41
|
IntOrganizationId,
|
|
38
42
|
IntUserId,
|
|
39
43
|
BirthDate,
|
|
40
44
|
DateOfBirth,
|
|
41
45
|
)
|
|
42
|
-
from
|
|
43
|
-
from
|
|
44
|
-
from
|
|
45
|
-
from maleo.types.string import OptStr
|
|
46
|
+
from nexo.types.datetime import OptDate
|
|
47
|
+
from nexo.types.integer import OptInt
|
|
48
|
+
from nexo.types.string import OptStr
|
|
46
49
|
from ..mixins.common import IdCard, FullName, BirthPlace, PlaceOfBirth
|
|
47
50
|
from ..mixins.api_key import APIKey
|
|
48
51
|
from ..mixins.organization_registration_code import Code, CurrentUses
|
|
@@ -66,7 +69,6 @@ class APIKeySchema(
|
|
|
66
69
|
IntOrganizationId[OptInt],
|
|
67
70
|
IntUserId[int],
|
|
68
71
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
69
|
-
LifecycleTimestamp,
|
|
70
72
|
DataIdentifier,
|
|
71
73
|
):
|
|
72
74
|
pass
|
|
@@ -83,7 +85,6 @@ class PatientSchema(
|
|
|
83
85
|
IntOrganizationId[int],
|
|
84
86
|
IntUserId[int],
|
|
85
87
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
86
|
-
LifecycleTimestamp,
|
|
87
88
|
DataIdentifier,
|
|
88
89
|
):
|
|
89
90
|
pass
|
|
@@ -94,7 +95,6 @@ class OrganizationRegistrationCodeSchema(
|
|
|
94
95
|
Code[str],
|
|
95
96
|
IntOrganizationId[int],
|
|
96
97
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
97
|
-
LifecycleTimestamp,
|
|
98
98
|
DataIdentifier,
|
|
99
99
|
):
|
|
100
100
|
pass
|
|
@@ -110,29 +110,30 @@ class OrganizationRegistrationCodeSchemaMixin(BaseModel):
|
|
|
110
110
|
] = None
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
class
|
|
113
|
+
class OrganizationSchema(
|
|
114
114
|
OrganizationName[str],
|
|
115
115
|
OrganizationKey[str],
|
|
116
116
|
FullOrganizationTypeMixin[OrganizationTypeKeyOrStandardSchema],
|
|
117
117
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
118
|
-
LifecycleTimestamp,
|
|
119
118
|
DataIdentifier,
|
|
120
119
|
):
|
|
121
120
|
pass
|
|
122
121
|
|
|
123
122
|
|
|
123
|
+
class OrganizationSchemaMixin(BaseModel):
|
|
124
|
+
organization: Annotated[OrganizationSchema, Field(..., description="Organization")]
|
|
125
|
+
|
|
126
|
+
|
|
124
127
|
class SourceOrganizationSchemaMixin(BaseModel):
|
|
125
|
-
source: Annotated[
|
|
126
|
-
StandardOrganizationSchema, Field(..., description="Source organization")
|
|
127
|
-
]
|
|
128
|
+
source: Annotated[OrganizationSchema, Field(..., description="Source organization")]
|
|
128
129
|
|
|
129
130
|
|
|
130
131
|
class SourceOrganizationRelationSchema(
|
|
131
132
|
Meta,
|
|
132
133
|
IsBidirectional[bool],
|
|
134
|
+
SimpleOrganizationRelationMixin[OrganizationRelation],
|
|
133
135
|
SourceOrganizationSchemaMixin,
|
|
134
136
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
135
|
-
LifecycleTimestamp,
|
|
136
137
|
DataIdentifier,
|
|
137
138
|
):
|
|
138
139
|
pass
|
|
@@ -146,17 +147,15 @@ class SourceOrganizationRelationsSchemaMixin(BaseModel):
|
|
|
146
147
|
|
|
147
148
|
|
|
148
149
|
class TargetOrganizationSchemaMixin(BaseModel):
|
|
149
|
-
target: Annotated[
|
|
150
|
-
StandardOrganizationSchema, Field(..., description="Target organization")
|
|
151
|
-
]
|
|
150
|
+
target: Annotated[OrganizationSchema, Field(..., description="Target organization")]
|
|
152
151
|
|
|
153
152
|
|
|
154
153
|
class TargetOrganizationRelationSchema(
|
|
155
154
|
Meta,
|
|
156
155
|
IsBidirectional[bool],
|
|
156
|
+
SimpleOrganizationRelationMixin[OrganizationRelation],
|
|
157
157
|
TargetOrganizationSchemaMixin,
|
|
158
158
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
159
|
-
LifecycleTimestamp,
|
|
160
159
|
DataIdentifier,
|
|
161
160
|
):
|
|
162
161
|
pass
|
|
@@ -169,35 +168,13 @@ class TargetOrganizationRelationsSchemaMixin(BaseModel):
|
|
|
169
168
|
] = list[TargetOrganizationRelationSchema]()
|
|
170
169
|
|
|
171
170
|
|
|
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
171
|
class OrganizationRelationSchema(
|
|
195
172
|
Meta,
|
|
196
173
|
IsBidirectional[bool],
|
|
174
|
+
SimpleOrganizationRelationMixin[OrganizationRelation],
|
|
197
175
|
TargetOrganizationSchemaMixin,
|
|
198
176
|
SourceOrganizationSchemaMixin,
|
|
199
177
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
200
|
-
LifecycleTimestamp,
|
|
201
178
|
DataIdentifier,
|
|
202
179
|
):
|
|
203
180
|
pass
|
|
@@ -208,7 +185,6 @@ class UserMedicalRoleSchema(
|
|
|
208
185
|
IntOrganizationId[int],
|
|
209
186
|
IntUserId[int],
|
|
210
187
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
211
|
-
LifecycleTimestamp,
|
|
212
188
|
DataIdentifier,
|
|
213
189
|
):
|
|
214
190
|
pass
|
|
@@ -226,7 +202,6 @@ class UserOrganizationRoleSchema(
|
|
|
226
202
|
IntOrganizationId[int],
|
|
227
203
|
IntUserId[int],
|
|
228
204
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
229
|
-
LifecycleTimestamp,
|
|
230
205
|
DataIdentifier,
|
|
231
206
|
):
|
|
232
207
|
pass
|
|
@@ -255,7 +230,6 @@ class UserProfileSchema(
|
|
|
255
230
|
IdCard[OptStr],
|
|
256
231
|
IntUserId[int],
|
|
257
232
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
258
|
-
LifecycleTimestamp,
|
|
259
233
|
DataIdentifier,
|
|
260
234
|
):
|
|
261
235
|
avatar_url: Annotated[OptStr, Field(None, description="Avatar URL")]
|
|
@@ -274,7 +248,6 @@ class UserSystemRoleSchema(
|
|
|
274
248
|
FullSystemRoleMixin[SystemRoleKeyOrStandardSchema],
|
|
275
249
|
IntUserId[int],
|
|
276
250
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
277
|
-
LifecycleTimestamp,
|
|
278
251
|
DataIdentifier,
|
|
279
252
|
):
|
|
280
253
|
pass
|
|
@@ -291,57 +264,28 @@ class UserSystemRolesSchemaMixin(BaseModel):
|
|
|
291
264
|
] = list[UserSystemRoleSchema]()
|
|
292
265
|
|
|
293
266
|
|
|
294
|
-
class
|
|
267
|
+
class UserSchema(
|
|
295
268
|
UserProfileSchemaMixin,
|
|
296
269
|
Phone[str],
|
|
297
270
|
Email[str],
|
|
298
271
|
Username[str],
|
|
299
272
|
FullUserTypeMixin[UserTypeKeyOrStandardSchema],
|
|
300
273
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
301
|
-
LifecycleTimestamp,
|
|
302
274
|
DataIdentifier,
|
|
303
275
|
):
|
|
304
276
|
pass
|
|
305
277
|
|
|
306
278
|
|
|
307
|
-
class
|
|
308
|
-
|
|
309
|
-
UserOrganizationRolesSchemaMixin,
|
|
310
|
-
OrganizationSchemaMixin[StandardOrganizationSchema],
|
|
311
|
-
SimpleDataStatusMixin[DataStatusEnum],
|
|
312
|
-
LifecycleTimestamp,
|
|
313
|
-
DataIdentifier,
|
|
314
|
-
):
|
|
315
|
-
pass
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
class UserOrganizationsSchemaMixin(BaseModel):
|
|
319
|
-
organizations: Annotated[
|
|
320
|
-
list[UserOrganizationSchema],
|
|
321
|
-
Field(list[UserOrganizationSchema](), description="Organizations"),
|
|
322
|
-
] = list[UserOrganizationSchema]()
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
class FullUserSchema(UserSystemRolesSchemaMixin, StandardUserSchema):
|
|
326
|
-
pass
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
AnyUserSchemaType = Type[StandardUserSchema] | Type[FullUserSchema]
|
|
330
|
-
AnyUserSchema = StandardUserSchema | FullUserSchema
|
|
331
|
-
AnyUserSchemaT = TypeVar("AnyUserSchemaT", bound=AnyUserSchema)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
class UserSchemaMixin(BaseModel, Generic[AnyUserSchemaT]):
|
|
335
|
-
user: Annotated[AnyUserSchemaT, Field(..., description="User")]
|
|
279
|
+
class UserSchemaMixin(BaseModel):
|
|
280
|
+
user: Annotated[UserSchema, Field(..., description="User")]
|
|
336
281
|
|
|
337
282
|
|
|
338
283
|
class UserAndOrganizationSchema(
|
|
339
284
|
UserMedicalRolesSchemaMixin,
|
|
340
285
|
UserOrganizationRolesSchemaMixin,
|
|
341
|
-
OrganizationSchemaMixin
|
|
342
|
-
UserSchemaMixin
|
|
286
|
+
OrganizationSchemaMixin,
|
|
287
|
+
UserSchemaMixin,
|
|
343
288
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
344
|
-
LifecycleTimestamp,
|
|
345
289
|
DataIdentifier,
|
|
346
290
|
):
|
|
347
291
|
pass
|
|
@@ -1,55 +1,67 @@
|
|
|
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.organization import (
|
|
5
5
|
OptOrganizationRelation,
|
|
6
6
|
OrganizationType,
|
|
7
|
-
OptOrganizationType,
|
|
8
7
|
FullOrganizationTypeMixin,
|
|
9
8
|
OptListOfOrganizationTypes,
|
|
10
9
|
FullOrganizationTypesMixin,
|
|
11
10
|
)
|
|
12
|
-
from
|
|
11
|
+
from nexo.enums.status import (
|
|
13
12
|
ListOfDataStatuses,
|
|
14
13
|
FULL_DATA_STATUSES,
|
|
15
14
|
)
|
|
16
|
-
from
|
|
17
|
-
from
|
|
15
|
+
from nexo.schemas.mixins.filter import convert as convert_filter
|
|
16
|
+
from nexo.schemas.mixins.identity import (
|
|
18
17
|
IdentifierMixin,
|
|
19
18
|
Ids,
|
|
20
19
|
UUIDs,
|
|
21
20
|
Keys,
|
|
22
21
|
Names,
|
|
23
22
|
)
|
|
24
|
-
from
|
|
25
|
-
from
|
|
26
|
-
from
|
|
23
|
+
from nexo.schemas.mixins.sort import convert as convert_sort
|
|
24
|
+
from nexo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
25
|
+
from nexo.schemas.parameter import (
|
|
27
26
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
28
27
|
ReadPaginatedMultipleParameter,
|
|
29
28
|
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
30
29
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
31
30
|
)
|
|
32
|
-
from
|
|
33
|
-
from
|
|
34
|
-
from
|
|
35
|
-
from
|
|
36
|
-
from ..enums.organization import IdentifierType
|
|
37
|
-
from ..mixins.organization import Key, Name, OrganizationIdentifier
|
|
31
|
+
from nexo.types.dict import StrToAnyDict
|
|
32
|
+
from nexo.types.integer import OptInt, OptListOfInts
|
|
33
|
+
from nexo.types.string import OptStr, OptListOfStrs
|
|
34
|
+
from nexo.types.uuid import OptListOfUUIDs
|
|
35
|
+
from ..enums.organization import IdentifierType, OptListOfExpandableFields
|
|
36
|
+
from ..mixins.organization import Key, Name, Expand, OrganizationIdentifier
|
|
38
37
|
from ..types.organization import IdentifierValueType
|
|
39
38
|
|
|
40
39
|
|
|
41
|
-
class
|
|
40
|
+
class CreateData(Name[str], Key[str], FullOrganizationTypeMixin[OrganizationType]):
|
|
42
41
|
pass
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
class
|
|
44
|
+
class CreateParameterDump(CreateData):
|
|
46
45
|
related_to: Annotated[OptInt, Field(None, description="Related to", ge=1)] = None
|
|
47
46
|
relation: Annotated[
|
|
48
47
|
OptOrganizationRelation, Field(None, description="Relation")
|
|
49
48
|
] = None
|
|
50
49
|
|
|
50
|
+
@model_validator(mode="after")
|
|
51
|
+
def validate_relation(self) -> Self:
|
|
52
|
+
if (self.related_to is None) != (self.relation is None):
|
|
53
|
+
raise ValueError(
|
|
54
|
+
"Field 'related_to' and 'relation' must be both None or Not None"
|
|
55
|
+
)
|
|
56
|
+
return self
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class CreateParameter(Expand, CreateData):
|
|
60
|
+
pass
|
|
61
|
+
|
|
51
62
|
|
|
52
63
|
class ReadMultipleParameter(
|
|
64
|
+
Expand,
|
|
53
65
|
ReadPaginatedMultipleParameter,
|
|
54
66
|
Names[OptListOfStrs],
|
|
55
67
|
Keys[OptListOfStrs],
|
|
@@ -78,6 +90,7 @@ class ReadMultipleParameter(
|
|
|
78
90
|
"page",
|
|
79
91
|
"limit",
|
|
80
92
|
"use_cache",
|
|
93
|
+
"expand",
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
def to_query_params(self) -> StrToAnyDict:
|
|
@@ -90,15 +103,18 @@ class ReadMultipleParameter(
|
|
|
90
103
|
return params
|
|
91
104
|
|
|
92
105
|
|
|
93
|
-
class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
106
|
+
class ReadSingleParameter(Expand, BaseReadSingleParameter[OrganizationIdentifier]):
|
|
94
107
|
@classmethod
|
|
95
108
|
def from_identifier(
|
|
96
109
|
cls,
|
|
97
110
|
identifier: OrganizationIdentifier,
|
|
98
111
|
statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
|
|
99
112
|
use_cache: bool = True,
|
|
113
|
+
expand: OptListOfExpandableFields = None,
|
|
100
114
|
) -> "ReadSingleParameter":
|
|
101
|
-
return cls(
|
|
115
|
+
return cls(
|
|
116
|
+
identifier=identifier, statuses=statuses, use_cache=use_cache, expand=expand
|
|
117
|
+
)
|
|
102
118
|
|
|
103
119
|
@overload
|
|
104
120
|
@classmethod
|
|
@@ -108,6 +124,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
|
108
124
|
identifier_value: int,
|
|
109
125
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
110
126
|
use_cache: bool = True,
|
|
127
|
+
expand: OptListOfExpandableFields = None,
|
|
111
128
|
) -> "ReadSingleParameter": ...
|
|
112
129
|
@overload
|
|
113
130
|
@classmethod
|
|
@@ -117,6 +134,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
|
117
134
|
identifier_value: UUID,
|
|
118
135
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
119
136
|
use_cache: bool = True,
|
|
137
|
+
expand: OptListOfExpandableFields = None,
|
|
120
138
|
) -> "ReadSingleParameter": ...
|
|
121
139
|
@overload
|
|
122
140
|
@classmethod
|
|
@@ -126,6 +144,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
|
126
144
|
identifier_value: str,
|
|
127
145
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
128
146
|
use_cache: bool = True,
|
|
147
|
+
expand: OptListOfExpandableFields = None,
|
|
129
148
|
) -> "ReadSingleParameter": ...
|
|
130
149
|
@overload
|
|
131
150
|
@classmethod
|
|
@@ -135,6 +154,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
|
135
154
|
identifier_value: IdentifierValueType,
|
|
136
155
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
137
156
|
use_cache: bool = True,
|
|
157
|
+
expand: OptListOfExpandableFields = None,
|
|
138
158
|
) -> "ReadSingleParameter": ...
|
|
139
159
|
@classmethod
|
|
140
160
|
def new(
|
|
@@ -143,6 +163,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
|
143
163
|
identifier_value: IdentifierValueType,
|
|
144
164
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
145
165
|
use_cache: bool = True,
|
|
166
|
+
expand: OptListOfExpandableFields = None,
|
|
146
167
|
) -> "ReadSingleParameter":
|
|
147
168
|
return cls(
|
|
148
169
|
identifier=OrganizationIdentifier(
|
|
@@ -150,21 +171,20 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
|
|
|
150
171
|
),
|
|
151
172
|
statuses=statuses,
|
|
152
173
|
use_cache=use_cache,
|
|
174
|
+
expand=expand,
|
|
153
175
|
)
|
|
154
176
|
|
|
155
177
|
def to_query_params(self) -> StrToAnyDict:
|
|
156
178
|
return self.model_dump(
|
|
157
|
-
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
179
|
+
mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
|
|
158
180
|
)
|
|
159
181
|
|
|
160
182
|
|
|
161
|
-
class FullUpdateData(Name[str]
|
|
183
|
+
class FullUpdateData(Name[str]):
|
|
162
184
|
pass
|
|
163
185
|
|
|
164
186
|
|
|
165
|
-
class PartialUpdateData(
|
|
166
|
-
Name[OptStr], Key[OptStr], FullOrganizationTypeMixin[OptOrganizationType]
|
|
167
|
-
):
|
|
187
|
+
class PartialUpdateData(Name[OptStr]):
|
|
168
188
|
pass
|
|
169
189
|
|
|
170
190
|
|
|
@@ -176,6 +196,7 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
|
176
196
|
|
|
177
197
|
|
|
178
198
|
class UpdateParameter(
|
|
199
|
+
Expand,
|
|
179
200
|
UpdateDataMixin[UpdateDataT],
|
|
180
201
|
IdentifierMixin[OrganizationIdentifier],
|
|
181
202
|
Generic[UpdateDataT],
|
|
@@ -187,6 +208,7 @@ class UpdateParameter(
|
|
|
187
208
|
identifier_type: Literal[IdentifierType.ID],
|
|
188
209
|
identifier_value: int,
|
|
189
210
|
data: UpdateDataT,
|
|
211
|
+
expand: OptListOfExpandableFields = None,
|
|
190
212
|
) -> "UpdateParameter": ...
|
|
191
213
|
@overload
|
|
192
214
|
@classmethod
|
|
@@ -195,6 +217,7 @@ class UpdateParameter(
|
|
|
195
217
|
identifier_type: Literal[IdentifierType.UUID],
|
|
196
218
|
identifier_value: UUID,
|
|
197
219
|
data: UpdateDataT,
|
|
220
|
+
expand: OptListOfExpandableFields = None,
|
|
198
221
|
) -> "UpdateParameter": ...
|
|
199
222
|
@overload
|
|
200
223
|
@classmethod
|
|
@@ -203,6 +226,7 @@ class UpdateParameter(
|
|
|
203
226
|
identifier_type: Literal[IdentifierType.KEY],
|
|
204
227
|
identifier_value: str,
|
|
205
228
|
data: UpdateDataT,
|
|
229
|
+
expand: OptListOfExpandableFields = None,
|
|
206
230
|
) -> "UpdateParameter": ...
|
|
207
231
|
@overload
|
|
208
232
|
@classmethod
|
|
@@ -211,6 +235,7 @@ class UpdateParameter(
|
|
|
211
235
|
identifier_type: IdentifierType,
|
|
212
236
|
identifier_value: IdentifierValueType,
|
|
213
237
|
data: UpdateDataT,
|
|
238
|
+
expand: OptListOfExpandableFields = None,
|
|
214
239
|
) -> "UpdateParameter": ...
|
|
215
240
|
@classmethod
|
|
216
241
|
def new(
|
|
@@ -218,16 +243,19 @@ class UpdateParameter(
|
|
|
218
243
|
identifier_type: IdentifierType,
|
|
219
244
|
identifier_value: IdentifierValueType,
|
|
220
245
|
data: UpdateDataT,
|
|
246
|
+
expand: OptListOfExpandableFields = None,
|
|
221
247
|
) -> "UpdateParameter":
|
|
222
248
|
return cls(
|
|
223
249
|
identifier=OrganizationIdentifier(
|
|
224
250
|
type=identifier_type, value=identifier_value
|
|
225
251
|
),
|
|
226
252
|
data=data,
|
|
253
|
+
expand=expand,
|
|
227
254
|
)
|
|
228
255
|
|
|
229
256
|
|
|
230
257
|
class StatusUpdateParameter(
|
|
258
|
+
Expand,
|
|
231
259
|
BaseStatusUpdateParameter[OrganizationIdentifier],
|
|
232
260
|
):
|
|
233
261
|
@overload
|
|
@@ -237,6 +265,7 @@ class StatusUpdateParameter(
|
|
|
237
265
|
identifier_type: Literal[IdentifierType.ID],
|
|
238
266
|
identifier_value: int,
|
|
239
267
|
type: ResourceOperationStatusUpdateType,
|
|
268
|
+
expand: OptListOfExpandableFields = None,
|
|
240
269
|
) -> "StatusUpdateParameter": ...
|
|
241
270
|
@overload
|
|
242
271
|
@classmethod
|
|
@@ -245,6 +274,7 @@ class StatusUpdateParameter(
|
|
|
245
274
|
identifier_type: Literal[IdentifierType.UUID],
|
|
246
275
|
identifier_value: UUID,
|
|
247
276
|
type: ResourceOperationStatusUpdateType,
|
|
277
|
+
expand: OptListOfExpandableFields = None,
|
|
248
278
|
) -> "StatusUpdateParameter": ...
|
|
249
279
|
@overload
|
|
250
280
|
@classmethod
|
|
@@ -253,6 +283,7 @@ class StatusUpdateParameter(
|
|
|
253
283
|
identifier_type: Literal[IdentifierType.KEY],
|
|
254
284
|
identifier_value: str,
|
|
255
285
|
type: ResourceOperationStatusUpdateType,
|
|
286
|
+
expand: OptListOfExpandableFields = None,
|
|
256
287
|
) -> "StatusUpdateParameter": ...
|
|
257
288
|
@overload
|
|
258
289
|
@classmethod
|
|
@@ -261,6 +292,7 @@ class StatusUpdateParameter(
|
|
|
261
292
|
identifier_type: IdentifierType,
|
|
262
293
|
identifier_value: IdentifierValueType,
|
|
263
294
|
type: ResourceOperationStatusUpdateType,
|
|
295
|
+
expand: OptListOfExpandableFields = None,
|
|
264
296
|
) -> "StatusUpdateParameter": ...
|
|
265
297
|
@classmethod
|
|
266
298
|
def new(
|
|
@@ -268,12 +300,14 @@ class StatusUpdateParameter(
|
|
|
268
300
|
identifier_type: IdentifierType,
|
|
269
301
|
identifier_value: IdentifierValueType,
|
|
270
302
|
type: ResourceOperationStatusUpdateType,
|
|
303
|
+
expand: OptListOfExpandableFields = None,
|
|
271
304
|
) -> "StatusUpdateParameter":
|
|
272
305
|
return cls(
|
|
273
306
|
identifier=OrganizationIdentifier(
|
|
274
307
|
type=identifier_type, value=identifier_value
|
|
275
308
|
),
|
|
276
309
|
type=type,
|
|
310
|
+
expand=expand,
|
|
277
311
|
)
|
|
278
312
|
|
|
279
313
|
|
|
@@ -1,31 +1,31 @@
|
|
|
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.status import (
|
|
5
5
|
ListOfDataStatuses,
|
|
6
6
|
FULL_DATA_STATUSES,
|
|
7
7
|
)
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
8
|
+
from nexo.schemas.mixins.filter import convert as convert_filter
|
|
9
|
+
from nexo.schemas.mixins.general import Codes
|
|
10
|
+
from nexo.schemas.mixins.identity import (
|
|
11
11
|
IdentifierMixin,
|
|
12
12
|
Ids,
|
|
13
13
|
IntOrganizationId,
|
|
14
14
|
IntOrganizationIds,
|
|
15
15
|
UUIDs,
|
|
16
16
|
)
|
|
17
|
-
from
|
|
18
|
-
from
|
|
19
|
-
from
|
|
17
|
+
from nexo.schemas.mixins.sort import convert as convert_sort
|
|
18
|
+
from nexo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
19
|
+
from nexo.schemas.parameter import (
|
|
20
20
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
21
21
|
ReadPaginatedMultipleParameter,
|
|
22
22
|
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
23
23
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
24
24
|
)
|
|
25
|
-
from
|
|
26
|
-
from
|
|
27
|
-
from
|
|
28
|
-
from
|
|
25
|
+
from nexo.types.dict import StrToAnyDict
|
|
26
|
+
from nexo.types.integer import OptInt, OptListOfInts
|
|
27
|
+
from nexo.types.string import OptStr, OptListOfStrs
|
|
28
|
+
from nexo.types.uuid import OptListOfUUIDs
|
|
29
29
|
from ..enums.organization_registration_code import IdentifierType
|
|
30
30
|
from ..mixins.organization_registration_code import (
|
|
31
31
|
CodeOrLength,
|