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,314 @@
|
|
|
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.schemas.mixins.filter import convert as convert_filter
|
|
9
|
+
from maleo.schemas.mixins.general import Codes
|
|
10
|
+
from maleo.schemas.mixins.identity import (
|
|
11
|
+
IdentifierMixin,
|
|
12
|
+
Ids,
|
|
13
|
+
IntOrganizationId,
|
|
14
|
+
IntOrganizationIds,
|
|
15
|
+
UUIDs,
|
|
16
|
+
)
|
|
17
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
18
|
+
from maleo.schemas.operation.enums import ResourceOperationStatusUpdateType
|
|
19
|
+
from maleo.schemas.parameter import (
|
|
20
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
21
|
+
ReadPaginatedMultipleParameter,
|
|
22
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
23
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
24
|
+
)
|
|
25
|
+
from maleo.types.dict import StrToAnyDict
|
|
26
|
+
from maleo.types.integer import OptInt, OptListOfInts
|
|
27
|
+
from maleo.types.string import OptStr, OptListOfStrs
|
|
28
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
29
|
+
from ..enums.organization_registration_code import IdentifierType
|
|
30
|
+
from ..mixins.organization_registration_code import (
|
|
31
|
+
CodeOrLength,
|
|
32
|
+
Code,
|
|
33
|
+
MaxUses,
|
|
34
|
+
OrganizationRegistrationCodeIdentifier,
|
|
35
|
+
)
|
|
36
|
+
from ..types.organization_registration_code import IdentifierValueType
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class StandardCreateData(CodeOrLength):
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class FullCreateData(
|
|
44
|
+
StandardCreateData,
|
|
45
|
+
IntOrganizationId[int],
|
|
46
|
+
):
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CreateParameter(FullCreateData):
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ReadMultipleParameter(
|
|
55
|
+
ReadPaginatedMultipleParameter,
|
|
56
|
+
Codes[OptListOfStrs],
|
|
57
|
+
IntOrganizationIds[OptListOfInts],
|
|
58
|
+
UUIDs[OptListOfUUIDs],
|
|
59
|
+
Ids[OptListOfInts],
|
|
60
|
+
):
|
|
61
|
+
ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
|
|
62
|
+
uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
|
|
63
|
+
organization_ids: Annotated[
|
|
64
|
+
OptListOfInts, Field(None, description="Organization's IDs")
|
|
65
|
+
] = None
|
|
66
|
+
codes: Annotated[OptListOfStrs, Field(None, description="Codes")] = None
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def _query_param_fields(self) -> set[str]:
|
|
70
|
+
return {
|
|
71
|
+
"ids",
|
|
72
|
+
"uuids",
|
|
73
|
+
"statuses",
|
|
74
|
+
"organization_ids",
|
|
75
|
+
"codes",
|
|
76
|
+
"search",
|
|
77
|
+
"page",
|
|
78
|
+
"limit",
|
|
79
|
+
"use_cache",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
83
|
+
params = self.model_dump(
|
|
84
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
85
|
+
)
|
|
86
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
87
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
88
|
+
params = {k: v for k, v in params.items()}
|
|
89
|
+
return params
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ReadSingleParameter(
|
|
93
|
+
BaseReadSingleParameter[OrganizationRegistrationCodeIdentifier]
|
|
94
|
+
):
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_identifier(
|
|
97
|
+
cls,
|
|
98
|
+
identifier: OrganizationRegistrationCodeIdentifier,
|
|
99
|
+
statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
|
|
100
|
+
use_cache: bool = True,
|
|
101
|
+
) -> "ReadSingleParameter":
|
|
102
|
+
return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
|
|
103
|
+
|
|
104
|
+
@overload
|
|
105
|
+
@classmethod
|
|
106
|
+
def new(
|
|
107
|
+
cls,
|
|
108
|
+
identifier_type: Literal[IdentifierType.ID, IdentifierType.ORGANIZATION_ID],
|
|
109
|
+
identifier_value: int,
|
|
110
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
111
|
+
use_cache: bool = True,
|
|
112
|
+
) -> "ReadSingleParameter": ...
|
|
113
|
+
@overload
|
|
114
|
+
@classmethod
|
|
115
|
+
def new(
|
|
116
|
+
cls,
|
|
117
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
118
|
+
identifier_value: UUID,
|
|
119
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
120
|
+
use_cache: bool = True,
|
|
121
|
+
) -> "ReadSingleParameter": ...
|
|
122
|
+
@overload
|
|
123
|
+
@classmethod
|
|
124
|
+
def new(
|
|
125
|
+
cls,
|
|
126
|
+
identifier_type: Literal[IdentifierType.CODE],
|
|
127
|
+
identifier_value: str,
|
|
128
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
129
|
+
use_cache: bool = True,
|
|
130
|
+
) -> "ReadSingleParameter": ...
|
|
131
|
+
@overload
|
|
132
|
+
@classmethod
|
|
133
|
+
def new(
|
|
134
|
+
cls,
|
|
135
|
+
identifier_type: IdentifierType,
|
|
136
|
+
identifier_value: IdentifierValueType,
|
|
137
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
138
|
+
use_cache: bool = True,
|
|
139
|
+
) -> "ReadSingleParameter": ...
|
|
140
|
+
@classmethod
|
|
141
|
+
def new(
|
|
142
|
+
cls,
|
|
143
|
+
identifier_type: IdentifierType,
|
|
144
|
+
identifier_value: IdentifierValueType,
|
|
145
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
146
|
+
use_cache: bool = True,
|
|
147
|
+
) -> "ReadSingleParameter":
|
|
148
|
+
return cls(
|
|
149
|
+
identifier=OrganizationRegistrationCodeIdentifier(
|
|
150
|
+
type=identifier_type, value=identifier_value
|
|
151
|
+
),
|
|
152
|
+
statuses=statuses,
|
|
153
|
+
use_cache=use_cache,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
157
|
+
return self.model_dump(
|
|
158
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class FullUpdateData(MaxUses[int], Code[str]):
|
|
163
|
+
pass
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class PartialUpdateData(MaxUses[OptInt], Code[OptStr]):
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
174
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class UpdateParameter(
|
|
178
|
+
UpdateDataMixin[UpdateDataT],
|
|
179
|
+
IdentifierMixin[OrganizationRegistrationCodeIdentifier],
|
|
180
|
+
Generic[UpdateDataT],
|
|
181
|
+
):
|
|
182
|
+
@overload
|
|
183
|
+
@classmethod
|
|
184
|
+
def new(
|
|
185
|
+
cls,
|
|
186
|
+
identifier_type: Literal[IdentifierType.ID, IdentifierType.ORGANIZATION_ID],
|
|
187
|
+
identifier_value: int,
|
|
188
|
+
data: UpdateDataT,
|
|
189
|
+
) -> "UpdateParameter": ...
|
|
190
|
+
@overload
|
|
191
|
+
@classmethod
|
|
192
|
+
def new(
|
|
193
|
+
cls,
|
|
194
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
195
|
+
identifier_value: UUID,
|
|
196
|
+
data: UpdateDataT,
|
|
197
|
+
) -> "UpdateParameter": ...
|
|
198
|
+
@overload
|
|
199
|
+
@classmethod
|
|
200
|
+
def new(
|
|
201
|
+
cls,
|
|
202
|
+
identifier_type: Literal[IdentifierType.CODE],
|
|
203
|
+
identifier_value: str,
|
|
204
|
+
data: UpdateDataT,
|
|
205
|
+
) -> "UpdateParameter": ...
|
|
206
|
+
@overload
|
|
207
|
+
@classmethod
|
|
208
|
+
def new(
|
|
209
|
+
cls,
|
|
210
|
+
identifier_type: IdentifierType,
|
|
211
|
+
identifier_value: IdentifierValueType,
|
|
212
|
+
data: UpdateDataT,
|
|
213
|
+
) -> "UpdateParameter": ...
|
|
214
|
+
@classmethod
|
|
215
|
+
def new(
|
|
216
|
+
cls,
|
|
217
|
+
identifier_type: IdentifierType,
|
|
218
|
+
identifier_value: IdentifierValueType,
|
|
219
|
+
data: UpdateDataT,
|
|
220
|
+
) -> "UpdateParameter":
|
|
221
|
+
return cls(
|
|
222
|
+
identifier=OrganizationRegistrationCodeIdentifier(
|
|
223
|
+
type=identifier_type, value=identifier_value
|
|
224
|
+
),
|
|
225
|
+
data=data,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class StatusUpdateParameter(
|
|
230
|
+
BaseStatusUpdateParameter[OrganizationRegistrationCodeIdentifier],
|
|
231
|
+
):
|
|
232
|
+
@overload
|
|
233
|
+
@classmethod
|
|
234
|
+
def new(
|
|
235
|
+
cls,
|
|
236
|
+
identifier_type: Literal[IdentifierType.ID, IdentifierType.ORGANIZATION_ID],
|
|
237
|
+
identifier_value: int,
|
|
238
|
+
type: ResourceOperationStatusUpdateType,
|
|
239
|
+
) -> "StatusUpdateParameter": ...
|
|
240
|
+
@overload
|
|
241
|
+
@classmethod
|
|
242
|
+
def new(
|
|
243
|
+
cls,
|
|
244
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
245
|
+
identifier_value: UUID,
|
|
246
|
+
type: ResourceOperationStatusUpdateType,
|
|
247
|
+
) -> "StatusUpdateParameter": ...
|
|
248
|
+
@overload
|
|
249
|
+
@classmethod
|
|
250
|
+
def new(
|
|
251
|
+
cls,
|
|
252
|
+
identifier_type: Literal[IdentifierType.CODE],
|
|
253
|
+
identifier_value: str,
|
|
254
|
+
type: ResourceOperationStatusUpdateType,
|
|
255
|
+
) -> "StatusUpdateParameter": ...
|
|
256
|
+
@overload
|
|
257
|
+
@classmethod
|
|
258
|
+
def new(
|
|
259
|
+
cls,
|
|
260
|
+
identifier_type: IdentifierType,
|
|
261
|
+
identifier_value: IdentifierValueType,
|
|
262
|
+
type: ResourceOperationStatusUpdateType,
|
|
263
|
+
) -> "StatusUpdateParameter": ...
|
|
264
|
+
@classmethod
|
|
265
|
+
def new(
|
|
266
|
+
cls,
|
|
267
|
+
identifier_type: IdentifierType,
|
|
268
|
+
identifier_value: IdentifierValueType,
|
|
269
|
+
type: ResourceOperationStatusUpdateType,
|
|
270
|
+
) -> "StatusUpdateParameter":
|
|
271
|
+
return cls(
|
|
272
|
+
identifier=OrganizationRegistrationCodeIdentifier(
|
|
273
|
+
type=identifier_type, value=identifier_value
|
|
274
|
+
),
|
|
275
|
+
type=type,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class DeleteSingleParameter(
|
|
280
|
+
BaseDeleteSingleParameter[OrganizationRegistrationCodeIdentifier]
|
|
281
|
+
):
|
|
282
|
+
@overload
|
|
283
|
+
@classmethod
|
|
284
|
+
def new(
|
|
285
|
+
cls,
|
|
286
|
+
identifier_type: Literal[IdentifierType.ID, IdentifierType.ORGANIZATION_ID],
|
|
287
|
+
identifier_value: int,
|
|
288
|
+
) -> "DeleteSingleParameter": ...
|
|
289
|
+
@overload
|
|
290
|
+
@classmethod
|
|
291
|
+
def new(
|
|
292
|
+
cls, identifier_type: Literal[IdentifierType.UUID], identifier_value: UUID
|
|
293
|
+
) -> "DeleteSingleParameter": ...
|
|
294
|
+
@overload
|
|
295
|
+
@classmethod
|
|
296
|
+
def new(
|
|
297
|
+
cls,
|
|
298
|
+
identifier_type: Literal[IdentifierType.CODE],
|
|
299
|
+
identifier_value: str,
|
|
300
|
+
) -> "DeleteSingleParameter": ...
|
|
301
|
+
@overload
|
|
302
|
+
@classmethod
|
|
303
|
+
def new(
|
|
304
|
+
cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
|
|
305
|
+
) -> "DeleteSingleParameter": ...
|
|
306
|
+
@classmethod
|
|
307
|
+
def new(
|
|
308
|
+
cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
|
|
309
|
+
) -> "DeleteSingleParameter":
|
|
310
|
+
return cls(
|
|
311
|
+
identifier=OrganizationRegistrationCodeIdentifier(
|
|
312
|
+
type=identifier_type, value=identifier_value
|
|
313
|
+
)
|
|
314
|
+
)
|
|
@@ -0,0 +1,315 @@
|
|
|
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
|
+
OrganizationRelation,
|
|
6
|
+
SimpleOrganizationRelationMixin,
|
|
7
|
+
OptListOfOrganizationRelations,
|
|
8
|
+
SimpleOrganizationRelationsMixin,
|
|
9
|
+
)
|
|
10
|
+
from maleo.enums.status import (
|
|
11
|
+
ListOfDataStatuses,
|
|
12
|
+
FULL_DATA_STATUSES,
|
|
13
|
+
)
|
|
14
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
15
|
+
from maleo.schemas.mixins.identity import (
|
|
16
|
+
IdentifierMixin,
|
|
17
|
+
Ids,
|
|
18
|
+
UUIDs,
|
|
19
|
+
IntSourceId,
|
|
20
|
+
IntSourceIds,
|
|
21
|
+
IntTargetId,
|
|
22
|
+
IntTargetIds,
|
|
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.boolean import OptBool
|
|
33
|
+
from maleo.types.dict import StrToAnyDict
|
|
34
|
+
from maleo.types.integer import OptListOfInts
|
|
35
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
36
|
+
from ..enums.organization_relation import IdentifierType
|
|
37
|
+
from ..mixins.organization_relation import (
|
|
38
|
+
IsBidirectional,
|
|
39
|
+
Meta,
|
|
40
|
+
OrganizationRelationIdentifier,
|
|
41
|
+
)
|
|
42
|
+
from ..types.organization_relation import CompositeIdentifierType, IdentifierValueType
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CreateParameter(
|
|
46
|
+
Meta,
|
|
47
|
+
IsBidirectional[bool],
|
|
48
|
+
SimpleOrganizationRelationMixin[OrganizationRelation],
|
|
49
|
+
IntTargetId[int],
|
|
50
|
+
IntSourceId[int],
|
|
51
|
+
):
|
|
52
|
+
is_bidirectional: Annotated[bool, Field(False, description="Is Bidirectional")] = (
|
|
53
|
+
False
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ReadMultipleParameter(
|
|
58
|
+
ReadPaginatedMultipleParameter,
|
|
59
|
+
SimpleOrganizationRelationsMixin[OptListOfOrganizationRelations],
|
|
60
|
+
IntTargetIds[OptListOfInts],
|
|
61
|
+
IntSourceIds[OptListOfInts],
|
|
62
|
+
UUIDs[OptListOfUUIDs],
|
|
63
|
+
Ids[OptListOfInts],
|
|
64
|
+
):
|
|
65
|
+
ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
|
|
66
|
+
uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
|
|
67
|
+
source_ids: Annotated[OptListOfInts, Field(None, description="Source's IDs")] = None
|
|
68
|
+
target_ids: Annotated[OptListOfInts, Field(None, description="Target's IDs")] = None
|
|
69
|
+
relations: Annotated[
|
|
70
|
+
OptListOfOrganizationRelations,
|
|
71
|
+
Field(None, description="Organization Relations"),
|
|
72
|
+
] = None
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def _query_param_fields(self) -> set[str]:
|
|
76
|
+
return {
|
|
77
|
+
"ids",
|
|
78
|
+
"uuids",
|
|
79
|
+
"statuses",
|
|
80
|
+
"source_ids",
|
|
81
|
+
"target_ids",
|
|
82
|
+
"relations",
|
|
83
|
+
"search",
|
|
84
|
+
"page",
|
|
85
|
+
"limit",
|
|
86
|
+
"use_cache",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
90
|
+
params = self.model_dump(
|
|
91
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
92
|
+
)
|
|
93
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
94
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
95
|
+
params = {k: v for k, v in params.items()}
|
|
96
|
+
return params
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier]):
|
|
100
|
+
@classmethod
|
|
101
|
+
def from_identifier(
|
|
102
|
+
cls,
|
|
103
|
+
identifier: OrganizationRelationIdentifier,
|
|
104
|
+
statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
|
|
105
|
+
use_cache: bool = True,
|
|
106
|
+
) -> "ReadSingleParameter":
|
|
107
|
+
return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
|
|
108
|
+
|
|
109
|
+
@overload
|
|
110
|
+
@classmethod
|
|
111
|
+
def new(
|
|
112
|
+
cls,
|
|
113
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
114
|
+
identifier_value: int,
|
|
115
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
116
|
+
use_cache: bool = True,
|
|
117
|
+
) -> "ReadSingleParameter": ...
|
|
118
|
+
@overload
|
|
119
|
+
@classmethod
|
|
120
|
+
def new(
|
|
121
|
+
cls,
|
|
122
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
123
|
+
identifier_value: UUID,
|
|
124
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
125
|
+
use_cache: bool = True,
|
|
126
|
+
) -> "ReadSingleParameter": ...
|
|
127
|
+
@overload
|
|
128
|
+
@classmethod
|
|
129
|
+
def new(
|
|
130
|
+
cls,
|
|
131
|
+
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
132
|
+
identifier_value: CompositeIdentifierType,
|
|
133
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
134
|
+
use_cache: bool = True,
|
|
135
|
+
) -> "ReadSingleParameter": ...
|
|
136
|
+
@overload
|
|
137
|
+
@classmethod
|
|
138
|
+
def new(
|
|
139
|
+
cls,
|
|
140
|
+
identifier_type: IdentifierType,
|
|
141
|
+
identifier_value: IdentifierValueType,
|
|
142
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
143
|
+
use_cache: bool = True,
|
|
144
|
+
) -> "ReadSingleParameter": ...
|
|
145
|
+
@classmethod
|
|
146
|
+
def new(
|
|
147
|
+
cls,
|
|
148
|
+
identifier_type: IdentifierType,
|
|
149
|
+
identifier_value: IdentifierValueType,
|
|
150
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
151
|
+
use_cache: bool = True,
|
|
152
|
+
) -> "ReadSingleParameter":
|
|
153
|
+
return cls(
|
|
154
|
+
identifier=OrganizationRelationIdentifier(
|
|
155
|
+
type=identifier_type, value=identifier_value
|
|
156
|
+
),
|
|
157
|
+
statuses=statuses,
|
|
158
|
+
use_cache=use_cache,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
162
|
+
return self.model_dump(
|
|
163
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class FullUpdateData(Meta, IsBidirectional[bool]):
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class PartialUpdateData(Meta, IsBidirectional[OptBool]):
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
179
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class UpdateParameter(
|
|
183
|
+
UpdateDataMixin[UpdateDataT],
|
|
184
|
+
IdentifierMixin[OrganizationRelationIdentifier],
|
|
185
|
+
Generic[UpdateDataT],
|
|
186
|
+
):
|
|
187
|
+
@overload
|
|
188
|
+
@classmethod
|
|
189
|
+
def new(
|
|
190
|
+
cls,
|
|
191
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
192
|
+
identifier_value: int,
|
|
193
|
+
data: UpdateDataT,
|
|
194
|
+
) -> "UpdateParameter": ...
|
|
195
|
+
@overload
|
|
196
|
+
@classmethod
|
|
197
|
+
def new(
|
|
198
|
+
cls,
|
|
199
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
200
|
+
identifier_value: UUID,
|
|
201
|
+
data: UpdateDataT,
|
|
202
|
+
) -> "UpdateParameter": ...
|
|
203
|
+
@overload
|
|
204
|
+
@classmethod
|
|
205
|
+
def new(
|
|
206
|
+
cls,
|
|
207
|
+
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
208
|
+
identifier_value: CompositeIdentifierType,
|
|
209
|
+
data: UpdateDataT,
|
|
210
|
+
) -> "UpdateParameter": ...
|
|
211
|
+
@overload
|
|
212
|
+
@classmethod
|
|
213
|
+
def new(
|
|
214
|
+
cls,
|
|
215
|
+
identifier_type: IdentifierType,
|
|
216
|
+
identifier_value: IdentifierValueType,
|
|
217
|
+
data: UpdateDataT,
|
|
218
|
+
) -> "UpdateParameter": ...
|
|
219
|
+
@classmethod
|
|
220
|
+
def new(
|
|
221
|
+
cls,
|
|
222
|
+
identifier_type: IdentifierType,
|
|
223
|
+
identifier_value: IdentifierValueType,
|
|
224
|
+
data: UpdateDataT,
|
|
225
|
+
) -> "UpdateParameter":
|
|
226
|
+
return cls(
|
|
227
|
+
identifier=OrganizationRelationIdentifier(
|
|
228
|
+
type=identifier_type, value=identifier_value
|
|
229
|
+
),
|
|
230
|
+
data=data,
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class StatusUpdateParameter(
|
|
235
|
+
BaseStatusUpdateParameter[OrganizationRelationIdentifier],
|
|
236
|
+
):
|
|
237
|
+
@overload
|
|
238
|
+
@classmethod
|
|
239
|
+
def new(
|
|
240
|
+
cls,
|
|
241
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
242
|
+
identifier_value: int,
|
|
243
|
+
type: ResourceOperationStatusUpdateType,
|
|
244
|
+
) -> "StatusUpdateParameter": ...
|
|
245
|
+
@overload
|
|
246
|
+
@classmethod
|
|
247
|
+
def new(
|
|
248
|
+
cls,
|
|
249
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
250
|
+
identifier_value: UUID,
|
|
251
|
+
type: ResourceOperationStatusUpdateType,
|
|
252
|
+
) -> "StatusUpdateParameter": ...
|
|
253
|
+
@overload
|
|
254
|
+
@classmethod
|
|
255
|
+
def new(
|
|
256
|
+
cls,
|
|
257
|
+
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
258
|
+
identifier_value: CompositeIdentifierType,
|
|
259
|
+
type: ResourceOperationStatusUpdateType,
|
|
260
|
+
) -> "StatusUpdateParameter": ...
|
|
261
|
+
@overload
|
|
262
|
+
@classmethod
|
|
263
|
+
def new(
|
|
264
|
+
cls,
|
|
265
|
+
identifier_type: IdentifierType,
|
|
266
|
+
identifier_value: IdentifierValueType,
|
|
267
|
+
type: ResourceOperationStatusUpdateType,
|
|
268
|
+
) -> "StatusUpdateParameter": ...
|
|
269
|
+
@classmethod
|
|
270
|
+
def new(
|
|
271
|
+
cls,
|
|
272
|
+
identifier_type: IdentifierType,
|
|
273
|
+
identifier_value: IdentifierValueType,
|
|
274
|
+
type: ResourceOperationStatusUpdateType,
|
|
275
|
+
) -> "StatusUpdateParameter":
|
|
276
|
+
return cls(
|
|
277
|
+
identifier=OrganizationRelationIdentifier(
|
|
278
|
+
type=identifier_type, value=identifier_value
|
|
279
|
+
),
|
|
280
|
+
type=type,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
class DeleteSingleParameter(BaseDeleteSingleParameter[OrganizationRelationIdentifier]):
|
|
285
|
+
@overload
|
|
286
|
+
@classmethod
|
|
287
|
+
def new(
|
|
288
|
+
cls, identifier_type: Literal[IdentifierType.ID], identifier_value: int
|
|
289
|
+
) -> "DeleteSingleParameter": ...
|
|
290
|
+
@overload
|
|
291
|
+
@classmethod
|
|
292
|
+
def new(
|
|
293
|
+
cls, identifier_type: Literal[IdentifierType.UUID], identifier_value: UUID
|
|
294
|
+
) -> "DeleteSingleParameter": ...
|
|
295
|
+
@overload
|
|
296
|
+
@classmethod
|
|
297
|
+
def new(
|
|
298
|
+
cls,
|
|
299
|
+
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
300
|
+
identifier_value: CompositeIdentifierType,
|
|
301
|
+
) -> "DeleteSingleParameter": ...
|
|
302
|
+
@overload
|
|
303
|
+
@classmethod
|
|
304
|
+
def new(
|
|
305
|
+
cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
|
|
306
|
+
) -> "DeleteSingleParameter": ...
|
|
307
|
+
@classmethod
|
|
308
|
+
def new(
|
|
309
|
+
cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
|
|
310
|
+
) -> "DeleteSingleParameter":
|
|
311
|
+
return cls(
|
|
312
|
+
identifier=OrganizationRelationIdentifier(
|
|
313
|
+
type=identifier_type, value=identifier_value
|
|
314
|
+
)
|
|
315
|
+
)
|