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.
Files changed (138) hide show
  1. maleo/identity/constants/api_key.py +13 -0
  2. maleo/identity/constants/organization.py +3 -10
  3. maleo/identity/constants/organization_registration_code.py +5 -17
  4. maleo/identity/constants/organization_relation.py +13 -0
  5. maleo/identity/constants/patient.py +7 -0
  6. maleo/identity/constants/user.py +3 -20
  7. maleo/identity/constants/user_medical_role.py +13 -0
  8. maleo/identity/constants/user_organization_role.py +5 -39
  9. maleo/identity/constants/user_profile.py +3 -21
  10. maleo/identity/constants/user_system_role.py +9 -8
  11. maleo/identity/enums/api_key.py +25 -0
  12. maleo/identity/enums/organization.py +16 -3
  13. maleo/identity/enums/organization_registration_code.py +9 -0
  14. maleo/identity/enums/organization_relation.py +22 -0
  15. maleo/identity/enums/patient.py +29 -0
  16. maleo/identity/enums/user.py +16 -7
  17. maleo/identity/enums/user_medical_role.py +22 -0
  18. maleo/identity/enums/user_organization_role.py +19 -12
  19. maleo/identity/enums/user_profile.py +7 -9
  20. maleo/identity/enums/user_system_role.py +30 -0
  21. maleo/identity/mixins/api_key.py +72 -0
  22. maleo/identity/mixins/common.py +29 -0
  23. maleo/identity/mixins/organization.py +68 -8
  24. maleo/identity/mixins/organization_registration_code.py +126 -9
  25. maleo/identity/mixins/organization_relation.py +80 -0
  26. maleo/identity/mixins/patient.py +65 -0
  27. maleo/identity/mixins/user.py +86 -24
  28. maleo/identity/mixins/user_medical_role.py +68 -0
  29. maleo/identity/mixins/user_organization_role.py +68 -4
  30. maleo/identity/mixins/user_profile.py +84 -53
  31. maleo/identity/mixins/user_system_role.py +72 -4
  32. maleo/identity/schemas/api_key.py +171 -0
  33. maleo/identity/schemas/common.py +335 -0
  34. maleo/identity/schemas/organization.py +311 -0
  35. maleo/identity/schemas/organization_registration_code.py +314 -0
  36. maleo/identity/schemas/organization_relation.py +315 -0
  37. maleo/identity/schemas/patient.py +349 -0
  38. maleo/identity/schemas/user.py +318 -0
  39. maleo/identity/schemas/user_medical_role.py +316 -0
  40. maleo/identity/schemas/user_organization_role.py +317 -0
  41. maleo/identity/schemas/user_profile.py +362 -0
  42. maleo/identity/schemas/user_system_role.py +339 -0
  43. maleo/identity/types/api_key.py +7 -0
  44. maleo/identity/types/organization.py +4 -0
  45. maleo/identity/types/organization_registration_code.py +4 -0
  46. maleo/identity/types/organization_relation.py +7 -0
  47. maleo/identity/types/patient.py +4 -0
  48. maleo/identity/types/user.py +4 -0
  49. maleo/identity/types/user_medical_role.py +7 -0
  50. maleo/identity/types/user_organization_role.py +7 -0
  51. maleo/identity/types/user_profile.py +4 -0
  52. maleo/identity/types/user_system_role.py +8 -0
  53. maleo/identity/utils/organization.py +32 -0
  54. maleo/identity/utils/user.py +32 -0
  55. maleo_identity-0.1.24.dist-info/METADATA +119 -0
  56. maleo_identity-0.1.24.dist-info/RECORD +66 -0
  57. maleo_identity-0.1.24.dist-info/licenses/LICENSE +57 -0
  58. maleo/identity/client/manager.py +0 -157
  59. maleo/identity/client/services/__init__.py +0 -0
  60. maleo/identity/client/services/organization.py +0 -1944
  61. maleo/identity/client/services/organization_registration_code.py +0 -470
  62. maleo/identity/client/services/organization_role.py +0 -276
  63. maleo/identity/client/services/user.py +0 -1559
  64. maleo/identity/client/services/user_organization.py +0 -276
  65. maleo/identity/client/services/user_organization_role.py +0 -278
  66. maleo/identity/client/services/user_profile.py +0 -276
  67. maleo/identity/client/services/user_system_role.py +0 -276
  68. maleo/identity/constants/organization_role.py +0 -35
  69. maleo/identity/constants/user_organization.py +0 -58
  70. maleo/identity/db.py +0 -4
  71. maleo/identity/dtos/__init__.py +0 -0
  72. maleo/identity/dtos/configuration.py +0 -15
  73. maleo/identity/dtos/data/__init__.py +0 -0
  74. maleo/identity/dtos/data/organization_registration_code.py +0 -15
  75. maleo/identity/dtos/data/user_profile.py +0 -29
  76. maleo/identity/dtos/settings.py +0 -17
  77. maleo/identity/enums/general.py +0 -5
  78. maleo/identity/enums/organization_role.py +0 -7
  79. maleo/identity/enums/user_organization.py +0 -14
  80. maleo/identity/mixins/organization_role.py +0 -15
  81. maleo/identity/mixins/user_organization.py +0 -6
  82. maleo/identity/models/__init__.py +0 -0
  83. maleo/identity/models/organization.py +0 -62
  84. maleo/identity/models/organization_registration_code.py +0 -33
  85. maleo/identity/models/organization_role.py +0 -37
  86. maleo/identity/models/user.py +0 -39
  87. maleo/identity/models/user_organization.py +0 -48
  88. maleo/identity/models/user_organization_role.py +0 -61
  89. maleo/identity/models/user_profile.py +0 -33
  90. maleo/identity/models/user_system_role.py +0 -26
  91. maleo/identity/schemas/data/__init__.py +0 -0
  92. maleo/identity/schemas/data/organization.py +0 -36
  93. maleo/identity/schemas/data/organization_registration_code.py +0 -27
  94. maleo/identity/schemas/data/organization_role.py +0 -32
  95. maleo/identity/schemas/data/user.py +0 -33
  96. maleo/identity/schemas/data/user_organization.py +0 -23
  97. maleo/identity/schemas/data/user_organization_role.py +0 -13
  98. maleo/identity/schemas/data/user_profile.py +0 -59
  99. maleo/identity/schemas/data/user_system_role.py +0 -25
  100. maleo/identity/schemas/metadata/__init__.py +0 -0
  101. maleo/identity/schemas/metadata/user.py +0 -6
  102. maleo/identity/schemas/parameter/__init__.py +0 -0
  103. maleo/identity/schemas/parameter/client/__init__.py +0 -0
  104. maleo/identity/schemas/parameter/client/organization.py +0 -74
  105. maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
  106. maleo/identity/schemas/parameter/client/organization_role.py +0 -42
  107. maleo/identity/schemas/parameter/client/user.py +0 -44
  108. maleo/identity/schemas/parameter/client/user_organization.py +0 -62
  109. maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
  110. maleo/identity/schemas/parameter/client/user_profile.py +0 -28
  111. maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
  112. maleo/identity/schemas/parameter/general/__init__.py +0 -0
  113. maleo/identity/schemas/parameter/general/organization.py +0 -43
  114. maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -54
  115. maleo/identity/schemas/parameter/general/organization_role.py +0 -14
  116. maleo/identity/schemas/parameter/general/user.py +0 -101
  117. maleo/identity/schemas/parameter/general/user_organization.py +0 -18
  118. maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
  119. maleo/identity/schemas/parameter/general/user_profile.py +0 -70
  120. maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
  121. maleo/identity/schemas/parameter/service/__init__.py +0 -0
  122. maleo/identity/schemas/parameter/service/organization.py +0 -60
  123. maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
  124. maleo/identity/schemas/parameter/service/organization_role.py +0 -35
  125. maleo/identity/schemas/parameter/service/user.py +0 -47
  126. maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
  127. maleo/identity/schemas/parameter/service/user_profile.py +0 -28
  128. maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
  129. maleo/identity/types/base/__init__.py +0 -0
  130. maleo/identity/types/base/organization.py +0 -5
  131. maleo/identity/types/base/organization_registration_code.py +0 -4
  132. maleo/identity/types/base/user.py +0 -5
  133. maleo/identity/types/base/user_profile.py +0 -5
  134. maleo_identity-0.0.85.dist-info/METADATA +0 -40
  135. maleo_identity-0.0.85.dist-info/RECORD +0 -105
  136. /maleo/identity/{client → utils}/__init__.py +0 -0
  137. {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
  138. {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
@@ -1,276 +0,0 @@
1
- # import json
2
- # from copy import deepcopy
3
- # from Crypto.PublicKey.RSA import RsaKey
4
- # from datetime import datetime, timezone
5
- # from redis.asyncio.client import Redis
6
- # from typing import Dict, List, Optional
7
- # from uuid import UUID
8
- # from maleo.soma.authorization import BearerAuth
9
- # from maleo.soma.dtos.configurations.cache.redis import RedisCacheNamespaces
10
- # from maleo.soma.enums.environment import Environment
11
- # from maleo.soma.enums.expiration import Expiration
12
- # from maleo.soma.enums.logging import LogLevel
13
- # from maleo.soma.enums.operation import OperationTarget
14
- # from maleo.soma.managers.client.maleo import MaleoClientService
15
- # from maleo.soma.managers.client.http import HTTPClientManager
16
- # from maleo.soma.managers.credential import CredentialManager
17
- # from maleo.soma.schemas.authentication import Authentication
18
- # from maleo.soma.schemas.authorization import Authorization
19
- # from maleo.soma.schemas.data import DataPair
20
- # from maleo.soma.schemas.operation.context import (
21
- # OperationContextSchema,
22
- # OperationOriginSchema,
23
- # OperationLayerSchema,
24
- # OperationTargetSchema,
25
- # )
26
- # from maleo.soma.schemas.operation.resource import (
27
- # ReadMultipleResourceOperationSchema,
28
- # )
29
- # from maleo.soma.schemas.operation.resource.action import ReadResourceOperationAction
30
- # from maleo.soma.schemas.operation.resource.result import (
31
- # ReadMultipleResourceOperationResult,
32
- # )
33
- # from maleo.soma.schemas.operation.timestamp import OperationTimestamp
34
- # from maleo.soma.schemas.pagination import StrictPagination
35
- # from maleo.soma.schemas.request import RequestContext
36
- # from maleo.soma.schemas.response import (
37
- # MultipleDataResponseSchema,
38
- # )
39
- # from maleo.soma.schemas.service import ServiceContext
40
- # from maleo.soma.utils.cache import build_key
41
- # from maleo.soma.utils.logging import ClientLogger
42
- # from maleo.soma.utils.merger import merge_dicts
43
- # from maleo.soma.utils.token import reencode
44
- # from maleo.identity.constants.user_organization import RESOURCE
45
- # from maleo.identity.schemas.data.user_organization import UserOrganizationDataSchema
46
- # from maleo.identity.schemas.parameter.client.user_organization import (
47
- # ReadMultipleParameter,
48
- # ReadMultipleQueryParameter,
49
- # )
50
-
51
-
52
- # class UserOrganizationClientService(MaleoClientService):
53
- # def __init__(
54
- # self,
55
- # environment: Environment,
56
- # key: str,
57
- # url: str,
58
- # operation_origin: OperationOriginSchema,
59
- # logger: ClientLogger,
60
- # credential_manager: CredentialManager,
61
- # http_client_manager: HTTPClientManager,
62
- # private_key: RsaKey,
63
- # redis: Redis,
64
- # redis_namespaces: RedisCacheNamespaces,
65
- # service_context: ServiceContext,
66
- # ):
67
- # super().__init__(
68
- # environment,
69
- # key,
70
- # url,
71
- # operation_origin,
72
- # logger,
73
- # credential_manager,
74
- # http_client_manager,
75
- # private_key,
76
- # redis,
77
- # redis_namespaces,
78
- # service_context,
79
- # )
80
- # # self._controllers = controllers
81
- # self._namespace = self._redis_namespaces.create(
82
- # self._key,
83
- # RESOURCE.aggregate(),
84
- # origin=self._CACHE_ORIGIN,
85
- # layer=self._CACHE_LAYER,
86
- # )
87
- # self._default_operation_context = OperationContextSchema(
88
- # origin=self._operation_origin,
89
- # layer=OperationLayerSchema(type=self._OPERATION_LAYER_TYPE, details=None),
90
- # target=OperationTargetSchema(
91
- # type=self._OPERATION_TARGET_TYPE, details=None
92
- # ),
93
- # )
94
-
95
- # async def read_user_organizations(
96
- # self,
97
- # operation_id: UUID,
98
- # request_context: RequestContext,
99
- # authentication: Authentication,
100
- # parameters: ReadMultipleParameter,
101
- # authorization: Optional[Authorization] = None,
102
- # headers: Optional[Dict[str, str]] = None,
103
- # ) -> ReadMultipleResourceOperationResult[
104
- # UserOrganizationDataSchema, StrictPagination, None
105
- # ]:
106
- # """Retrieve user organizations from MaleoIdentity"""
107
- # operation_action = ReadResourceOperationAction()
108
- # executed_at = datetime.now(tz=timezone.utc)
109
-
110
- # # Get function identifier
111
- # func = self.__class__
112
- # module, qualname = func.__module__, func.__qualname__
113
-
114
- # # Define arguments being used in this function
115
- # positional_arguments = []
116
- # keyword_arguments = {
117
- # "authentication": authentication.model_dump(
118
- # mode="json",
119
- # exclude={
120
- # "credentials": {
121
- # "token": {
122
- # "payload": {
123
- # "iat_dt",
124
- # "iat",
125
- # "exp_dt",
126
- # "exp",
127
- # }
128
- # }
129
- # }
130
- # },
131
- # ),
132
- # "parameters": parameters.model_dump(mode="json"),
133
- # }
134
-
135
- # # Define full function string
136
- # function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
137
-
138
- # # Define full cache key
139
- # cache_key = build_key(module, function, namespace=self._namespace)
140
-
141
- # if parameters.use_cache:
142
- # operation_context = deepcopy(self._default_operation_context)
143
- # operation_context.target.type = OperationTarget.CACHE
144
-
145
- # # Check redis for data
146
- # result_str = await self._redis.get(cache_key)
147
-
148
- # if result_str is not None:
149
- # completed_at = datetime.now(tz=timezone.utc)
150
- # result = ReadMultipleResourceOperationResult[
151
- # UserOrganizationDataSchema, StrictPagination, None
152
- # ].model_validate(json.loads(result_str))
153
- # ReadMultipleResourceOperationSchema[
154
- # UserOrganizationDataSchema, StrictPagination, None
155
- # ](
156
- # service_context=self._service_context,
157
- # id=operation_id,
158
- # context=operation_context,
159
- # timestamp=OperationTimestamp(
160
- # executed_at=executed_at,
161
- # completed_at=completed_at,
162
- # duration=(completed_at - executed_at).total_seconds(),
163
- # ),
164
- # summary="Successfully retrieved multiple user organizations from cache",
165
- # request_context=request_context,
166
- # authentication=authentication,
167
- # action=operation_action,
168
- # resource=RESOURCE,
169
- # result=result,
170
- # ).log(
171
- # self._logger, level=LogLevel.INFO
172
- # )
173
- # return result
174
-
175
- # operation_context = deepcopy(self._default_operation_context)
176
- # async with self._http_client_manager.get() as http_client:
177
- # url = f"{self._url}/v1/{RESOURCE.identifiers[0].url_slug}/"
178
-
179
- # # Parse parameters to query params
180
- # params = ReadMultipleQueryParameter.model_validate(
181
- # parameters.model_dump()
182
- # ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
183
-
184
- # # Create headers
185
- # base_headers = {
186
- # "Content-Type": "application/json",
187
- # "X-Operation_Id": str(operation_id),
188
- # }
189
- # if headers is not None:
190
- # headers = merge_dicts(base_headers, headers)
191
- # else:
192
- # headers = base_headers
193
-
194
- # # Create auth
195
- # token = None
196
- # if authentication.credentials.token is not None:
197
- # try:
198
- # token = reencode(
199
- # payload=authentication.credentials.token.payload,
200
- # key=self._private_key,
201
- # )
202
- # except Exception:
203
- # pass
204
-
205
- # if (
206
- # token is None
207
- # and authorization is not None
208
- # and authorization.scheme == "Bearer"
209
- # ):
210
- # token = authorization.credentials
211
-
212
- # if token is None:
213
- # token = self._credential_manager.token
214
-
215
- # auth = BearerAuth(token) if token is not None else None
216
-
217
- # # Send request and wait for response
218
- # response = await http_client.get(
219
- # url=url, params=params, headers=headers, auth=auth
220
- # )
221
-
222
- # if response.is_success:
223
- # completed_at = datetime.now(tz=timezone.utc)
224
- # validated_response = MultipleDataResponseSchema[
225
- # UserOrganizationDataSchema, StrictPagination, None
226
- # ].model_validate(response.json())
227
- # data = DataPair[List[UserOrganizationDataSchema], None](
228
- # old=validated_response.data,
229
- # new=None,
230
- # )
231
- # result = ReadMultipleResourceOperationResult[
232
- # UserOrganizationDataSchema, StrictPagination, None
233
- # ](
234
- # data=data,
235
- # pagination=validated_response.pagination,
236
- # metadata=None,
237
- # other=None,
238
- # )
239
- # ReadMultipleResourceOperationSchema[
240
- # UserOrganizationDataSchema, StrictPagination, None
241
- # ](
242
- # service_context=self._service_context,
243
- # id=operation_id,
244
- # context=operation_context,
245
- # timestamp=OperationTimestamp(
246
- # executed_at=executed_at,
247
- # completed_at=completed_at,
248
- # duration=(completed_at - executed_at).total_seconds(),
249
- # ),
250
- # summary="Successfully retrieved multiple user organizations from http request",
251
- # request_context=request_context,
252
- # authentication=authentication,
253
- # action=operation_action,
254
- # resource=RESOURCE,
255
- # result=result,
256
- # ).log(
257
- # self._logger, level=LogLevel.INFO
258
- # )
259
-
260
- # if parameters.use_cache:
261
- # await self._redis.set(
262
- # cache_key, result.model_dump_json(), Expiration.EXP_1WK
263
- # )
264
-
265
- # return result
266
-
267
- # self._raise_resource_http_request_error(
268
- # response=response,
269
- # operation_id=operation_id,
270
- # operation_context=operation_context,
271
- # executed_at=executed_at,
272
- # operation_action=operation_action,
273
- # request_context=request_context,
274
- # authentication=authentication,
275
- # resource=RESOURCE,
276
- # )
@@ -1,278 +0,0 @@
1
- # import json
2
- # from copy import deepcopy
3
- # from Crypto.PublicKey.RSA import RsaKey
4
- # from datetime import datetime, timezone
5
- # from redis.asyncio.client import Redis
6
- # from typing import Dict, List, Optional
7
- # from uuid import UUID
8
- # from maleo.soma.authorization import BearerAuth
9
- # from maleo.soma.dtos.configurations.cache.redis import RedisCacheNamespaces
10
- # from maleo.soma.enums.environment import Environment
11
- # from maleo.soma.enums.expiration import Expiration
12
- # from maleo.soma.enums.logging import LogLevel
13
- # from maleo.soma.enums.operation import OperationTarget
14
- # from maleo.soma.managers.client.maleo import MaleoClientService
15
- # from maleo.soma.managers.client.http import HTTPClientManager
16
- # from maleo.soma.managers.credential import CredentialManager
17
- # from maleo.soma.schemas.authentication import Authentication
18
- # from maleo.soma.schemas.authorization import Authorization
19
- # from maleo.soma.schemas.data import DataPair
20
- # from maleo.soma.schemas.operation.context import (
21
- # OperationContextSchema,
22
- # OperationOriginSchema,
23
- # OperationLayerSchema,
24
- # OperationTargetSchema,
25
- # )
26
- # from maleo.soma.schemas.operation.resource import (
27
- # ReadMultipleResourceOperationSchema,
28
- # )
29
- # from maleo.soma.schemas.operation.resource.action import ReadResourceOperationAction
30
- # from maleo.soma.schemas.operation.resource.result import (
31
- # ReadMultipleResourceOperationResult,
32
- # )
33
- # from maleo.soma.schemas.operation.timestamp import OperationTimestamp
34
- # from maleo.soma.schemas.pagination import StrictPagination
35
- # from maleo.soma.schemas.request import RequestContext
36
- # from maleo.soma.schemas.response import (
37
- # MultipleDataResponseSchema,
38
- # )
39
- # from maleo.soma.schemas.service import ServiceContext
40
- # from maleo.soma.utils.cache import build_key
41
- # from maleo.soma.utils.logging import ClientLogger
42
- # from maleo.soma.utils.merger import merge_dicts
43
- # from maleo.soma.utils.token import reencode
44
- # from maleo.identity.constants.user_organization_role import RESOURCE
45
- # from maleo.identity.schemas.data.user_organization_role import (
46
- # UserOrganizationRoleDataSchema,
47
- # )
48
- # from maleo.identity.schemas.parameter.client.user_organization_role import (
49
- # ReadMultipleParameter,
50
- # ReadMultipleQueryParameter,
51
- # )
52
-
53
-
54
- # class UserOrganizationRoleClientService(MaleoClientService):
55
- # def __init__(
56
- # self,
57
- # environment: Environment,
58
- # key: str,
59
- # url: str,
60
- # operation_origin: OperationOriginSchema,
61
- # logger: ClientLogger,
62
- # credential_manager: CredentialManager,
63
- # http_client_manager: HTTPClientManager,
64
- # private_key: RsaKey,
65
- # redis: Redis,
66
- # redis_namespaces: RedisCacheNamespaces,
67
- # service_context: ServiceContext,
68
- # ):
69
- # super().__init__(
70
- # environment,
71
- # key,
72
- # url,
73
- # operation_origin,
74
- # logger,
75
- # credential_manager,
76
- # http_client_manager,
77
- # private_key,
78
- # redis,
79
- # redis_namespaces,
80
- # service_context,
81
- # )
82
- # # self._controllers = controllers
83
- # self._namespace = self._redis_namespaces.create(
84
- # self._key,
85
- # RESOURCE.aggregate(),
86
- # origin=self._CACHE_ORIGIN,
87
- # layer=self._CACHE_LAYER,
88
- # )
89
- # self._default_operation_context = OperationContextSchema(
90
- # origin=self._operation_origin,
91
- # layer=OperationLayerSchema(type=self._OPERATION_LAYER_TYPE, details=None),
92
- # target=OperationTargetSchema(
93
- # type=self._OPERATION_TARGET_TYPE, details=None
94
- # ),
95
- # )
96
-
97
- # async def read_user_organization_roles(
98
- # self,
99
- # operation_id: UUID,
100
- # request_context: RequestContext,
101
- # authentication: Authentication,
102
- # parameters: ReadMultipleParameter,
103
- # authorization: Optional[Authorization] = None,
104
- # headers: Optional[Dict[str, str]] = None,
105
- # ) -> ReadMultipleResourceOperationResult[
106
- # UserOrganizationRoleDataSchema, StrictPagination, None
107
- # ]:
108
- # """Retrieve user organization roles from MaleoIdentity"""
109
- # operation_action = ReadResourceOperationAction()
110
- # executed_at = datetime.now(tz=timezone.utc)
111
-
112
- # # Get function identifier
113
- # func = self.__class__
114
- # module, qualname = func.__module__, func.__qualname__
115
-
116
- # # Define arguments being used in this function
117
- # positional_arguments = []
118
- # keyword_arguments = {
119
- # "authentication": authentication.model_dump(
120
- # mode="json",
121
- # exclude={
122
- # "credentials": {
123
- # "token": {
124
- # "payload": {
125
- # "iat_dt",
126
- # "iat",
127
- # "exp_dt",
128
- # "exp",
129
- # }
130
- # }
131
- # }
132
- # },
133
- # ),
134
- # "parameters": parameters.model_dump(mode="json"),
135
- # }
136
-
137
- # # Define full function string
138
- # function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
139
-
140
- # # Define full cache key
141
- # cache_key = build_key(module, function, namespace=self._namespace)
142
-
143
- # if parameters.use_cache:
144
- # operation_context = deepcopy(self._default_operation_context)
145
- # operation_context.target.type = OperationTarget.CACHE
146
-
147
- # # Check redis for data
148
- # result_str = await self._redis.get(cache_key)
149
-
150
- # if result_str is not None:
151
- # completed_at = datetime.now(tz=timezone.utc)
152
- # result = ReadMultipleResourceOperationResult[
153
- # UserOrganizationRoleDataSchema, StrictPagination, None
154
- # ].model_validate(json.loads(result_str))
155
- # ReadMultipleResourceOperationSchema[
156
- # UserOrganizationRoleDataSchema, StrictPagination, None
157
- # ](
158
- # service_context=self._service_context,
159
- # id=operation_id,
160
- # context=operation_context,
161
- # timestamp=OperationTimestamp(
162
- # executed_at=executed_at,
163
- # completed_at=completed_at,
164
- # duration=(completed_at - executed_at).total_seconds(),
165
- # ),
166
- # summary="Successfully retrieved multiple user organization roles from cache",
167
- # request_context=request_context,
168
- # authentication=authentication,
169
- # action=operation_action,
170
- # resource=RESOURCE,
171
- # result=result,
172
- # ).log(
173
- # self._logger, level=LogLevel.INFO
174
- # )
175
- # return result
176
-
177
- # operation_context = deepcopy(self._default_operation_context)
178
- # async with self._http_client_manager.get() as http_client:
179
- # url = f"{self._url}/v1/{RESOURCE.identifiers[0].url_slug}/"
180
-
181
- # # Parse parameters to query params
182
- # params = ReadMultipleQueryParameter.model_validate(
183
- # parameters.model_dump()
184
- # ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
185
-
186
- # # Create headers
187
- # base_headers = {
188
- # "Content-Type": "application/json",
189
- # "X-Operation_Id": str(operation_id),
190
- # }
191
- # if headers is not None:
192
- # headers = merge_dicts(base_headers, headers)
193
- # else:
194
- # headers = base_headers
195
-
196
- # # Create auth
197
- # token = None
198
- # if authentication.credentials.token is not None:
199
- # try:
200
- # token = reencode(
201
- # payload=authentication.credentials.token.payload,
202
- # key=self._private_key,
203
- # )
204
- # except Exception:
205
- # pass
206
-
207
- # if (
208
- # token is None
209
- # and authorization is not None
210
- # and authorization.scheme == "Bearer"
211
- # ):
212
- # token = authorization.credentials
213
-
214
- # if token is None:
215
- # token = self._credential_manager.token
216
-
217
- # auth = BearerAuth(token) if token is not None else None
218
-
219
- # # Send request and wait for response
220
- # response = await http_client.get(
221
- # url=url, params=params, headers=headers, auth=auth
222
- # )
223
-
224
- # if response.is_success:
225
- # completed_at = datetime.now(tz=timezone.utc)
226
- # validated_response = MultipleDataResponseSchema[
227
- # UserOrganizationRoleDataSchema, StrictPagination, None
228
- # ].model_validate(response.json())
229
- # data = DataPair[List[UserOrganizationRoleDataSchema], None](
230
- # old=validated_response.data,
231
- # new=None,
232
- # )
233
- # result = ReadMultipleResourceOperationResult[
234
- # UserOrganizationRoleDataSchema, StrictPagination, None
235
- # ](
236
- # data=data,
237
- # pagination=validated_response.pagination,
238
- # metadata=None,
239
- # other=None,
240
- # )
241
- # ReadMultipleResourceOperationSchema[
242
- # UserOrganizationRoleDataSchema, StrictPagination, None
243
- # ](
244
- # service_context=self._service_context,
245
- # id=operation_id,
246
- # context=operation_context,
247
- # timestamp=OperationTimestamp(
248
- # executed_at=executed_at,
249
- # completed_at=completed_at,
250
- # duration=(completed_at - executed_at).total_seconds(),
251
- # ),
252
- # summary="Successfully retrieved multiple user organization roles from http request",
253
- # request_context=request_context,
254
- # authentication=authentication,
255
- # action=operation_action,
256
- # resource=RESOURCE,
257
- # result=result,
258
- # ).log(
259
- # self._logger, level=LogLevel.INFO
260
- # )
261
-
262
- # if parameters.use_cache:
263
- # await self._redis.set(
264
- # cache_key, result.model_dump_json(), Expiration.EXP_1WK
265
- # )
266
-
267
- # return result
268
-
269
- # self._raise_resource_http_request_error(
270
- # response=response,
271
- # operation_id=operation_id,
272
- # operation_context=operation_context,
273
- # executed_at=executed_at,
274
- # operation_action=operation_action,
275
- # request_context=request_context,
276
- # authentication=authentication,
277
- # resource=RESOURCE,
278
- # )