maleo-identity 0.0.85__py3-none-any.whl → 0.1.24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maleo/identity/constants/api_key.py +13 -0
- maleo/identity/constants/organization.py +3 -10
- maleo/identity/constants/organization_registration_code.py +5 -17
- maleo/identity/constants/organization_relation.py +13 -0
- maleo/identity/constants/patient.py +7 -0
- maleo/identity/constants/user.py +3 -20
- maleo/identity/constants/user_medical_role.py +13 -0
- maleo/identity/constants/user_organization_role.py +5 -39
- maleo/identity/constants/user_profile.py +3 -21
- maleo/identity/constants/user_system_role.py +9 -8
- maleo/identity/enums/api_key.py +25 -0
- maleo/identity/enums/organization.py +16 -3
- maleo/identity/enums/organization_registration_code.py +9 -0
- maleo/identity/enums/organization_relation.py +22 -0
- maleo/identity/enums/patient.py +29 -0
- maleo/identity/enums/user.py +16 -7
- maleo/identity/enums/user_medical_role.py +22 -0
- maleo/identity/enums/user_organization_role.py +19 -12
- maleo/identity/enums/user_profile.py +7 -9
- maleo/identity/enums/user_system_role.py +30 -0
- maleo/identity/mixins/api_key.py +72 -0
- maleo/identity/mixins/common.py +29 -0
- maleo/identity/mixins/organization.py +68 -8
- maleo/identity/mixins/organization_registration_code.py +126 -9
- maleo/identity/mixins/organization_relation.py +80 -0
- maleo/identity/mixins/patient.py +65 -0
- maleo/identity/mixins/user.py +86 -24
- maleo/identity/mixins/user_medical_role.py +68 -0
- maleo/identity/mixins/user_organization_role.py +68 -4
- maleo/identity/mixins/user_profile.py +84 -53
- maleo/identity/mixins/user_system_role.py +72 -4
- maleo/identity/schemas/api_key.py +171 -0
- maleo/identity/schemas/common.py +335 -0
- maleo/identity/schemas/organization.py +311 -0
- maleo/identity/schemas/organization_registration_code.py +314 -0
- maleo/identity/schemas/organization_relation.py +315 -0
- maleo/identity/schemas/patient.py +349 -0
- maleo/identity/schemas/user.py +318 -0
- maleo/identity/schemas/user_medical_role.py +316 -0
- maleo/identity/schemas/user_organization_role.py +317 -0
- maleo/identity/schemas/user_profile.py +362 -0
- maleo/identity/schemas/user_system_role.py +339 -0
- maleo/identity/types/api_key.py +7 -0
- maleo/identity/types/organization.py +4 -0
- maleo/identity/types/organization_registration_code.py +4 -0
- maleo/identity/types/organization_relation.py +7 -0
- maleo/identity/types/patient.py +4 -0
- maleo/identity/types/user.py +4 -0
- maleo/identity/types/user_medical_role.py +7 -0
- maleo/identity/types/user_organization_role.py +7 -0
- maleo/identity/types/user_profile.py +4 -0
- maleo/identity/types/user_system_role.py +8 -0
- maleo/identity/utils/organization.py +32 -0
- maleo/identity/utils/user.py +32 -0
- maleo_identity-0.1.24.dist-info/METADATA +119 -0
- maleo_identity-0.1.24.dist-info/RECORD +66 -0
- maleo_identity-0.1.24.dist-info/licenses/LICENSE +57 -0
- maleo/identity/client/manager.py +0 -157
- maleo/identity/client/services/__init__.py +0 -0
- maleo/identity/client/services/organization.py +0 -1944
- maleo/identity/client/services/organization_registration_code.py +0 -470
- maleo/identity/client/services/organization_role.py +0 -276
- maleo/identity/client/services/user.py +0 -1559
- maleo/identity/client/services/user_organization.py +0 -276
- maleo/identity/client/services/user_organization_role.py +0 -278
- maleo/identity/client/services/user_profile.py +0 -276
- maleo/identity/client/services/user_system_role.py +0 -276
- maleo/identity/constants/organization_role.py +0 -35
- maleo/identity/constants/user_organization.py +0 -58
- maleo/identity/db.py +0 -4
- maleo/identity/dtos/__init__.py +0 -0
- maleo/identity/dtos/configuration.py +0 -15
- maleo/identity/dtos/data/__init__.py +0 -0
- maleo/identity/dtos/data/organization_registration_code.py +0 -15
- maleo/identity/dtos/data/user_profile.py +0 -29
- maleo/identity/dtos/settings.py +0 -17
- maleo/identity/enums/general.py +0 -5
- maleo/identity/enums/organization_role.py +0 -7
- maleo/identity/enums/user_organization.py +0 -14
- maleo/identity/mixins/organization_role.py +0 -15
- maleo/identity/mixins/user_organization.py +0 -6
- maleo/identity/models/__init__.py +0 -0
- maleo/identity/models/organization.py +0 -62
- maleo/identity/models/organization_registration_code.py +0 -33
- maleo/identity/models/organization_role.py +0 -37
- maleo/identity/models/user.py +0 -39
- maleo/identity/models/user_organization.py +0 -48
- maleo/identity/models/user_organization_role.py +0 -61
- maleo/identity/models/user_profile.py +0 -33
- maleo/identity/models/user_system_role.py +0 -26
- maleo/identity/schemas/data/__init__.py +0 -0
- maleo/identity/schemas/data/organization.py +0 -36
- maleo/identity/schemas/data/organization_registration_code.py +0 -27
- maleo/identity/schemas/data/organization_role.py +0 -32
- maleo/identity/schemas/data/user.py +0 -33
- maleo/identity/schemas/data/user_organization.py +0 -23
- maleo/identity/schemas/data/user_organization_role.py +0 -13
- maleo/identity/schemas/data/user_profile.py +0 -59
- maleo/identity/schemas/data/user_system_role.py +0 -25
- maleo/identity/schemas/metadata/__init__.py +0 -0
- maleo/identity/schemas/metadata/user.py +0 -6
- maleo/identity/schemas/parameter/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/organization.py +0 -74
- maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
- maleo/identity/schemas/parameter/client/organization_role.py +0 -42
- maleo/identity/schemas/parameter/client/user.py +0 -44
- maleo/identity/schemas/parameter/client/user_organization.py +0 -62
- maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
- maleo/identity/schemas/parameter/client/user_profile.py +0 -28
- maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
- maleo/identity/schemas/parameter/general/__init__.py +0 -0
- maleo/identity/schemas/parameter/general/organization.py +0 -43
- maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -54
- maleo/identity/schemas/parameter/general/organization_role.py +0 -14
- maleo/identity/schemas/parameter/general/user.py +0 -101
- maleo/identity/schemas/parameter/general/user_organization.py +0 -18
- maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
- maleo/identity/schemas/parameter/general/user_profile.py +0 -70
- maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
- maleo/identity/schemas/parameter/service/__init__.py +0 -0
- maleo/identity/schemas/parameter/service/organization.py +0 -60
- maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
- maleo/identity/schemas/parameter/service/organization_role.py +0 -35
- maleo/identity/schemas/parameter/service/user.py +0 -47
- maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
- maleo/identity/schemas/parameter/service/user_profile.py +0 -28
- maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
- maleo/identity/types/base/__init__.py +0 -0
- maleo/identity/types/base/organization.py +0 -5
- maleo/identity/types/base/organization_registration_code.py +0 -4
- maleo/identity/types/base/user.py +0 -5
- maleo/identity/types/base/user_profile.py +0 -5
- maleo_identity-0.0.85.dist-info/METADATA +0 -40
- maleo_identity-0.0.85.dist-info/RECORD +0 -105
- /maleo/identity/{client → utils}/__init__.py +0 -0
- {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
- {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
|
@@ -1,1559 +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
|
-
# ReadSingleResourceOperationSchema,
|
|
28
|
-
# ReadMultipleResourceOperationSchema,
|
|
29
|
-
# )
|
|
30
|
-
# from maleo.soma.schemas.operation.resource.action import ReadResourceOperationAction
|
|
31
|
-
# from maleo.soma.schemas.operation.resource.result import (
|
|
32
|
-
# ReadSingleResourceOperationResult,
|
|
33
|
-
# ReadMultipleResourceOperationResult,
|
|
34
|
-
# )
|
|
35
|
-
# from maleo.soma.schemas.operation.timestamp import OperationTimestamp
|
|
36
|
-
# from maleo.soma.schemas.pagination import StrictPagination
|
|
37
|
-
# from maleo.soma.schemas.request import RequestContext
|
|
38
|
-
# from maleo.soma.schemas.response import (
|
|
39
|
-
# SingleDataResponseSchema,
|
|
40
|
-
# MultipleDataResponseSchema,
|
|
41
|
-
# )
|
|
42
|
-
# from maleo.soma.schemas.service import ServiceContext
|
|
43
|
-
# from maleo.soma.utils.cache import build_key
|
|
44
|
-
# from maleo.soma.utils.logging import ClientLogger
|
|
45
|
-
# from maleo.soma.utils.merger import merge_dicts
|
|
46
|
-
# from maleo.soma.utils.token import reencode
|
|
47
|
-
# from maleo.identity.constants.user import RESOURCE as USER_RESOURCE
|
|
48
|
-
# from maleo.identity.schemas.data.user_organization_role import (
|
|
49
|
-
# UserOrganizationRoleDataSchema,
|
|
50
|
-
# )
|
|
51
|
-
# from maleo.identity.schemas.data.user_organization import UserOrganizationDataSchema
|
|
52
|
-
# from maleo.identity.schemas.data.user_system_role import UserSystemRoleDataSchema
|
|
53
|
-
# from maleo.identity.schemas.data.user import UserDataSchema
|
|
54
|
-
# from maleo.identity.schemas.parameter.client.user_organization_role import (
|
|
55
|
-
# ReadMultipleFromUserOrganizationParameter as UserOrganizationRoleReadMultipleFromUserOrganizationParameter,
|
|
56
|
-
# ReadMultipleFromUserOrganizationQueryParameter as UserOrganizationRoleReadMultipleFromUserOrganizationQueryParameter,
|
|
57
|
-
# )
|
|
58
|
-
# from maleo.identity.schemas.parameter.client.user_organization import (
|
|
59
|
-
# ReadMultipleFromUserParameter as UserOrganizationReadMultipleFromUserParameter,
|
|
60
|
-
# ReadMultipleFromUserQueryParameter as UserOrganizationReadMultipleFromUserQueryParameter,
|
|
61
|
-
# )
|
|
62
|
-
# from maleo.identity.schemas.parameter.client.user_system_role import (
|
|
63
|
-
# ReadMultipleFromUserParameter as UserSystemRoleReadMultipleFromUserParameter,
|
|
64
|
-
# ReadMultipleFromUserQueryParameter as UserSystemRoleReadMultipleFromUserQueryParameter,
|
|
65
|
-
# )
|
|
66
|
-
# from maleo.identity.schemas.parameter.client.user import (
|
|
67
|
-
# ReadMultipleParameter as UserReadMultipleParameter,
|
|
68
|
-
# ReadMultipleQueryParameter as UserReadMultipleQueryParameter,
|
|
69
|
-
# )
|
|
70
|
-
# from maleo.identity.schemas.parameter.general.user_organization_role import (
|
|
71
|
-
# ReadSingleQueryParameter as UserOrganizationRoleReadSingleQueryParameter,
|
|
72
|
-
# ReadSingleParameter as UserOrganizationRoleReadSingleParameter,
|
|
73
|
-
# )
|
|
74
|
-
# from maleo.identity.schemas.parameter.general.user_organization import (
|
|
75
|
-
# ReadSingleQueryParameter as UserOrganizationReadSingleQueryParameter,
|
|
76
|
-
# ReadSingleParameter as UserOrganizationReadSingleParameter,
|
|
77
|
-
# )
|
|
78
|
-
# from maleo.identity.schemas.parameter.general.user_system_role import (
|
|
79
|
-
# ReadSingleQueryParameter as UserSystemRoleReadSingleQueryParameter,
|
|
80
|
-
# ReadSingleParameter as UserSystemRoleReadSingleParameter,
|
|
81
|
-
# )
|
|
82
|
-
# from maleo.identity.schemas.parameter.general.user import (
|
|
83
|
-
# ReadSingleQueryParameter as UserReadSingleQueryParameter,
|
|
84
|
-
# ReadSingleParameter as UserReadSingleParameter,
|
|
85
|
-
# )
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# class UserClientService(MaleoClientService):
|
|
89
|
-
# def __init__(
|
|
90
|
-
# self,
|
|
91
|
-
# environment: Environment,
|
|
92
|
-
# key: str,
|
|
93
|
-
# url: str,
|
|
94
|
-
# operation_origin: OperationOriginSchema,
|
|
95
|
-
# logger: ClientLogger,
|
|
96
|
-
# credential_manager: CredentialManager,
|
|
97
|
-
# http_client_manager: HTTPClientManager,
|
|
98
|
-
# private_key: RsaKey,
|
|
99
|
-
# redis: Redis,
|
|
100
|
-
# redis_namespaces: RedisCacheNamespaces,
|
|
101
|
-
# service_context: ServiceContext,
|
|
102
|
-
# ):
|
|
103
|
-
# super().__init__(
|
|
104
|
-
# environment,
|
|
105
|
-
# key,
|
|
106
|
-
# url,
|
|
107
|
-
# operation_origin,
|
|
108
|
-
# logger,
|
|
109
|
-
# credential_manager,
|
|
110
|
-
# http_client_manager,
|
|
111
|
-
# private_key,
|
|
112
|
-
# redis,
|
|
113
|
-
# redis_namespaces,
|
|
114
|
-
# service_context,
|
|
115
|
-
# )
|
|
116
|
-
# # self._controllers = controllers
|
|
117
|
-
# self._namespace = self._redis_namespaces.create(
|
|
118
|
-
# self._key,
|
|
119
|
-
# USER_RESOURCE.aggregate(),
|
|
120
|
-
# origin=self._CACHE_ORIGIN,
|
|
121
|
-
# layer=self._CACHE_LAYER,
|
|
122
|
-
# )
|
|
123
|
-
# self._default_operation_context = OperationContextSchema(
|
|
124
|
-
# origin=self._operation_origin,
|
|
125
|
-
# layer=OperationLayerSchema(type=self._OPERATION_LAYER_TYPE, details=None),
|
|
126
|
-
# target=OperationTargetSchema(
|
|
127
|
-
# type=self._OPERATION_TARGET_TYPE, details=None
|
|
128
|
-
# ),
|
|
129
|
-
# )
|
|
130
|
-
|
|
131
|
-
# async def read_users(
|
|
132
|
-
# self,
|
|
133
|
-
# operation_id: UUID,
|
|
134
|
-
# request_context: RequestContext,
|
|
135
|
-
# authentication: Authentication,
|
|
136
|
-
# parameters: UserReadMultipleParameter,
|
|
137
|
-
# authorization: Optional[Authorization] = None,
|
|
138
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
139
|
-
# ) -> ReadMultipleResourceOperationResult[UserDataSchema, StrictPagination, None]:
|
|
140
|
-
# """Retrieve users from MaleoIdentity"""
|
|
141
|
-
# operation_action = ReadResourceOperationAction()
|
|
142
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
143
|
-
|
|
144
|
-
# # Get function identifier
|
|
145
|
-
# func = self.__class__
|
|
146
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
147
|
-
|
|
148
|
-
# # Define arguments being used in this function
|
|
149
|
-
# positional_arguments = []
|
|
150
|
-
# keyword_arguments = {
|
|
151
|
-
# "authentication": authentication.model_dump(
|
|
152
|
-
# mode="json",
|
|
153
|
-
# exclude={
|
|
154
|
-
# "credentials": {
|
|
155
|
-
# "token": {
|
|
156
|
-
# "payload": {
|
|
157
|
-
# "iat_dt",
|
|
158
|
-
# "iat",
|
|
159
|
-
# "exp_dt",
|
|
160
|
-
# "exp",
|
|
161
|
-
# }
|
|
162
|
-
# }
|
|
163
|
-
# }
|
|
164
|
-
# },
|
|
165
|
-
# ),
|
|
166
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
167
|
-
# }
|
|
168
|
-
|
|
169
|
-
# # Define full function string
|
|
170
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
171
|
-
|
|
172
|
-
# # Define full cache key
|
|
173
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
174
|
-
|
|
175
|
-
# if parameters.use_cache:
|
|
176
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
177
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
178
|
-
|
|
179
|
-
# # Check redis for data
|
|
180
|
-
# result_str = await self._redis.get(cache_key)
|
|
181
|
-
|
|
182
|
-
# if result_str is not None:
|
|
183
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
184
|
-
# result = ReadMultipleResourceOperationResult[
|
|
185
|
-
# UserDataSchema, StrictPagination, None
|
|
186
|
-
# ].model_validate(json.loads(result_str))
|
|
187
|
-
# ReadMultipleResourceOperationSchema[
|
|
188
|
-
# UserDataSchema, StrictPagination, None
|
|
189
|
-
# ](
|
|
190
|
-
# service_context=self._service_context,
|
|
191
|
-
# id=operation_id,
|
|
192
|
-
# context=operation_context,
|
|
193
|
-
# timestamp=OperationTimestamp(
|
|
194
|
-
# executed_at=executed_at,
|
|
195
|
-
# completed_at=completed_at,
|
|
196
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
197
|
-
# ),
|
|
198
|
-
# summary="Successfully retrieved multiple users from cache",
|
|
199
|
-
# request_context=request_context,
|
|
200
|
-
# authentication=authentication,
|
|
201
|
-
# action=operation_action,
|
|
202
|
-
# resource=USER_RESOURCE,
|
|
203
|
-
# result=result,
|
|
204
|
-
# ).log(
|
|
205
|
-
# self._logger, level=LogLevel.INFO
|
|
206
|
-
# )
|
|
207
|
-
# return result
|
|
208
|
-
|
|
209
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
210
|
-
# async with self._http_client_manager.get() as http_client:
|
|
211
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/"
|
|
212
|
-
|
|
213
|
-
# # Parse parameters to query params
|
|
214
|
-
# params = UserReadMultipleQueryParameter.model_validate(
|
|
215
|
-
# parameters.model_dump()
|
|
216
|
-
# ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
|
|
217
|
-
|
|
218
|
-
# # Create headers
|
|
219
|
-
# base_headers = {
|
|
220
|
-
# "Content-Type": "application/json",
|
|
221
|
-
# "X-Operation_Id": str(operation_id),
|
|
222
|
-
# }
|
|
223
|
-
# if headers is not None:
|
|
224
|
-
# headers = merge_dicts(base_headers, headers)
|
|
225
|
-
# else:
|
|
226
|
-
# headers = base_headers
|
|
227
|
-
|
|
228
|
-
# # Create auth
|
|
229
|
-
# token = None
|
|
230
|
-
# if authentication.credentials.token is not None:
|
|
231
|
-
# try:
|
|
232
|
-
# token = reencode(
|
|
233
|
-
# payload=authentication.credentials.token.payload,
|
|
234
|
-
# key=self._private_key,
|
|
235
|
-
# )
|
|
236
|
-
# except Exception:
|
|
237
|
-
# pass
|
|
238
|
-
|
|
239
|
-
# if (
|
|
240
|
-
# token is None
|
|
241
|
-
# and authorization is not None
|
|
242
|
-
# and authorization.scheme == "Bearer"
|
|
243
|
-
# ):
|
|
244
|
-
# token = authorization.credentials
|
|
245
|
-
|
|
246
|
-
# if token is None:
|
|
247
|
-
# token = self._credential_manager.token
|
|
248
|
-
|
|
249
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
250
|
-
|
|
251
|
-
# # Send request and wait for response
|
|
252
|
-
# response = await http_client.get(
|
|
253
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
254
|
-
# )
|
|
255
|
-
|
|
256
|
-
# if response.is_success:
|
|
257
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
258
|
-
# validated_response = MultipleDataResponseSchema[
|
|
259
|
-
# UserDataSchema, StrictPagination, None
|
|
260
|
-
# ].model_validate(response.json())
|
|
261
|
-
# data = DataPair[List[UserDataSchema], None](
|
|
262
|
-
# old=validated_response.data,
|
|
263
|
-
# new=None,
|
|
264
|
-
# )
|
|
265
|
-
# result = ReadMultipleResourceOperationResult[
|
|
266
|
-
# UserDataSchema, StrictPagination, None
|
|
267
|
-
# ](
|
|
268
|
-
# data=data,
|
|
269
|
-
# pagination=validated_response.pagination,
|
|
270
|
-
# metadata=None,
|
|
271
|
-
# other=None,
|
|
272
|
-
# )
|
|
273
|
-
# ReadMultipleResourceOperationSchema[
|
|
274
|
-
# UserDataSchema, StrictPagination, None
|
|
275
|
-
# ](
|
|
276
|
-
# service_context=self._service_context,
|
|
277
|
-
# id=operation_id,
|
|
278
|
-
# context=operation_context,
|
|
279
|
-
# timestamp=OperationTimestamp(
|
|
280
|
-
# executed_at=executed_at,
|
|
281
|
-
# completed_at=completed_at,
|
|
282
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
283
|
-
# ),
|
|
284
|
-
# summary="Successfully retrieved multiple users from http request",
|
|
285
|
-
# request_context=request_context,
|
|
286
|
-
# authentication=authentication,
|
|
287
|
-
# action=operation_action,
|
|
288
|
-
# resource=USER_RESOURCE,
|
|
289
|
-
# result=result,
|
|
290
|
-
# ).log(
|
|
291
|
-
# self._logger, level=LogLevel.INFO
|
|
292
|
-
# )
|
|
293
|
-
|
|
294
|
-
# if parameters.use_cache:
|
|
295
|
-
# await self._redis.set(
|
|
296
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
297
|
-
# )
|
|
298
|
-
|
|
299
|
-
# return result
|
|
300
|
-
|
|
301
|
-
# self._raise_resource_http_request_error(
|
|
302
|
-
# response=response,
|
|
303
|
-
# operation_id=operation_id,
|
|
304
|
-
# operation_context=operation_context,
|
|
305
|
-
# executed_at=executed_at,
|
|
306
|
-
# operation_action=operation_action,
|
|
307
|
-
# request_context=request_context,
|
|
308
|
-
# authentication=authentication,
|
|
309
|
-
# resource=USER_RESOURCE,
|
|
310
|
-
# )
|
|
311
|
-
|
|
312
|
-
# async def read_user(
|
|
313
|
-
# self,
|
|
314
|
-
# operation_id: UUID,
|
|
315
|
-
# request_context: RequestContext,
|
|
316
|
-
# authentication: Authentication,
|
|
317
|
-
# parameters: UserReadSingleParameter,
|
|
318
|
-
# authorization: Optional[Authorization] = None,
|
|
319
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
320
|
-
# ) -> ReadSingleResourceOperationResult[UserDataSchema, None]:
|
|
321
|
-
# """Retrieve user from MaleoIdentity"""
|
|
322
|
-
# operation_action = ReadResourceOperationAction()
|
|
323
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
324
|
-
|
|
325
|
-
# # Get function identifier
|
|
326
|
-
# func = self.__class__
|
|
327
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
328
|
-
|
|
329
|
-
# # Define arguments being used in this function
|
|
330
|
-
# positional_arguments = []
|
|
331
|
-
# keyword_arguments = {
|
|
332
|
-
# "authentication": authentication.model_dump(
|
|
333
|
-
# mode="json",
|
|
334
|
-
# exclude={
|
|
335
|
-
# "credentials": {
|
|
336
|
-
# "token": {
|
|
337
|
-
# "payload": {
|
|
338
|
-
# "iat_dt",
|
|
339
|
-
# "iat",
|
|
340
|
-
# "exp_dt",
|
|
341
|
-
# "exp",
|
|
342
|
-
# }
|
|
343
|
-
# }
|
|
344
|
-
# }
|
|
345
|
-
# },
|
|
346
|
-
# ),
|
|
347
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
348
|
-
# }
|
|
349
|
-
|
|
350
|
-
# # Define full function string
|
|
351
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
352
|
-
|
|
353
|
-
# # Define full cache key
|
|
354
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
355
|
-
|
|
356
|
-
# if parameters.use_cache:
|
|
357
|
-
# # Cache operation
|
|
358
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
359
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
360
|
-
# # Check redis for data
|
|
361
|
-
# result_str = await self._redis.get(cache_key)
|
|
362
|
-
|
|
363
|
-
# if result_str is not None:
|
|
364
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
365
|
-
# result = ReadSingleResourceOperationResult[
|
|
366
|
-
# UserDataSchema, None
|
|
367
|
-
# ].model_validate(json.loads(result_str))
|
|
368
|
-
# ReadSingleResourceOperationSchema[UserDataSchema, None](
|
|
369
|
-
# service_context=self._service_context,
|
|
370
|
-
# id=operation_id,
|
|
371
|
-
# context=operation_context,
|
|
372
|
-
# timestamp=OperationTimestamp(
|
|
373
|
-
# executed_at=executed_at,
|
|
374
|
-
# completed_at=completed_at,
|
|
375
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
376
|
-
# ),
|
|
377
|
-
# summary="Successfully retrieved single user from cache",
|
|
378
|
-
# request_context=request_context,
|
|
379
|
-
# authentication=authentication,
|
|
380
|
-
# action=operation_action,
|
|
381
|
-
# resource=USER_RESOURCE,
|
|
382
|
-
# result=result,
|
|
383
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
384
|
-
# return result
|
|
385
|
-
|
|
386
|
-
# # HTTP Request
|
|
387
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
388
|
-
# async with self._http_client_manager.get() as client:
|
|
389
|
-
# # Define URL
|
|
390
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.identifier}/{parameters.value}"
|
|
391
|
-
|
|
392
|
-
# # Parse parameters to query params
|
|
393
|
-
# params = UserReadSingleQueryParameter.model_validate(
|
|
394
|
-
# parameters.model_dump()
|
|
395
|
-
# ).model_dump(exclude_none=True)
|
|
396
|
-
|
|
397
|
-
# # Create headers
|
|
398
|
-
# base_headers = {
|
|
399
|
-
# "Content-Type": "application/json",
|
|
400
|
-
# "X-Operation_Id": str(operation_id),
|
|
401
|
-
# }
|
|
402
|
-
# if headers is not None:
|
|
403
|
-
# headers = merge_dicts(base_headers, headers)
|
|
404
|
-
# else:
|
|
405
|
-
# headers = base_headers
|
|
406
|
-
|
|
407
|
-
# # Create auth
|
|
408
|
-
# token = None
|
|
409
|
-
# if authentication.credentials.token is not None:
|
|
410
|
-
# try:
|
|
411
|
-
# token = reencode(
|
|
412
|
-
# payload=authentication.credentials.token.payload,
|
|
413
|
-
# key=self._private_key,
|
|
414
|
-
# )
|
|
415
|
-
# except Exception:
|
|
416
|
-
# pass
|
|
417
|
-
|
|
418
|
-
# if (
|
|
419
|
-
# token is None
|
|
420
|
-
# and authorization is not None
|
|
421
|
-
# and authorization.scheme == "Bearer"
|
|
422
|
-
# ):
|
|
423
|
-
# token = authorization.credentials
|
|
424
|
-
|
|
425
|
-
# if token is None:
|
|
426
|
-
# token = self._credential_manager.token
|
|
427
|
-
|
|
428
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
429
|
-
|
|
430
|
-
# # Send request and wait for response
|
|
431
|
-
# response = await client.get(
|
|
432
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
433
|
-
# )
|
|
434
|
-
|
|
435
|
-
# if response.is_success:
|
|
436
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
437
|
-
# validated_response = SingleDataResponseSchema[
|
|
438
|
-
# UserDataSchema, None
|
|
439
|
-
# ].model_validate(response.json())
|
|
440
|
-
# data = DataPair[UserDataSchema, None](
|
|
441
|
-
# old=validated_response.data,
|
|
442
|
-
# new=None,
|
|
443
|
-
# )
|
|
444
|
-
# result = ReadSingleResourceOperationResult[UserDataSchema, None](
|
|
445
|
-
# data=data,
|
|
446
|
-
# pagination=validated_response.pagination,
|
|
447
|
-
# metadata=None,
|
|
448
|
-
# other=None,
|
|
449
|
-
# )
|
|
450
|
-
# ReadSingleResourceOperationSchema[UserDataSchema, None](
|
|
451
|
-
# service_context=self._service_context,
|
|
452
|
-
# id=operation_id,
|
|
453
|
-
# context=operation_context,
|
|
454
|
-
# timestamp=OperationTimestamp(
|
|
455
|
-
# executed_at=executed_at,
|
|
456
|
-
# completed_at=completed_at,
|
|
457
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
458
|
-
# ),
|
|
459
|
-
# summary="Successfully retrieved single user from http request",
|
|
460
|
-
# request_context=request_context,
|
|
461
|
-
# authentication=authentication,
|
|
462
|
-
# action=operation_action,
|
|
463
|
-
# resource=USER_RESOURCE,
|
|
464
|
-
# result=result,
|
|
465
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
466
|
-
|
|
467
|
-
# if parameters.use_cache:
|
|
468
|
-
# await self._redis.set(
|
|
469
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
470
|
-
# )
|
|
471
|
-
|
|
472
|
-
# return result
|
|
473
|
-
|
|
474
|
-
# self._raise_resource_http_request_error(
|
|
475
|
-
# response=response,
|
|
476
|
-
# operation_id=operation_id,
|
|
477
|
-
# operation_context=operation_context,
|
|
478
|
-
# executed_at=executed_at,
|
|
479
|
-
# operation_action=operation_action,
|
|
480
|
-
# request_context=request_context,
|
|
481
|
-
# authentication=authentication,
|
|
482
|
-
# resource=USER_RESOURCE,
|
|
483
|
-
# )
|
|
484
|
-
|
|
485
|
-
# async def read_user_organizations(
|
|
486
|
-
# self,
|
|
487
|
-
# operation_id: UUID,
|
|
488
|
-
# request_context: RequestContext,
|
|
489
|
-
# authentication: Authentication,
|
|
490
|
-
# parameters: UserOrganizationReadMultipleFromUserParameter,
|
|
491
|
-
# authorization: Optional[Authorization] = None,
|
|
492
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
493
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
494
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
495
|
-
# ]:
|
|
496
|
-
# """Retrieve user organizations from MaleoIdentity"""
|
|
497
|
-
# operation_action = ReadResourceOperationAction()
|
|
498
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
499
|
-
|
|
500
|
-
# # Get function identifier
|
|
501
|
-
# func = self.__class__
|
|
502
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
503
|
-
|
|
504
|
-
# # Define arguments being used in this function
|
|
505
|
-
# positional_arguments = []
|
|
506
|
-
# keyword_arguments = {
|
|
507
|
-
# "authentication": authentication.model_dump(
|
|
508
|
-
# mode="json",
|
|
509
|
-
# exclude={
|
|
510
|
-
# "credentials": {
|
|
511
|
-
# "token": {
|
|
512
|
-
# "payload": {
|
|
513
|
-
# "iat_dt",
|
|
514
|
-
# "iat",
|
|
515
|
-
# "exp_dt",
|
|
516
|
-
# "exp",
|
|
517
|
-
# }
|
|
518
|
-
# }
|
|
519
|
-
# }
|
|
520
|
-
# },
|
|
521
|
-
# ),
|
|
522
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
523
|
-
# }
|
|
524
|
-
|
|
525
|
-
# # Define full function string
|
|
526
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
527
|
-
|
|
528
|
-
# # Define full cache key
|
|
529
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
530
|
-
|
|
531
|
-
# if parameters.use_cache:
|
|
532
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
533
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
534
|
-
|
|
535
|
-
# # Check redis for data
|
|
536
|
-
# result_str = await self._redis.get(cache_key)
|
|
537
|
-
|
|
538
|
-
# if result_str is not None:
|
|
539
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
540
|
-
# result = ReadMultipleResourceOperationResult[
|
|
541
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
542
|
-
# ].model_validate(json.loads(result_str))
|
|
543
|
-
# ReadMultipleResourceOperationSchema[
|
|
544
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
545
|
-
# ](
|
|
546
|
-
# service_context=self._service_context,
|
|
547
|
-
# id=operation_id,
|
|
548
|
-
# context=operation_context,
|
|
549
|
-
# timestamp=OperationTimestamp(
|
|
550
|
-
# executed_at=executed_at,
|
|
551
|
-
# completed_at=completed_at,
|
|
552
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
553
|
-
# ),
|
|
554
|
-
# summary="Successfully retrieved multiple user organizations from cache",
|
|
555
|
-
# request_context=request_context,
|
|
556
|
-
# authentication=authentication,
|
|
557
|
-
# action=operation_action,
|
|
558
|
-
# resource=USER_RESOURCE,
|
|
559
|
-
# result=result,
|
|
560
|
-
# ).log(
|
|
561
|
-
# self._logger, level=LogLevel.INFO
|
|
562
|
-
# )
|
|
563
|
-
# return result
|
|
564
|
-
|
|
565
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
566
|
-
# async with self._http_client_manager.get() as http_client:
|
|
567
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.user_id}/organizations/"
|
|
568
|
-
|
|
569
|
-
# # Parse parameters to query params
|
|
570
|
-
# params = UserOrganizationReadMultipleFromUserQueryParameter.model_validate(
|
|
571
|
-
# parameters.model_dump()
|
|
572
|
-
# ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
|
|
573
|
-
|
|
574
|
-
# # Create headers
|
|
575
|
-
# base_headers = {
|
|
576
|
-
# "Content-Type": "application/json",
|
|
577
|
-
# "X-Operation_Id": str(operation_id),
|
|
578
|
-
# }
|
|
579
|
-
# if headers is not None:
|
|
580
|
-
# headers = merge_dicts(base_headers, headers)
|
|
581
|
-
# else:
|
|
582
|
-
# headers = base_headers
|
|
583
|
-
|
|
584
|
-
# # Create auth
|
|
585
|
-
# token = None
|
|
586
|
-
# if authentication.credentials.token is not None:
|
|
587
|
-
# try:
|
|
588
|
-
# token = reencode(
|
|
589
|
-
# payload=authentication.credentials.token.payload,
|
|
590
|
-
# key=self._private_key,
|
|
591
|
-
# )
|
|
592
|
-
# except Exception:
|
|
593
|
-
# pass
|
|
594
|
-
|
|
595
|
-
# if (
|
|
596
|
-
# token is None
|
|
597
|
-
# and authorization is not None
|
|
598
|
-
# and authorization.scheme == "Bearer"
|
|
599
|
-
# ):
|
|
600
|
-
# token = authorization.credentials
|
|
601
|
-
|
|
602
|
-
# if token is None:
|
|
603
|
-
# token = self._credential_manager.token
|
|
604
|
-
|
|
605
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
606
|
-
|
|
607
|
-
# # Send request and wait for response
|
|
608
|
-
# response = await http_client.get(
|
|
609
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
610
|
-
# )
|
|
611
|
-
|
|
612
|
-
# if response.is_success:
|
|
613
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
614
|
-
# validated_response = MultipleDataResponseSchema[
|
|
615
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
616
|
-
# ].model_validate(response.json())
|
|
617
|
-
# data = DataPair[List[UserOrganizationDataSchema], None](
|
|
618
|
-
# old=validated_response.data,
|
|
619
|
-
# new=None,
|
|
620
|
-
# )
|
|
621
|
-
# result = ReadMultipleResourceOperationResult[
|
|
622
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
623
|
-
# ](
|
|
624
|
-
# data=data,
|
|
625
|
-
# pagination=validated_response.pagination,
|
|
626
|
-
# metadata=None,
|
|
627
|
-
# other=None,
|
|
628
|
-
# )
|
|
629
|
-
# ReadMultipleResourceOperationSchema[
|
|
630
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
631
|
-
# ](
|
|
632
|
-
# service_context=self._service_context,
|
|
633
|
-
# id=operation_id,
|
|
634
|
-
# context=operation_context,
|
|
635
|
-
# timestamp=OperationTimestamp(
|
|
636
|
-
# executed_at=executed_at,
|
|
637
|
-
# completed_at=completed_at,
|
|
638
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
639
|
-
# ),
|
|
640
|
-
# summary="Successfully retrieved multiple user organizations from http request",
|
|
641
|
-
# request_context=request_context,
|
|
642
|
-
# authentication=authentication,
|
|
643
|
-
# action=operation_action,
|
|
644
|
-
# resource=USER_RESOURCE,
|
|
645
|
-
# result=result,
|
|
646
|
-
# ).log(
|
|
647
|
-
# self._logger, level=LogLevel.INFO
|
|
648
|
-
# )
|
|
649
|
-
|
|
650
|
-
# if parameters.use_cache:
|
|
651
|
-
# await self._redis.set(
|
|
652
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
653
|
-
# )
|
|
654
|
-
|
|
655
|
-
# return result
|
|
656
|
-
|
|
657
|
-
# self._raise_resource_http_request_error(
|
|
658
|
-
# response=response,
|
|
659
|
-
# operation_id=operation_id,
|
|
660
|
-
# operation_context=operation_context,
|
|
661
|
-
# executed_at=executed_at,
|
|
662
|
-
# operation_action=operation_action,
|
|
663
|
-
# request_context=request_context,
|
|
664
|
-
# authentication=authentication,
|
|
665
|
-
# resource=USER_RESOURCE,
|
|
666
|
-
# )
|
|
667
|
-
|
|
668
|
-
# async def read_user_organization(
|
|
669
|
-
# self,
|
|
670
|
-
# operation_id: UUID,
|
|
671
|
-
# request_context: RequestContext,
|
|
672
|
-
# authentication: Authentication,
|
|
673
|
-
# parameters: UserOrganizationReadSingleParameter,
|
|
674
|
-
# authorization: Optional[Authorization] = None,
|
|
675
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
676
|
-
# ) -> ReadSingleResourceOperationResult[UserOrganizationDataSchema, None]:
|
|
677
|
-
# """Retrieve user organization from MaleoIdentity"""
|
|
678
|
-
# operation_action = ReadResourceOperationAction()
|
|
679
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
680
|
-
|
|
681
|
-
# # Get function identifier
|
|
682
|
-
# func = self.__class__
|
|
683
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
684
|
-
|
|
685
|
-
# # Define arguments being used in this function
|
|
686
|
-
# positional_arguments = []
|
|
687
|
-
# keyword_arguments = {
|
|
688
|
-
# "authentication": authentication.model_dump(
|
|
689
|
-
# mode="json",
|
|
690
|
-
# exclude={
|
|
691
|
-
# "credentials": {
|
|
692
|
-
# "token": {
|
|
693
|
-
# "payload": {
|
|
694
|
-
# "iat_dt",
|
|
695
|
-
# "iat",
|
|
696
|
-
# "exp_dt",
|
|
697
|
-
# "exp",
|
|
698
|
-
# }
|
|
699
|
-
# }
|
|
700
|
-
# }
|
|
701
|
-
# },
|
|
702
|
-
# ),
|
|
703
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
704
|
-
# }
|
|
705
|
-
|
|
706
|
-
# # Define full function string
|
|
707
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
708
|
-
|
|
709
|
-
# # Define full cache key
|
|
710
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
711
|
-
|
|
712
|
-
# if parameters.use_cache:
|
|
713
|
-
# # Cache operation
|
|
714
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
715
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
716
|
-
# # Check redis for data
|
|
717
|
-
# result_str = await self._redis.get(cache_key)
|
|
718
|
-
|
|
719
|
-
# if result_str is not None:
|
|
720
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
721
|
-
# result = ReadSingleResourceOperationResult[
|
|
722
|
-
# UserOrganizationDataSchema, None
|
|
723
|
-
# ].model_validate(json.loads(result_str))
|
|
724
|
-
# ReadSingleResourceOperationSchema[UserOrganizationDataSchema, None](
|
|
725
|
-
# service_context=self._service_context,
|
|
726
|
-
# id=operation_id,
|
|
727
|
-
# context=operation_context,
|
|
728
|
-
# timestamp=OperationTimestamp(
|
|
729
|
-
# executed_at=executed_at,
|
|
730
|
-
# completed_at=completed_at,
|
|
731
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
732
|
-
# ),
|
|
733
|
-
# summary="Successfully retrieved single user organization from cache",
|
|
734
|
-
# request_context=request_context,
|
|
735
|
-
# authentication=authentication,
|
|
736
|
-
# action=operation_action,
|
|
737
|
-
# resource=USER_RESOURCE,
|
|
738
|
-
# result=result,
|
|
739
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
740
|
-
# return result
|
|
741
|
-
|
|
742
|
-
# # HTTP Request
|
|
743
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
744
|
-
# async with self._http_client_manager.get() as client:
|
|
745
|
-
# # Define URL
|
|
746
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.user_id}/organizations/{parameters.organization_id}"
|
|
747
|
-
|
|
748
|
-
# # Parse parameters to query params
|
|
749
|
-
# params = UserOrganizationReadSingleQueryParameter.model_validate(
|
|
750
|
-
# parameters.model_dump()
|
|
751
|
-
# ).model_dump(exclude_none=True)
|
|
752
|
-
|
|
753
|
-
# # Create headers
|
|
754
|
-
# base_headers = {
|
|
755
|
-
# "Content-Type": "application/json",
|
|
756
|
-
# "X-Operation_Id": str(operation_id),
|
|
757
|
-
# }
|
|
758
|
-
# if headers is not None:
|
|
759
|
-
# headers = merge_dicts(base_headers, headers)
|
|
760
|
-
# else:
|
|
761
|
-
# headers = base_headers
|
|
762
|
-
|
|
763
|
-
# # Create auth
|
|
764
|
-
# token = None
|
|
765
|
-
# if authentication.credentials.token is not None:
|
|
766
|
-
# try:
|
|
767
|
-
# token = reencode(
|
|
768
|
-
# payload=authentication.credentials.token.payload,
|
|
769
|
-
# key=self._private_key,
|
|
770
|
-
# )
|
|
771
|
-
# except Exception:
|
|
772
|
-
# pass
|
|
773
|
-
|
|
774
|
-
# if (
|
|
775
|
-
# token is None
|
|
776
|
-
# and authorization is not None
|
|
777
|
-
# and authorization.scheme == "Bearer"
|
|
778
|
-
# ):
|
|
779
|
-
# token = authorization.credentials
|
|
780
|
-
|
|
781
|
-
# if token is None:
|
|
782
|
-
# token = self._credential_manager.token
|
|
783
|
-
|
|
784
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
785
|
-
|
|
786
|
-
# # Send request and wait for response
|
|
787
|
-
# response = await client.get(
|
|
788
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
789
|
-
# )
|
|
790
|
-
|
|
791
|
-
# if response.is_success:
|
|
792
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
793
|
-
# validated_response = SingleDataResponseSchema[
|
|
794
|
-
# UserOrganizationDataSchema, None
|
|
795
|
-
# ].model_validate(response.json())
|
|
796
|
-
# data = DataPair[UserOrganizationDataSchema, None](
|
|
797
|
-
# old=validated_response.data,
|
|
798
|
-
# new=None,
|
|
799
|
-
# )
|
|
800
|
-
# result = ReadSingleResourceOperationResult[
|
|
801
|
-
# UserOrganizationDataSchema, None
|
|
802
|
-
# ](
|
|
803
|
-
# data=data,
|
|
804
|
-
# pagination=validated_response.pagination,
|
|
805
|
-
# metadata=None,
|
|
806
|
-
# other=None,
|
|
807
|
-
# )
|
|
808
|
-
# ReadSingleResourceOperationSchema[UserOrganizationDataSchema, None](
|
|
809
|
-
# service_context=self._service_context,
|
|
810
|
-
# id=operation_id,
|
|
811
|
-
# context=operation_context,
|
|
812
|
-
# timestamp=OperationTimestamp(
|
|
813
|
-
# executed_at=executed_at,
|
|
814
|
-
# completed_at=completed_at,
|
|
815
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
816
|
-
# ),
|
|
817
|
-
# summary="Successfully retrieved single user organization from http request",
|
|
818
|
-
# request_context=request_context,
|
|
819
|
-
# authentication=authentication,
|
|
820
|
-
# action=operation_action,
|
|
821
|
-
# resource=USER_RESOURCE,
|
|
822
|
-
# result=result,
|
|
823
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
824
|
-
|
|
825
|
-
# if parameters.use_cache:
|
|
826
|
-
# await self._redis.set(
|
|
827
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
828
|
-
# )
|
|
829
|
-
|
|
830
|
-
# return result
|
|
831
|
-
|
|
832
|
-
# self._raise_resource_http_request_error(
|
|
833
|
-
# response=response,
|
|
834
|
-
# operation_id=operation_id,
|
|
835
|
-
# operation_context=operation_context,
|
|
836
|
-
# executed_at=executed_at,
|
|
837
|
-
# operation_action=operation_action,
|
|
838
|
-
# request_context=request_context,
|
|
839
|
-
# authentication=authentication,
|
|
840
|
-
# resource=USER_RESOURCE,
|
|
841
|
-
# )
|
|
842
|
-
|
|
843
|
-
# async def read_user_organization_roles(
|
|
844
|
-
# self,
|
|
845
|
-
# operation_id: UUID,
|
|
846
|
-
# request_context: RequestContext,
|
|
847
|
-
# authentication: Authentication,
|
|
848
|
-
# parameters: UserOrganizationRoleReadMultipleFromUserOrganizationParameter,
|
|
849
|
-
# authorization: Optional[Authorization] = None,
|
|
850
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
851
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
852
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
853
|
-
# ]:
|
|
854
|
-
# """Retrieve user organization roles from MaleoIdentity"""
|
|
855
|
-
# operation_action = ReadResourceOperationAction()
|
|
856
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
857
|
-
|
|
858
|
-
# # Get function identifier
|
|
859
|
-
# func = self.__class__
|
|
860
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
861
|
-
|
|
862
|
-
# # Define arguments being used in this function
|
|
863
|
-
# positional_arguments = []
|
|
864
|
-
# keyword_arguments = {
|
|
865
|
-
# "authentication": authentication.model_dump(
|
|
866
|
-
# mode="json",
|
|
867
|
-
# exclude={
|
|
868
|
-
# "credentials": {
|
|
869
|
-
# "token": {
|
|
870
|
-
# "payload": {
|
|
871
|
-
# "iat_dt",
|
|
872
|
-
# "iat",
|
|
873
|
-
# "exp_dt",
|
|
874
|
-
# "exp",
|
|
875
|
-
# }
|
|
876
|
-
# }
|
|
877
|
-
# }
|
|
878
|
-
# },
|
|
879
|
-
# ),
|
|
880
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
881
|
-
# }
|
|
882
|
-
|
|
883
|
-
# # Define full function string
|
|
884
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
885
|
-
|
|
886
|
-
# # Define full cache key
|
|
887
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
888
|
-
|
|
889
|
-
# if parameters.use_cache:
|
|
890
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
891
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
892
|
-
|
|
893
|
-
# # Check redis for data
|
|
894
|
-
# result_str = await self._redis.get(cache_key)
|
|
895
|
-
|
|
896
|
-
# if result_str is not None:
|
|
897
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
898
|
-
# result = ReadMultipleResourceOperationResult[
|
|
899
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
900
|
-
# ].model_validate(json.loads(result_str))
|
|
901
|
-
# ReadMultipleResourceOperationSchema[
|
|
902
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
903
|
-
# ](
|
|
904
|
-
# service_context=self._service_context,
|
|
905
|
-
# id=operation_id,
|
|
906
|
-
# context=operation_context,
|
|
907
|
-
# timestamp=OperationTimestamp(
|
|
908
|
-
# executed_at=executed_at,
|
|
909
|
-
# completed_at=completed_at,
|
|
910
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
911
|
-
# ),
|
|
912
|
-
# summary="Successfully retrieved multiple user organization roles from cache",
|
|
913
|
-
# request_context=request_context,
|
|
914
|
-
# authentication=authentication,
|
|
915
|
-
# action=operation_action,
|
|
916
|
-
# resource=USER_RESOURCE,
|
|
917
|
-
# result=result,
|
|
918
|
-
# ).log(
|
|
919
|
-
# self._logger, level=LogLevel.INFO
|
|
920
|
-
# )
|
|
921
|
-
# return result
|
|
922
|
-
|
|
923
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
924
|
-
# async with self._http_client_manager.get() as http_client:
|
|
925
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.user_id}/organizations/{parameters.organization_id}/roles/"
|
|
926
|
-
|
|
927
|
-
# # Parse parameters to query params
|
|
928
|
-
# params = UserOrganizationRoleReadMultipleFromUserOrganizationQueryParameter.model_validate(
|
|
929
|
-
# parameters.model_dump()
|
|
930
|
-
# ).model_dump(
|
|
931
|
-
# exclude={"sort_columns", "date_filters"}, exclude_none=True
|
|
932
|
-
# )
|
|
933
|
-
|
|
934
|
-
# # Create headers
|
|
935
|
-
# base_headers = {
|
|
936
|
-
# "Content-Type": "application/json",
|
|
937
|
-
# "X-Operation_Id": str(operation_id),
|
|
938
|
-
# }
|
|
939
|
-
# if headers is not None:
|
|
940
|
-
# headers = merge_dicts(base_headers, headers)
|
|
941
|
-
# else:
|
|
942
|
-
# headers = base_headers
|
|
943
|
-
|
|
944
|
-
# # Create auth
|
|
945
|
-
# token = None
|
|
946
|
-
# if authentication.credentials.token is not None:
|
|
947
|
-
# try:
|
|
948
|
-
# token = reencode(
|
|
949
|
-
# payload=authentication.credentials.token.payload,
|
|
950
|
-
# key=self._private_key,
|
|
951
|
-
# )
|
|
952
|
-
# except Exception:
|
|
953
|
-
# pass
|
|
954
|
-
|
|
955
|
-
# if (
|
|
956
|
-
# token is None
|
|
957
|
-
# and authorization is not None
|
|
958
|
-
# and authorization.scheme == "Bearer"
|
|
959
|
-
# ):
|
|
960
|
-
# token = authorization.credentials
|
|
961
|
-
|
|
962
|
-
# if token is None:
|
|
963
|
-
# token = self._credential_manager.token
|
|
964
|
-
|
|
965
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
966
|
-
|
|
967
|
-
# # Send request and wait for response
|
|
968
|
-
# response = await http_client.get(
|
|
969
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
970
|
-
# )
|
|
971
|
-
|
|
972
|
-
# if response.is_success:
|
|
973
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
974
|
-
# validated_response = MultipleDataResponseSchema[
|
|
975
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
976
|
-
# ].model_validate(response.json())
|
|
977
|
-
# data = DataPair[List[UserOrganizationRoleDataSchema], None](
|
|
978
|
-
# old=validated_response.data,
|
|
979
|
-
# new=None,
|
|
980
|
-
# )
|
|
981
|
-
# result = ReadMultipleResourceOperationResult[
|
|
982
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
983
|
-
# ](
|
|
984
|
-
# data=data,
|
|
985
|
-
# pagination=validated_response.pagination,
|
|
986
|
-
# metadata=None,
|
|
987
|
-
# other=None,
|
|
988
|
-
# )
|
|
989
|
-
# ReadMultipleResourceOperationSchema[
|
|
990
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
991
|
-
# ](
|
|
992
|
-
# service_context=self._service_context,
|
|
993
|
-
# id=operation_id,
|
|
994
|
-
# context=operation_context,
|
|
995
|
-
# timestamp=OperationTimestamp(
|
|
996
|
-
# executed_at=executed_at,
|
|
997
|
-
# completed_at=completed_at,
|
|
998
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
999
|
-
# ),
|
|
1000
|
-
# summary="Successfully retrieved multiple user organization roles from http request",
|
|
1001
|
-
# request_context=request_context,
|
|
1002
|
-
# authentication=authentication,
|
|
1003
|
-
# action=operation_action,
|
|
1004
|
-
# resource=USER_RESOURCE,
|
|
1005
|
-
# result=result,
|
|
1006
|
-
# ).log(
|
|
1007
|
-
# self._logger, level=LogLevel.INFO
|
|
1008
|
-
# )
|
|
1009
|
-
|
|
1010
|
-
# if parameters.use_cache:
|
|
1011
|
-
# await self._redis.set(
|
|
1012
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1013
|
-
# )
|
|
1014
|
-
|
|
1015
|
-
# return result
|
|
1016
|
-
|
|
1017
|
-
# self._raise_resource_http_request_error(
|
|
1018
|
-
# response=response,
|
|
1019
|
-
# operation_id=operation_id,
|
|
1020
|
-
# operation_context=operation_context,
|
|
1021
|
-
# executed_at=executed_at,
|
|
1022
|
-
# operation_action=operation_action,
|
|
1023
|
-
# request_context=request_context,
|
|
1024
|
-
# authentication=authentication,
|
|
1025
|
-
# resource=USER_RESOURCE,
|
|
1026
|
-
# )
|
|
1027
|
-
|
|
1028
|
-
# async def read_user_organization_role(
|
|
1029
|
-
# self,
|
|
1030
|
-
# operation_id: UUID,
|
|
1031
|
-
# request_context: RequestContext,
|
|
1032
|
-
# authentication: Authentication,
|
|
1033
|
-
# parameters: UserOrganizationRoleReadSingleParameter,
|
|
1034
|
-
# authorization: Optional[Authorization] = None,
|
|
1035
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1036
|
-
# ) -> ReadSingleResourceOperationResult[UserOrganizationRoleDataSchema, None]:
|
|
1037
|
-
# """Retrieve user organization role from MaleoIdentity"""
|
|
1038
|
-
# operation_action = ReadResourceOperationAction()
|
|
1039
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1040
|
-
|
|
1041
|
-
# # Get function identifier
|
|
1042
|
-
# func = self.__class__
|
|
1043
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1044
|
-
|
|
1045
|
-
# # Define arguments being used in this function
|
|
1046
|
-
# positional_arguments = []
|
|
1047
|
-
# keyword_arguments = {
|
|
1048
|
-
# "authentication": authentication.model_dump(
|
|
1049
|
-
# mode="json",
|
|
1050
|
-
# exclude={
|
|
1051
|
-
# "credentials": {
|
|
1052
|
-
# "token": {
|
|
1053
|
-
# "payload": {
|
|
1054
|
-
# "iat_dt",
|
|
1055
|
-
# "iat",
|
|
1056
|
-
# "exp_dt",
|
|
1057
|
-
# "exp",
|
|
1058
|
-
# }
|
|
1059
|
-
# }
|
|
1060
|
-
# }
|
|
1061
|
-
# },
|
|
1062
|
-
# ),
|
|
1063
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1064
|
-
# }
|
|
1065
|
-
|
|
1066
|
-
# # Define full function string
|
|
1067
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1068
|
-
|
|
1069
|
-
# # Define full cache key
|
|
1070
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1071
|
-
|
|
1072
|
-
# if parameters.use_cache:
|
|
1073
|
-
# # Cache operation
|
|
1074
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1075
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1076
|
-
# # Check redis for data
|
|
1077
|
-
# result_str = await self._redis.get(cache_key)
|
|
1078
|
-
|
|
1079
|
-
# if result_str is not None:
|
|
1080
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1081
|
-
# result = ReadSingleResourceOperationResult[
|
|
1082
|
-
# UserOrganizationRoleDataSchema, None
|
|
1083
|
-
# ].model_validate(json.loads(result_str))
|
|
1084
|
-
# ReadSingleResourceOperationSchema[UserOrganizationRoleDataSchema, None](
|
|
1085
|
-
# service_context=self._service_context,
|
|
1086
|
-
# id=operation_id,
|
|
1087
|
-
# context=operation_context,
|
|
1088
|
-
# timestamp=OperationTimestamp(
|
|
1089
|
-
# executed_at=executed_at,
|
|
1090
|
-
# completed_at=completed_at,
|
|
1091
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1092
|
-
# ),
|
|
1093
|
-
# summary="Successfully retrieved single user organization role from cache",
|
|
1094
|
-
# request_context=request_context,
|
|
1095
|
-
# authentication=authentication,
|
|
1096
|
-
# action=operation_action,
|
|
1097
|
-
# resource=USER_RESOURCE,
|
|
1098
|
-
# result=result,
|
|
1099
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1100
|
-
# return result
|
|
1101
|
-
|
|
1102
|
-
# # HTTP Request
|
|
1103
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1104
|
-
# async with self._http_client_manager.get() as client:
|
|
1105
|
-
# # Define URL
|
|
1106
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.user_id}/organizations/{parameters.organization_id}/roles/{parameters.key}"
|
|
1107
|
-
|
|
1108
|
-
# # Parse parameters to query params
|
|
1109
|
-
# params = UserOrganizationRoleReadSingleQueryParameter.model_validate(
|
|
1110
|
-
# parameters.model_dump()
|
|
1111
|
-
# ).model_dump(exclude_none=True)
|
|
1112
|
-
|
|
1113
|
-
# # Create headers
|
|
1114
|
-
# base_headers = {
|
|
1115
|
-
# "Content-Type": "application/json",
|
|
1116
|
-
# "X-Operation_Id": str(operation_id),
|
|
1117
|
-
# }
|
|
1118
|
-
# if headers is not None:
|
|
1119
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1120
|
-
# else:
|
|
1121
|
-
# headers = base_headers
|
|
1122
|
-
|
|
1123
|
-
# # Create auth
|
|
1124
|
-
# token = None
|
|
1125
|
-
# if authentication.credentials.token is not None:
|
|
1126
|
-
# try:
|
|
1127
|
-
# token = reencode(
|
|
1128
|
-
# payload=authentication.credentials.token.payload,
|
|
1129
|
-
# key=self._private_key,
|
|
1130
|
-
# )
|
|
1131
|
-
# except Exception:
|
|
1132
|
-
# pass
|
|
1133
|
-
|
|
1134
|
-
# if (
|
|
1135
|
-
# token is None
|
|
1136
|
-
# and authorization is not None
|
|
1137
|
-
# and authorization.scheme == "Bearer"
|
|
1138
|
-
# ):
|
|
1139
|
-
# token = authorization.credentials
|
|
1140
|
-
|
|
1141
|
-
# if token is None:
|
|
1142
|
-
# token = self._credential_manager.token
|
|
1143
|
-
|
|
1144
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1145
|
-
|
|
1146
|
-
# # Send request and wait for response
|
|
1147
|
-
# response = await client.get(
|
|
1148
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1149
|
-
# )
|
|
1150
|
-
|
|
1151
|
-
# if response.is_success:
|
|
1152
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1153
|
-
# validated_response = SingleDataResponseSchema[
|
|
1154
|
-
# UserOrganizationRoleDataSchema, None
|
|
1155
|
-
# ].model_validate(response.json())
|
|
1156
|
-
# data = DataPair[UserOrganizationRoleDataSchema, None](
|
|
1157
|
-
# old=validated_response.data,
|
|
1158
|
-
# new=None,
|
|
1159
|
-
# )
|
|
1160
|
-
# result = ReadSingleResourceOperationResult[
|
|
1161
|
-
# UserOrganizationRoleDataSchema, None
|
|
1162
|
-
# ](
|
|
1163
|
-
# data=data,
|
|
1164
|
-
# pagination=validated_response.pagination,
|
|
1165
|
-
# metadata=None,
|
|
1166
|
-
# other=None,
|
|
1167
|
-
# )
|
|
1168
|
-
# ReadSingleResourceOperationSchema[UserOrganizationRoleDataSchema, None](
|
|
1169
|
-
# service_context=self._service_context,
|
|
1170
|
-
# id=operation_id,
|
|
1171
|
-
# context=operation_context,
|
|
1172
|
-
# timestamp=OperationTimestamp(
|
|
1173
|
-
# executed_at=executed_at,
|
|
1174
|
-
# completed_at=completed_at,
|
|
1175
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1176
|
-
# ),
|
|
1177
|
-
# summary="Successfully retrieved single user organization role from http request",
|
|
1178
|
-
# request_context=request_context,
|
|
1179
|
-
# authentication=authentication,
|
|
1180
|
-
# action=operation_action,
|
|
1181
|
-
# resource=USER_RESOURCE,
|
|
1182
|
-
# result=result,
|
|
1183
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1184
|
-
|
|
1185
|
-
# if parameters.use_cache:
|
|
1186
|
-
# await self._redis.set(
|
|
1187
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1188
|
-
# )
|
|
1189
|
-
|
|
1190
|
-
# return result
|
|
1191
|
-
|
|
1192
|
-
# self._raise_resource_http_request_error(
|
|
1193
|
-
# response=response,
|
|
1194
|
-
# operation_id=operation_id,
|
|
1195
|
-
# operation_context=operation_context,
|
|
1196
|
-
# executed_at=executed_at,
|
|
1197
|
-
# operation_action=operation_action,
|
|
1198
|
-
# request_context=request_context,
|
|
1199
|
-
# authentication=authentication,
|
|
1200
|
-
# resource=USER_RESOURCE,
|
|
1201
|
-
# )
|
|
1202
|
-
|
|
1203
|
-
# async def read_user_system_roles(
|
|
1204
|
-
# self,
|
|
1205
|
-
# operation_id: UUID,
|
|
1206
|
-
# request_context: RequestContext,
|
|
1207
|
-
# authentication: Authentication,
|
|
1208
|
-
# parameters: UserSystemRoleReadMultipleFromUserParameter,
|
|
1209
|
-
# authorization: Optional[Authorization] = None,
|
|
1210
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1211
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
1212
|
-
# UserSystemRoleDataSchema, StrictPagination, None
|
|
1213
|
-
# ]:
|
|
1214
|
-
# """Retrieve user system roles from MaleoIdentity"""
|
|
1215
|
-
# operation_action = ReadResourceOperationAction()
|
|
1216
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1217
|
-
|
|
1218
|
-
# # Get function identifier
|
|
1219
|
-
# func = self.__class__
|
|
1220
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1221
|
-
|
|
1222
|
-
# # Define arguments being used in this function
|
|
1223
|
-
# positional_arguments = []
|
|
1224
|
-
# keyword_arguments = {
|
|
1225
|
-
# "authentication": authentication.model_dump(
|
|
1226
|
-
# mode="json",
|
|
1227
|
-
# exclude={
|
|
1228
|
-
# "credentials": {
|
|
1229
|
-
# "token": {
|
|
1230
|
-
# "payload": {
|
|
1231
|
-
# "iat_dt",
|
|
1232
|
-
# "iat",
|
|
1233
|
-
# "exp_dt",
|
|
1234
|
-
# "exp",
|
|
1235
|
-
# }
|
|
1236
|
-
# }
|
|
1237
|
-
# }
|
|
1238
|
-
# },
|
|
1239
|
-
# ),
|
|
1240
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1241
|
-
# }
|
|
1242
|
-
|
|
1243
|
-
# # Define full function string
|
|
1244
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1245
|
-
|
|
1246
|
-
# # Define full cache key
|
|
1247
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1248
|
-
|
|
1249
|
-
# if parameters.use_cache:
|
|
1250
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1251
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1252
|
-
|
|
1253
|
-
# # Check redis for data
|
|
1254
|
-
# result_str = await self._redis.get(cache_key)
|
|
1255
|
-
|
|
1256
|
-
# if result_str is not None:
|
|
1257
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1258
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1259
|
-
# UserSystemRoleDataSchema, StrictPagination, None
|
|
1260
|
-
# ].model_validate(json.loads(result_str))
|
|
1261
|
-
# ReadMultipleResourceOperationSchema[
|
|
1262
|
-
# UserSystemRoleDataSchema, StrictPagination, None
|
|
1263
|
-
# ](
|
|
1264
|
-
# service_context=self._service_context,
|
|
1265
|
-
# id=operation_id,
|
|
1266
|
-
# context=operation_context,
|
|
1267
|
-
# timestamp=OperationTimestamp(
|
|
1268
|
-
# executed_at=executed_at,
|
|
1269
|
-
# completed_at=completed_at,
|
|
1270
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1271
|
-
# ),
|
|
1272
|
-
# summary="Successfully retrieved multiple user system roles from cache",
|
|
1273
|
-
# request_context=request_context,
|
|
1274
|
-
# authentication=authentication,
|
|
1275
|
-
# action=operation_action,
|
|
1276
|
-
# resource=USER_RESOURCE,
|
|
1277
|
-
# result=result,
|
|
1278
|
-
# ).log(
|
|
1279
|
-
# self._logger, level=LogLevel.INFO
|
|
1280
|
-
# )
|
|
1281
|
-
# return result
|
|
1282
|
-
|
|
1283
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1284
|
-
# async with self._http_client_manager.get() as http_client:
|
|
1285
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.user_id}/system-roles/"
|
|
1286
|
-
|
|
1287
|
-
# # Parse parameters to query params
|
|
1288
|
-
# params = UserSystemRoleReadMultipleFromUserQueryParameter.model_validate(
|
|
1289
|
-
# parameters.model_dump()
|
|
1290
|
-
# ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
|
|
1291
|
-
|
|
1292
|
-
# # Create headers
|
|
1293
|
-
# base_headers = {
|
|
1294
|
-
# "Content-Type": "application/json",
|
|
1295
|
-
# "X-Operation_Id": str(operation_id),
|
|
1296
|
-
# }
|
|
1297
|
-
# if headers is not None:
|
|
1298
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1299
|
-
# else:
|
|
1300
|
-
# headers = base_headers
|
|
1301
|
-
|
|
1302
|
-
# # Create auth
|
|
1303
|
-
# token = None
|
|
1304
|
-
# if authentication.credentials.token is not None:
|
|
1305
|
-
# try:
|
|
1306
|
-
# token = reencode(
|
|
1307
|
-
# payload=authentication.credentials.token.payload,
|
|
1308
|
-
# key=self._private_key,
|
|
1309
|
-
# )
|
|
1310
|
-
# except Exception:
|
|
1311
|
-
# pass
|
|
1312
|
-
|
|
1313
|
-
# if (
|
|
1314
|
-
# token is None
|
|
1315
|
-
# and authorization is not None
|
|
1316
|
-
# and authorization.scheme == "Bearer"
|
|
1317
|
-
# ):
|
|
1318
|
-
# token = authorization.credentials
|
|
1319
|
-
|
|
1320
|
-
# if token is None:
|
|
1321
|
-
# token = self._credential_manager.token
|
|
1322
|
-
|
|
1323
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1324
|
-
|
|
1325
|
-
# # Send request and wait for response
|
|
1326
|
-
# response = await http_client.get(
|
|
1327
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1328
|
-
# )
|
|
1329
|
-
|
|
1330
|
-
# if response.is_success:
|
|
1331
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1332
|
-
# validated_response = MultipleDataResponseSchema[
|
|
1333
|
-
# UserSystemRoleDataSchema, StrictPagination, None
|
|
1334
|
-
# ].model_validate(response.json())
|
|
1335
|
-
# data = DataPair[List[UserSystemRoleDataSchema], None](
|
|
1336
|
-
# old=validated_response.data,
|
|
1337
|
-
# new=None,
|
|
1338
|
-
# )
|
|
1339
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1340
|
-
# UserSystemRoleDataSchema, StrictPagination, None
|
|
1341
|
-
# ](
|
|
1342
|
-
# data=data,
|
|
1343
|
-
# pagination=validated_response.pagination,
|
|
1344
|
-
# metadata=None,
|
|
1345
|
-
# other=None,
|
|
1346
|
-
# )
|
|
1347
|
-
# ReadMultipleResourceOperationSchema[
|
|
1348
|
-
# UserSystemRoleDataSchema, StrictPagination, None
|
|
1349
|
-
# ](
|
|
1350
|
-
# service_context=self._service_context,
|
|
1351
|
-
# id=operation_id,
|
|
1352
|
-
# context=operation_context,
|
|
1353
|
-
# timestamp=OperationTimestamp(
|
|
1354
|
-
# executed_at=executed_at,
|
|
1355
|
-
# completed_at=completed_at,
|
|
1356
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1357
|
-
# ),
|
|
1358
|
-
# summary="Successfully retrieved multiple user system roles from http request",
|
|
1359
|
-
# request_context=request_context,
|
|
1360
|
-
# authentication=authentication,
|
|
1361
|
-
# action=operation_action,
|
|
1362
|
-
# resource=USER_RESOURCE,
|
|
1363
|
-
# result=result,
|
|
1364
|
-
# ).log(
|
|
1365
|
-
# self._logger, level=LogLevel.INFO
|
|
1366
|
-
# )
|
|
1367
|
-
|
|
1368
|
-
# if parameters.use_cache:
|
|
1369
|
-
# await self._redis.set(
|
|
1370
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1371
|
-
# )
|
|
1372
|
-
|
|
1373
|
-
# return result
|
|
1374
|
-
|
|
1375
|
-
# self._raise_resource_http_request_error(
|
|
1376
|
-
# response=response,
|
|
1377
|
-
# operation_id=operation_id,
|
|
1378
|
-
# operation_context=operation_context,
|
|
1379
|
-
# executed_at=executed_at,
|
|
1380
|
-
# operation_action=operation_action,
|
|
1381
|
-
# request_context=request_context,
|
|
1382
|
-
# authentication=authentication,
|
|
1383
|
-
# resource=USER_RESOURCE,
|
|
1384
|
-
# )
|
|
1385
|
-
|
|
1386
|
-
# async def read_user_system_role(
|
|
1387
|
-
# self,
|
|
1388
|
-
# operation_id: UUID,
|
|
1389
|
-
# request_context: RequestContext,
|
|
1390
|
-
# authentication: Authentication,
|
|
1391
|
-
# parameters: UserSystemRoleReadSingleParameter,
|
|
1392
|
-
# authorization: Optional[Authorization] = None,
|
|
1393
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1394
|
-
# ) -> ReadSingleResourceOperationResult[UserSystemRoleDataSchema, None]:
|
|
1395
|
-
# """Retrieve user system role from MaleoIdentity"""
|
|
1396
|
-
# operation_action = ReadResourceOperationAction()
|
|
1397
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1398
|
-
|
|
1399
|
-
# # Get function identifier
|
|
1400
|
-
# func = self.__class__
|
|
1401
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1402
|
-
|
|
1403
|
-
# # Define arguments being used in this function
|
|
1404
|
-
# positional_arguments = []
|
|
1405
|
-
# keyword_arguments = {
|
|
1406
|
-
# "authentication": authentication.model_dump(
|
|
1407
|
-
# mode="json",
|
|
1408
|
-
# exclude={
|
|
1409
|
-
# "credentials": {
|
|
1410
|
-
# "token": {
|
|
1411
|
-
# "payload": {
|
|
1412
|
-
# "iat_dt",
|
|
1413
|
-
# "iat",
|
|
1414
|
-
# "exp_dt",
|
|
1415
|
-
# "exp",
|
|
1416
|
-
# }
|
|
1417
|
-
# }
|
|
1418
|
-
# }
|
|
1419
|
-
# },
|
|
1420
|
-
# ),
|
|
1421
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1422
|
-
# }
|
|
1423
|
-
|
|
1424
|
-
# # Define full function string
|
|
1425
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1426
|
-
|
|
1427
|
-
# # Define full cache key
|
|
1428
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1429
|
-
|
|
1430
|
-
# if parameters.use_cache:
|
|
1431
|
-
# # Cache operation
|
|
1432
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1433
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1434
|
-
# # Check redis for data
|
|
1435
|
-
# result_str = await self._redis.get(cache_key)
|
|
1436
|
-
|
|
1437
|
-
# if result_str is not None:
|
|
1438
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1439
|
-
# result = ReadSingleResourceOperationResult[
|
|
1440
|
-
# UserSystemRoleDataSchema, None
|
|
1441
|
-
# ].model_validate(json.loads(result_str))
|
|
1442
|
-
# ReadSingleResourceOperationSchema[UserSystemRoleDataSchema, None](
|
|
1443
|
-
# service_context=self._service_context,
|
|
1444
|
-
# id=operation_id,
|
|
1445
|
-
# context=operation_context,
|
|
1446
|
-
# timestamp=OperationTimestamp(
|
|
1447
|
-
# executed_at=executed_at,
|
|
1448
|
-
# completed_at=completed_at,
|
|
1449
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1450
|
-
# ),
|
|
1451
|
-
# summary="Successfully retrieved single user system role from cache",
|
|
1452
|
-
# request_context=request_context,
|
|
1453
|
-
# authentication=authentication,
|
|
1454
|
-
# action=operation_action,
|
|
1455
|
-
# resource=USER_RESOURCE,
|
|
1456
|
-
# result=result,
|
|
1457
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1458
|
-
# return result
|
|
1459
|
-
|
|
1460
|
-
# # HTTP Request
|
|
1461
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1462
|
-
# async with self._http_client_manager.get() as client:
|
|
1463
|
-
# # Define URL
|
|
1464
|
-
# url = f"{self._url}/v1/{USER_RESOURCE.identifiers[0].url_slug}/{parameters.user_id}/system-roles/{parameters.system_role}"
|
|
1465
|
-
|
|
1466
|
-
# # Parse parameters to query params
|
|
1467
|
-
# params = UserSystemRoleReadSingleQueryParameter.model_validate(
|
|
1468
|
-
# parameters.model_dump()
|
|
1469
|
-
# ).model_dump(exclude_none=True)
|
|
1470
|
-
|
|
1471
|
-
# # Create headers
|
|
1472
|
-
# base_headers = {
|
|
1473
|
-
# "Content-Type": "application/json",
|
|
1474
|
-
# "X-Operation_Id": str(operation_id),
|
|
1475
|
-
# }
|
|
1476
|
-
# if headers is not None:
|
|
1477
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1478
|
-
# else:
|
|
1479
|
-
# headers = base_headers
|
|
1480
|
-
|
|
1481
|
-
# # Create auth
|
|
1482
|
-
# token = None
|
|
1483
|
-
# if authentication.credentials.token is not None:
|
|
1484
|
-
# try:
|
|
1485
|
-
# token = reencode(
|
|
1486
|
-
# payload=authentication.credentials.token.payload,
|
|
1487
|
-
# key=self._private_key,
|
|
1488
|
-
# )
|
|
1489
|
-
# except Exception:
|
|
1490
|
-
# pass
|
|
1491
|
-
|
|
1492
|
-
# if (
|
|
1493
|
-
# token is None
|
|
1494
|
-
# and authorization is not None
|
|
1495
|
-
# and authorization.scheme == "Bearer"
|
|
1496
|
-
# ):
|
|
1497
|
-
# token = authorization.credentials
|
|
1498
|
-
|
|
1499
|
-
# if token is None:
|
|
1500
|
-
# token = self._credential_manager.token
|
|
1501
|
-
|
|
1502
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1503
|
-
|
|
1504
|
-
# # Send request and wait for response
|
|
1505
|
-
# response = await client.get(
|
|
1506
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1507
|
-
# )
|
|
1508
|
-
|
|
1509
|
-
# if response.is_success:
|
|
1510
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1511
|
-
# validated_response = SingleDataResponseSchema[
|
|
1512
|
-
# UserSystemRoleDataSchema, None
|
|
1513
|
-
# ].model_validate(response.json())
|
|
1514
|
-
# data = DataPair[UserSystemRoleDataSchema, None](
|
|
1515
|
-
# old=validated_response.data,
|
|
1516
|
-
# new=None,
|
|
1517
|
-
# )
|
|
1518
|
-
# result = ReadSingleResourceOperationResult[
|
|
1519
|
-
# UserSystemRoleDataSchema, None
|
|
1520
|
-
# ](
|
|
1521
|
-
# data=data,
|
|
1522
|
-
# pagination=validated_response.pagination,
|
|
1523
|
-
# metadata=None,
|
|
1524
|
-
# other=None,
|
|
1525
|
-
# )
|
|
1526
|
-
# ReadSingleResourceOperationSchema[UserSystemRoleDataSchema, None](
|
|
1527
|
-
# service_context=self._service_context,
|
|
1528
|
-
# id=operation_id,
|
|
1529
|
-
# context=operation_context,
|
|
1530
|
-
# timestamp=OperationTimestamp(
|
|
1531
|
-
# executed_at=executed_at,
|
|
1532
|
-
# completed_at=completed_at,
|
|
1533
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1534
|
-
# ),
|
|
1535
|
-
# summary="Successfully retrieved single user system role from http request",
|
|
1536
|
-
# request_context=request_context,
|
|
1537
|
-
# authentication=authentication,
|
|
1538
|
-
# action=operation_action,
|
|
1539
|
-
# resource=USER_RESOURCE,
|
|
1540
|
-
# result=result,
|
|
1541
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1542
|
-
|
|
1543
|
-
# if parameters.use_cache:
|
|
1544
|
-
# await self._redis.set(
|
|
1545
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1546
|
-
# )
|
|
1547
|
-
|
|
1548
|
-
# return result
|
|
1549
|
-
|
|
1550
|
-
# self._raise_resource_http_request_error(
|
|
1551
|
-
# response=response,
|
|
1552
|
-
# operation_id=operation_id,
|
|
1553
|
-
# operation_context=operation_context,
|
|
1554
|
-
# executed_at=executed_at,
|
|
1555
|
-
# operation_action=operation_action,
|
|
1556
|
-
# request_context=request_context,
|
|
1557
|
-
# authentication=authentication,
|
|
1558
|
-
# resource=USER_RESOURCE,
|
|
1559
|
-
# )
|