maleo-identity 0.0.96__py3-none-any.whl → 0.0.99__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.
Potentially problematic release.
This version of maleo-identity might be problematic. Click here for more details.
- maleo/identity/constants/api_key.py +13 -0
- maleo/identity/constants/organization.py +0 -14
- maleo/identity/constants/organization_registration_code.py +0 -15
- maleo/identity/constants/organization_relation.py +13 -0
- maleo/identity/constants/patient.py +7 -0
- maleo/identity/constants/user.py +0 -15
- maleo/identity/constants/user_medical_role.py +13 -0
- maleo/identity/constants/user_organization_role.py +13 -0
- maleo/identity/constants/user_profile.py +0 -15
- maleo/identity/constants/user_system_role.py +13 -0
- maleo/identity/dtos.py +295 -0
- maleo/identity/enums/api_key.py +13 -0
- maleo/identity/enums/organization.py +5 -6
- maleo/identity/enums/organization_relation.py +12 -0
- maleo/identity/enums/patient.py +22 -0
- maleo/identity/enums/user.py +10 -6
- maleo/identity/enums/user_medical_role.py +12 -0
- maleo/identity/enums/user_organization_role.py +12 -0
- maleo/identity/enums/user_profile.py +9 -0
- maleo/identity/enums/user_system_role.py +12 -0
- maleo/identity/mixins/api_key.py +6 -0
- maleo/identity/mixins/common.py +29 -0
- maleo/identity/mixins/organization_relation.py +14 -0
- maleo/identity/mixins/patient.py +8 -0
- maleo/identity/mixins/user_profile.py +4 -21
- maleo/identity/models.py +89 -95
- maleo/identity/schemas/api_key.py +128 -0
- maleo/identity/schemas/common.py +152 -120
- maleo/identity/schemas/organization.py +39 -6
- maleo/identity/schemas/organization_registration_code.py +14 -5
- maleo/identity/schemas/organization_relation.py +178 -0
- maleo/identity/schemas/patient.py +234 -0
- maleo/identity/schemas/user.py +19 -4
- maleo/identity/schemas/user_medical_role.py +181 -0
- maleo/identity/schemas/user_organization_role.py +181 -0
- maleo/identity/schemas/user_profile.py +68 -10
- maleo/identity/schemas/user_system_role.py +174 -0
- maleo/identity/types/api_key.py +7 -0
- maleo/identity/types/organization.py +1 -2
- maleo/identity/types/organization_registration_code.py +1 -2
- maleo/identity/types/organization_relation.py +7 -0
- maleo/identity/types/patient.py +4 -0
- maleo/identity/types/user.py +1 -2
- maleo/identity/types/user_medical_role.py +7 -0
- maleo/identity/types/user_organization_role.py +7 -0
- maleo/identity/types/user_profile.py +1 -2
- maleo/identity/types/user_system_role.py +7 -0
- maleo/identity/utils/organization.py +33 -27
- maleo/identity/utils/user.py +33 -27
- maleo/identity/validators/__init__.py +0 -0
- maleo/identity/validators/patient.py +6 -0
- {maleo_identity-0.0.96.dist-info → maleo_identity-0.0.99.dist-info}/METADATA +2 -1
- maleo_identity-0.0.99.dist-info/RECORD +67 -0
- maleo_identity-0.0.96.dist-info/RECORD +0 -36
- {maleo_identity-0.0.96.dist-info → maleo_identity-0.0.99.dist-info}/WHEEL +0 -0
- {maleo_identity-0.0.96.dist-info → maleo_identity-0.0.99.dist-info}/licenses/LICENSE +0 -0
- {maleo_identity-0.0.96.dist-info → maleo_identity-0.0.99.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Generic, Literal, Tuple, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.organization import (
|
|
5
|
+
OrganizationRole,
|
|
6
|
+
OptOrganizationRole,
|
|
7
|
+
FullOrganizationRoleMixin,
|
|
8
|
+
OptListOfOrganizationRoles,
|
|
9
|
+
FullOrganizationRolesMixin,
|
|
10
|
+
)
|
|
11
|
+
from maleo.enums.status import (
|
|
12
|
+
ListOfDataStatuses,
|
|
13
|
+
FULL_DATA_STATUSES,
|
|
14
|
+
)
|
|
15
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
16
|
+
from maleo.schemas.mixins.identity import (
|
|
17
|
+
IdentifierTypeValue,
|
|
18
|
+
Ids,
|
|
19
|
+
UUIDs,
|
|
20
|
+
IntUserId,
|
|
21
|
+
IntUserIds,
|
|
22
|
+
IntOrganizationId,
|
|
23
|
+
IntOrganizationIds,
|
|
24
|
+
)
|
|
25
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
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.uuid import OptListOfUUIDs
|
|
35
|
+
from ..enums.user_organization_role import IdentifierType
|
|
36
|
+
from ..types.user_organization_role import IdentifierValueType
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CreateParameter(
|
|
40
|
+
FullOrganizationRoleMixin[OrganizationRole],
|
|
41
|
+
IntOrganizationId[int],
|
|
42
|
+
IntUserId[int],
|
|
43
|
+
):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ReadMultipleParameter(
|
|
48
|
+
ReadPaginatedMultipleParameter,
|
|
49
|
+
FullOrganizationRolesMixin[OptListOfOrganizationRoles],
|
|
50
|
+
IntOrganizationIds[OptListOfInts],
|
|
51
|
+
IntUserIds[OptListOfInts],
|
|
52
|
+
UUIDs[OptListOfUUIDs],
|
|
53
|
+
Ids[OptListOfInts],
|
|
54
|
+
):
|
|
55
|
+
@property
|
|
56
|
+
def _query_param_fields(self) -> set[str]:
|
|
57
|
+
return {
|
|
58
|
+
"ids",
|
|
59
|
+
"uuids",
|
|
60
|
+
"statuses",
|
|
61
|
+
"user_ids",
|
|
62
|
+
"organization_ids",
|
|
63
|
+
"organization_roles",
|
|
64
|
+
"search",
|
|
65
|
+
"page",
|
|
66
|
+
"limit",
|
|
67
|
+
"use_cache",
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
71
|
+
params = self.model_dump(
|
|
72
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
73
|
+
)
|
|
74
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
75
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
76
|
+
params = {k: v for k, v in params.items()}
|
|
77
|
+
return params
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
|
|
81
|
+
@overload
|
|
82
|
+
@classmethod
|
|
83
|
+
def new(
|
|
84
|
+
cls,
|
|
85
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
86
|
+
identifier_value: int,
|
|
87
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
88
|
+
use_cache: bool = True,
|
|
89
|
+
) -> "ReadSingleParameter": ...
|
|
90
|
+
@overload
|
|
91
|
+
@classmethod
|
|
92
|
+
def new(
|
|
93
|
+
cls,
|
|
94
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
95
|
+
identifier_value: UUID,
|
|
96
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
97
|
+
use_cache: bool = True,
|
|
98
|
+
) -> "ReadSingleParameter": ...
|
|
99
|
+
@overload
|
|
100
|
+
@classmethod
|
|
101
|
+
def new(
|
|
102
|
+
cls,
|
|
103
|
+
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
104
|
+
identifier_value: Tuple[int, int, OrganizationRole],
|
|
105
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
106
|
+
use_cache: bool = True,
|
|
107
|
+
) -> "ReadSingleParameter": ...
|
|
108
|
+
@overload
|
|
109
|
+
@classmethod
|
|
110
|
+
def new(
|
|
111
|
+
cls,
|
|
112
|
+
identifier_type: IdentifierType,
|
|
113
|
+
identifier_value: IdentifierValueType,
|
|
114
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
115
|
+
use_cache: bool = True,
|
|
116
|
+
) -> "ReadSingleParameter": ...
|
|
117
|
+
@classmethod
|
|
118
|
+
def new(
|
|
119
|
+
cls,
|
|
120
|
+
identifier_type: IdentifierType,
|
|
121
|
+
identifier_value: IdentifierValueType,
|
|
122
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
123
|
+
use_cache: bool = True,
|
|
124
|
+
) -> "ReadSingleParameter":
|
|
125
|
+
return cls(
|
|
126
|
+
identifier_type=identifier_type,
|
|
127
|
+
identifier_value=identifier_value,
|
|
128
|
+
statuses=statuses,
|
|
129
|
+
use_cache=use_cache,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
133
|
+
return self.model_dump(
|
|
134
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class FullUpdateData(
|
|
139
|
+
FullOrganizationRoleMixin[OrganizationRole],
|
|
140
|
+
IntOrganizationId[int],
|
|
141
|
+
IntUserId[int],
|
|
142
|
+
):
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class PartialUpdateData(
|
|
147
|
+
FullOrganizationRoleMixin[OptOrganizationRole],
|
|
148
|
+
IntOrganizationId[OptInt],
|
|
149
|
+
IntUserId[OptInt],
|
|
150
|
+
):
|
|
151
|
+
pass
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
158
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class UpdateParameter(
|
|
162
|
+
UpdateDataMixin[UpdateDataT],
|
|
163
|
+
IdentifierTypeValue[
|
|
164
|
+
IdentifierType,
|
|
165
|
+
IdentifierValueType,
|
|
166
|
+
],
|
|
167
|
+
Generic[UpdateDataT],
|
|
168
|
+
):
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class StatusUpdateParameter(
|
|
173
|
+
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
174
|
+
):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class DeleteSingleParameter(
|
|
179
|
+
BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
|
|
180
|
+
):
|
|
181
|
+
pass
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
|
-
from typing import Generic, Literal, TypeVar, overload
|
|
2
|
+
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from maleo.enums.identity import
|
|
4
|
+
from maleo.enums.identity import (
|
|
5
|
+
OptBloodType,
|
|
6
|
+
BloodTypeMixin,
|
|
7
|
+
OptListOfBloodTypes,
|
|
8
|
+
BloodTypesMixin,
|
|
9
|
+
OptGender,
|
|
10
|
+
GenderMixin,
|
|
11
|
+
OptListOfGenders,
|
|
12
|
+
GendersMixin,
|
|
13
|
+
)
|
|
5
14
|
from maleo.enums.status import (
|
|
6
15
|
ListOfDataStatuses,
|
|
7
16
|
FULL_DATA_STATUSES,
|
|
8
17
|
)
|
|
9
18
|
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
10
|
-
from maleo.schemas.mixins.identity import
|
|
19
|
+
from maleo.schemas.mixins.identity import (
|
|
20
|
+
IdentifierTypeValue,
|
|
21
|
+
Ids,
|
|
22
|
+
UUIDs,
|
|
23
|
+
IntUserId,
|
|
24
|
+
IntOrganizationIds,
|
|
25
|
+
BirthDate,
|
|
26
|
+
)
|
|
11
27
|
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
12
28
|
from maleo.schemas.parameter import (
|
|
13
29
|
ReadSingleParameter as BaseReadSingleParameter,
|
|
@@ -20,22 +36,29 @@ from maleo.types.dict import StrToAnyDict
|
|
|
20
36
|
from maleo.types.integer import OptListOfInts
|
|
21
37
|
from maleo.types.string import OptStr
|
|
22
38
|
from maleo.types.uuid import OptListOfUUIDs
|
|
23
|
-
from ..enums.user_profile import IdentifierType
|
|
24
|
-
from ..mixins.
|
|
39
|
+
from ..enums.user_profile import IdentifierType, OptListOfExpandableFields
|
|
40
|
+
from ..mixins.common import (
|
|
25
41
|
IdCard,
|
|
42
|
+
FullName,
|
|
43
|
+
BirthPlace,
|
|
44
|
+
)
|
|
45
|
+
from ..mixins.user_profile import (
|
|
26
46
|
LeadingTitle,
|
|
27
47
|
FirstName,
|
|
28
48
|
MiddleName,
|
|
29
49
|
LastName,
|
|
30
50
|
EndingTitle,
|
|
31
|
-
FullName,
|
|
32
|
-
BirthPlace,
|
|
33
|
-
BirthDate,
|
|
34
51
|
AvatarName,
|
|
35
52
|
)
|
|
36
53
|
from ..types.user_profile import IdentifierValueType
|
|
37
54
|
|
|
38
55
|
|
|
56
|
+
class Expand(BaseModel):
|
|
57
|
+
expand: Annotated[
|
|
58
|
+
OptListOfExpandableFields, Field(None, description="Expand", min_length=1)
|
|
59
|
+
] = None
|
|
60
|
+
|
|
61
|
+
|
|
39
62
|
class CoreCreateData(
|
|
40
63
|
BloodTypeMixin[OptBloodType],
|
|
41
64
|
GenderMixin[OptGender],
|
|
@@ -76,21 +99,47 @@ class InsertData(
|
|
|
76
99
|
pass
|
|
77
100
|
|
|
78
101
|
|
|
102
|
+
class CreateParameter(
|
|
103
|
+
AvatarName[str],
|
|
104
|
+
BloodTypeMixin[OptBloodType],
|
|
105
|
+
GenderMixin[OptGender],
|
|
106
|
+
BirthDate[OptDate],
|
|
107
|
+
BirthPlace[OptStr],
|
|
108
|
+
FullName[str],
|
|
109
|
+
EndingTitle[OptStr],
|
|
110
|
+
LastName[str],
|
|
111
|
+
MiddleName[OptStr],
|
|
112
|
+
FirstName[str],
|
|
113
|
+
LeadingTitle[OptStr],
|
|
114
|
+
IdCard[OptStr],
|
|
115
|
+
IntUserId[int],
|
|
116
|
+
):
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
|
|
79
120
|
class ReadMultipleParameter(
|
|
121
|
+
Expand,
|
|
80
122
|
ReadPaginatedMultipleParameter,
|
|
123
|
+
BloodTypesMixin[OptListOfBloodTypes],
|
|
124
|
+
GendersMixin[OptListOfGenders],
|
|
81
125
|
UUIDs[OptListOfUUIDs],
|
|
82
126
|
Ids[OptListOfInts],
|
|
127
|
+
IntOrganizationIds[OptListOfInts],
|
|
83
128
|
):
|
|
84
129
|
@property
|
|
85
130
|
def _query_param_fields(self) -> set[str]:
|
|
86
131
|
return {
|
|
132
|
+
"organization_ids",
|
|
87
133
|
"ids",
|
|
88
134
|
"uuids",
|
|
89
135
|
"statuses",
|
|
136
|
+
"genders",
|
|
137
|
+
"blood_types",
|
|
90
138
|
"search",
|
|
91
139
|
"page",
|
|
92
140
|
"limit",
|
|
93
141
|
"use_cache",
|
|
142
|
+
"expand",
|
|
94
143
|
}
|
|
95
144
|
|
|
96
145
|
def to_query_params(self) -> StrToAnyDict:
|
|
@@ -103,7 +152,9 @@ class ReadMultipleParameter(
|
|
|
103
152
|
return params
|
|
104
153
|
|
|
105
154
|
|
|
106
|
-
class ReadSingleParameter(
|
|
155
|
+
class ReadSingleParameter(
|
|
156
|
+
Expand, BaseReadSingleParameter[IdentifierType, IdentifierValueType]
|
|
157
|
+
):
|
|
107
158
|
@overload
|
|
108
159
|
@classmethod
|
|
109
160
|
def new(
|
|
@@ -112,6 +163,7 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
112
163
|
identifier_value: int,
|
|
113
164
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
114
165
|
use_cache: bool = True,
|
|
166
|
+
expand: OptListOfExpandableFields = None,
|
|
115
167
|
) -> "ReadSingleParameter": ...
|
|
116
168
|
@overload
|
|
117
169
|
@classmethod
|
|
@@ -121,6 +173,7 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
121
173
|
identifier_value: UUID,
|
|
122
174
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
123
175
|
use_cache: bool = True,
|
|
176
|
+
expand: OptListOfExpandableFields = None,
|
|
124
177
|
) -> "ReadSingleParameter": ...
|
|
125
178
|
@overload
|
|
126
179
|
@classmethod
|
|
@@ -130,6 +183,7 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
130
183
|
identifier_value: str,
|
|
131
184
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
132
185
|
use_cache: bool = True,
|
|
186
|
+
expand: OptListOfExpandableFields = None,
|
|
133
187
|
) -> "ReadSingleParameter": ...
|
|
134
188
|
@classmethod
|
|
135
189
|
def new(
|
|
@@ -138,17 +192,19 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
138
192
|
identifier_value: IdentifierValueType,
|
|
139
193
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
140
194
|
use_cache: bool = True,
|
|
195
|
+
expand: OptListOfExpandableFields = None,
|
|
141
196
|
) -> "ReadSingleParameter":
|
|
142
197
|
return cls(
|
|
143
198
|
identifier_type=identifier_type,
|
|
144
199
|
identifier_value=identifier_value,
|
|
145
200
|
statuses=statuses,
|
|
146
201
|
use_cache=use_cache,
|
|
202
|
+
expand=expand,
|
|
147
203
|
)
|
|
148
204
|
|
|
149
205
|
def to_query_params(self) -> StrToAnyDict:
|
|
150
206
|
return self.model_dump(
|
|
151
|
-
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
207
|
+
mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
|
|
152
208
|
)
|
|
153
209
|
|
|
154
210
|
|
|
@@ -190,6 +246,7 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
|
190
246
|
|
|
191
247
|
|
|
192
248
|
class UpdateParameter(
|
|
249
|
+
Expand,
|
|
193
250
|
UpdateDataMixin[UpdateDataT],
|
|
194
251
|
IdentifierTypeValue[
|
|
195
252
|
IdentifierType,
|
|
@@ -201,6 +258,7 @@ class UpdateParameter(
|
|
|
201
258
|
|
|
202
259
|
|
|
203
260
|
class StatusUpdateParameter(
|
|
261
|
+
Expand,
|
|
204
262
|
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
205
263
|
):
|
|
206
264
|
pass
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Generic, Literal, Tuple, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.system import (
|
|
5
|
+
SystemRole,
|
|
6
|
+
OptSystemRole,
|
|
7
|
+
FullSystemRoleMixin,
|
|
8
|
+
OptListOfSystemRoles,
|
|
9
|
+
FullSystemRolesMixin,
|
|
10
|
+
)
|
|
11
|
+
from maleo.enums.status import (
|
|
12
|
+
ListOfDataStatuses,
|
|
13
|
+
FULL_DATA_STATUSES,
|
|
14
|
+
)
|
|
15
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
16
|
+
from maleo.schemas.mixins.identity import (
|
|
17
|
+
IdentifierTypeValue,
|
|
18
|
+
Ids,
|
|
19
|
+
UUIDs,
|
|
20
|
+
IntUserId,
|
|
21
|
+
IntUserIds,
|
|
22
|
+
)
|
|
23
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
24
|
+
from maleo.schemas.parameter import (
|
|
25
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
26
|
+
ReadPaginatedMultipleParameter,
|
|
27
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
28
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
29
|
+
)
|
|
30
|
+
from maleo.types.dict import StrToAnyDict
|
|
31
|
+
from maleo.types.integer import OptInt, OptListOfInts
|
|
32
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
33
|
+
from ..enums.user_system_role import IdentifierType
|
|
34
|
+
from ..types.user_system_role import IdentifierValueType
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class CreateParameter(
|
|
38
|
+
FullSystemRoleMixin[SystemRole],
|
|
39
|
+
IntUserId[int],
|
|
40
|
+
):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ReadMultipleParameter(
|
|
45
|
+
ReadPaginatedMultipleParameter,
|
|
46
|
+
FullSystemRolesMixin[OptListOfSystemRoles],
|
|
47
|
+
IntUserIds[OptListOfInts],
|
|
48
|
+
UUIDs[OptListOfUUIDs],
|
|
49
|
+
Ids[OptListOfInts],
|
|
50
|
+
):
|
|
51
|
+
@property
|
|
52
|
+
def _query_param_fields(self) -> set[str]:
|
|
53
|
+
return {
|
|
54
|
+
"ids",
|
|
55
|
+
"uuids",
|
|
56
|
+
"statuses",
|
|
57
|
+
"user_ids",
|
|
58
|
+
"system_roles",
|
|
59
|
+
"search",
|
|
60
|
+
"page",
|
|
61
|
+
"limit",
|
|
62
|
+
"use_cache",
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
66
|
+
params = self.model_dump(
|
|
67
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
68
|
+
)
|
|
69
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
70
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
71
|
+
params = {k: v for k, v in params.items()}
|
|
72
|
+
return params
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
|
|
76
|
+
@overload
|
|
77
|
+
@classmethod
|
|
78
|
+
def new(
|
|
79
|
+
cls,
|
|
80
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
81
|
+
identifier_value: int,
|
|
82
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
83
|
+
use_cache: bool = True,
|
|
84
|
+
) -> "ReadSingleParameter": ...
|
|
85
|
+
@overload
|
|
86
|
+
@classmethod
|
|
87
|
+
def new(
|
|
88
|
+
cls,
|
|
89
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
90
|
+
identifier_value: UUID,
|
|
91
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
92
|
+
use_cache: bool = True,
|
|
93
|
+
) -> "ReadSingleParameter": ...
|
|
94
|
+
@overload
|
|
95
|
+
@classmethod
|
|
96
|
+
def new(
|
|
97
|
+
cls,
|
|
98
|
+
identifier_type: Literal[IdentifierType.COMPOSITE],
|
|
99
|
+
identifier_value: Tuple[int, SystemRole],
|
|
100
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
101
|
+
use_cache: bool = True,
|
|
102
|
+
) -> "ReadSingleParameter": ...
|
|
103
|
+
@overload
|
|
104
|
+
@classmethod
|
|
105
|
+
def new(
|
|
106
|
+
cls,
|
|
107
|
+
identifier_type: IdentifierType,
|
|
108
|
+
identifier_value: IdentifierValueType,
|
|
109
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
110
|
+
use_cache: bool = True,
|
|
111
|
+
) -> "ReadSingleParameter": ...
|
|
112
|
+
@classmethod
|
|
113
|
+
def new(
|
|
114
|
+
cls,
|
|
115
|
+
identifier_type: IdentifierType,
|
|
116
|
+
identifier_value: IdentifierValueType,
|
|
117
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
118
|
+
use_cache: bool = True,
|
|
119
|
+
) -> "ReadSingleParameter":
|
|
120
|
+
return cls(
|
|
121
|
+
identifier_type=identifier_type,
|
|
122
|
+
identifier_value=identifier_value,
|
|
123
|
+
statuses=statuses,
|
|
124
|
+
use_cache=use_cache,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
128
|
+
return self.model_dump(
|
|
129
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class FullUpdateData(
|
|
134
|
+
FullSystemRoleMixin[SystemRole],
|
|
135
|
+
IntUserId[int],
|
|
136
|
+
):
|
|
137
|
+
pass
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class PartialUpdateData(
|
|
141
|
+
FullSystemRoleMixin[OptSystemRole],
|
|
142
|
+
IntUserId[OptInt],
|
|
143
|
+
):
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
151
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class UpdateParameter(
|
|
155
|
+
UpdateDataMixin[UpdateDataT],
|
|
156
|
+
IdentifierTypeValue[
|
|
157
|
+
IdentifierType,
|
|
158
|
+
IdentifierValueType,
|
|
159
|
+
],
|
|
160
|
+
Generic[UpdateDataT],
|
|
161
|
+
):
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class StatusUpdateParameter(
|
|
166
|
+
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
167
|
+
):
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class DeleteSingleParameter(
|
|
172
|
+
BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
|
|
173
|
+
):
|
|
174
|
+
pass
|
maleo/identity/types/user.py
CHANGED