maleo-identity 0.1.4__tar.gz → 0.1.14__tar.gz
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-0.1.4 → maleo_identity-0.1.14}/PKG-INFO +7 -8
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/maleo_identity.egg-info/PKG-INFO +7 -8
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/maleo_identity.egg-info/SOURCES.txt +3 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/maleo_identity.egg-info/requires.txt +6 -7
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/pyproject.toml +7 -8
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/api_key.py +2 -2
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/organization.py +1 -1
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/organization_registration_code.py +2 -2
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/organization_relation.py +2 -2
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/patient.py +1 -1
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/user.py +1 -1
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/user_medical_role.py +2 -2
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/user_organization_role.py +2 -2
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/user_profile.py +1 -1
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/user_system_role.py +6 -2
- maleo_identity-0.1.14/src/enums/api_key.py +25 -0
- maleo_identity-0.1.14/src/enums/organization_relation.py +22 -0
- maleo_identity-0.1.14/src/enums/user_medical_role.py +22 -0
- maleo_identity-0.1.14/src/enums/user_organization_role.py +22 -0
- maleo_identity-0.1.14/src/enums/user_system_role.py +22 -0
- maleo_identity-0.1.14/src/mixins/api_key.py +72 -0
- maleo_identity-0.1.14/src/mixins/organization.py +73 -0
- maleo_identity-0.1.14/src/mixins/organization_registration_code.py +100 -0
- maleo_identity-0.1.14/src/mixins/organization_relation.py +80 -0
- maleo_identity-0.1.14/src/mixins/patient.py +96 -0
- maleo_identity-0.1.14/src/mixins/user.py +107 -0
- maleo_identity-0.1.14/src/mixins/user_medical_role.py +68 -0
- maleo_identity-0.1.14/src/mixins/user_organization_role.py +70 -0
- maleo_identity-0.1.14/src/mixins/user_profile.py +117 -0
- maleo_identity-0.1.14/src/mixins/user_system_role.py +68 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/models.py +8 -4
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/api_key.py +36 -10
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/common.py +3 -4
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/organization.py +131 -16
- maleo_identity-0.1.14/src/schemas/organization_registration_code.py +297 -0
- maleo_identity-0.1.14/src/schemas/organization_relation.py +297 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/patient.py +140 -21
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/user.py +126 -16
- maleo_identity-0.1.14/src/schemas/user_medical_role.py +297 -0
- maleo_identity-0.1.14/src/schemas/user_organization_role.py +298 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/user_profile.py +134 -58
- maleo_identity-0.1.14/src/schemas/user_system_role.py +298 -0
- maleo_identity-0.1.4/src/enums/api_key.py +0 -13
- maleo_identity-0.1.4/src/enums/organization_relation.py +0 -12
- maleo_identity-0.1.4/src/enums/user_medical_role.py +0 -12
- maleo_identity-0.1.4/src/enums/user_organization_role.py +0 -12
- maleo_identity-0.1.4/src/enums/user_system_role.py +0 -12
- maleo_identity-0.1.4/src/mixins/api_key.py +0 -6
- maleo_identity-0.1.4/src/mixins/organization.py +0 -17
- maleo_identity-0.1.4/src/mixins/organization_registration_code.py +0 -16
- maleo_identity-0.1.4/src/mixins/organization_relation.py +0 -12
- maleo_identity-0.1.4/src/mixins/patient.py +0 -20
- maleo_identity-0.1.4/src/mixins/user.py +0 -33
- maleo_identity-0.1.4/src/mixins/user_profile.py +0 -41
- maleo_identity-0.1.4/src/schemas/organization_registration_code.py +0 -171
- maleo_identity-0.1.4/src/schemas/organization_relation.py +0 -178
- maleo_identity-0.1.4/src/schemas/user_medical_role.py +0 -181
- maleo_identity-0.1.4/src/schemas/user_organization_role.py +0 -181
- maleo_identity-0.1.4/src/schemas/user_system_role.py +0 -174
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/LICENSE +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/README.md +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/maleo_identity.egg-info/dependency_links.txt +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/maleo_identity.egg-info/top_level.txt +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/setup.cfg +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/enums/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/enums/organization.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/enums/organization_registration_code.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/enums/patient.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/enums/user.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/enums/user_profile.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/mixins/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/mixins/common.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/schemas/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/api_key.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/organization.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/organization_registration_code.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/organization_relation.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/patient.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/user.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/user_medical_role.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/user_organization_role.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/user_profile.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/types/user_system_role.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/utils/__init__.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/utils/organization.py +0 -0
- {maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/utils/user.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maleo-identity
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: MaleoIdentity service package
|
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -41,13 +41,12 @@ Requires-Dist: identify>=2.6.15
|
|
|
41
41
|
Requires-Dist: idna>=3.10
|
|
42
42
|
Requires-Dist: importlib_metadata>=8.7.0
|
|
43
43
|
Requires-Dist: iniconfig>=2.1.0
|
|
44
|
-
Requires-Dist: maleo-crypto>=0.0.
|
|
45
|
-
Requires-Dist: maleo-enums>=0.0.
|
|
46
|
-
Requires-Dist: maleo-logging>=0.0.
|
|
47
|
-
Requires-Dist: maleo-
|
|
48
|
-
Requires-Dist: maleo-
|
|
49
|
-
Requires-Dist: maleo-
|
|
50
|
-
Requires-Dist: maleo-utils>=0.0.46
|
|
44
|
+
Requires-Dist: maleo-crypto>=0.0.50
|
|
45
|
+
Requires-Dist: maleo-enums>=0.0.50
|
|
46
|
+
Requires-Dist: maleo-logging>=0.0.50
|
|
47
|
+
Requires-Dist: maleo-schemas>=0.4.30
|
|
48
|
+
Requires-Dist: maleo-types>=0.0.50
|
|
49
|
+
Requires-Dist: maleo-utils>=0.0.50
|
|
51
50
|
Requires-Dist: mypy_extensions>=1.1.0
|
|
52
51
|
Requires-Dist: nodeenv>=1.9.1
|
|
53
52
|
Requires-Dist: opentelemetry-api>=1.37.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maleo-identity
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: MaleoIdentity service package
|
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -41,13 +41,12 @@ Requires-Dist: identify>=2.6.15
|
|
|
41
41
|
Requires-Dist: idna>=3.10
|
|
42
42
|
Requires-Dist: importlib_metadata>=8.7.0
|
|
43
43
|
Requires-Dist: iniconfig>=2.1.0
|
|
44
|
-
Requires-Dist: maleo-crypto>=0.0.
|
|
45
|
-
Requires-Dist: maleo-enums>=0.0.
|
|
46
|
-
Requires-Dist: maleo-logging>=0.0.
|
|
47
|
-
Requires-Dist: maleo-
|
|
48
|
-
Requires-Dist: maleo-
|
|
49
|
-
Requires-Dist: maleo-
|
|
50
|
-
Requires-Dist: maleo-utils>=0.0.46
|
|
44
|
+
Requires-Dist: maleo-crypto>=0.0.50
|
|
45
|
+
Requires-Dist: maleo-enums>=0.0.50
|
|
46
|
+
Requires-Dist: maleo-logging>=0.0.50
|
|
47
|
+
Requires-Dist: maleo-schemas>=0.4.30
|
|
48
|
+
Requires-Dist: maleo-types>=0.0.50
|
|
49
|
+
Requires-Dist: maleo-utils>=0.0.50
|
|
51
50
|
Requires-Dist: mypy_extensions>=1.1.0
|
|
52
51
|
Requires-Dist: nodeenv>=1.9.1
|
|
53
52
|
Requires-Dist: opentelemetry-api>=1.37.0
|
|
@@ -38,7 +38,10 @@ src/mixins/organization_registration_code.py
|
|
|
38
38
|
src/mixins/organization_relation.py
|
|
39
39
|
src/mixins/patient.py
|
|
40
40
|
src/mixins/user.py
|
|
41
|
+
src/mixins/user_medical_role.py
|
|
42
|
+
src/mixins/user_organization_role.py
|
|
41
43
|
src/mixins/user_profile.py
|
|
44
|
+
src/mixins/user_system_role.py
|
|
42
45
|
src/schemas/__init__.py
|
|
43
46
|
src/schemas/api_key.py
|
|
44
47
|
src/schemas/common.py
|
|
@@ -32,13 +32,12 @@ identify>=2.6.15
|
|
|
32
32
|
idna>=3.10
|
|
33
33
|
importlib_metadata>=8.7.0
|
|
34
34
|
iniconfig>=2.1.0
|
|
35
|
-
maleo-crypto>=0.0.
|
|
36
|
-
maleo-enums>=0.0.
|
|
37
|
-
maleo-logging>=0.0.
|
|
38
|
-
maleo-
|
|
39
|
-
maleo-
|
|
40
|
-
maleo-
|
|
41
|
-
maleo-utils>=0.0.46
|
|
35
|
+
maleo-crypto>=0.0.50
|
|
36
|
+
maleo-enums>=0.0.50
|
|
37
|
+
maleo-logging>=0.0.50
|
|
38
|
+
maleo-schemas>=0.4.30
|
|
39
|
+
maleo-types>=0.0.50
|
|
40
|
+
maleo-utils>=0.0.50
|
|
42
41
|
mypy_extensions>=1.1.0
|
|
43
42
|
nodeenv>=1.9.1
|
|
44
43
|
opentelemetry-api>=1.37.0
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "maleo-identity"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.14"
|
|
8
8
|
description = "MaleoIdentity service package"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
|
|
@@ -47,13 +47,12 @@ dependencies = [
|
|
|
47
47
|
"idna>=3.10",
|
|
48
48
|
"importlib_metadata>=8.7.0",
|
|
49
49
|
"iniconfig>=2.1.0",
|
|
50
|
-
"maleo-crypto>=0.0.
|
|
51
|
-
"maleo-enums>=0.0.
|
|
52
|
-
"maleo-logging>=0.0.
|
|
53
|
-
"maleo-
|
|
54
|
-
"maleo-
|
|
55
|
-
"maleo-
|
|
56
|
-
"maleo-utils>=0.0.46",
|
|
50
|
+
"maleo-crypto>=0.0.50",
|
|
51
|
+
"maleo-enums>=0.0.50",
|
|
52
|
+
"maleo-logging>=0.0.50",
|
|
53
|
+
"maleo-schemas>=0.4.30",
|
|
54
|
+
"maleo-types>=0.0.50",
|
|
55
|
+
"maleo-utils>=0.0.50",
|
|
57
56
|
"mypy_extensions>=1.1.0",
|
|
58
57
|
"nodeenv>=1.9.1",
|
|
59
58
|
"opentelemetry-api>=1.37.0",
|
|
@@ -4,7 +4,7 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
ORGANIZATION_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
7
|
+
key="organization", name="Organization", slug="organizations"
|
|
8
8
|
)
|
|
9
9
|
],
|
|
10
10
|
details=None,
|
{maleo_identity-0.1.4 → maleo_identity-0.1.14}/src/constants/organization_registration_code.py
RENAMED
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
ORGANIZATION_REGISTRATION_CODE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="Organization Registration
|
|
7
|
+
key="organization_registration_code",
|
|
8
|
+
name="Organization Registration Code",
|
|
9
9
|
slug="organization-registration-codes",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
ORGANIZATION_RELATION_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="Organization
|
|
7
|
+
key="organization_relation",
|
|
8
|
+
name="Organization Relation",
|
|
9
9
|
slug="organization-relations",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -2,6 +2,6 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
PATIENT_RESOURCE = Resource(
|
|
5
|
-
identifiers=[ResourceIdentifier(key="
|
|
5
|
+
identifiers=[ResourceIdentifier(key="patient", name="Patient", slug="patients")],
|
|
6
6
|
details=None,
|
|
7
7
|
)
|
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
USER_MEDICAL_ROLE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="User Medical
|
|
7
|
+
key="user_medical_role",
|
|
8
|
+
name="User Medical Role",
|
|
9
9
|
slug="user-medical-roles",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
USER_ORGANIZATION_ROLE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="User Organization
|
|
7
|
+
key="user_organization_role",
|
|
8
|
+
name="User Organization Role",
|
|
9
9
|
slug="user-organization-roles",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -4,7 +4,7 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
USER_PROFILE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
7
|
+
key="user_profile", name="User Profile", slug="user-profiles"
|
|
8
8
|
)
|
|
9
9
|
],
|
|
10
10
|
details=None,
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
2
|
+
from maleo.types.string import DoubleStrs
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
USER_SYSTEM_ROLE_RESOURCE = Resource(
|
|
5
6
|
identifiers=[
|
|
6
7
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="User System
|
|
8
|
+
key="user_system_role",
|
|
9
|
+
name="User System Role",
|
|
9
10
|
slug="user-system-roles",
|
|
10
11
|
)
|
|
11
12
|
],
|
|
12
13
|
details=None,
|
|
13
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}")
|
|
@@ -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,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}")
|
|
@@ -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", "organization_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -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", "system_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -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 CompositeIdentifier, 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], CompositeIdentifier]
|
|
39
|
+
):
|
|
40
|
+
type: Annotated[
|
|
41
|
+
Literal[IdentifierType.COMPOSITE],
|
|
42
|
+
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
43
|
+
] = IdentifierType.COMPOSITE
|
|
44
|
+
value: Annotated[CompositeIdentifier, 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,73 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.schemas.mixins.identity import Identifier, Key as BaseKey, Name as BaseName
|
|
5
|
+
from maleo.types.string import OptStrT
|
|
6
|
+
from maleo.types.uuid import OptUUIDT
|
|
7
|
+
from ..enums.organization import IdentifierType
|
|
8
|
+
from ..types.organization import IdentifierValueType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Key(BaseKey, Generic[OptStrT]):
|
|
12
|
+
key: Annotated[OptStrT, Field(..., description="Key", max_length=255)]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Name(BaseName, Generic[OptStrT]):
|
|
16
|
+
name: Annotated[OptStrT, Field(..., description="Name", max_length=255)]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Secret(BaseModel, Generic[OptUUIDT]):
|
|
20
|
+
secret: Annotated[OptUUIDT, Field(..., description="Secret")]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OrganizationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class IdOrganizationIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
28
|
+
type: Annotated[
|
|
29
|
+
Literal[IdentifierType.ID],
|
|
30
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
31
|
+
] = IdentifierType.ID
|
|
32
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class UUIDOrganizationIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
36
|
+
type: Annotated[
|
|
37
|
+
Literal[IdentifierType.UUID],
|
|
38
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
39
|
+
] = IdentifierType.UUID
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class KeyOrganizationIdentifier(Identifier[Literal[IdentifierType.KEY], str]):
|
|
43
|
+
type: Annotated[
|
|
44
|
+
Literal[IdentifierType.KEY],
|
|
45
|
+
Field(IdentifierType.KEY, description="Identifier's type"),
|
|
46
|
+
] = IdentifierType.KEY
|
|
47
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=255)]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
AnyOrganizationIdentifier = (
|
|
51
|
+
OrganizationIdentifier
|
|
52
|
+
| IdOrganizationIdentifier
|
|
53
|
+
| UUIDOrganizationIdentifier
|
|
54
|
+
| KeyOrganizationIdentifier
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def is_id_identifier(
|
|
59
|
+
identifier: AnyOrganizationIdentifier,
|
|
60
|
+
) -> TypeGuard[IdOrganizationIdentifier]:
|
|
61
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def is_uuid_identifier(
|
|
65
|
+
identifier: AnyOrganizationIdentifier,
|
|
66
|
+
) -> TypeGuard[UUIDOrganizationIdentifier]:
|
|
67
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def is_key_identifier(
|
|
71
|
+
identifier: AnyOrganizationIdentifier,
|
|
72
|
+
) -> TypeGuard[KeyOrganizationIdentifier]:
|
|
73
|
+
return identifier.type is IdentifierType.KEY and isinstance(identifier.value, str)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.schemas.mixins.identity import Identifier
|
|
5
|
+
from maleo.types.integer import OptIntT
|
|
6
|
+
from maleo.types.string import OptStrT
|
|
7
|
+
from ..enums.organization_registration_code import IdentifierType
|
|
8
|
+
from ..types.organization_registration_code import IdentifierValueType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Code(BaseModel, Generic[OptStrT]):
|
|
12
|
+
code: Annotated[OptStrT, Field(..., description="Code", max_length=36)]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class MaxUses(BaseModel, Generic[OptIntT]):
|
|
16
|
+
max_uses: Annotated[OptIntT, Field(..., description="Max Uses", ge=1)]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CurrentUses(BaseModel):
|
|
20
|
+
current_uses: Annotated[int, Field(0, description="Current Uses", ge=0)] = 0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OrganizationRegistrationCodeIdentifier(
|
|
24
|
+
Identifier[IdentifierType, IdentifierValueType]
|
|
25
|
+
):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class IdOrganizationRegistrationCodeIdentifier(
|
|
30
|
+
Identifier[Literal[IdentifierType.ID], int]
|
|
31
|
+
):
|
|
32
|
+
type: Annotated[
|
|
33
|
+
Literal[IdentifierType.ID],
|
|
34
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
35
|
+
] = IdentifierType.ID
|
|
36
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class OrgIdOrganizationRegistrationCodeIdentifier(
|
|
40
|
+
Identifier[Literal[IdentifierType.ORGANIZATION_ID], int]
|
|
41
|
+
):
|
|
42
|
+
type: Annotated[
|
|
43
|
+
Literal[IdentifierType.ORGANIZATION_ID],
|
|
44
|
+
Field(IdentifierType.ORGANIZATION_ID, description="Identifier's type"),
|
|
45
|
+
] = IdentifierType.ORGANIZATION_ID
|
|
46
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class UUIDOrganizationRegistrationCodeIdentifier(
|
|
50
|
+
Identifier[Literal[IdentifierType.UUID], UUID]
|
|
51
|
+
):
|
|
52
|
+
type: Annotated[
|
|
53
|
+
Literal[IdentifierType.UUID],
|
|
54
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
55
|
+
] = IdentifierType.UUID
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CodeOrganizationRegistrationCodeIdentifier(
|
|
59
|
+
Identifier[Literal[IdentifierType.CODE], str]
|
|
60
|
+
):
|
|
61
|
+
type: Annotated[
|
|
62
|
+
Literal[IdentifierType.CODE],
|
|
63
|
+
Field(IdentifierType.CODE, description="Identifier's type"),
|
|
64
|
+
] = IdentifierType.CODE
|
|
65
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=36)]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
AnyOrganizationRegistrationCodeIdentifier = (
|
|
69
|
+
OrganizationRegistrationCodeIdentifier
|
|
70
|
+
| IdOrganizationRegistrationCodeIdentifier
|
|
71
|
+
| OrgIdOrganizationRegistrationCodeIdentifier
|
|
72
|
+
| UUIDOrganizationRegistrationCodeIdentifier
|
|
73
|
+
| CodeOrganizationRegistrationCodeIdentifier
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def is_id_identifier(
|
|
78
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
79
|
+
) -> TypeGuard[IdOrganizationRegistrationCodeIdentifier]:
|
|
80
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def is_org_id_identifier(
|
|
84
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
85
|
+
) -> TypeGuard[OrgIdOrganizationRegistrationCodeIdentifier]:
|
|
86
|
+
return identifier.type is IdentifierType.ORGANIZATION_ID and isinstance(
|
|
87
|
+
identifier.value, int
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def is_uuid_identifier(
|
|
92
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
93
|
+
) -> TypeGuard[UUIDOrganizationRegistrationCodeIdentifier]:
|
|
94
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def is_code_identifier(
|
|
98
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
99
|
+
) -> TypeGuard[CodeOrganizationRegistrationCodeIdentifier]:
|
|
100
|
+
return identifier.type is IdentifierType.CODE and isinstance(identifier.value, str)
|