maleo-identity 0.0.43__py3-none-any.whl → 0.0.44__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/client/controllers/http/organization.py +87 -0
- maleo_identity/client/services/organization.py +380 -8
- maleo_identity/client/services/user.py +108 -9
- maleo_identity/constants/user.py +0 -9
- maleo_identity/constants/user_system_role.py +6 -8
- maleo_identity/enums/user_system_role.py +3 -0
- maleo_identity/models/__init__.py +2 -0
- maleo_identity/models/responses/organization.py +17 -5
- maleo_identity/models/schemas/__init__.py +14 -4
- maleo_identity/models/schemas/general.py +15 -0
- maleo_identity/models/schemas/{general/organization.py → organization.py} +10 -9
- maleo_identity/models/schemas/organization_role.py +15 -0
- maleo_identity/models/schemas/{general/user.py → user.py} +12 -11
- maleo_identity/models/schemas/user_organization.py +8 -0
- maleo_identity/models/schemas/user_organization_role.py +15 -0
- maleo_identity/models/schemas/{general/user_profile.py → user_profile.py} +5 -10
- maleo_identity/models/schemas/user_system_role.py +8 -0
- maleo_identity/models/tables/organization.py +16 -2
- maleo_identity/models/tables/user.py +13 -1
- maleo_identity/models/tables/user_profile.py +2 -0
- maleo_identity/models/tables/user_system_role.py +2 -0
- maleo_identity/models/transfers/general/organization.py +15 -13
- maleo_identity/models/transfers/general/organization_role.py +7 -6
- maleo_identity/models/transfers/general/user.py +8 -3
- maleo_identity/models/transfers/general/user_organization.py +3 -2
- maleo_identity/models/transfers/general/user_organization_role.py +8 -7
- maleo_identity/models/transfers/general/user_profile.py +18 -2
- maleo_identity/models/transfers/general/user_system_role.py +3 -2
- maleo_identity/models/transfers/parameters/client/organization.py +65 -14
- maleo_identity/models/transfers/parameters/client/organization_role.py +14 -12
- maleo_identity/models/transfers/parameters/client/user.py +20 -20
- maleo_identity/models/transfers/parameters/client/user_organization.py +18 -17
- maleo_identity/models/transfers/parameters/client/user_organization_role.py +17 -15
- maleo_identity/models/transfers/parameters/client/user_profile.py +10 -9
- maleo_identity/models/transfers/parameters/client/user_system_role.py +13 -12
- maleo_identity/models/transfers/parameters/general/organization.py +18 -13
- maleo_identity/models/transfers/parameters/general/organization_role.py +9 -8
- maleo_identity/models/transfers/parameters/general/user.py +23 -14
- maleo_identity/models/transfers/parameters/general/user_organization.py +14 -10
- maleo_identity/models/transfers/parameters/general/user_organization_role.py +10 -8
- maleo_identity/models/transfers/parameters/general/user_profile.py +30 -14
- maleo_identity/models/transfers/parameters/general/user_system_role.py +14 -10
- maleo_identity/models/transfers/parameters/service/organization.py +54 -14
- maleo_identity/models/transfers/parameters/service/organization_role.py +11 -9
- maleo_identity/models/transfers/parameters/service/user.py +20 -20
- maleo_identity/models/transfers/parameters/service/user_organization.py +12 -11
- maleo_identity/models/transfers/parameters/service/user_organization_role.py +13 -11
- maleo_identity/models/transfers/parameters/service/user_profile.py +10 -9
- maleo_identity/models/transfers/parameters/service/user_system_role.py +10 -9
- maleo_identity/models/transfers/results/client/organization.py +8 -2
- maleo_identity/models/transfers/results/general/organization.py +8 -2
- maleo_identity/models/transfers/results/repository/organization.py +10 -8
- maleo_identity/models/transfers/results/repository/organization_role.py +4 -8
- maleo_identity/models/transfers/results/repository/user.py +5 -15
- maleo_identity/models/transfers/results/repository/user_organization.py +4 -8
- maleo_identity/models/transfers/results/repository/user_organization_role.py +4 -8
- maleo_identity/models/transfers/results/repository/user_profile.py +4 -8
- maleo_identity/models/transfers/results/repository/user_system_role.py +4 -8
- maleo_identity/types/results/client/organization.py +11 -0
- maleo_identity/types/results/general/organization.py +12 -0
- maleo_identity/types/results/repository/organization.py +12 -0
- {maleo_identity-0.0.43.dist-info → maleo_identity-0.0.44.dist-info}/METADATA +3 -3
- {maleo_identity-0.0.43.dist-info → maleo_identity-0.0.44.dist-info}/RECORD +65 -81
- {maleo_identity-0.0.43.dist-info → maleo_identity-0.0.44.dist-info}/WHEEL +1 -1
- maleo_identity/models/schemas/general/__init__.py +0 -17
- maleo_identity/models/schemas/general/organization_role.py +0 -29
- maleo_identity/models/schemas/general/user_organization.py +0 -20
- maleo_identity/models/schemas/general/user_organization_role.py +0 -35
- maleo_identity/models/schemas/general/user_system_role.py +0 -14
- maleo_identity/models/schemas/parameters/__init__.py +0 -17
- maleo_identity/models/schemas/parameters/organization.py +0 -10
- maleo_identity/models/schemas/parameters/organization_role.py +0 -7
- maleo_identity/models/schemas/parameters/user.py +0 -16
- maleo_identity/models/schemas/parameters/user_organization.py +0 -7
- maleo_identity/models/schemas/parameters/user_organization_role.py +0 -8
- maleo_identity/models/schemas/parameters/user_profile.py +0 -22
- maleo_identity/models/schemas/parameters/user_system_role.py +0 -8
- maleo_identity/models/schemas/results/__init__.py +0 -17
- maleo_identity/models/schemas/results/organization.py +0 -18
- maleo_identity/models/schemas/results/organization_role.py +0 -10
- maleo_identity/models/schemas/results/user.py +0 -22
- maleo_identity/models/schemas/results/user_organization.py +0 -7
- maleo_identity/models/schemas/results/user_organization_role.py +0 -11
- maleo_identity/models/schemas/results/user_profile.py +0 -34
- maleo_identity/models/schemas/results/user_system_role.py +0 -8
- {maleo_identity-0.0.43.dist-info → maleo_identity-0.0.44.dist-info}/top_level.txt +0 -0
|
@@ -50,6 +50,36 @@ class MaleoIdentityOrganizationHTTPController(MaleoClientHTTPController):
|
|
|
50
50
|
response = await client.get(url=url, params=params, auth=auth)
|
|
51
51
|
return BaseClientHTTPControllerResults(response=response)
|
|
52
52
|
|
|
53
|
+
async def get_structured_organizations(
|
|
54
|
+
self,
|
|
55
|
+
parameters:MaleoIdentityOrganizationClientParametersTransfers.GetMultipleStructured
|
|
56
|
+
) -> BaseClientHTTPControllerResults:
|
|
57
|
+
"""Fetch structured organizations from MaleoIdentity"""
|
|
58
|
+
async with self._manager.get_client() as client:
|
|
59
|
+
#* Define URL
|
|
60
|
+
url = f"{self._manager.url.api}/v1/organizations/structured"
|
|
61
|
+
|
|
62
|
+
#* Parse parameters to query params
|
|
63
|
+
params = (
|
|
64
|
+
MaleoIdentityOrganizationClientParametersTransfers
|
|
65
|
+
.GetMultipleStructuredQuery
|
|
66
|
+
.model_validate(
|
|
67
|
+
parameters.model_dump()
|
|
68
|
+
)
|
|
69
|
+
.model_dump(
|
|
70
|
+
exclude={"sort_columns", "date_filters"},
|
|
71
|
+
exclude_none=True
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
#* Create auth
|
|
76
|
+
token = self._service_manager.token
|
|
77
|
+
auth = BearerAuth(token=token) if token is not None else None
|
|
78
|
+
|
|
79
|
+
#* Send request and wait for response
|
|
80
|
+
response = await client.get(url=url, params=params, auth=auth)
|
|
81
|
+
return BaseClientHTTPControllerResults(response=response)
|
|
82
|
+
|
|
53
83
|
async def get_organization(
|
|
54
84
|
self,
|
|
55
85
|
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.GetSingle
|
|
@@ -77,6 +107,63 @@ class MaleoIdentityOrganizationHTTPController(MaleoClientHTTPController):
|
|
|
77
107
|
response = await client.get(url=url, params=params, auth=auth)
|
|
78
108
|
return BaseClientHTTPControllerResults(response=response)
|
|
79
109
|
|
|
110
|
+
async def get_structured_organization(
|
|
111
|
+
self,
|
|
112
|
+
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.GetSingle
|
|
113
|
+
) -> BaseClientHTTPControllerResults:
|
|
114
|
+
"""Fetch structured organization from MaleoIdentity"""
|
|
115
|
+
async with self._manager.get_client() as client:
|
|
116
|
+
#* Define URL
|
|
117
|
+
url = f"{self._manager.url.api}/v1/organizations/{parameters.identifier}/{parameters.value}/structured"
|
|
118
|
+
|
|
119
|
+
#* Parse parameters to query params
|
|
120
|
+
params = (
|
|
121
|
+
MaleoIdentityOrganizationGeneralParametersTransfers
|
|
122
|
+
.GetSingleQuery
|
|
123
|
+
.model_validate(
|
|
124
|
+
parameters.model_dump()
|
|
125
|
+
)
|
|
126
|
+
.model_dump(exclude_none=True)
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
#* Create auth
|
|
130
|
+
token = self._service_manager.token
|
|
131
|
+
auth = BearerAuth(token=token) if token is not None else None
|
|
132
|
+
|
|
133
|
+
#* Send request and wait for response
|
|
134
|
+
response = await client.get(url=url, params=params, auth=auth)
|
|
135
|
+
return BaseClientHTTPControllerResults(response=response)
|
|
136
|
+
|
|
137
|
+
async def get_organization_children(
|
|
138
|
+
self,
|
|
139
|
+
parameters:MaleoIdentityOrganizationClientParametersTransfers.GetMultipleChildren
|
|
140
|
+
) -> BaseClientHTTPControllerResults:
|
|
141
|
+
"""Fetch organization's children from MaleoIdentity"""
|
|
142
|
+
async with self._manager.get_client() as client:
|
|
143
|
+
#* Define URL
|
|
144
|
+
url = f"{self._manager.url.api}/v1/organizations/{parameters.organization_id}/children"
|
|
145
|
+
|
|
146
|
+
#* Parse parameters to query params
|
|
147
|
+
params = (
|
|
148
|
+
MaleoIdentityOrganizationClientParametersTransfers
|
|
149
|
+
.GetMultipleChildrenQuery
|
|
150
|
+
.model_validate(
|
|
151
|
+
parameters.model_dump()
|
|
152
|
+
)
|
|
153
|
+
.model_dump(
|
|
154
|
+
exclude={"sort_columns", "date_filters"},
|
|
155
|
+
exclude_none=True
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
#* Create auth
|
|
160
|
+
token = self._service_manager.token
|
|
161
|
+
auth = BearerAuth(token=token) if token is not None else None
|
|
162
|
+
|
|
163
|
+
#* Send request and wait for response
|
|
164
|
+
response = await client.get(url=url, params=params, auth=auth)
|
|
165
|
+
return BaseClientHTTPControllerResults(response=response)
|
|
166
|
+
|
|
80
167
|
async def create(
|
|
81
168
|
self,
|
|
82
169
|
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.Create
|
|
@@ -72,13 +72,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
72
72
|
no_data_class=MaleoIdentityOrganizationClientResultsTransfers.NoData
|
|
73
73
|
)
|
|
74
74
|
@cached(
|
|
75
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
75
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
76
76
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
77
77
|
"organization",
|
|
78
78
|
type=BaseEnums.CacheType.CLIENT,
|
|
79
79
|
base_override=self.key
|
|
80
80
|
),
|
|
81
81
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
82
|
+
skip_cache_func=lambda x: (
|
|
83
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
84
|
+
or x is None
|
|
85
|
+
or (
|
|
86
|
+
isinstance(x, dict)
|
|
87
|
+
and (
|
|
88
|
+
x.get("success") in [False, None]
|
|
89
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
),
|
|
82
93
|
cache=Cache.REDIS,
|
|
83
94
|
serializer=JsonSerializer(),
|
|
84
95
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -142,6 +153,104 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
142
153
|
controller_type=controller_type
|
|
143
154
|
)
|
|
144
155
|
|
|
156
|
+
async def get_structured_organizations(
|
|
157
|
+
self,
|
|
158
|
+
parameters:MaleoIdentityOrganizationClientParametersTransfers.GetMultipleStructured,
|
|
159
|
+
controller_type:MaleoIdentityGeneralEnums.ClientControllerType = MaleoIdentityGeneralEnums.ClientControllerType.HTTP
|
|
160
|
+
) -> MaleoIdentityOrganizationClientResultsTypes.GetMultipleStructured:
|
|
161
|
+
"""Retrieve structured organizations from MaleoIdentity"""
|
|
162
|
+
@BaseExceptions.service_exception_handler(
|
|
163
|
+
operation="retrieving structured organizations",
|
|
164
|
+
logger=self._logger,
|
|
165
|
+
fail_result_class=MaleoIdentityOrganizationClientResultsTransfers.Fail
|
|
166
|
+
)
|
|
167
|
+
@BaseClientUtils.result_processor(
|
|
168
|
+
fail_class=MaleoIdentityOrganizationClientResultsTransfers.Fail,
|
|
169
|
+
data_found_class=MaleoIdentityOrganizationClientResultsTransfers.MultipleStructured,
|
|
170
|
+
no_data_class=MaleoIdentityOrganizationClientResultsTransfers.NoData
|
|
171
|
+
)
|
|
172
|
+
@cached(
|
|
173
|
+
ttl=int(BaseEnums.CacheTTL.TTL_1WK),
|
|
174
|
+
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
175
|
+
"organization",
|
|
176
|
+
type=BaseEnums.CacheType.CLIENT,
|
|
177
|
+
base_override=self.key
|
|
178
|
+
),
|
|
179
|
+
key_builder=BaseCacheConfigurations.key_builder,
|
|
180
|
+
skip_cache_func=lambda x: (
|
|
181
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
182
|
+
or x is None
|
|
183
|
+
or (
|
|
184
|
+
isinstance(x, dict)
|
|
185
|
+
and (
|
|
186
|
+
x.get("success") in [False, None]
|
|
187
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
),
|
|
191
|
+
cache=Cache.REDIS,
|
|
192
|
+
serializer=JsonSerializer(),
|
|
193
|
+
endpoint=self.service_manager.configs.cache.redis.host,
|
|
194
|
+
port=self.service_manager.configs.cache.redis.port,
|
|
195
|
+
password=self.service_manager.configs.cache.redis.password,
|
|
196
|
+
db=self.service_manager.configs.cache.redis.db
|
|
197
|
+
)
|
|
198
|
+
async def _impl(
|
|
199
|
+
parameters:MaleoIdentityOrganizationClientParametersTransfers.GetMultipleStructured,
|
|
200
|
+
controller_type:MaleoIdentityGeneralEnums.ClientControllerType = MaleoIdentityGeneralEnums.ClientControllerType.HTTP
|
|
201
|
+
):
|
|
202
|
+
#* Validate chosen controller type
|
|
203
|
+
if not isinstance(
|
|
204
|
+
controller_type,
|
|
205
|
+
MaleoIdentityGeneralEnums.ClientControllerType
|
|
206
|
+
):
|
|
207
|
+
message = "Invalid controller type"
|
|
208
|
+
description = "The provided controller type did not exists"
|
|
209
|
+
return MaleoIdentityOrganizationClientResultsTransfers.Fail(
|
|
210
|
+
message=message,
|
|
211
|
+
description=description
|
|
212
|
+
)
|
|
213
|
+
#* Retrieve structured organizations using chosen controller
|
|
214
|
+
if controller_type == MaleoIdentityGeneralEnums.ClientControllerType.HTTP:
|
|
215
|
+
controller_result = (
|
|
216
|
+
await self._controllers.http
|
|
217
|
+
.get_structured_organizations(parameters=parameters)
|
|
218
|
+
)
|
|
219
|
+
else:
|
|
220
|
+
message = "Invalid controller type"
|
|
221
|
+
description = "The provided controller type has not been implemented"
|
|
222
|
+
return MaleoIdentityOrganizationClientResultsTransfers.Fail(
|
|
223
|
+
message=message,
|
|
224
|
+
description=description
|
|
225
|
+
)
|
|
226
|
+
#* Return proper response
|
|
227
|
+
if not controller_result.success:
|
|
228
|
+
return (
|
|
229
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
230
|
+
.Fail
|
|
231
|
+
.model_validate(controller_result.content)
|
|
232
|
+
.model_dump(mode="json")
|
|
233
|
+
)
|
|
234
|
+
else:
|
|
235
|
+
if controller_result.content["data"] is None:
|
|
236
|
+
return (
|
|
237
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
238
|
+
.NoData
|
|
239
|
+
.model_validate(controller_result.content)
|
|
240
|
+
.model_dump(mode="json")
|
|
241
|
+
)
|
|
242
|
+
else:
|
|
243
|
+
return (
|
|
244
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
245
|
+
.MultipleStructured
|
|
246
|
+
.model_validate(controller_result.content)
|
|
247
|
+
.model_dump(mode="json")
|
|
248
|
+
)
|
|
249
|
+
return await _impl(
|
|
250
|
+
parameters=parameters,
|
|
251
|
+
controller_type=controller_type
|
|
252
|
+
)
|
|
253
|
+
|
|
145
254
|
async def get_organization(
|
|
146
255
|
self,
|
|
147
256
|
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.GetSingle,
|
|
@@ -158,13 +267,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
158
267
|
data_found_class=MaleoIdentityOrganizationClientResultsTransfers.SingleData
|
|
159
268
|
)
|
|
160
269
|
@cached(
|
|
161
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
270
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
162
271
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
163
272
|
"organization",
|
|
164
273
|
type=BaseEnums.CacheType.CLIENT,
|
|
165
274
|
base_override=self.key
|
|
166
275
|
),
|
|
167
276
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
277
|
+
skip_cache_func=lambda x: (
|
|
278
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
279
|
+
or x is None
|
|
280
|
+
or (
|
|
281
|
+
isinstance(x, dict)
|
|
282
|
+
and (
|
|
283
|
+
x.get("success") in [False, None]
|
|
284
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
285
|
+
)
|
|
286
|
+
)
|
|
287
|
+
),
|
|
168
288
|
cache=Cache.REDIS,
|
|
169
289
|
serializer=JsonSerializer(),
|
|
170
290
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -220,6 +340,192 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
220
340
|
controller_type=controller_type
|
|
221
341
|
)
|
|
222
342
|
|
|
343
|
+
async def get_structured_organization(
|
|
344
|
+
self,
|
|
345
|
+
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.GetSingle,
|
|
346
|
+
controller_type:MaleoIdentityGeneralEnums.ClientControllerType = MaleoIdentityGeneralEnums.ClientControllerType.HTTP
|
|
347
|
+
) -> MaleoIdentityOrganizationClientResultsTypes.GetSingleStructured:
|
|
348
|
+
"""Retrieve structured organization from MaleoIdentity"""
|
|
349
|
+
@BaseExceptions.service_exception_handler(
|
|
350
|
+
operation="retrieving structured organization",
|
|
351
|
+
logger=self._logger,
|
|
352
|
+
fail_result_class=MaleoIdentityOrganizationClientResultsTransfers.Fail
|
|
353
|
+
)
|
|
354
|
+
@BaseClientUtils.result_processor(
|
|
355
|
+
fail_class=MaleoIdentityOrganizationClientResultsTransfers.Fail,
|
|
356
|
+
data_found_class=MaleoIdentityOrganizationClientResultsTransfers.SingleStructured
|
|
357
|
+
)
|
|
358
|
+
@cached(
|
|
359
|
+
ttl=int(BaseEnums.CacheTTL.TTL_1WK),
|
|
360
|
+
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
361
|
+
"organization",
|
|
362
|
+
type=BaseEnums.CacheType.CLIENT,
|
|
363
|
+
base_override=self.key
|
|
364
|
+
),
|
|
365
|
+
key_builder=BaseCacheConfigurations.key_builder,
|
|
366
|
+
skip_cache_func=lambda x: (
|
|
367
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
368
|
+
or x is None
|
|
369
|
+
or (
|
|
370
|
+
isinstance(x, dict)
|
|
371
|
+
and (
|
|
372
|
+
x.get("success") in [False, None]
|
|
373
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
374
|
+
)
|
|
375
|
+
)
|
|
376
|
+
),
|
|
377
|
+
cache=Cache.REDIS,
|
|
378
|
+
serializer=JsonSerializer(),
|
|
379
|
+
endpoint=self.service_manager.configs.cache.redis.host,
|
|
380
|
+
port=self.service_manager.configs.cache.redis.port,
|
|
381
|
+
password=self.service_manager.configs.cache.redis.password,
|
|
382
|
+
db=self.service_manager.configs.cache.redis.db
|
|
383
|
+
)
|
|
384
|
+
async def _impl(
|
|
385
|
+
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.GetSingle,
|
|
386
|
+
controller_type:MaleoIdentityGeneralEnums.ClientControllerType = MaleoIdentityGeneralEnums.ClientControllerType.HTTP
|
|
387
|
+
):
|
|
388
|
+
#* Validate chosen controller type
|
|
389
|
+
if not isinstance(
|
|
390
|
+
controller_type,
|
|
391
|
+
MaleoIdentityGeneralEnums.ClientControllerType
|
|
392
|
+
):
|
|
393
|
+
message = "Invalid controller type"
|
|
394
|
+
description = "The provided controller type did not exists"
|
|
395
|
+
return MaleoIdentityOrganizationClientResultsTransfers.Fail(
|
|
396
|
+
message=message,
|
|
397
|
+
description=description
|
|
398
|
+
)
|
|
399
|
+
#* Retrieve structured organization using chosen controller
|
|
400
|
+
if controller_type == MaleoIdentityGeneralEnums.ClientControllerType.HTTP:
|
|
401
|
+
controller_result = (
|
|
402
|
+
await self._controllers.http
|
|
403
|
+
.get_structured_organization(parameters=parameters)
|
|
404
|
+
)
|
|
405
|
+
else:
|
|
406
|
+
message = "Invalid controller type"
|
|
407
|
+
description = "The provided controller type has not been implemented"
|
|
408
|
+
return MaleoIdentityOrganizationClientResultsTransfers.Fail(
|
|
409
|
+
message=message,
|
|
410
|
+
description=description
|
|
411
|
+
)
|
|
412
|
+
#* Return proper response
|
|
413
|
+
if not controller_result.success:
|
|
414
|
+
return (
|
|
415
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
416
|
+
.Fail
|
|
417
|
+
.model_validate(controller_result.content)
|
|
418
|
+
.model_dump(mode="json")
|
|
419
|
+
)
|
|
420
|
+
else:
|
|
421
|
+
return (
|
|
422
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
423
|
+
.SingleStructured
|
|
424
|
+
.model_validate(controller_result.content)
|
|
425
|
+
.model_dump(mode="json")
|
|
426
|
+
)
|
|
427
|
+
return await _impl(
|
|
428
|
+
parameters=parameters,
|
|
429
|
+
controller_type=controller_type
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
async def get_organization_children(
|
|
433
|
+
self,
|
|
434
|
+
parameters:MaleoIdentityOrganizationClientParametersTransfers.GetMultipleChildren,
|
|
435
|
+
controller_type:MaleoIdentityGeneralEnums.ClientControllerType = MaleoIdentityGeneralEnums.ClientControllerType.HTTP
|
|
436
|
+
) -> MaleoIdentityOrganizationClientResultsTypes.GetMultiple:
|
|
437
|
+
"""Retrieve organization's children from MaleoIdentity"""
|
|
438
|
+
@BaseExceptions.service_exception_handler(
|
|
439
|
+
operation="retrieving organization's children",
|
|
440
|
+
logger=self._logger,
|
|
441
|
+
fail_result_class=MaleoIdentityOrganizationClientResultsTransfers.Fail
|
|
442
|
+
)
|
|
443
|
+
@BaseClientUtils.result_processor(
|
|
444
|
+
fail_class=MaleoIdentityOrganizationClientResultsTransfers.Fail,
|
|
445
|
+
data_found_class=MaleoIdentityOrganizationClientResultsTransfers.MultipleData
|
|
446
|
+
)
|
|
447
|
+
@cached(
|
|
448
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
449
|
+
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
450
|
+
"organization",
|
|
451
|
+
type=BaseEnums.CacheType.CLIENT,
|
|
452
|
+
base_override=self.key
|
|
453
|
+
),
|
|
454
|
+
key_builder=BaseCacheConfigurations.key_builder,
|
|
455
|
+
skip_cache_func=lambda x: (
|
|
456
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
457
|
+
or x is None
|
|
458
|
+
or (
|
|
459
|
+
isinstance(x, dict)
|
|
460
|
+
and (
|
|
461
|
+
x.get("success") in [False, None]
|
|
462
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
463
|
+
)
|
|
464
|
+
)
|
|
465
|
+
),
|
|
466
|
+
cache=Cache.REDIS,
|
|
467
|
+
serializer=JsonSerializer(),
|
|
468
|
+
endpoint=self.service_manager.configs.cache.redis.host,
|
|
469
|
+
port=self.service_manager.configs.cache.redis.port,
|
|
470
|
+
password=self.service_manager.configs.cache.redis.password,
|
|
471
|
+
db=self.service_manager.configs.cache.redis.db
|
|
472
|
+
)
|
|
473
|
+
async def _impl(
|
|
474
|
+
parameters:MaleoIdentityOrganizationClientParametersTransfers.GetMultipleChildren,
|
|
475
|
+
controller_type:MaleoIdentityGeneralEnums.ClientControllerType = MaleoIdentityGeneralEnums.ClientControllerType.HTTP
|
|
476
|
+
):
|
|
477
|
+
#* Validate chosen controller type
|
|
478
|
+
if not isinstance(
|
|
479
|
+
controller_type,
|
|
480
|
+
MaleoIdentityGeneralEnums.ClientControllerType
|
|
481
|
+
):
|
|
482
|
+
message = "Invalid controller type"
|
|
483
|
+
description = "The provided controller type did not exists"
|
|
484
|
+
return MaleoIdentityOrganizationClientResultsTransfers.Fail(
|
|
485
|
+
message=message,
|
|
486
|
+
description=description
|
|
487
|
+
)
|
|
488
|
+
#* Retrieve organization's children using chosen controller
|
|
489
|
+
if controller_type == MaleoIdentityGeneralEnums.ClientControllerType.HTTP:
|
|
490
|
+
controller_result = (
|
|
491
|
+
await self._controllers.http
|
|
492
|
+
.get_organization_children(parameters=parameters)
|
|
493
|
+
)
|
|
494
|
+
else:
|
|
495
|
+
message = "Invalid controller type"
|
|
496
|
+
description = "The provided controller type has not been implemented"
|
|
497
|
+
return MaleoIdentityOrganizationClientResultsTransfers.Fail(
|
|
498
|
+
message=message,
|
|
499
|
+
description=description
|
|
500
|
+
)
|
|
501
|
+
#* Return proper response
|
|
502
|
+
if not controller_result.success:
|
|
503
|
+
return (
|
|
504
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
505
|
+
.Fail
|
|
506
|
+
.model_validate(controller_result.content)
|
|
507
|
+
.model_dump(mode="json")
|
|
508
|
+
)
|
|
509
|
+
else:
|
|
510
|
+
if controller_result.content["data"] is None:
|
|
511
|
+
return (
|
|
512
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
513
|
+
.NoData
|
|
514
|
+
.model_validate(controller_result.content)
|
|
515
|
+
.model_dump(mode="json")
|
|
516
|
+
)
|
|
517
|
+
else:
|
|
518
|
+
return (
|
|
519
|
+
MaleoIdentityOrganizationClientResultsTransfers
|
|
520
|
+
.MultipleData
|
|
521
|
+
.model_validate(controller_result.content)
|
|
522
|
+
.model_dump(mode="json")
|
|
523
|
+
)
|
|
524
|
+
return await _impl(
|
|
525
|
+
parameters=parameters,
|
|
526
|
+
controller_type=controller_type
|
|
527
|
+
)
|
|
528
|
+
|
|
223
529
|
async def create(
|
|
224
530
|
self,
|
|
225
531
|
parameters:MaleoIdentityOrganizationGeneralParametersTransfers.Create,
|
|
@@ -351,13 +657,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
351
657
|
no_data_class=MaleoIdentityUserOrganizationClientResultsTransfers.NoData
|
|
352
658
|
)
|
|
353
659
|
@cached(
|
|
354
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
660
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
355
661
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
356
662
|
"organization_user",
|
|
357
663
|
type=BaseEnums.CacheType.CLIENT,
|
|
358
664
|
base_override=self.key
|
|
359
665
|
),
|
|
360
666
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
667
|
+
skip_cache_func=lambda x: (
|
|
668
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
669
|
+
or x is None
|
|
670
|
+
or (
|
|
671
|
+
isinstance(x, dict)
|
|
672
|
+
and (
|
|
673
|
+
x.get("success") in [False, None]
|
|
674
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
675
|
+
)
|
|
676
|
+
)
|
|
677
|
+
),
|
|
361
678
|
cache=Cache.REDIS,
|
|
362
679
|
serializer=JsonSerializer(),
|
|
363
680
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -437,13 +754,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
437
754
|
data_found_class=MaleoIdentityUserOrganizationClientResultsTransfers.SingleData
|
|
438
755
|
)
|
|
439
756
|
@cached(
|
|
440
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
757
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
441
758
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
442
759
|
"user_organization",
|
|
443
760
|
type=BaseEnums.CacheType.CLIENT,
|
|
444
761
|
base_override=self.key
|
|
445
762
|
),
|
|
446
763
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
764
|
+
skip_cache_func=lambda x: (
|
|
765
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
766
|
+
or x is None
|
|
767
|
+
or (
|
|
768
|
+
isinstance(x, dict)
|
|
769
|
+
and (
|
|
770
|
+
x.get("success") in [False, None]
|
|
771
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
772
|
+
)
|
|
773
|
+
)
|
|
774
|
+
),
|
|
447
775
|
cache=Cache.REDIS,
|
|
448
776
|
serializer=JsonSerializer(),
|
|
449
777
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -516,13 +844,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
516
844
|
no_data_class=MaleoIdentityOrganizationRoleClientResultsTransfers.NoData
|
|
517
845
|
)
|
|
518
846
|
@cached(
|
|
519
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
847
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
520
848
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
521
849
|
"organization_role",
|
|
522
850
|
type=BaseEnums.CacheType.CLIENT,
|
|
523
851
|
base_override=self.key
|
|
524
852
|
),
|
|
525
853
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
854
|
+
skip_cache_func=lambda x: (
|
|
855
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
856
|
+
or x is None
|
|
857
|
+
or (
|
|
858
|
+
isinstance(x, dict)
|
|
859
|
+
and (
|
|
860
|
+
x.get("success") in [False, None]
|
|
861
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
862
|
+
)
|
|
863
|
+
)
|
|
864
|
+
),
|
|
526
865
|
cache=Cache.REDIS,
|
|
527
866
|
serializer=JsonSerializer(),
|
|
528
867
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -602,13 +941,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
602
941
|
data_found_class=MaleoIdentityOrganizationRoleClientResultsTransfers.SingleData
|
|
603
942
|
)
|
|
604
943
|
@cached(
|
|
605
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
944
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
606
945
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
607
946
|
"organization_role",
|
|
608
947
|
type=BaseEnums.CacheType.CLIENT,
|
|
609
948
|
base_override=self.key
|
|
610
949
|
),
|
|
611
950
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
951
|
+
skip_cache_func=lambda x: (
|
|
952
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
953
|
+
or x is None
|
|
954
|
+
or (
|
|
955
|
+
isinstance(x, dict)
|
|
956
|
+
and (
|
|
957
|
+
x.get("success") in [False, None]
|
|
958
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
959
|
+
)
|
|
960
|
+
)
|
|
961
|
+
),
|
|
612
962
|
cache=Cache.REDIS,
|
|
613
963
|
serializer=JsonSerializer(),
|
|
614
964
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -681,13 +1031,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
681
1031
|
no_data_class=MaleoIdentityUserOrganizationRoleClientResultsTransfers.NoData
|
|
682
1032
|
)
|
|
683
1033
|
@cached(
|
|
684
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
1034
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
685
1035
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
686
1036
|
"user_organization_role",
|
|
687
1037
|
type=BaseEnums.CacheType.CLIENT,
|
|
688
1038
|
base_override=self.key
|
|
689
1039
|
),
|
|
690
1040
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
1041
|
+
skip_cache_func=lambda x: (
|
|
1042
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
1043
|
+
or x is None
|
|
1044
|
+
or (
|
|
1045
|
+
isinstance(x, dict)
|
|
1046
|
+
and (
|
|
1047
|
+
x.get("success") in [False, None]
|
|
1048
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
1049
|
+
)
|
|
1050
|
+
)
|
|
1051
|
+
),
|
|
691
1052
|
cache=Cache.REDIS,
|
|
692
1053
|
serializer=JsonSerializer(),
|
|
693
1054
|
endpoint=self.service_manager.configs.cache.redis.host,
|
|
@@ -767,13 +1128,24 @@ class MaleoIdentityOrganizationClientService(MaleoClientService):
|
|
|
767
1128
|
data_found_class=MaleoIdentityUserOrganizationRoleClientResultsTransfers.SingleData
|
|
768
1129
|
)
|
|
769
1130
|
@cached(
|
|
770
|
-
ttl=int(BaseEnums.CacheTTL.
|
|
1131
|
+
ttl=int(BaseEnums.CacheTTL.TTL_30MN),
|
|
771
1132
|
namespace=self.service_manager.configs.cache.redis.namespaces.create(
|
|
772
1133
|
"user_organization_role",
|
|
773
1134
|
type=BaseEnums.CacheType.CLIENT,
|
|
774
1135
|
base_override=self.key
|
|
775
1136
|
),
|
|
776
1137
|
key_builder=BaseCacheConfigurations.key_builder,
|
|
1138
|
+
skip_cache_func=lambda x: (
|
|
1139
|
+
self.service_manager.settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
|
|
1140
|
+
or x is None
|
|
1141
|
+
or (
|
|
1142
|
+
isinstance(x, dict)
|
|
1143
|
+
and (
|
|
1144
|
+
x.get("success") in [False, None]
|
|
1145
|
+
or (x.get("success") is True and x.get("data") is None)
|
|
1146
|
+
)
|
|
1147
|
+
)
|
|
1148
|
+
),
|
|
777
1149
|
cache=Cache.REDIS,
|
|
778
1150
|
serializer=JsonSerializer(),
|
|
779
1151
|
endpoint=self.service_manager.configs.cache.redis.host,
|