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
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
from
|
|
2
|
-
from uuid import UUID
|
|
3
|
-
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
4
|
-
from maleo.identity.enums.organization import IdentifierType
|
|
5
|
-
from maleo.identity.types.base.organization import IdentifierValueType
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
6
2
|
|
|
7
|
-
IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
|
|
8
|
-
IdentifierType, Callable[..., IdentifierValueType]
|
|
9
|
-
] = {IdentifierType.ID: int, IdentifierType.UUID: UUID, IdentifierType.KEY: str}
|
|
10
3
|
|
|
11
|
-
|
|
4
|
+
ORGANIZATION_RESOURCE = Resource(
|
|
12
5
|
identifiers=[
|
|
13
6
|
ResourceIdentifier(
|
|
14
|
-
key="
|
|
7
|
+
key="organization", name="Organization", slug="organizations"
|
|
15
8
|
)
|
|
16
9
|
],
|
|
17
10
|
details=None,
|
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
from
|
|
2
|
-
from uuid import UUID
|
|
3
|
-
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
4
|
-
from maleo.identity.enums.organization_registration_code import IdentifierType
|
|
5
|
-
from maleo.identity.types.base.organization_registration_code import IdentifierValueType
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
6
2
|
|
|
7
|
-
IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
|
|
8
|
-
IdentifierType, Callable[..., IdentifierValueType]
|
|
9
|
-
] = {
|
|
10
|
-
IdentifierType.ID: int,
|
|
11
|
-
IdentifierType.UUID: UUID,
|
|
12
|
-
IdentifierType.ORGANIZATION_ID: int,
|
|
13
|
-
IdentifierType.CODE: UUID,
|
|
14
|
-
}
|
|
15
3
|
|
|
16
|
-
|
|
4
|
+
ORGANIZATION_REGISTRATION_CODE_RESOURCE = Resource(
|
|
17
5
|
identifiers=[
|
|
18
6
|
ResourceIdentifier(
|
|
19
|
-
key="
|
|
20
|
-
name="Organization Registration
|
|
21
|
-
|
|
7
|
+
key="organization_registration_code",
|
|
8
|
+
name="Organization Registration Code",
|
|
9
|
+
slug="organization-registration-codes",
|
|
22
10
|
)
|
|
23
11
|
],
|
|
24
12
|
details=None,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
ORGANIZATION_RELATION_RESOURCE = Resource(
|
|
5
|
+
identifiers=[
|
|
6
|
+
ResourceIdentifier(
|
|
7
|
+
key="organization_relation",
|
|
8
|
+
name="Organization Relation",
|
|
9
|
+
slug="organization-relations",
|
|
10
|
+
)
|
|
11
|
+
],
|
|
12
|
+
details=None,
|
|
13
|
+
)
|
maleo/identity/constants/user.py
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
from
|
|
2
|
-
from uuid import UUID
|
|
3
|
-
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
4
|
-
from maleo.identity.enums.user import IdentifierType, ExpandableField
|
|
5
|
-
from maleo.identity.types.base.user import IdentifierValueType
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
6
2
|
|
|
7
|
-
IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
|
|
8
|
-
IdentifierType, Callable[..., IdentifierValueType]
|
|
9
|
-
] = {
|
|
10
|
-
IdentifierType.ID: int,
|
|
11
|
-
IdentifierType.UUID: UUID,
|
|
12
|
-
IdentifierType.USERNAME: str,
|
|
13
|
-
IdentifierType.EMAIL: str,
|
|
14
|
-
}
|
|
15
3
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ExpandableField.SYSTEM_ROLES: [ExpandableField.SYSTEM_ROLE_DETAILS],
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
RESOURCE = Resource(
|
|
22
|
-
identifiers=[ResourceIdentifier(key="users", name="Users", url_slug="users")],
|
|
4
|
+
USER_RESOURCE = Resource(
|
|
5
|
+
identifiers=[ResourceIdentifier(key="user", name="User", slug="users")],
|
|
23
6
|
details=None,
|
|
24
7
|
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
USER_MEDICAL_ROLE_RESOURCE = Resource(
|
|
5
|
+
identifiers=[
|
|
6
|
+
ResourceIdentifier(
|
|
7
|
+
key="user_medical_role",
|
|
8
|
+
name="User Medical Role",
|
|
9
|
+
slug="user-medical-roles",
|
|
10
|
+
)
|
|
11
|
+
],
|
|
12
|
+
details=None,
|
|
13
|
+
)
|
|
@@ -1,46 +1,12 @@
|
|
|
1
|
-
from
|
|
2
|
-
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
3
|
-
from maleo.identity.enums.user import ExpandableField as UserExpandableField
|
|
4
|
-
from maleo.identity.enums.organization import (
|
|
5
|
-
ExpandableField as OrganizationExpandableField,
|
|
6
|
-
)
|
|
7
|
-
from maleo.identity.enums.user_organization_role import (
|
|
8
|
-
ExpandableField as UserOrganizationRoleExpandableField,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[
|
|
12
|
-
UserOrganizationRoleExpandableField, List[UserOrganizationRoleExpandableField]
|
|
13
|
-
] = {
|
|
14
|
-
UserOrganizationRoleExpandableField.USER: [
|
|
15
|
-
UserOrganizationRoleExpandableField.USER_TYPE,
|
|
16
|
-
UserOrganizationRoleExpandableField.PROFILE,
|
|
17
|
-
],
|
|
18
|
-
UserOrganizationRoleExpandableField.ORGANIZATION: [
|
|
19
|
-
UserOrganizationRoleExpandableField.ORGANIZATION_TYPE,
|
|
20
|
-
UserOrganizationRoleExpandableField.REGISTRATION_CODE,
|
|
21
|
-
],
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
USER_EXPANDABLE_FIELDS_MAP: Dict[
|
|
25
|
-
UserOrganizationRoleExpandableField, UserExpandableField
|
|
26
|
-
] = {
|
|
27
|
-
UserOrganizationRoleExpandableField.USER_TYPE: UserExpandableField.USER_TYPE,
|
|
28
|
-
UserOrganizationRoleExpandableField.PROFILE: UserExpandableField.PROFILE,
|
|
29
|
-
}
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
30
2
|
|
|
31
|
-
ORGANIZATION_EXPANDABLE_FIELDS_MAP: Dict[
|
|
32
|
-
UserOrganizationRoleExpandableField, OrganizationExpandableField
|
|
33
|
-
] = {
|
|
34
|
-
UserOrganizationRoleExpandableField.ORGANIZATION_TYPE: OrganizationExpandableField.ORGANIZATION_TYPE,
|
|
35
|
-
UserOrganizationRoleExpandableField.REGISTRATION_CODE: OrganizationExpandableField.REGISTRATION_CODE,
|
|
36
|
-
}
|
|
37
3
|
|
|
38
|
-
|
|
4
|
+
USER_ORGANIZATION_ROLE_RESOURCE = Resource(
|
|
39
5
|
identifiers=[
|
|
40
6
|
ResourceIdentifier(
|
|
41
|
-
key="
|
|
42
|
-
name="
|
|
43
|
-
|
|
7
|
+
key="user_organization_role",
|
|
8
|
+
name="User Organization Role",
|
|
9
|
+
slug="user-organization-roles",
|
|
44
10
|
)
|
|
45
11
|
],
|
|
46
12
|
details=None,
|
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
from
|
|
2
|
-
from uuid import UUID
|
|
3
|
-
from maleo.soma.schemas.resource import Resource, ResourceIdentifier
|
|
4
|
-
from maleo.identity.enums.user_profile import IdentifierType, ValidImageMimeType
|
|
5
|
-
from maleo.identity.types.base.user_profile import IdentifierValueType
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
6
2
|
|
|
7
|
-
IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
|
|
8
|
-
IdentifierType, Callable[..., IdentifierValueType]
|
|
9
|
-
] = {
|
|
10
|
-
IdentifierType.ID: int,
|
|
11
|
-
IdentifierType.UUID: UUID,
|
|
12
|
-
IdentifierType.USER_ID: int,
|
|
13
|
-
IdentifierType.ID_CARD: str,
|
|
14
|
-
}
|
|
15
3
|
|
|
16
|
-
|
|
17
|
-
ValidImageMimeType.JPEG: ".jpeg",
|
|
18
|
-
ValidImageMimeType.JPG: ".jpg",
|
|
19
|
-
ValidImageMimeType.PNG: ".png",
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
RESOURCE = Resource(
|
|
4
|
+
USER_PROFILE_RESOURCE = Resource(
|
|
23
5
|
identifiers=[
|
|
24
6
|
ResourceIdentifier(
|
|
25
|
-
key="
|
|
7
|
+
key="user_profile", name="User Profile", slug="user-profiles"
|
|
26
8
|
)
|
|
27
9
|
],
|
|
28
10
|
details=None,
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
from
|
|
2
|
-
from maleo.
|
|
3
|
-
from maleo.identity.enums.user_system_role import ExpandableField
|
|
1
|
+
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
2
|
+
from maleo.types.string import DoubleStrs
|
|
4
3
|
|
|
5
|
-
EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[ExpandableField, List[ExpandableField]] = {}
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
USER_SYSTEM_ROLE_RESOURCE = Resource(
|
|
8
6
|
identifiers=[
|
|
9
7
|
ResourceIdentifier(
|
|
10
|
-
key="
|
|
11
|
-
name="User System
|
|
12
|
-
|
|
8
|
+
key="user_system_role",
|
|
9
|
+
name="User System Role",
|
|
10
|
+
slug="user-system-roles",
|
|
13
11
|
)
|
|
14
12
|
],
|
|
15
13
|
details=None,
|
|
16
14
|
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
COMPOSITE_COLUMS: DoubleStrs = ("user_id", "system_role")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
API_KEY = "api_key"
|
|
9
|
+
COMPOSITE = "composite"
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def choices(cls) -> ListOfStrs:
|
|
13
|
+
return [e.value for e in cls]
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def columns(self) -> ManyStrs:
|
|
17
|
+
if self is IdentifierType.ID:
|
|
18
|
+
return ("id",)
|
|
19
|
+
elif self is IdentifierType.UUID:
|
|
20
|
+
return ("uuid",)
|
|
21
|
+
elif self is IdentifierType.API_KEY:
|
|
22
|
+
return ("api_key",)
|
|
23
|
+
elif self is IdentifierType.COMPOSITE:
|
|
24
|
+
return ("user_id", "organization_id")
|
|
25
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Granularity(StrEnum):
|
|
6
|
+
STANDARD = "standard"
|
|
7
|
+
FULL = "full"
|
|
8
|
+
|
|
9
|
+
@classmethod
|
|
10
|
+
def choices(cls) -> ListOfStrs:
|
|
11
|
+
return [e.value for e in cls]
|
|
2
12
|
|
|
3
13
|
|
|
4
14
|
class IdentifierType(StrEnum):
|
|
@@ -6,7 +16,10 @@ class IdentifierType(StrEnum):
|
|
|
6
16
|
UUID = "uuid"
|
|
7
17
|
KEY = "key"
|
|
8
18
|
|
|
19
|
+
@classmethod
|
|
20
|
+
def choices(cls) -> ListOfStrs:
|
|
21
|
+
return [e.value for e in cls]
|
|
9
22
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
@property
|
|
24
|
+
def column(self) -> str:
|
|
25
|
+
return self.value
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class IdentifierType(StrEnum):
|
|
@@ -6,3 +7,11 @@ class IdentifierType(StrEnum):
|
|
|
6
7
|
UUID = "uuid"
|
|
7
8
|
ORGANIZATION_ID = "organization_id"
|
|
8
9
|
CODE = "code"
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def choices(cls) -> ListOfStrs:
|
|
13
|
+
return [e.value for e in cls]
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def column(self) -> str:
|
|
17
|
+
return self.value
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
COMPOSITE = "composite"
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def choices(cls) -> ListOfStrs:
|
|
12
|
+
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("source_id", "target_id", "relation")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
|
|
9
|
+
@classmethod
|
|
10
|
+
def choices(cls) -> ListOfStrs:
|
|
11
|
+
return [e.value for e in cls]
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def column(self) -> str:
|
|
15
|
+
return self.value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ExpandableField(StrEnum):
|
|
19
|
+
GENDER = "gender"
|
|
20
|
+
BLOOD_TYPE = "blood_type"
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def choices(cls) -> ListOfStrs:
|
|
24
|
+
return [e.value for e in cls]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
OptExpandableField = ExpandableField | None
|
|
28
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
29
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
maleo/identity/enums/user.py
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Granularity(StrEnum):
|
|
6
|
+
STANDARD = "standard"
|
|
7
|
+
FULL = "full"
|
|
8
|
+
|
|
9
|
+
@classmethod
|
|
10
|
+
def choices(cls) -> ListOfStrs:
|
|
11
|
+
return [e.value for e in cls]
|
|
2
12
|
|
|
3
13
|
|
|
4
14
|
class IdentifierType(StrEnum):
|
|
@@ -7,11 +17,10 @@ class IdentifierType(StrEnum):
|
|
|
7
17
|
USERNAME = "username"
|
|
8
18
|
EMAIL = "email"
|
|
9
19
|
|
|
20
|
+
@classmethod
|
|
21
|
+
def choices(cls) -> ListOfStrs:
|
|
22
|
+
return [e.value for e in cls]
|
|
10
23
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
|
|
15
|
-
PROFILE = "profile"
|
|
16
|
-
GENDER = "profile.gender"
|
|
17
|
-
BLOOD_TYPE = "profile.blood_type"
|
|
24
|
+
@property
|
|
25
|
+
def column(self) -> str:
|
|
26
|
+
return self.value
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
COMPOSITE = "composite"
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def choices(cls) -> ListOfStrs:
|
|
12
|
+
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "organization_id", "medical_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
2
3
|
|
|
3
4
|
|
|
4
|
-
class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
COMPOSITE = "composite"
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def choices(cls) -> ListOfStrs:
|
|
12
|
+
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "organization_id", "organization_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class IdentifierType(StrEnum):
|
|
@@ -7,13 +8,10 @@ class IdentifierType(StrEnum):
|
|
|
7
8
|
USER_ID = "user_id"
|
|
8
9
|
ID_CARD = "id_card"
|
|
9
10
|
|
|
11
|
+
@classmethod
|
|
12
|
+
def choices(cls) -> ListOfStrs:
|
|
13
|
+
return [e.value for e in cls]
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
PNG = "image/png"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class ExpandableField(StrEnum):
|
|
18
|
-
GENDER = "gender"
|
|
19
|
-
BLOOD_TYPE = "blood_type"
|
|
15
|
+
@property
|
|
16
|
+
def column(self) -> str:
|
|
17
|
+
return self.value
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
COMPOSITE = "composite"
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def choices(cls) -> ListOfStrs:
|
|
12
|
+
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "system_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
2
23
|
|
|
3
24
|
|
|
4
25
|
class ExpandableField(StrEnum):
|
|
5
26
|
SYSTEM_ROLE = "system_role"
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def choices(cls) -> ListOfStrs:
|
|
30
|
+
return [e.value for e in cls]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
OptExpandableField = ExpandableField | None
|
|
34
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
35
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Literal, TypeGuard
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.schemas.mixins.identity import Identifier
|
|
5
|
+
from maleo.types.any import ManyAny
|
|
6
|
+
from maleo.types.string import ManyStrs
|
|
7
|
+
from ..enums.api_key import IdentifierType
|
|
8
|
+
from ..types.api_key import CompositeIdentifierType, IdentifierValueType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class APIKey(BaseModel):
|
|
12
|
+
api_key: Annotated[str, Field(..., description="API Key", max_length=255)]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class APIKeyIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
16
|
+
@property
|
|
17
|
+
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
18
|
+
values = self.value if isinstance(self.value, tuple) else (self.value,)
|
|
19
|
+
return self.type.columns, values
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class IdAPIKeyIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
23
|
+
type: Annotated[
|
|
24
|
+
Literal[IdentifierType.ID],
|
|
25
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
26
|
+
] = IdentifierType.ID
|
|
27
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class UUIDAPIKeyIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
31
|
+
type: Annotated[
|
|
32
|
+
Literal[IdentifierType.UUID],
|
|
33
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
34
|
+
] = IdentifierType.UUID
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class CompositeAPIKeyIdentifier(
|
|
38
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
39
|
+
):
|
|
40
|
+
type: Annotated[
|
|
41
|
+
Literal[IdentifierType.COMPOSITE],
|
|
42
|
+
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
43
|
+
] = IdentifierType.COMPOSITE
|
|
44
|
+
value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
AnyAPIKeyIdentifier = (
|
|
48
|
+
APIKeyIdentifier
|
|
49
|
+
| IdAPIKeyIdentifier
|
|
50
|
+
| UUIDAPIKeyIdentifier
|
|
51
|
+
| CompositeAPIKeyIdentifier
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def is_id_identifier(
|
|
56
|
+
identifier: AnyAPIKeyIdentifier,
|
|
57
|
+
) -> TypeGuard[IdAPIKeyIdentifier]:
|
|
58
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def is_uuid_identifier(
|
|
62
|
+
identifier: AnyAPIKeyIdentifier,
|
|
63
|
+
) -> TypeGuard[UUIDAPIKeyIdentifier]:
|
|
64
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def is_composite_identifier(
|
|
68
|
+
identifier: AnyAPIKeyIdentifier,
|
|
69
|
+
) -> TypeGuard[CompositeAPIKeyIdentifier]:
|
|
70
|
+
return identifier.type is IdentifierType.COMPOSITE and isinstance(
|
|
71
|
+
identifier.value, tuple
|
|
72
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
from typing import Annotated, Generic
|
|
3
|
+
from maleo.schemas.mixins.identity import (
|
|
4
|
+
IdCard as BaseIdCard,
|
|
5
|
+
FullName as BaseFullName,
|
|
6
|
+
BirthPlace as BaseBirthPlace,
|
|
7
|
+
PlaceOfBirth as BasePlaceOfBirth,
|
|
8
|
+
)
|
|
9
|
+
from maleo.types.string import OptStrT
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class IdCard(BaseIdCard[OptStrT], Generic[OptStrT]):
|
|
13
|
+
id_card: Annotated[OptStrT, Field(..., description="Id Card", max_length=16)]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FullName(BaseFullName[OptStrT], Generic[OptStrT]):
|
|
17
|
+
full_name: Annotated[OptStrT, Field(..., description="Full Name", max_length=200)]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BirthPlace(BaseBirthPlace[OptStrT], Generic[OptStrT]):
|
|
21
|
+
birth_place: Annotated[
|
|
22
|
+
OptStrT, Field(..., description="Birth Place", max_length=50)
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class PlaceOfBirth(BasePlaceOfBirth[OptStrT], Generic[OptStrT]):
|
|
27
|
+
place_of_birth: Annotated[
|
|
28
|
+
OptStrT, Field(..., description="Place of Birth", max_length=50)
|
|
29
|
+
]
|