ipulse-shared-core-ftredge 2.5__py3-none-any.whl → 2.6.1__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 ipulse-shared-core-ftredge might be problematic. Click here for more details.
- ipulse_shared_core_ftredge/__init__.py +21 -4
- ipulse_shared_core_ftredge/enums/__init__.py +32 -0
- ipulse_shared_core_ftredge/enums/enums_cloud.py +17 -0
- ipulse_shared_core_ftredge/enums/enums_common_utils.py +98 -0
- ipulse_shared_core_ftredge/enums/enums_data_eng.py +109 -0
- ipulse_shared_core_ftredge/enums/enums_logs.py +79 -0
- ipulse_shared_core_ftredge/enums/enums_module_fincore.py +58 -0
- ipulse_shared_core_ftredge/enums/enums_modules.py +25 -0
- ipulse_shared_core_ftredge/{models → enums}/pulse_enums.py +10 -46
- ipulse_shared_core_ftredge/models/__init__.py +0 -1
- ipulse_shared_core_ftredge/models/organisation.py +61 -55
- ipulse_shared_core_ftredge/models/resource_catalog_item.py +97 -171
- ipulse_shared_core_ftredge/models/user_profile.py +10 -9
- ipulse_shared_core_ftredge/models/user_profile_update.py +32 -14
- ipulse_shared_core_ftredge/models/user_status.py +21 -11
- ipulse_shared_core_ftredge/utils/__init__.py +19 -0
- ipulse_shared_core_ftredge/utils/logs/__init__.py +2 -0
- ipulse_shared_core_ftredge/{models → utils/logs}/audit_log_firestore.py +1 -1
- ipulse_shared_core_ftredge/utils/logs/context_log.py +211 -0
- ipulse_shared_core_ftredge/utils/logs/get_logger.py +76 -0
- ipulse_shared_core_ftredge/utils/utils_cloud.py +44 -0
- ipulse_shared_core_ftredge/utils/utils_cloud_gcp.py +311 -0
- ipulse_shared_core_ftredge/utils/utils_cloud_gcp_with_collectors.py +169 -0
- ipulse_shared_core_ftredge/utils/utils_cloud_with_collectors.py +26 -0
- ipulse_shared_core_ftredge/utils/utils_collector_pipelinemon.py +356 -0
- ipulse_shared_core_ftredge/utils/utils_common.py +145 -0
- ipulse_shared_core_ftredge/utils/utils_templates_and_schemas.py +151 -0
- ipulse_shared_core_ftredge-2.6.1.dist-info/METADATA +14 -0
- ipulse_shared_core_ftredge-2.6.1.dist-info/RECORD +33 -0
- {ipulse_shared_core_ftredge-2.5.dist-info → ipulse_shared_core_ftredge-2.6.1.dist-info}/WHEEL +1 -1
- ipulse_shared_core_ftredge/tests/__init__.py +0 -0
- ipulse_shared_core_ftredge/tests/test.py +0 -17
- ipulse_shared_core_ftredge-2.5.dist-info/METADATA +0 -12
- ipulse_shared_core_ftredge-2.5.dist-info/RECORD +0 -17
- {ipulse_shared_core_ftredge-2.5.dist-info → ipulse_shared_core_ftredge-2.6.1.dist-info}/LICENCE +0 -0
- {ipulse_shared_core_ftredge-2.5.dist-info → ipulse_shared_core_ftredge-2.6.1.dist-info}/top_level.txt +0 -0
|
@@ -1,65 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
# pylint: disable=missing-module-docstring
|
|
2
|
+
# pylint: disable=missing-function-docstring
|
|
3
|
+
# pylint: disable=missing-class-docstring
|
|
4
|
+
# pylint: disable=broad-exception-caught
|
|
5
|
+
# pylint: disable=line-too-long
|
|
6
|
+
# pylint: disable=unused-variable
|
|
7
|
+
# pylint: disable=broad-exception-caught
|
|
8
|
+
# from pydantic import BaseModel, validator, ValidationError, Field
|
|
9
|
+
# from typing import Set, Optional
|
|
10
|
+
# import uuid
|
|
11
|
+
# from datetime import datetime
|
|
12
|
+
# import dateutil.parser
|
|
7
13
|
|
|
8
|
-
CLASS_VERSION= 1.0
|
|
9
|
-
MODULE= "core"
|
|
10
|
-
CLASS_REF="orgn"
|
|
14
|
+
# CLASS_VERSION= 1.0
|
|
15
|
+
# MODULE= "core"
|
|
16
|
+
# CLASS_REF="orgn"
|
|
11
17
|
|
|
12
18
|
|
|
13
|
-
class Organisation(BaseModel):
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
# class Organisation(BaseModel):
|
|
20
|
+
# puid: str = Field(default_factory=f"{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}_{MODULE}{CLASS_REF}".lower())
|
|
21
|
+
# name: str
|
|
22
|
+
# creat_date: datetime = Field(default_factory=datetime.utcnow())
|
|
23
|
+
# updt_date: datetime = Field(default_factory=datetime.utcnow())
|
|
24
|
+
# creat_by_user: Optional[str] = None
|
|
25
|
+
# updt_by_user: Optional[str] = None
|
|
26
|
+
# relations: Optional[Set[str]]=None
|
|
27
|
+
# description: Optional[str] = None # Updated to use Optional
|
|
28
|
+
# industries: Optional[Set[str]] = None # Updated to use Optional
|
|
29
|
+
# website: Optional[str] = None # Updated to use Optional
|
|
30
|
+
# org_admin_user_uids: Optional[Set[str]] = None # Updated to use Optional
|
|
31
|
+
# class Config:
|
|
32
|
+
# extra = "forbid"
|
|
27
33
|
|
|
28
34
|
|
|
29
|
-
@validator('relations', pre=True, always=True)
|
|
30
|
-
def validate_relations(cls, relations):
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
# @validator('relations', pre=True, always=True)
|
|
36
|
+
# def validate_relations(cls, relations):
|
|
37
|
+
# if not set(relations).issubset(enums.organisation_relations):
|
|
38
|
+
# raise ValueError("Invalid relation values provided.")
|
|
39
|
+
# return relations
|
|
34
40
|
|
|
35
41
|
|
|
36
|
-
@validator('industries', pre=True, always=True)
|
|
37
|
-
def validate_industries(cls, industries):
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
# @validator('industries', pre=True, always=True)
|
|
43
|
+
# def validate_industries(cls, industries):
|
|
44
|
+
# if industries is not None and not set(industries).issubset(enums.organisation_industries):
|
|
45
|
+
# raise ValueError("Invalid industry values provided.")
|
|
46
|
+
# return industries
|
|
41
47
|
|
|
42
|
-
@validator('creat_date', 'updt_date', pre=True)
|
|
43
|
-
def parse_date(cls, value):
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
# @validator('creat_date', 'updt_date', pre=True)
|
|
49
|
+
# def parse_date(cls, value):
|
|
50
|
+
# if value is None:
|
|
51
|
+
# return value
|
|
52
|
+
# if isinstance(value, datetime):
|
|
53
|
+
# return value
|
|
54
|
+
# try:
|
|
55
|
+
# # Assuming Firestore returns an ISO 8601 string, adjust if necessary
|
|
56
|
+
# print("Putting Updt or Creat date in a valid format in a Validator when creating Organisation object")
|
|
57
|
+
# return dateutil.parser.isoparse(value)
|
|
58
|
+
# except (TypeError, ValueError):
|
|
59
|
+
# raise ValidationError(f"Invalid datetime format inside Organisation: {value}")
|
|
54
60
|
|
|
55
61
|
|
|
56
|
-
### Description, Industries, and Website are optional for Retail Customer and mandatory for Non Retail Customer
|
|
57
|
-
@validator('description', 'industries', 'website', pre=True, always=True)
|
|
58
|
-
def validate_optional_fields(cls, value, values):
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
# ### Description, Industries, and Website are optional for Retail Customer and mandatory for Non Retail Customer
|
|
63
|
+
# @validator('description', 'industries', 'website', pre=True, always=True)
|
|
64
|
+
# def validate_optional_fields(cls, value, values):
|
|
65
|
+
# if values.get('name') == 'Retail Customer' and values.get('relations') == {"retail_customer"} or values.get('relations') == ["retail_customer"]:
|
|
66
|
+
# if value is not None:
|
|
67
|
+
# raise ValueError("For 'Retail Customer' with only 'retail_customer' relations, description, industries, and website should not be provided.")
|
|
68
|
+
# else:
|
|
69
|
+
# if value is None:
|
|
70
|
+
# raise ValueError("For Non Retail Customer, description, industries, and website are mandatory.")
|
|
71
|
+
# return value
|
|
@@ -1,189 +1,115 @@
|
|
|
1
|
-
import uuid
|
|
2
|
-
from datetime import datetime
|
|
3
|
-
from pydantic import BaseModel, validator, ValidationError
|
|
4
|
-
from typing import Dict, Any, Set, Optional
|
|
5
|
-
from . import pulse_enums as enums
|
|
1
|
+
# import uuid
|
|
2
|
+
# from datetime import datetime
|
|
3
|
+
# from pydantic import BaseModel, validator, ValidationError
|
|
4
|
+
# from typing import Dict, Any, Set, Optional
|
|
6
5
|
|
|
7
|
-
import dateutil.parser
|
|
6
|
+
# import dateutil.parser
|
|
8
7
|
|
|
9
|
-
CLASS_VERSION = 1.0
|
|
10
|
-
CLASS_REF = "resdes"
|
|
11
|
-
MODULE = "core"
|
|
8
|
+
# CLASS_VERSION = 1.0
|
|
9
|
+
# CLASS_REF = "resdes"
|
|
10
|
+
# MODULE = "core"
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
# "resr_puid_or_name":"Users",
|
|
15
|
-
# "resr_path":"firestore/Users",
|
|
16
|
-
# "resr_name":"Users",
|
|
17
|
-
# "resr_pulse_module":MODULE,
|
|
18
|
-
# "resr_type":"firestore_collection",
|
|
19
|
-
# "resr_classifications":{ "auth_required_confidential"},
|
|
20
|
-
# "resr_contents":{"user_core_profile"},
|
|
21
|
-
# "resr_original_or_processed":"original_source",
|
|
22
|
-
# "resr_origin":"internal",
|
|
23
|
-
# "resr_origin_organisations_uids":{"20231220futureedgegroup_coreorgn"},
|
|
24
|
-
# }
|
|
12
|
+
# class ResourceCatalogItem(BaseModel):
|
|
25
13
|
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
# "resr_creat_date":datetime(2023, 12, 23),
|
|
58
|
-
# "resr_creat_by_user":"Russlan Ramdowar;russlan@ftredge.com",
|
|
59
|
-
# "metadata_updt_date":datetime(2023, 12, 23),
|
|
60
|
-
# "metadata_updt_by_user":"Russlan Ramdowar;russlan@ftredge.com"}
|
|
61
|
-
|
|
62
|
-
# metadata={"resr_classification":"auth_required_confidential",
|
|
63
|
-
# "resr_readable_by": ["owner", "selected_by_admin"],
|
|
64
|
-
# "resr_updatable_by": ["admin"],
|
|
65
|
-
# "resr_original_or_processed" : "original_source",
|
|
66
|
-
# "resr_origin":"internal",
|
|
67
|
-
# "resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
68
|
-
# "resr_origin_description":"Original User field",
|
|
69
|
-
# "resr_creat_date":datetime(2023, 12, 23),
|
|
70
|
-
# "resr_creat_by_user":"Russlan Ramdowar",
|
|
71
|
-
# "metadata_updt_date":datetime(2023, 12, 23),
|
|
72
|
-
# "metadata_updt_by_user":"Russlan Ramdowar"}
|
|
73
|
-
|
|
74
|
-
# metadata={"resr_classification":"auth_required_confidential",
|
|
75
|
-
# "resr_readable_by": ["owner", "selected_by_admin"],
|
|
76
|
-
# "resr_updatable_by": ["selected_by_admin"],
|
|
77
|
-
# "resr_original_or_processed" : "original_source",
|
|
78
|
-
# "resr_origin":"internal",
|
|
79
|
-
# "resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
80
|
-
# "resr_origin_description":"Original User field",
|
|
81
|
-
# "resr_creat_date":datetime(2023, 12, 23),
|
|
82
|
-
# "resr_creat_by_user":"Russlan Ramdowar",
|
|
83
|
-
# "metadata_updt_date":datetime(2023, 12, 23),
|
|
84
|
-
# "metadata_updt_by_user":"Russlan Ramdowar"}
|
|
85
|
-
|
|
86
|
-
class ResourceCatalogItem(BaseModel):
|
|
87
|
-
|
|
88
|
-
resr_puid_or_name: str #Ex: username
|
|
89
|
-
resr_path: str #Ex: ipulse-401013/cloud/firesotre/Users/{user_uid}/username
|
|
90
|
-
resr_name: str #Ex: username
|
|
91
|
-
resr_pulse_module: str #Ex: core
|
|
92
|
-
resr_type: str
|
|
93
|
-
resr_classifications: Set[str]
|
|
94
|
-
resr_contents:Set[str]
|
|
95
|
-
resr_original_or_processed: str
|
|
96
|
-
resr_origin: str
|
|
97
|
-
resr_origin_organisations_uids: Set[str]
|
|
98
|
-
resr_origin_description: str
|
|
99
|
-
resr_licences_types: Set[str]
|
|
100
|
-
resr_description_details: str
|
|
101
|
-
resr_updtbl_by_non_staff: bool
|
|
102
|
-
resr_creat_by_user_uid: str
|
|
103
|
-
resr_creat_date: datetime
|
|
104
|
-
class_version:float = CLASS_VERSION
|
|
105
|
-
resr_columns_count: int
|
|
106
|
-
resr_columns: Optional[Dict[Any, Any]] = None #OPTIONAL
|
|
107
|
-
resr_structure_version: Optional[str]=None # OPTIONAL
|
|
108
|
-
resr_structure_updt_date: Optional[str]=None #OPTIONAL
|
|
109
|
-
resr_structure_updt_by_user_uid: Optional[str]=None # OPTIONAL
|
|
110
|
-
resr_tags: Optional[Dict[Any, Any]] = None #OPTIONAL
|
|
111
|
-
resr_content_updt_date: Optional[str]=None #OPTIONAL
|
|
112
|
-
resr_content_updt_by_user_uid: Optional[str]=None # OPTIONAL
|
|
113
|
-
puid: Optional[str] = None #TO BE SETUP BY Validator
|
|
114
|
-
metadata_version: Optional[float] = None #TO BE SETUP BY Validator
|
|
115
|
-
metadata_creat_date: Optional[datetime] = None #TO BE SETUP BY Management Service
|
|
116
|
-
metadata_creat_by: Optional[str] = None #TO BE SETUP BY Management Service
|
|
117
|
-
metadata_updt_date: Optional[datetime] = None #TO BE SETUP BY Management Service
|
|
118
|
-
metadata_updt_by: Optional[str] = None #TO BE SETUP BY Management Service
|
|
14
|
+
# resr_puid_or_name: str #Ex: username
|
|
15
|
+
# resr_path: str #Ex: ipulse-401013/cloud/firesotre/Users/{user_uid}/username
|
|
16
|
+
# resr_name: str #Ex: username
|
|
17
|
+
# resr_pulse_module: str #Ex: core
|
|
18
|
+
# resr_type: str
|
|
19
|
+
# resr_classifications: Set[str]
|
|
20
|
+
# resr_contents:Set[str]
|
|
21
|
+
# resr_original_or_processed: str
|
|
22
|
+
# resr_origin: str
|
|
23
|
+
# resr_origin_organisations_uids: Set[str]
|
|
24
|
+
# resr_origin_description: str
|
|
25
|
+
# resr_licences_types: Set[str]
|
|
26
|
+
# resr_description_details: str
|
|
27
|
+
# resr_updtbl_by_non_staff: bool
|
|
28
|
+
# resr_creat_by_user_uid: str
|
|
29
|
+
# resr_creat_date: datetime
|
|
30
|
+
# class_version:float = CLASS_VERSION
|
|
31
|
+
# resr_columns_count: int
|
|
32
|
+
# resr_columns: Optional[Dict[Any, Any]] = None #OPTIONAL
|
|
33
|
+
# resr_structure_version: Optional[str]=None # OPTIONAL
|
|
34
|
+
# resr_structure_updt_date: Optional[str]=None #OPTIONAL
|
|
35
|
+
# resr_structure_updt_by_user_uid: Optional[str]=None # OPTIONAL
|
|
36
|
+
# resr_tags: Optional[Dict[Any, Any]] = None #OPTIONAL
|
|
37
|
+
# resr_content_updt_date: Optional[str]=None #OPTIONAL
|
|
38
|
+
# resr_content_updt_by_user_uid: Optional[str]=None # OPTIONAL
|
|
39
|
+
# puid: Optional[str] = None #TO BE SETUP BY Validator
|
|
40
|
+
# metadata_version: Optional[float] = None #TO BE SETUP BY Validator
|
|
41
|
+
# metadata_creat_date: Optional[datetime] = None #TO BE SETUP BY Management Service
|
|
42
|
+
# metadata_creat_by: Optional[str] = None #TO BE SETUP BY Management Service
|
|
43
|
+
# metadata_updt_date: Optional[datetime] = None #TO BE SETUP BY Management Service
|
|
44
|
+
# metadata_updt_by: Optional[str] = None #TO BE SETUP BY Management Service
|
|
119
45
|
|
|
120
|
-
@validator('puid', pre=True, always=True)
|
|
121
|
-
def set_puid(cls, puid, values):
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
46
|
+
# @validator('puid', pre=True, always=True)
|
|
47
|
+
# def set_puid(cls, puid, values):
|
|
48
|
+
# if puid is None:
|
|
49
|
+
# return f"{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}_{MODULE}{CLASS_REF}".lower()
|
|
50
|
+
# return puid
|
|
125
51
|
|
|
126
|
-
@validator('metadata_version', pre=True, always=True)
|
|
127
|
-
def set_metadata_version(cls, metadata_version, values):
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
52
|
+
# @validator('metadata_version', pre=True, always=True)
|
|
53
|
+
# def set_metadata_version(cls, metadata_version, values):
|
|
54
|
+
# if metadata_version is None:
|
|
55
|
+
# return 1.0
|
|
56
|
+
# else:
|
|
57
|
+
# return metadata_version + 0.1
|
|
132
58
|
|
|
133
59
|
|
|
134
|
-
@validator('resr_pulse_module', pre=True, always=True)
|
|
135
|
-
def validate_resr_pulse_module(cls, resr_pulse_modules):
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
60
|
+
# @validator('resr_pulse_module', pre=True, always=True)
|
|
61
|
+
# def validate_resr_pulse_module(cls, resr_pulse_modules):
|
|
62
|
+
# if resr_pulse_modules not in enums.pulse_modules:
|
|
63
|
+
# raise ValueError("Invalid pulse_modules values provided.")
|
|
64
|
+
# return resr_pulse_modules
|
|
139
65
|
|
|
140
|
-
@validator('resr_type', pre=True, always=True)
|
|
141
|
-
def validate_resr_type(cls, resr_type):
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
66
|
+
# @validator('resr_type', pre=True, always=True)
|
|
67
|
+
# def validate_resr_type(cls, resr_type):
|
|
68
|
+
# if resr_type not in enums.resource_types:
|
|
69
|
+
# raise ValueError("Invalid resource_types value provided.")
|
|
70
|
+
# return resr_type
|
|
145
71
|
|
|
146
|
-
@validator('resr_classifications', pre=True, always=True)
|
|
147
|
-
def validate_resr_classifications(cls, resr_classifications):
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
72
|
+
# @validator('resr_classifications', pre=True, always=True)
|
|
73
|
+
# def validate_resr_classifications(cls, resr_classifications):
|
|
74
|
+
# if not resr_classifications.issubset(enums.resource_classifications):
|
|
75
|
+
# raise ValueError("Invalid resr_classifications values provided.")
|
|
76
|
+
# return resr_classifications
|
|
151
77
|
|
|
152
|
-
@validator('resr_contents', pre=True, always=True)
|
|
153
|
-
def validate_resr_contents(cls, resr_contents):
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
78
|
+
# @validator('resr_contents', pre=True, always=True)
|
|
79
|
+
# def validate_resr_contents(cls, resr_contents):
|
|
80
|
+
# if not resr_contents.issubset(enums.resource_contents):
|
|
81
|
+
# raise ValueError("Invalid resr_contents values provided.")
|
|
82
|
+
# return resr_contents
|
|
157
83
|
|
|
158
|
-
@validator('resr_original_or_processed', pre=True, always=True)
|
|
159
|
-
def validate_resr_original_or_processed(cls, resr_original_or_processed):
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
84
|
+
# @validator('resr_original_or_processed', pre=True, always=True)
|
|
85
|
+
# def validate_resr_original_or_processed(cls, resr_original_or_processed):
|
|
86
|
+
# if resr_original_or_processed not in enums.resource_original_or_processed:
|
|
87
|
+
# raise ValueError("Invalid resr_original_or_processed value provided.")
|
|
88
|
+
# return resr_original_or_processed
|
|
163
89
|
|
|
164
|
-
@validator('resr_origin', pre=True, always=True)
|
|
165
|
-
def validate_resr_origin(cls, resr_origin):
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
90
|
+
# @validator('resr_origin', pre=True, always=True)
|
|
91
|
+
# def validate_resr_origin(cls, resr_origin):
|
|
92
|
+
# if resr_origin not in enums.resource_origins:
|
|
93
|
+
# raise ValueError("Invalid resource_origins value provided.")
|
|
94
|
+
# return resr_origin
|
|
169
95
|
|
|
170
96
|
|
|
171
|
-
@validator('metadata_creat_date', 'metadata_updt_date', pre=True)
|
|
172
|
-
def parse_date(cls, value):
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
97
|
+
# @validator('metadata_creat_date', 'metadata_updt_date', pre=True)
|
|
98
|
+
# def parse_date(cls, value):
|
|
99
|
+
# if value is None:
|
|
100
|
+
# return value
|
|
101
|
+
# if isinstance(value, datetime):
|
|
102
|
+
# return value
|
|
103
|
+
# try:
|
|
104
|
+
# # Assuming Firestore returns an ISO 8601 string, adjust if necessary
|
|
105
|
+
# return dateutil.parser.isoparse(value)
|
|
106
|
+
# except (TypeError, ValueError):
|
|
107
|
+
# raise ValidationError(f"Invalid datetime format inside Resource Description: {value}")
|
|
182
108
|
|
|
183
109
|
|
|
184
110
|
|
|
185
|
-
@validator('metadata_updt_date', 'metadata_updt_date', pre=True, always=True)
|
|
186
|
-
def set_default_updt_date(cls, date, values):
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
111
|
+
# @validator('metadata_updt_date', 'metadata_updt_date', pre=True, always=True)
|
|
112
|
+
# def set_default_updt_date(cls, date, values):
|
|
113
|
+
# if date is None:
|
|
114
|
+
# return datetime.utcnow().isoformat()
|
|
115
|
+
# return date
|
|
@@ -11,6 +11,8 @@ CLASS_ORGIN_DATE=datetime(2024, 1, 16, 20, 5)
|
|
|
11
11
|
CLASS_VERSION = 3.01
|
|
12
12
|
CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
|
|
13
13
|
CLASS_REVISION_DATE=datetime(2024, 2, 13, 20, 15)
|
|
14
|
+
LAST_MODIFICATION="Fixed typo"
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
DOMAIN="user"
|
|
16
18
|
OBJ_REF = "usprfl"
|
|
@@ -24,17 +26,16 @@ class UserProfile(BaseModel):
|
|
|
24
26
|
email: EmailStr = Field(frozen=True, description="Propagated from Firebase Auth" ) #User can Read only
|
|
25
27
|
organizations_uids: Set[str] = Field( description="Depends on Subscription Plan, Regularly Updated") #User can Read only
|
|
26
28
|
creat_date: datetime #User can Read only
|
|
29
|
+
creat_by_user: str #User can Read only
|
|
30
|
+
updt_date: datetime #User can Read only
|
|
31
|
+
updt_by_user: str #User can Read only
|
|
32
|
+
aliases: Optional[Set[str]] = None #User can Read only
|
|
33
|
+
provider_id: str #User can Read only
|
|
27
34
|
|
|
28
35
|
username: Optional[str] = None #User can Read and Edit
|
|
29
|
-
dob: Optional[date] = None #User can Read and Edit
|
|
30
|
-
first_name: Optional[str] = None #User can Read and Edit
|
|
31
|
-
last_name: Optional[str] = None #User can Read and Edit
|
|
36
|
+
dob: Optional[date] = None #User can Read and Edit
|
|
37
|
+
first_name: Optional[str] = None #User can Read and Edit
|
|
38
|
+
last_name: Optional[str] = None #User can Read and Edit
|
|
32
39
|
mobile: Optional[str] = None #User can Read and Edit
|
|
33
|
-
|
|
34
|
-
creat_by_user: str #User shouldn't see this or edit this
|
|
35
|
-
updt_date: datetime #User shouldn't see this or edit this
|
|
36
|
-
updt_by_user: str #User shouldn't see this or edit this
|
|
37
|
-
aliases: Optional[Set[str]] = None #User shouldn't see this or edit this
|
|
38
|
-
provider_id: str #User shouldn't see this or edit this
|
|
39
40
|
class Config:
|
|
40
41
|
extra = "forbid"
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
|
|
2
1
|
from typing import Optional, Set
|
|
3
|
-
from pydantic import BaseModel
|
|
4
|
-
from datetime import
|
|
2
|
+
from pydantic import BaseModel, Field, EmailStr
|
|
3
|
+
from datetime import date, datetime
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
CLASS_ORIGIN_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
|
|
7
|
+
CLASS_ORGIN_DATE=datetime(2024, 3, 15, 20, 15)
|
|
8
|
+
|
|
9
|
+
CLASS_VERSION = 2.01
|
|
10
|
+
CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
|
|
11
|
+
CLASS_REVISION_DATE=datetime(2024, 3, 15, 20, 15)
|
|
12
|
+
LAST_MODIFICATION="Created , with all fields Optional"
|
|
5
13
|
|
|
6
14
|
class UserProfileUpdate(BaseModel):
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
schema_version: Optional[float] = Field(None, description="Version of this Class == version of DB Schema")
|
|
16
|
+
email: Optional[EmailStr] = Field(None, description="Propagated from Firebase Auth")
|
|
17
|
+
organizations_uids: Optional[Set[str]] = Field(None, description="Depends on Subscription Plan, Regularly Updated")
|
|
18
|
+
creat_date: Optional[datetime] = Field(None, description="Creation date")
|
|
19
|
+
creat_by_user: Optional[str] = Field(None, description="Created by user")
|
|
20
|
+
updt_date: Optional[datetime] = Field(None, description="Update date")
|
|
21
|
+
updt_by_user: Optional[str] = Field(None, description="Updated by user")
|
|
22
|
+
aliases: Optional[Set[str]] = Field(None, description="User aliases")
|
|
23
|
+
provider_id: Optional[str] = Field(None, description="Provider ID")
|
|
24
|
+
|
|
25
|
+
username: Optional[str] = Field(None, description="Username")
|
|
26
|
+
dob: Optional[date] = Field(None, description="Date of Birth")
|
|
27
|
+
first_name: Optional[str] = Field(None, description="First Name")
|
|
28
|
+
last_name: Optional[str] = Field(None, description="Last Name")
|
|
29
|
+
mobile: Optional[str] = Field(None, description="Mobile Number")
|
|
16
30
|
|
|
17
|
-
def model_dump(self, **kwargs):
|
|
18
|
-
|
|
31
|
+
# def model_dump(self, **kwargs):
|
|
32
|
+
# return super().model_dump(exclude_none=True, **kwargs)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
|
+
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
from dateutil.relativedelta import relativedelta
|
|
4
|
-
from typing import Set, Optional
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
from typing import Set, Optional, Dict, List
|
|
6
|
+
|
|
7
|
+
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
CLASS_ORIGIN_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
|
|
10
11
|
CLASS_ORGIN_DATE=datetime(2024, 2, 12, 20, 5)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
SCHEMA_VERSION = 2.3
|
|
13
14
|
CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
|
|
14
15
|
CLASS_REVISION_DATE=datetime(2024, 2, 13, 20, 15)
|
|
16
|
+
LAST_MODIFICATION="Changed default IAM_GROUPS"
|
|
15
17
|
|
|
16
18
|
DOMAIN="user"
|
|
17
19
|
OBJ_REF = "usrsttus"
|
|
20
|
+
|
|
21
|
+
DEFAULT_IAM_GROUPS={"pulseroot":["full_open_read"]}
|
|
22
|
+
DEFAULT_SUBSCRIPTION_PLAN="subscription_free"
|
|
23
|
+
DEFAULT_SUBSCRIPTION_STATUS="active"
|
|
24
|
+
DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS=10
|
|
25
|
+
DEFAULT_EXTRA_INSIGHT_CREDITS=0
|
|
26
|
+
|
|
27
|
+
############################################ !!!!! ALWAYS UPDATE SCHEMA VERSION , IF SCHEMA IS BEING MODIFIED !!! ############################################
|
|
18
28
|
class UserStatus(BaseModel):
|
|
19
|
-
schema_version: float = Field(default=
|
|
29
|
+
schema_version: float = Field(default=SCHEMA_VERSION, description="Version of this Class == version of DB Schema") #User can Read only
|
|
20
30
|
# uid: str = Field(frozen=True, description="Generated by Firebase Auth") #User can Read only
|
|
21
31
|
# puid:str = Field(default_factory=lambda: f"{DOMAIN}{OBJ_REF}{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}".lower(),
|
|
22
32
|
# frozen=True,
|
|
23
33
|
# description="Generated Automatically by default_factory") #User can Read only
|
|
24
34
|
|
|
25
|
-
iam_groups:
|
|
26
|
-
sbscrptn_plan: str=Field(default_factory=lambda:
|
|
27
|
-
sbscrptn_status: str=Field(default_factory=lambda:
|
|
35
|
+
iam_groups: Dict[str, List[str]] = Field(default_factory=lambda:DEFAULT_IAM_GROUPS, description="User's Groups, with a default one for all authenticated Pulse users") #User can Read only
|
|
36
|
+
sbscrptn_plan: str=Field(default_factory=lambda:DEFAULT_SUBSCRIPTION_PLAN, description="Subscription Plan ") #User can Read only
|
|
37
|
+
sbscrptn_status: str=Field(default_factory=lambda:DEFAULT_SUBSCRIPTION_STATUS, description="Subscription Status") #User can Read only
|
|
28
38
|
sbscrptn_start_date: datetime=Field(default_factory=lambda:datetime.utcnow(), description="Subscription Start Date") #User can Read only
|
|
29
39
|
sbscrptn_end_date: datetime=Field(default_factory=lambda:datetime.utcnow()+relativedelta(years=1) , description="Subscription End Date") #User can Read only
|
|
30
|
-
sbscrptn_insight_credits: int= Field(default_factory=lambda:
|
|
40
|
+
sbscrptn_insight_credits: int= Field(default_factory=lambda:DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS, description="Depends on Subscription Plan, Set Amount udated at Regular Intervals or at Regular Time") #User can Read only
|
|
31
41
|
sbscrptn_ins_crdts_updtd_since_datetime: datetime=Field(default_factory=lambda:datetime.utcnow(), description="Subscription Start Date") #User can Read only #User can Read only #User can Read only
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
extra_insight_credits: int= Field(default_factory=lambda:DEFAULT_EXTRA_INSIGHT_CREDITS, description="If user purchased extra Insigth Credits they shouldn't Expire") #User can Read only
|
|
43
|
+
payment_refs_uids: Optional[Set[str]] = None #User can Read only
|
|
34
44
|
|
|
35
45
|
creat_date: datetime #User can Read only
|
|
36
46
|
creat_by_user: str #User can Read only / Ideally shouldn't be able to see even
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# pylint: disable=missing-module-docstring
|
|
2
|
+
from .utils_common import (save_json_locally_extended)
|
|
3
|
+
from .utils_collector_pipelinemon import ( Pipelinemon)
|
|
4
|
+
|
|
5
|
+
from .utils_cloud_gcp import (setup_gcp_logging,
|
|
6
|
+
create_bigquery_schema_from_json,
|
|
7
|
+
read_csv_from_gcs, read_json_from_gcs,
|
|
8
|
+
write_csv_to_gcs,write_json_to_gcs_extended)
|
|
9
|
+
|
|
10
|
+
from .utils_cloud_gcp_with_collectors import (write_json_to_gcs_with_pipelinemon_extended )
|
|
11
|
+
|
|
12
|
+
from .utils_cloud import (write_json_to_cloud_storage_extended,
|
|
13
|
+
read_json_from_cloud_storage)
|
|
14
|
+
from .utils_cloud_with_collectors import (write_json_to_cloud_storage_with_pipelinemon_extended)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
from .utils_templates_and_schemas import (check_format_against_schema_template)
|
|
18
|
+
|
|
19
|
+
from .logs import (ContextLog, get_logger)
|