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,1944 +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.parameter.general import ReadSingleQueryParameterSchema
|
|
38
|
-
# from maleo.soma.schemas.request import RequestContext
|
|
39
|
-
# from maleo.soma.schemas.response import (
|
|
40
|
-
# SingleDataResponseSchema,
|
|
41
|
-
# MultipleDataResponseSchema,
|
|
42
|
-
# )
|
|
43
|
-
# from maleo.soma.schemas.service import ServiceContext
|
|
44
|
-
# from maleo.soma.utils.cache import build_key
|
|
45
|
-
# from maleo.soma.utils.logging import ClientLogger
|
|
46
|
-
# from maleo.soma.utils.merger import merge_dicts
|
|
47
|
-
# from maleo.soma.utils.token import reencode
|
|
48
|
-
# from maleo.identity.constants.organization import RESOURCE as ORGANIZATION_RESOURCE
|
|
49
|
-
# from maleo.identity.schemas.data.organization_registration_code import (
|
|
50
|
-
# OrganizationRegistrationCodeDataSchema,
|
|
51
|
-
# )
|
|
52
|
-
# from maleo.identity.schemas.data.organization_role import OrganizationRoleDataSchema
|
|
53
|
-
# from maleo.identity.schemas.data.organization import OrganizationDataSchema
|
|
54
|
-
# from maleo.identity.schemas.data.user_organization_role import (
|
|
55
|
-
# UserOrganizationRoleDataSchema,
|
|
56
|
-
# )
|
|
57
|
-
# from maleo.identity.schemas.data.user_organization import UserOrganizationDataSchema
|
|
58
|
-
# from maleo.identity.schemas.parameter.client.organization_role import (
|
|
59
|
-
# ReadMultipleFromOrganizationParameter as OrganizationRoleReadMultipleFromOrganizationParameter,
|
|
60
|
-
# ReadMultipleFromOrganizationQueryParameter as OrganizationRoleReadMultipleFromOrganizationQueryParameter,
|
|
61
|
-
# )
|
|
62
|
-
# from maleo.identity.schemas.parameter.client.organization import (
|
|
63
|
-
# ReadMultipleParameter as OrganizationReadMultipleParameter,
|
|
64
|
-
# ReadMultipleChildrenParameter as OrganizationReadMultipleChildrenParameter,
|
|
65
|
-
# ReadMultipleQueryParameter as OrganizationReadMultipleQueryParameter,
|
|
66
|
-
# ReadMultipleChildrenQueryParameter as OrganizationReadMultipleChildrenQueryParameter,
|
|
67
|
-
# )
|
|
68
|
-
# from maleo.identity.schemas.parameter.client.user_organization_role import (
|
|
69
|
-
# ReadMultipleFromUserOrganizationParameter as UserOrganizationRoleReadMultipleFromUserOrganizationParameter,
|
|
70
|
-
# ReadMultipleFromUserOrganizationQueryParameter as UserOrganizationRoleReadMultipleFromUserOrganizationQueryParameter,
|
|
71
|
-
# )
|
|
72
|
-
# from maleo.identity.schemas.parameter.client.user_organization import (
|
|
73
|
-
# ReadMultipleFromOrganizationParameter as UserOrganizationReadMultipleFromOrganizationParameter,
|
|
74
|
-
# ReadMultipleFromOrganizationQueryParameter as UserOrganizationReadMultipleFromOrganizationQueryParameter,
|
|
75
|
-
# )
|
|
76
|
-
# from maleo.identity.schemas.parameter.general.organization_registration_code import (
|
|
77
|
-
# ReadSingleParameter as OrganizationRegistrationCodeReadSingleParameter,
|
|
78
|
-
# )
|
|
79
|
-
# from maleo.identity.schemas.parameter.general.organization_role import (
|
|
80
|
-
# ReadSingleParameter as OrganizationRoleReadSingleParameter,
|
|
81
|
-
# ReadSingleQueryParameter as OrganizationRoleReadSingleQueryParameter,
|
|
82
|
-
# )
|
|
83
|
-
# from maleo.identity.schemas.parameter.general.organization import (
|
|
84
|
-
# ReadSingleQueryParameter as OrganizationReadSingleQueryParameter,
|
|
85
|
-
# ReadSingleParameter as OrganizationReadSingleParameter,
|
|
86
|
-
# )
|
|
87
|
-
# from maleo.identity.schemas.parameter.general.user_organization_role import (
|
|
88
|
-
# ReadSingleQueryParameter as UserOrganizationRoleReadSingleQueryParameter,
|
|
89
|
-
# ReadSingleParameter as UserOrganizationRoleReadSingleParameter,
|
|
90
|
-
# )
|
|
91
|
-
# from maleo.identity.schemas.parameter.general.user_organization import (
|
|
92
|
-
# ReadSingleQueryParameter as UserOrganizationReadSingleQueryParameter,
|
|
93
|
-
# ReadSingleParameter as UserOrganizationReadSingleParameter,
|
|
94
|
-
# )
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
# class OrganizationClientService(MaleoClientService):
|
|
98
|
-
# def __init__(
|
|
99
|
-
# self,
|
|
100
|
-
# environment: Environment,
|
|
101
|
-
# key: str,
|
|
102
|
-
# url: str,
|
|
103
|
-
# operation_origin: OperationOriginSchema,
|
|
104
|
-
# logger: ClientLogger,
|
|
105
|
-
# credential_manager: CredentialManager,
|
|
106
|
-
# http_client_manager: HTTPClientManager,
|
|
107
|
-
# private_key: RsaKey,
|
|
108
|
-
# redis: Redis,
|
|
109
|
-
# redis_namespaces: RedisCacheNamespaces,
|
|
110
|
-
# service_context: ServiceContext,
|
|
111
|
-
# ):
|
|
112
|
-
# super().__init__(
|
|
113
|
-
# environment,
|
|
114
|
-
# key,
|
|
115
|
-
# url,
|
|
116
|
-
# operation_origin,
|
|
117
|
-
# logger,
|
|
118
|
-
# credential_manager,
|
|
119
|
-
# http_client_manager,
|
|
120
|
-
# private_key,
|
|
121
|
-
# redis,
|
|
122
|
-
# redis_namespaces,
|
|
123
|
-
# service_context,
|
|
124
|
-
# )
|
|
125
|
-
# # self._controllers = controllers
|
|
126
|
-
# self._namespace = self._redis_namespaces.create(
|
|
127
|
-
# self._key,
|
|
128
|
-
# ORGANIZATION_RESOURCE.aggregate(),
|
|
129
|
-
# origin=self._CACHE_ORIGIN,
|
|
130
|
-
# layer=self._CACHE_LAYER,
|
|
131
|
-
# )
|
|
132
|
-
# self._default_operation_context = OperationContextSchema(
|
|
133
|
-
# origin=self._operation_origin,
|
|
134
|
-
# layer=OperationLayerSchema(type=self._OPERATION_LAYER_TYPE, details=None),
|
|
135
|
-
# target=OperationTargetSchema(
|
|
136
|
-
# type=self._OPERATION_TARGET_TYPE, details=None
|
|
137
|
-
# ),
|
|
138
|
-
# )
|
|
139
|
-
|
|
140
|
-
# async def read_organizations(
|
|
141
|
-
# self,
|
|
142
|
-
# operation_id: UUID,
|
|
143
|
-
# request_context: RequestContext,
|
|
144
|
-
# authentication: Authentication,
|
|
145
|
-
# parameters: OrganizationReadMultipleParameter,
|
|
146
|
-
# authorization: Optional[Authorization] = None,
|
|
147
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
148
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
149
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
150
|
-
# ]:
|
|
151
|
-
# """Retrieve organizations from MaleoIdentity"""
|
|
152
|
-
# operation_action = ReadResourceOperationAction()
|
|
153
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
154
|
-
|
|
155
|
-
# # Get function identifier
|
|
156
|
-
# func = self.__class__
|
|
157
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
158
|
-
|
|
159
|
-
# # Define arguments being used in this function
|
|
160
|
-
# positional_arguments = []
|
|
161
|
-
# keyword_arguments = {
|
|
162
|
-
# "authentication": authentication.model_dump(
|
|
163
|
-
# mode="json",
|
|
164
|
-
# exclude={
|
|
165
|
-
# "credentials": {
|
|
166
|
-
# "token": {
|
|
167
|
-
# "payload": {
|
|
168
|
-
# "iat_dt",
|
|
169
|
-
# "iat",
|
|
170
|
-
# "exp_dt",
|
|
171
|
-
# "exp",
|
|
172
|
-
# }
|
|
173
|
-
# }
|
|
174
|
-
# }
|
|
175
|
-
# },
|
|
176
|
-
# ),
|
|
177
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
178
|
-
# }
|
|
179
|
-
|
|
180
|
-
# # Define full function string
|
|
181
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
182
|
-
|
|
183
|
-
# # Define full cache key
|
|
184
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
185
|
-
|
|
186
|
-
# if parameters.use_cache:
|
|
187
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
188
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
189
|
-
|
|
190
|
-
# # Check redis for data
|
|
191
|
-
# result_str = await self._redis.get(cache_key)
|
|
192
|
-
|
|
193
|
-
# if result_str is not None:
|
|
194
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
195
|
-
# result = ReadMultipleResourceOperationResult[
|
|
196
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
197
|
-
# ].model_validate(json.loads(result_str))
|
|
198
|
-
# ReadMultipleResourceOperationSchema[
|
|
199
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
200
|
-
# ](
|
|
201
|
-
# service_context=self._service_context,
|
|
202
|
-
# id=operation_id,
|
|
203
|
-
# context=operation_context,
|
|
204
|
-
# timestamp=OperationTimestamp(
|
|
205
|
-
# executed_at=executed_at,
|
|
206
|
-
# completed_at=completed_at,
|
|
207
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
208
|
-
# ),
|
|
209
|
-
# summary="Successfully retrieved multiple organizations from cache",
|
|
210
|
-
# request_context=request_context,
|
|
211
|
-
# authentication=authentication,
|
|
212
|
-
# action=operation_action,
|
|
213
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
214
|
-
# result=result,
|
|
215
|
-
# ).log(
|
|
216
|
-
# self._logger, level=LogLevel.INFO
|
|
217
|
-
# )
|
|
218
|
-
# return result
|
|
219
|
-
|
|
220
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
221
|
-
# async with self._http_client_manager.get() as http_client:
|
|
222
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/"
|
|
223
|
-
|
|
224
|
-
# # Parse parameters to query params
|
|
225
|
-
# params = OrganizationReadMultipleQueryParameter.model_validate(
|
|
226
|
-
# parameters.model_dump()
|
|
227
|
-
# ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
|
|
228
|
-
|
|
229
|
-
# # Create headers
|
|
230
|
-
# base_headers = {
|
|
231
|
-
# "Content-Type": "application/json",
|
|
232
|
-
# "X-Operation_Id": str(operation_id),
|
|
233
|
-
# }
|
|
234
|
-
# if headers is not None:
|
|
235
|
-
# headers = merge_dicts(base_headers, headers)
|
|
236
|
-
# else:
|
|
237
|
-
# headers = base_headers
|
|
238
|
-
|
|
239
|
-
# # Create auth
|
|
240
|
-
# token = None
|
|
241
|
-
# if authentication.credentials.token is not None:
|
|
242
|
-
# try:
|
|
243
|
-
# token = reencode(
|
|
244
|
-
# payload=authentication.credentials.token.payload,
|
|
245
|
-
# key=self._private_key,
|
|
246
|
-
# )
|
|
247
|
-
# except Exception:
|
|
248
|
-
# pass
|
|
249
|
-
|
|
250
|
-
# if (
|
|
251
|
-
# token is None
|
|
252
|
-
# and authorization is not None
|
|
253
|
-
# and authorization.scheme == "Bearer"
|
|
254
|
-
# ):
|
|
255
|
-
# token = authorization.credentials
|
|
256
|
-
|
|
257
|
-
# if token is None:
|
|
258
|
-
# token = self._credential_manager.token
|
|
259
|
-
|
|
260
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
261
|
-
|
|
262
|
-
# # Send request and wait for response
|
|
263
|
-
# response = await http_client.get(
|
|
264
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
265
|
-
# )
|
|
266
|
-
|
|
267
|
-
# if response.is_success:
|
|
268
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
269
|
-
# validated_response = MultipleDataResponseSchema[
|
|
270
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
271
|
-
# ].model_validate(response.json())
|
|
272
|
-
# data = DataPair[List[OrganizationDataSchema], None](
|
|
273
|
-
# old=validated_response.data,
|
|
274
|
-
# new=None,
|
|
275
|
-
# )
|
|
276
|
-
# result = ReadMultipleResourceOperationResult[
|
|
277
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
278
|
-
# ](
|
|
279
|
-
# data=data,
|
|
280
|
-
# pagination=validated_response.pagination,
|
|
281
|
-
# metadata=None,
|
|
282
|
-
# other=None,
|
|
283
|
-
# )
|
|
284
|
-
# ReadMultipleResourceOperationSchema[
|
|
285
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
286
|
-
# ](
|
|
287
|
-
# service_context=self._service_context,
|
|
288
|
-
# id=operation_id,
|
|
289
|
-
# context=operation_context,
|
|
290
|
-
# timestamp=OperationTimestamp(
|
|
291
|
-
# executed_at=executed_at,
|
|
292
|
-
# completed_at=completed_at,
|
|
293
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
294
|
-
# ),
|
|
295
|
-
# summary="Successfully retrieved multiple organizations from http request",
|
|
296
|
-
# request_context=request_context,
|
|
297
|
-
# authentication=authentication,
|
|
298
|
-
# action=operation_action,
|
|
299
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
300
|
-
# result=result,
|
|
301
|
-
# ).log(
|
|
302
|
-
# self._logger, level=LogLevel.INFO
|
|
303
|
-
# )
|
|
304
|
-
|
|
305
|
-
# if parameters.use_cache:
|
|
306
|
-
# await self._redis.set(
|
|
307
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
308
|
-
# )
|
|
309
|
-
|
|
310
|
-
# return result
|
|
311
|
-
|
|
312
|
-
# self._raise_resource_http_request_error(
|
|
313
|
-
# response=response,
|
|
314
|
-
# operation_id=operation_id,
|
|
315
|
-
# operation_context=operation_context,
|
|
316
|
-
# executed_at=executed_at,
|
|
317
|
-
# operation_action=operation_action,
|
|
318
|
-
# request_context=request_context,
|
|
319
|
-
# authentication=authentication,
|
|
320
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
321
|
-
# )
|
|
322
|
-
|
|
323
|
-
# async def read_organization(
|
|
324
|
-
# self,
|
|
325
|
-
# operation_id: UUID,
|
|
326
|
-
# request_context: RequestContext,
|
|
327
|
-
# authentication: Authentication,
|
|
328
|
-
# parameters: OrganizationReadSingleParameter,
|
|
329
|
-
# authorization: Optional[Authorization] = None,
|
|
330
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
331
|
-
# ) -> ReadSingleResourceOperationResult[OrganizationDataSchema, None]:
|
|
332
|
-
# """Retrieve organization from MaleoIdentity"""
|
|
333
|
-
# operation_action = ReadResourceOperationAction()
|
|
334
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
335
|
-
|
|
336
|
-
# # Get function identifier
|
|
337
|
-
# func = self.__class__
|
|
338
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
339
|
-
|
|
340
|
-
# # Define arguments being used in this function
|
|
341
|
-
# positional_arguments = []
|
|
342
|
-
# keyword_arguments = {
|
|
343
|
-
# "authentication": authentication.model_dump(
|
|
344
|
-
# mode="json",
|
|
345
|
-
# exclude={
|
|
346
|
-
# "credentials": {
|
|
347
|
-
# "token": {
|
|
348
|
-
# "payload": {
|
|
349
|
-
# "iat_dt",
|
|
350
|
-
# "iat",
|
|
351
|
-
# "exp_dt",
|
|
352
|
-
# "exp",
|
|
353
|
-
# }
|
|
354
|
-
# }
|
|
355
|
-
# }
|
|
356
|
-
# },
|
|
357
|
-
# ),
|
|
358
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
359
|
-
# }
|
|
360
|
-
|
|
361
|
-
# # Define full function string
|
|
362
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
363
|
-
|
|
364
|
-
# # Define full cache key
|
|
365
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
366
|
-
|
|
367
|
-
# if parameters.use_cache:
|
|
368
|
-
# # Cache operation
|
|
369
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
370
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
371
|
-
# # Check redis for data
|
|
372
|
-
# result_str = await self._redis.get(cache_key)
|
|
373
|
-
|
|
374
|
-
# if result_str is not None:
|
|
375
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
376
|
-
# result = ReadSingleResourceOperationResult[
|
|
377
|
-
# OrganizationDataSchema, None
|
|
378
|
-
# ].model_validate(json.loads(result_str))
|
|
379
|
-
# ReadSingleResourceOperationSchema[OrganizationDataSchema, None](
|
|
380
|
-
# service_context=self._service_context,
|
|
381
|
-
# id=operation_id,
|
|
382
|
-
# context=operation_context,
|
|
383
|
-
# timestamp=OperationTimestamp(
|
|
384
|
-
# executed_at=executed_at,
|
|
385
|
-
# completed_at=completed_at,
|
|
386
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
387
|
-
# ),
|
|
388
|
-
# summary="Successfully retrieved single organization from cache",
|
|
389
|
-
# request_context=request_context,
|
|
390
|
-
# authentication=authentication,
|
|
391
|
-
# action=operation_action,
|
|
392
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
393
|
-
# result=result,
|
|
394
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
395
|
-
# return result
|
|
396
|
-
|
|
397
|
-
# # HTTP Request
|
|
398
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
399
|
-
# async with self._http_client_manager.get() as client:
|
|
400
|
-
# # Define URL
|
|
401
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.identifier}/{parameters.value}"
|
|
402
|
-
|
|
403
|
-
# # Parse parameters to query params
|
|
404
|
-
# params = OrganizationReadSingleQueryParameter.model_validate(
|
|
405
|
-
# parameters.model_dump()
|
|
406
|
-
# ).model_dump(exclude_none=True)
|
|
407
|
-
|
|
408
|
-
# # Create headers
|
|
409
|
-
# base_headers = {
|
|
410
|
-
# "Content-Type": "application/json",
|
|
411
|
-
# "X-Operation_Id": str(operation_id),
|
|
412
|
-
# }
|
|
413
|
-
# if headers is not None:
|
|
414
|
-
# headers = merge_dicts(base_headers, headers)
|
|
415
|
-
# else:
|
|
416
|
-
# headers = base_headers
|
|
417
|
-
|
|
418
|
-
# # Create auth
|
|
419
|
-
# token = None
|
|
420
|
-
# if authentication.credentials.token is not None:
|
|
421
|
-
# try:
|
|
422
|
-
# token = reencode(
|
|
423
|
-
# payload=authentication.credentials.token.payload,
|
|
424
|
-
# key=self._private_key,
|
|
425
|
-
# )
|
|
426
|
-
# except Exception:
|
|
427
|
-
# pass
|
|
428
|
-
|
|
429
|
-
# if (
|
|
430
|
-
# token is None
|
|
431
|
-
# and authorization is not None
|
|
432
|
-
# and authorization.scheme == "Bearer"
|
|
433
|
-
# ):
|
|
434
|
-
# token = authorization.credentials
|
|
435
|
-
|
|
436
|
-
# if token is None:
|
|
437
|
-
# token = self._credential_manager.token
|
|
438
|
-
|
|
439
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
440
|
-
|
|
441
|
-
# # Send request and wait for response
|
|
442
|
-
# response = await client.get(
|
|
443
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
444
|
-
# )
|
|
445
|
-
|
|
446
|
-
# if response.is_success:
|
|
447
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
448
|
-
# validated_response = SingleDataResponseSchema[
|
|
449
|
-
# OrganizationDataSchema, None
|
|
450
|
-
# ].model_validate(response.json())
|
|
451
|
-
# data = DataPair[OrganizationDataSchema, None](
|
|
452
|
-
# old=validated_response.data,
|
|
453
|
-
# new=None,
|
|
454
|
-
# )
|
|
455
|
-
# result = ReadSingleResourceOperationResult[
|
|
456
|
-
# OrganizationDataSchema, None
|
|
457
|
-
# ](
|
|
458
|
-
# data=data,
|
|
459
|
-
# pagination=validated_response.pagination,
|
|
460
|
-
# metadata=None,
|
|
461
|
-
# other=None,
|
|
462
|
-
# )
|
|
463
|
-
# ReadSingleResourceOperationSchema[OrganizationDataSchema, None](
|
|
464
|
-
# service_context=self._service_context,
|
|
465
|
-
# id=operation_id,
|
|
466
|
-
# context=operation_context,
|
|
467
|
-
# timestamp=OperationTimestamp(
|
|
468
|
-
# executed_at=executed_at,
|
|
469
|
-
# completed_at=completed_at,
|
|
470
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
471
|
-
# ),
|
|
472
|
-
# summary="Successfully retrieved single organization from http request",
|
|
473
|
-
# request_context=request_context,
|
|
474
|
-
# authentication=authentication,
|
|
475
|
-
# action=operation_action,
|
|
476
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
477
|
-
# result=result,
|
|
478
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
479
|
-
|
|
480
|
-
# if parameters.use_cache:
|
|
481
|
-
# await self._redis.set(
|
|
482
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
483
|
-
# )
|
|
484
|
-
|
|
485
|
-
# return result
|
|
486
|
-
|
|
487
|
-
# self._raise_resource_http_request_error(
|
|
488
|
-
# response=response,
|
|
489
|
-
# operation_id=operation_id,
|
|
490
|
-
# operation_context=operation_context,
|
|
491
|
-
# executed_at=executed_at,
|
|
492
|
-
# operation_action=operation_action,
|
|
493
|
-
# request_context=request_context,
|
|
494
|
-
# authentication=authentication,
|
|
495
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
496
|
-
# )
|
|
497
|
-
|
|
498
|
-
# async def read_organization_children(
|
|
499
|
-
# self,
|
|
500
|
-
# operation_id: UUID,
|
|
501
|
-
# request_context: RequestContext,
|
|
502
|
-
# authentication: Authentication,
|
|
503
|
-
# parameters: OrganizationReadMultipleChildrenParameter,
|
|
504
|
-
# authorization: Optional[Authorization] = None,
|
|
505
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
506
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
507
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
508
|
-
# ]:
|
|
509
|
-
# """Retrieve organizations from MaleoIdentity"""
|
|
510
|
-
# operation_action = ReadResourceOperationAction()
|
|
511
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
512
|
-
|
|
513
|
-
# # Get function identifier
|
|
514
|
-
# func = self.__class__
|
|
515
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
516
|
-
|
|
517
|
-
# # Define arguments being used in this function
|
|
518
|
-
# positional_arguments = []
|
|
519
|
-
# keyword_arguments = {
|
|
520
|
-
# "authentication": authentication.model_dump(
|
|
521
|
-
# mode="json",
|
|
522
|
-
# exclude={
|
|
523
|
-
# "credentials": {
|
|
524
|
-
# "token": {
|
|
525
|
-
# "payload": {
|
|
526
|
-
# "iat_dt",
|
|
527
|
-
# "iat",
|
|
528
|
-
# "exp_dt",
|
|
529
|
-
# "exp",
|
|
530
|
-
# }
|
|
531
|
-
# }
|
|
532
|
-
# }
|
|
533
|
-
# },
|
|
534
|
-
# ),
|
|
535
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
536
|
-
# }
|
|
537
|
-
|
|
538
|
-
# # Define full function string
|
|
539
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
540
|
-
|
|
541
|
-
# # Define full cache key
|
|
542
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
543
|
-
|
|
544
|
-
# if parameters.use_cache:
|
|
545
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
546
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
547
|
-
|
|
548
|
-
# # Check redis for data
|
|
549
|
-
# result_str = await self._redis.get(cache_key)
|
|
550
|
-
|
|
551
|
-
# if result_str is not None:
|
|
552
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
553
|
-
# result = ReadMultipleResourceOperationResult[
|
|
554
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
555
|
-
# ].model_validate(json.loads(result_str))
|
|
556
|
-
# ReadMultipleResourceOperationSchema[
|
|
557
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
558
|
-
# ](
|
|
559
|
-
# service_context=self._service_context,
|
|
560
|
-
# id=operation_id,
|
|
561
|
-
# context=operation_context,
|
|
562
|
-
# timestamp=OperationTimestamp(
|
|
563
|
-
# executed_at=executed_at,
|
|
564
|
-
# completed_at=completed_at,
|
|
565
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
566
|
-
# ),
|
|
567
|
-
# summary="Successfully retrieved multiple organizations from cache",
|
|
568
|
-
# request_context=request_context,
|
|
569
|
-
# authentication=authentication,
|
|
570
|
-
# action=operation_action,
|
|
571
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
572
|
-
# result=result,
|
|
573
|
-
# ).log(
|
|
574
|
-
# self._logger, level=LogLevel.INFO
|
|
575
|
-
# )
|
|
576
|
-
# return result
|
|
577
|
-
|
|
578
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
579
|
-
# async with self._http_client_manager.get() as http_client:
|
|
580
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/children"
|
|
581
|
-
|
|
582
|
-
# # Parse parameters to query params
|
|
583
|
-
# params = OrganizationReadMultipleChildrenQueryParameter.model_validate(
|
|
584
|
-
# parameters.model_dump()
|
|
585
|
-
# ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
|
|
586
|
-
|
|
587
|
-
# # Create headers
|
|
588
|
-
# base_headers = {
|
|
589
|
-
# "Content-Type": "application/json",
|
|
590
|
-
# "X-Operation_Id": str(operation_id),
|
|
591
|
-
# }
|
|
592
|
-
# if headers is not None:
|
|
593
|
-
# headers = merge_dicts(base_headers, headers)
|
|
594
|
-
# else:
|
|
595
|
-
# headers = base_headers
|
|
596
|
-
|
|
597
|
-
# # Create auth
|
|
598
|
-
# token = None
|
|
599
|
-
# if authentication.credentials.token is not None:
|
|
600
|
-
# try:
|
|
601
|
-
# token = reencode(
|
|
602
|
-
# payload=authentication.credentials.token.payload,
|
|
603
|
-
# key=self._private_key,
|
|
604
|
-
# )
|
|
605
|
-
# except Exception:
|
|
606
|
-
# pass
|
|
607
|
-
|
|
608
|
-
# if (
|
|
609
|
-
# token is None
|
|
610
|
-
# and authorization is not None
|
|
611
|
-
# and authorization.scheme == "Bearer"
|
|
612
|
-
# ):
|
|
613
|
-
# token = authorization.credentials
|
|
614
|
-
|
|
615
|
-
# if token is None:
|
|
616
|
-
# token = self._credential_manager.token
|
|
617
|
-
|
|
618
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
619
|
-
|
|
620
|
-
# # Send request and wait for response
|
|
621
|
-
# response = await http_client.get(
|
|
622
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
623
|
-
# )
|
|
624
|
-
|
|
625
|
-
# if response.is_success:
|
|
626
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
627
|
-
# validated_response = MultipleDataResponseSchema[
|
|
628
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
629
|
-
# ].model_validate(response.json())
|
|
630
|
-
# data = DataPair[List[OrganizationDataSchema], None](
|
|
631
|
-
# old=validated_response.data,
|
|
632
|
-
# new=None,
|
|
633
|
-
# )
|
|
634
|
-
# result = ReadMultipleResourceOperationResult[
|
|
635
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
636
|
-
# ](
|
|
637
|
-
# data=data,
|
|
638
|
-
# pagination=validated_response.pagination,
|
|
639
|
-
# metadata=None,
|
|
640
|
-
# other=None,
|
|
641
|
-
# )
|
|
642
|
-
# ReadMultipleResourceOperationSchema[
|
|
643
|
-
# OrganizationDataSchema, StrictPagination, None
|
|
644
|
-
# ](
|
|
645
|
-
# service_context=self._service_context,
|
|
646
|
-
# id=operation_id,
|
|
647
|
-
# context=operation_context,
|
|
648
|
-
# timestamp=OperationTimestamp(
|
|
649
|
-
# executed_at=executed_at,
|
|
650
|
-
# completed_at=completed_at,
|
|
651
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
652
|
-
# ),
|
|
653
|
-
# summary="Successfully retrieved multiple organizations from http request",
|
|
654
|
-
# request_context=request_context,
|
|
655
|
-
# authentication=authentication,
|
|
656
|
-
# action=operation_action,
|
|
657
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
658
|
-
# result=result,
|
|
659
|
-
# ).log(
|
|
660
|
-
# self._logger, level=LogLevel.INFO
|
|
661
|
-
# )
|
|
662
|
-
|
|
663
|
-
# if parameters.use_cache:
|
|
664
|
-
# await self._redis.set(
|
|
665
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
666
|
-
# )
|
|
667
|
-
|
|
668
|
-
# return result
|
|
669
|
-
|
|
670
|
-
# self._raise_resource_http_request_error(
|
|
671
|
-
# response=response,
|
|
672
|
-
# operation_id=operation_id,
|
|
673
|
-
# operation_context=operation_context,
|
|
674
|
-
# executed_at=executed_at,
|
|
675
|
-
# operation_action=operation_action,
|
|
676
|
-
# request_context=request_context,
|
|
677
|
-
# authentication=authentication,
|
|
678
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
679
|
-
# )
|
|
680
|
-
|
|
681
|
-
# async def read_organization_registration_code(
|
|
682
|
-
# self,
|
|
683
|
-
# operation_id: UUID,
|
|
684
|
-
# request_context: RequestContext,
|
|
685
|
-
# authentication: Authentication,
|
|
686
|
-
# parameters: OrganizationRegistrationCodeReadSingleParameter,
|
|
687
|
-
# authorization: Optional[Authorization] = None,
|
|
688
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
689
|
-
# ) -> ReadSingleResourceOperationResult[
|
|
690
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
691
|
-
# ]:
|
|
692
|
-
# """Retrieve organization registration code from MaleoIdentity"""
|
|
693
|
-
# operation_action = ReadResourceOperationAction()
|
|
694
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
695
|
-
|
|
696
|
-
# # Get function identifier
|
|
697
|
-
# func = self.__class__
|
|
698
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
699
|
-
|
|
700
|
-
# # Define arguments being used in this function
|
|
701
|
-
# positional_arguments = []
|
|
702
|
-
# keyword_arguments = {
|
|
703
|
-
# "authentication": authentication.model_dump(
|
|
704
|
-
# mode="json",
|
|
705
|
-
# exclude={
|
|
706
|
-
# "credentials": {
|
|
707
|
-
# "token": {
|
|
708
|
-
# "payload": {
|
|
709
|
-
# "iat_dt",
|
|
710
|
-
# "iat",
|
|
711
|
-
# "exp_dt",
|
|
712
|
-
# "exp",
|
|
713
|
-
# }
|
|
714
|
-
# }
|
|
715
|
-
# }
|
|
716
|
-
# },
|
|
717
|
-
# ),
|
|
718
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
719
|
-
# }
|
|
720
|
-
|
|
721
|
-
# # Define full function string
|
|
722
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
723
|
-
|
|
724
|
-
# # Define full cache key
|
|
725
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
726
|
-
|
|
727
|
-
# if parameters.use_cache:
|
|
728
|
-
# # Cache operation
|
|
729
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
730
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
731
|
-
# # Check redis for data
|
|
732
|
-
# result_str = await self._redis.get(cache_key)
|
|
733
|
-
|
|
734
|
-
# if result_str is not None:
|
|
735
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
736
|
-
# result = ReadSingleResourceOperationResult[
|
|
737
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
738
|
-
# ].model_validate(json.loads(result_str))
|
|
739
|
-
# ReadSingleResourceOperationSchema[
|
|
740
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
741
|
-
# ](
|
|
742
|
-
# service_context=self._service_context,
|
|
743
|
-
# id=operation_id,
|
|
744
|
-
# context=operation_context,
|
|
745
|
-
# timestamp=OperationTimestamp(
|
|
746
|
-
# executed_at=executed_at,
|
|
747
|
-
# completed_at=completed_at,
|
|
748
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
749
|
-
# ),
|
|
750
|
-
# summary="Successfully retrieved single organization registration code from cache",
|
|
751
|
-
# request_context=request_context,
|
|
752
|
-
# authentication=authentication,
|
|
753
|
-
# action=operation_action,
|
|
754
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
755
|
-
# result=result,
|
|
756
|
-
# ).log(
|
|
757
|
-
# self._logger, level=LogLevel.INFO
|
|
758
|
-
# )
|
|
759
|
-
# return result
|
|
760
|
-
|
|
761
|
-
# # HTTP Request
|
|
762
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
763
|
-
# async with self._http_client_manager.get() as client:
|
|
764
|
-
# # Define URL
|
|
765
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.identifier}/{parameters.value}/registration-code"
|
|
766
|
-
|
|
767
|
-
# # Parse parameters to query params
|
|
768
|
-
# params = ReadSingleQueryParameterSchema.model_validate(
|
|
769
|
-
# parameters.model_dump()
|
|
770
|
-
# ).model_dump(exclude_none=True)
|
|
771
|
-
|
|
772
|
-
# # Create headers
|
|
773
|
-
# base_headers = {
|
|
774
|
-
# "Content-Type": "application/json",
|
|
775
|
-
# "X-Operation_Id": str(operation_id),
|
|
776
|
-
# }
|
|
777
|
-
# if headers is not None:
|
|
778
|
-
# headers = merge_dicts(base_headers, headers)
|
|
779
|
-
# else:
|
|
780
|
-
# headers = base_headers
|
|
781
|
-
|
|
782
|
-
# # Create auth
|
|
783
|
-
# token = None
|
|
784
|
-
# if authentication.credentials.token is not None:
|
|
785
|
-
# try:
|
|
786
|
-
# token = reencode(
|
|
787
|
-
# payload=authentication.credentials.token.payload,
|
|
788
|
-
# key=self._private_key,
|
|
789
|
-
# )
|
|
790
|
-
# except Exception:
|
|
791
|
-
# pass
|
|
792
|
-
|
|
793
|
-
# if (
|
|
794
|
-
# token is None
|
|
795
|
-
# and authorization is not None
|
|
796
|
-
# and authorization.scheme == "Bearer"
|
|
797
|
-
# ):
|
|
798
|
-
# token = authorization.credentials
|
|
799
|
-
|
|
800
|
-
# if token is None:
|
|
801
|
-
# token = self._credential_manager.token
|
|
802
|
-
|
|
803
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
804
|
-
|
|
805
|
-
# # Send request and wait for response
|
|
806
|
-
# response = await client.get(
|
|
807
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
808
|
-
# )
|
|
809
|
-
|
|
810
|
-
# if response.is_success:
|
|
811
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
812
|
-
# validated_response = SingleDataResponseSchema[
|
|
813
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
814
|
-
# ].model_validate(response.json())
|
|
815
|
-
# data = DataPair[OrganizationRegistrationCodeDataSchema, None](
|
|
816
|
-
# old=validated_response.data,
|
|
817
|
-
# new=None,
|
|
818
|
-
# )
|
|
819
|
-
# result = ReadSingleResourceOperationResult[
|
|
820
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
821
|
-
# ](
|
|
822
|
-
# data=data,
|
|
823
|
-
# pagination=validated_response.pagination,
|
|
824
|
-
# metadata=None,
|
|
825
|
-
# other=None,
|
|
826
|
-
# )
|
|
827
|
-
# ReadSingleResourceOperationSchema[
|
|
828
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
829
|
-
# ](
|
|
830
|
-
# service_context=self._service_context,
|
|
831
|
-
# id=operation_id,
|
|
832
|
-
# context=operation_context,
|
|
833
|
-
# timestamp=OperationTimestamp(
|
|
834
|
-
# executed_at=executed_at,
|
|
835
|
-
# completed_at=completed_at,
|
|
836
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
837
|
-
# ),
|
|
838
|
-
# summary="Successfully retrieved single organization registration code from http request",
|
|
839
|
-
# request_context=request_context,
|
|
840
|
-
# authentication=authentication,
|
|
841
|
-
# action=operation_action,
|
|
842
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
843
|
-
# result=result,
|
|
844
|
-
# ).log(
|
|
845
|
-
# self._logger, level=LogLevel.INFO
|
|
846
|
-
# )
|
|
847
|
-
|
|
848
|
-
# if parameters.use_cache:
|
|
849
|
-
# await self._redis.set(
|
|
850
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
851
|
-
# )
|
|
852
|
-
|
|
853
|
-
# return result
|
|
854
|
-
|
|
855
|
-
# self._raise_resource_http_request_error(
|
|
856
|
-
# response=response,
|
|
857
|
-
# operation_id=operation_id,
|
|
858
|
-
# operation_context=operation_context,
|
|
859
|
-
# executed_at=executed_at,
|
|
860
|
-
# operation_action=operation_action,
|
|
861
|
-
# request_context=request_context,
|
|
862
|
-
# authentication=authentication,
|
|
863
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
864
|
-
# )
|
|
865
|
-
|
|
866
|
-
# async def read_organization_roles(
|
|
867
|
-
# self,
|
|
868
|
-
# operation_id: UUID,
|
|
869
|
-
# request_context: RequestContext,
|
|
870
|
-
# authentication: Authentication,
|
|
871
|
-
# parameters: OrganizationRoleReadMultipleFromOrganizationParameter,
|
|
872
|
-
# authorization: Optional[Authorization] = None,
|
|
873
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
874
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
875
|
-
# OrganizationRoleDataSchema, StrictPagination, None
|
|
876
|
-
# ]:
|
|
877
|
-
# """Retrieve organization roles from MaleoIdentity"""
|
|
878
|
-
# operation_action = ReadResourceOperationAction()
|
|
879
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
880
|
-
|
|
881
|
-
# # Get function identifier
|
|
882
|
-
# func = self.__class__
|
|
883
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
884
|
-
|
|
885
|
-
# # Define arguments being used in this function
|
|
886
|
-
# positional_arguments = []
|
|
887
|
-
# keyword_arguments = {
|
|
888
|
-
# "authentication": authentication.model_dump(
|
|
889
|
-
# mode="json",
|
|
890
|
-
# exclude={
|
|
891
|
-
# "credentials": {
|
|
892
|
-
# "token": {
|
|
893
|
-
# "payload": {
|
|
894
|
-
# "iat_dt",
|
|
895
|
-
# "iat",
|
|
896
|
-
# "exp_dt",
|
|
897
|
-
# "exp",
|
|
898
|
-
# }
|
|
899
|
-
# }
|
|
900
|
-
# }
|
|
901
|
-
# },
|
|
902
|
-
# ),
|
|
903
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
904
|
-
# }
|
|
905
|
-
|
|
906
|
-
# # Define full function string
|
|
907
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
908
|
-
|
|
909
|
-
# # Define full cache key
|
|
910
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
911
|
-
|
|
912
|
-
# if parameters.use_cache:
|
|
913
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
914
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
915
|
-
|
|
916
|
-
# # Check redis for data
|
|
917
|
-
# result_str = await self._redis.get(cache_key)
|
|
918
|
-
|
|
919
|
-
# if result_str is not None:
|
|
920
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
921
|
-
# result = ReadMultipleResourceOperationResult[
|
|
922
|
-
# OrganizationRoleDataSchema, StrictPagination, None
|
|
923
|
-
# ].model_validate(json.loads(result_str))
|
|
924
|
-
# ReadMultipleResourceOperationSchema[
|
|
925
|
-
# OrganizationRoleDataSchema, StrictPagination, None
|
|
926
|
-
# ](
|
|
927
|
-
# service_context=self._service_context,
|
|
928
|
-
# id=operation_id,
|
|
929
|
-
# context=operation_context,
|
|
930
|
-
# timestamp=OperationTimestamp(
|
|
931
|
-
# executed_at=executed_at,
|
|
932
|
-
# completed_at=completed_at,
|
|
933
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
934
|
-
# ),
|
|
935
|
-
# summary="Successfully retrieved multiple organization roles from cache",
|
|
936
|
-
# request_context=request_context,
|
|
937
|
-
# authentication=authentication,
|
|
938
|
-
# action=operation_action,
|
|
939
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
940
|
-
# result=result,
|
|
941
|
-
# ).log(
|
|
942
|
-
# self._logger, level=LogLevel.INFO
|
|
943
|
-
# )
|
|
944
|
-
# return result
|
|
945
|
-
|
|
946
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
947
|
-
# async with self._http_client_manager.get() as http_client:
|
|
948
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/roles/"
|
|
949
|
-
|
|
950
|
-
# # Parse parameters to query params
|
|
951
|
-
# params = OrganizationRoleReadMultipleFromOrganizationQueryParameter.model_validate(
|
|
952
|
-
# parameters.model_dump()
|
|
953
|
-
# ).model_dump(
|
|
954
|
-
# exclude={"sort_columns", "date_filters"}, exclude_none=True
|
|
955
|
-
# )
|
|
956
|
-
|
|
957
|
-
# # Create headers
|
|
958
|
-
# base_headers = {
|
|
959
|
-
# "Content-Type": "application/json",
|
|
960
|
-
# "X-Operation_Id": str(operation_id),
|
|
961
|
-
# }
|
|
962
|
-
# if headers is not None:
|
|
963
|
-
# headers = merge_dicts(base_headers, headers)
|
|
964
|
-
# else:
|
|
965
|
-
# headers = base_headers
|
|
966
|
-
|
|
967
|
-
# # Create auth
|
|
968
|
-
# token = None
|
|
969
|
-
# if authentication.credentials.token is not None:
|
|
970
|
-
# try:
|
|
971
|
-
# token = reencode(
|
|
972
|
-
# payload=authentication.credentials.token.payload,
|
|
973
|
-
# key=self._private_key,
|
|
974
|
-
# )
|
|
975
|
-
# except Exception:
|
|
976
|
-
# pass
|
|
977
|
-
|
|
978
|
-
# if (
|
|
979
|
-
# token is None
|
|
980
|
-
# and authorization is not None
|
|
981
|
-
# and authorization.scheme == "Bearer"
|
|
982
|
-
# ):
|
|
983
|
-
# token = authorization.credentials
|
|
984
|
-
|
|
985
|
-
# if token is None:
|
|
986
|
-
# token = self._credential_manager.token
|
|
987
|
-
|
|
988
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
989
|
-
|
|
990
|
-
# # Send request and wait for response
|
|
991
|
-
# response = await http_client.get(
|
|
992
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
993
|
-
# )
|
|
994
|
-
|
|
995
|
-
# if response.is_success:
|
|
996
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
997
|
-
# validated_response = MultipleDataResponseSchema[
|
|
998
|
-
# OrganizationRoleDataSchema, StrictPagination, None
|
|
999
|
-
# ].model_validate(response.json())
|
|
1000
|
-
# data = DataPair[List[OrganizationRoleDataSchema], None](
|
|
1001
|
-
# old=validated_response.data,
|
|
1002
|
-
# new=None,
|
|
1003
|
-
# )
|
|
1004
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1005
|
-
# OrganizationRoleDataSchema, StrictPagination, None
|
|
1006
|
-
# ](
|
|
1007
|
-
# data=data,
|
|
1008
|
-
# pagination=validated_response.pagination,
|
|
1009
|
-
# metadata=None,
|
|
1010
|
-
# other=None,
|
|
1011
|
-
# )
|
|
1012
|
-
# ReadMultipleResourceOperationSchema[
|
|
1013
|
-
# OrganizationRoleDataSchema, StrictPagination, None
|
|
1014
|
-
# ](
|
|
1015
|
-
# service_context=self._service_context,
|
|
1016
|
-
# id=operation_id,
|
|
1017
|
-
# context=operation_context,
|
|
1018
|
-
# timestamp=OperationTimestamp(
|
|
1019
|
-
# executed_at=executed_at,
|
|
1020
|
-
# completed_at=completed_at,
|
|
1021
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1022
|
-
# ),
|
|
1023
|
-
# summary="Successfully retrieved multiple organization roles from http request",
|
|
1024
|
-
# request_context=request_context,
|
|
1025
|
-
# authentication=authentication,
|
|
1026
|
-
# action=operation_action,
|
|
1027
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1028
|
-
# result=result,
|
|
1029
|
-
# ).log(
|
|
1030
|
-
# self._logger, level=LogLevel.INFO
|
|
1031
|
-
# )
|
|
1032
|
-
|
|
1033
|
-
# if parameters.use_cache:
|
|
1034
|
-
# await self._redis.set(
|
|
1035
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1036
|
-
# )
|
|
1037
|
-
|
|
1038
|
-
# return result
|
|
1039
|
-
|
|
1040
|
-
# self._raise_resource_http_request_error(
|
|
1041
|
-
# response=response,
|
|
1042
|
-
# operation_id=operation_id,
|
|
1043
|
-
# operation_context=operation_context,
|
|
1044
|
-
# executed_at=executed_at,
|
|
1045
|
-
# operation_action=operation_action,
|
|
1046
|
-
# request_context=request_context,
|
|
1047
|
-
# authentication=authentication,
|
|
1048
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1049
|
-
# )
|
|
1050
|
-
|
|
1051
|
-
# async def read_organization_role(
|
|
1052
|
-
# self,
|
|
1053
|
-
# operation_id: UUID,
|
|
1054
|
-
# request_context: RequestContext,
|
|
1055
|
-
# authentication: Authentication,
|
|
1056
|
-
# parameters: OrganizationRoleReadSingleParameter,
|
|
1057
|
-
# authorization: Optional[Authorization] = None,
|
|
1058
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1059
|
-
# ) -> ReadSingleResourceOperationResult[OrganizationRoleDataSchema, None]:
|
|
1060
|
-
# """Retrieve organization role from MaleoIdentity"""
|
|
1061
|
-
# operation_action = ReadResourceOperationAction()
|
|
1062
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1063
|
-
|
|
1064
|
-
# # Get function identifier
|
|
1065
|
-
# func = self.__class__
|
|
1066
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1067
|
-
|
|
1068
|
-
# # Define arguments being used in this function
|
|
1069
|
-
# positional_arguments = []
|
|
1070
|
-
# keyword_arguments = {
|
|
1071
|
-
# "authentication": authentication.model_dump(
|
|
1072
|
-
# mode="json",
|
|
1073
|
-
# exclude={
|
|
1074
|
-
# "credentials": {
|
|
1075
|
-
# "token": {
|
|
1076
|
-
# "payload": {
|
|
1077
|
-
# "iat_dt",
|
|
1078
|
-
# "iat",
|
|
1079
|
-
# "exp_dt",
|
|
1080
|
-
# "exp",
|
|
1081
|
-
# }
|
|
1082
|
-
# }
|
|
1083
|
-
# }
|
|
1084
|
-
# },
|
|
1085
|
-
# ),
|
|
1086
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1087
|
-
# }
|
|
1088
|
-
|
|
1089
|
-
# # Define full function string
|
|
1090
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1091
|
-
|
|
1092
|
-
# # Define full cache key
|
|
1093
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1094
|
-
|
|
1095
|
-
# if parameters.use_cache:
|
|
1096
|
-
# # Cache operation
|
|
1097
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1098
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1099
|
-
# # Check redis for data
|
|
1100
|
-
# result_str = await self._redis.get(cache_key)
|
|
1101
|
-
|
|
1102
|
-
# if result_str is not None:
|
|
1103
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1104
|
-
# result = ReadSingleResourceOperationResult[
|
|
1105
|
-
# OrganizationRoleDataSchema, None
|
|
1106
|
-
# ].model_validate(json.loads(result_str))
|
|
1107
|
-
# ReadSingleResourceOperationSchema[OrganizationRoleDataSchema, None](
|
|
1108
|
-
# service_context=self._service_context,
|
|
1109
|
-
# id=operation_id,
|
|
1110
|
-
# context=operation_context,
|
|
1111
|
-
# timestamp=OperationTimestamp(
|
|
1112
|
-
# executed_at=executed_at,
|
|
1113
|
-
# completed_at=completed_at,
|
|
1114
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1115
|
-
# ),
|
|
1116
|
-
# summary="Successfully retrieved single organization role from cache",
|
|
1117
|
-
# request_context=request_context,
|
|
1118
|
-
# authentication=authentication,
|
|
1119
|
-
# action=operation_action,
|
|
1120
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1121
|
-
# result=result,
|
|
1122
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1123
|
-
# return result
|
|
1124
|
-
|
|
1125
|
-
# # HTTP Request
|
|
1126
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1127
|
-
# async with self._http_client_manager.get() as client:
|
|
1128
|
-
# # Define URL
|
|
1129
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/roles/{parameters.key}"
|
|
1130
|
-
|
|
1131
|
-
# # Parse parameters to query params
|
|
1132
|
-
# params = OrganizationRoleReadSingleQueryParameter.model_validate(
|
|
1133
|
-
# parameters.model_dump()
|
|
1134
|
-
# ).model_dump(exclude_none=True)
|
|
1135
|
-
|
|
1136
|
-
# # Create headers
|
|
1137
|
-
# base_headers = {
|
|
1138
|
-
# "Content-Type": "application/json",
|
|
1139
|
-
# "X-Operation_Id": str(operation_id),
|
|
1140
|
-
# }
|
|
1141
|
-
# if headers is not None:
|
|
1142
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1143
|
-
# else:
|
|
1144
|
-
# headers = base_headers
|
|
1145
|
-
|
|
1146
|
-
# # Create auth
|
|
1147
|
-
# token = None
|
|
1148
|
-
# if authentication.credentials.token is not None:
|
|
1149
|
-
# try:
|
|
1150
|
-
# token = reencode(
|
|
1151
|
-
# payload=authentication.credentials.token.payload,
|
|
1152
|
-
# key=self._private_key,
|
|
1153
|
-
# )
|
|
1154
|
-
# except Exception:
|
|
1155
|
-
# pass
|
|
1156
|
-
|
|
1157
|
-
# if (
|
|
1158
|
-
# token is None
|
|
1159
|
-
# and authorization is not None
|
|
1160
|
-
# and authorization.scheme == "Bearer"
|
|
1161
|
-
# ):
|
|
1162
|
-
# token = authorization.credentials
|
|
1163
|
-
|
|
1164
|
-
# if token is None:
|
|
1165
|
-
# token = self._credential_manager.token
|
|
1166
|
-
|
|
1167
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1168
|
-
|
|
1169
|
-
# # Send request and wait for response
|
|
1170
|
-
# response = await client.get(
|
|
1171
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1172
|
-
# )
|
|
1173
|
-
|
|
1174
|
-
# if response.is_success:
|
|
1175
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1176
|
-
# validated_response = SingleDataResponseSchema[
|
|
1177
|
-
# OrganizationRoleDataSchema, None
|
|
1178
|
-
# ].model_validate(response.json())
|
|
1179
|
-
# data = DataPair[OrganizationRoleDataSchema, None](
|
|
1180
|
-
# old=validated_response.data,
|
|
1181
|
-
# new=None,
|
|
1182
|
-
# )
|
|
1183
|
-
# result = ReadSingleResourceOperationResult[
|
|
1184
|
-
# OrganizationRoleDataSchema, None
|
|
1185
|
-
# ](
|
|
1186
|
-
# data=data,
|
|
1187
|
-
# pagination=validated_response.pagination,
|
|
1188
|
-
# metadata=None,
|
|
1189
|
-
# other=None,
|
|
1190
|
-
# )
|
|
1191
|
-
# ReadSingleResourceOperationSchema[OrganizationRoleDataSchema, None](
|
|
1192
|
-
# service_context=self._service_context,
|
|
1193
|
-
# id=operation_id,
|
|
1194
|
-
# context=operation_context,
|
|
1195
|
-
# timestamp=OperationTimestamp(
|
|
1196
|
-
# executed_at=executed_at,
|
|
1197
|
-
# completed_at=completed_at,
|
|
1198
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1199
|
-
# ),
|
|
1200
|
-
# summary="Successfully retrieved single organization role from http request",
|
|
1201
|
-
# request_context=request_context,
|
|
1202
|
-
# authentication=authentication,
|
|
1203
|
-
# action=operation_action,
|
|
1204
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1205
|
-
# result=result,
|
|
1206
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1207
|
-
|
|
1208
|
-
# if parameters.use_cache:
|
|
1209
|
-
# await self._redis.set(
|
|
1210
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1211
|
-
# )
|
|
1212
|
-
|
|
1213
|
-
# return result
|
|
1214
|
-
|
|
1215
|
-
# self._raise_resource_http_request_error(
|
|
1216
|
-
# response=response,
|
|
1217
|
-
# operation_id=operation_id,
|
|
1218
|
-
# operation_context=operation_context,
|
|
1219
|
-
# executed_at=executed_at,
|
|
1220
|
-
# operation_action=operation_action,
|
|
1221
|
-
# request_context=request_context,
|
|
1222
|
-
# authentication=authentication,
|
|
1223
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1224
|
-
# )
|
|
1225
|
-
|
|
1226
|
-
# async def read_organization_users(
|
|
1227
|
-
# self,
|
|
1228
|
-
# operation_id: UUID,
|
|
1229
|
-
# request_context: RequestContext,
|
|
1230
|
-
# authentication: Authentication,
|
|
1231
|
-
# parameters: UserOrganizationReadMultipleFromOrganizationParameter,
|
|
1232
|
-
# authorization: Optional[Authorization] = None,
|
|
1233
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1234
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
1235
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
1236
|
-
# ]:
|
|
1237
|
-
# """Retrieve organization users from MaleoIdentity"""
|
|
1238
|
-
# operation_action = ReadResourceOperationAction()
|
|
1239
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1240
|
-
|
|
1241
|
-
# # Get function identifier
|
|
1242
|
-
# func = self.__class__
|
|
1243
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1244
|
-
|
|
1245
|
-
# # Define arguments being used in this function
|
|
1246
|
-
# positional_arguments = []
|
|
1247
|
-
# keyword_arguments = {
|
|
1248
|
-
# "authentication": authentication.model_dump(
|
|
1249
|
-
# mode="json",
|
|
1250
|
-
# exclude={
|
|
1251
|
-
# "credentials": {
|
|
1252
|
-
# "token": {
|
|
1253
|
-
# "payload": {
|
|
1254
|
-
# "iat_dt",
|
|
1255
|
-
# "iat",
|
|
1256
|
-
# "exp_dt",
|
|
1257
|
-
# "exp",
|
|
1258
|
-
# }
|
|
1259
|
-
# }
|
|
1260
|
-
# }
|
|
1261
|
-
# },
|
|
1262
|
-
# ),
|
|
1263
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1264
|
-
# }
|
|
1265
|
-
|
|
1266
|
-
# # Define full function string
|
|
1267
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1268
|
-
|
|
1269
|
-
# # Define full cache key
|
|
1270
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1271
|
-
|
|
1272
|
-
# if parameters.use_cache:
|
|
1273
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1274
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1275
|
-
|
|
1276
|
-
# # Check redis for data
|
|
1277
|
-
# result_str = await self._redis.get(cache_key)
|
|
1278
|
-
|
|
1279
|
-
# if result_str is not None:
|
|
1280
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1281
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1282
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
1283
|
-
# ].model_validate(json.loads(result_str))
|
|
1284
|
-
# ReadMultipleResourceOperationSchema[
|
|
1285
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
1286
|
-
# ](
|
|
1287
|
-
# service_context=self._service_context,
|
|
1288
|
-
# id=operation_id,
|
|
1289
|
-
# context=operation_context,
|
|
1290
|
-
# timestamp=OperationTimestamp(
|
|
1291
|
-
# executed_at=executed_at,
|
|
1292
|
-
# completed_at=completed_at,
|
|
1293
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1294
|
-
# ),
|
|
1295
|
-
# summary="Successfully retrieved multiple organization users from cache",
|
|
1296
|
-
# request_context=request_context,
|
|
1297
|
-
# authentication=authentication,
|
|
1298
|
-
# action=operation_action,
|
|
1299
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1300
|
-
# result=result,
|
|
1301
|
-
# ).log(
|
|
1302
|
-
# self._logger, level=LogLevel.INFO
|
|
1303
|
-
# )
|
|
1304
|
-
# return result
|
|
1305
|
-
|
|
1306
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1307
|
-
# async with self._http_client_manager.get() as http_client:
|
|
1308
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/users/"
|
|
1309
|
-
|
|
1310
|
-
# # Parse parameters to query params
|
|
1311
|
-
# params = UserOrganizationReadMultipleFromOrganizationQueryParameter.model_validate(
|
|
1312
|
-
# parameters.model_dump()
|
|
1313
|
-
# ).model_dump(
|
|
1314
|
-
# exclude={"sort_columns", "date_filters"}, exclude_none=True
|
|
1315
|
-
# )
|
|
1316
|
-
|
|
1317
|
-
# # Create headers
|
|
1318
|
-
# base_headers = {
|
|
1319
|
-
# "Content-Type": "application/json",
|
|
1320
|
-
# "X-Operation_Id": str(operation_id),
|
|
1321
|
-
# }
|
|
1322
|
-
# if headers is not None:
|
|
1323
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1324
|
-
# else:
|
|
1325
|
-
# headers = base_headers
|
|
1326
|
-
|
|
1327
|
-
# # Create auth
|
|
1328
|
-
# token = None
|
|
1329
|
-
# if authentication.credentials.token is not None:
|
|
1330
|
-
# try:
|
|
1331
|
-
# token = reencode(
|
|
1332
|
-
# payload=authentication.credentials.token.payload,
|
|
1333
|
-
# key=self._private_key,
|
|
1334
|
-
# )
|
|
1335
|
-
# except Exception:
|
|
1336
|
-
# pass
|
|
1337
|
-
|
|
1338
|
-
# if (
|
|
1339
|
-
# token is None
|
|
1340
|
-
# and authorization is not None
|
|
1341
|
-
# and authorization.scheme == "Bearer"
|
|
1342
|
-
# ):
|
|
1343
|
-
# token = authorization.credentials
|
|
1344
|
-
|
|
1345
|
-
# if token is None:
|
|
1346
|
-
# token = self._credential_manager.token
|
|
1347
|
-
|
|
1348
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1349
|
-
|
|
1350
|
-
# # Send request and wait for response
|
|
1351
|
-
# response = await http_client.get(
|
|
1352
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1353
|
-
# )
|
|
1354
|
-
|
|
1355
|
-
# if response.is_success:
|
|
1356
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1357
|
-
# validated_response = MultipleDataResponseSchema[
|
|
1358
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
1359
|
-
# ].model_validate(response.json())
|
|
1360
|
-
# data = DataPair[List[UserOrganizationDataSchema], None](
|
|
1361
|
-
# old=validated_response.data,
|
|
1362
|
-
# new=None,
|
|
1363
|
-
# )
|
|
1364
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1365
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
1366
|
-
# ](
|
|
1367
|
-
# data=data,
|
|
1368
|
-
# pagination=validated_response.pagination,
|
|
1369
|
-
# metadata=None,
|
|
1370
|
-
# other=None,
|
|
1371
|
-
# )
|
|
1372
|
-
# ReadMultipleResourceOperationSchema[
|
|
1373
|
-
# UserOrganizationDataSchema, StrictPagination, None
|
|
1374
|
-
# ](
|
|
1375
|
-
# service_context=self._service_context,
|
|
1376
|
-
# id=operation_id,
|
|
1377
|
-
# context=operation_context,
|
|
1378
|
-
# timestamp=OperationTimestamp(
|
|
1379
|
-
# executed_at=executed_at,
|
|
1380
|
-
# completed_at=completed_at,
|
|
1381
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1382
|
-
# ),
|
|
1383
|
-
# summary="Successfully retrieved multiple organization users from http request",
|
|
1384
|
-
# request_context=request_context,
|
|
1385
|
-
# authentication=authentication,
|
|
1386
|
-
# action=operation_action,
|
|
1387
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1388
|
-
# result=result,
|
|
1389
|
-
# ).log(
|
|
1390
|
-
# self._logger, level=LogLevel.INFO
|
|
1391
|
-
# )
|
|
1392
|
-
|
|
1393
|
-
# if parameters.use_cache:
|
|
1394
|
-
# await self._redis.set(
|
|
1395
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1396
|
-
# )
|
|
1397
|
-
|
|
1398
|
-
# return result
|
|
1399
|
-
|
|
1400
|
-
# self._raise_resource_http_request_error(
|
|
1401
|
-
# response=response,
|
|
1402
|
-
# operation_id=operation_id,
|
|
1403
|
-
# operation_context=operation_context,
|
|
1404
|
-
# executed_at=executed_at,
|
|
1405
|
-
# operation_action=operation_action,
|
|
1406
|
-
# request_context=request_context,
|
|
1407
|
-
# authentication=authentication,
|
|
1408
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1409
|
-
# )
|
|
1410
|
-
|
|
1411
|
-
# async def read_organization_user(
|
|
1412
|
-
# self,
|
|
1413
|
-
# operation_id: UUID,
|
|
1414
|
-
# request_context: RequestContext,
|
|
1415
|
-
# authentication: Authentication,
|
|
1416
|
-
# parameters: UserOrganizationReadSingleParameter,
|
|
1417
|
-
# authorization: Optional[Authorization] = None,
|
|
1418
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1419
|
-
# ) -> ReadSingleResourceOperationResult[UserOrganizationDataSchema, None]:
|
|
1420
|
-
# """Retrieve organization user from MaleoIdentity"""
|
|
1421
|
-
# operation_action = ReadResourceOperationAction()
|
|
1422
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1423
|
-
|
|
1424
|
-
# # Get function identifier
|
|
1425
|
-
# func = self.__class__
|
|
1426
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1427
|
-
|
|
1428
|
-
# # Define arguments being used in this function
|
|
1429
|
-
# positional_arguments = []
|
|
1430
|
-
# keyword_arguments = {
|
|
1431
|
-
# "authentication": authentication.model_dump(
|
|
1432
|
-
# mode="json",
|
|
1433
|
-
# exclude={
|
|
1434
|
-
# "credentials": {
|
|
1435
|
-
# "token": {
|
|
1436
|
-
# "payload": {
|
|
1437
|
-
# "iat_dt",
|
|
1438
|
-
# "iat",
|
|
1439
|
-
# "exp_dt",
|
|
1440
|
-
# "exp",
|
|
1441
|
-
# }
|
|
1442
|
-
# }
|
|
1443
|
-
# }
|
|
1444
|
-
# },
|
|
1445
|
-
# ),
|
|
1446
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1447
|
-
# }
|
|
1448
|
-
|
|
1449
|
-
# # Define full function string
|
|
1450
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1451
|
-
|
|
1452
|
-
# # Define full cache key
|
|
1453
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1454
|
-
|
|
1455
|
-
# if parameters.use_cache:
|
|
1456
|
-
# # Cache operation
|
|
1457
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1458
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1459
|
-
# # Check redis for data
|
|
1460
|
-
# result_str = await self._redis.get(cache_key)
|
|
1461
|
-
|
|
1462
|
-
# if result_str is not None:
|
|
1463
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1464
|
-
# result = ReadSingleResourceOperationResult[
|
|
1465
|
-
# UserOrganizationDataSchema, None
|
|
1466
|
-
# ].model_validate(json.loads(result_str))
|
|
1467
|
-
# ReadSingleResourceOperationSchema[UserOrganizationDataSchema, None](
|
|
1468
|
-
# service_context=self._service_context,
|
|
1469
|
-
# id=operation_id,
|
|
1470
|
-
# context=operation_context,
|
|
1471
|
-
# timestamp=OperationTimestamp(
|
|
1472
|
-
# executed_at=executed_at,
|
|
1473
|
-
# completed_at=completed_at,
|
|
1474
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1475
|
-
# ),
|
|
1476
|
-
# summary="Successfully retrieved single organization user from cache",
|
|
1477
|
-
# request_context=request_context,
|
|
1478
|
-
# authentication=authentication,
|
|
1479
|
-
# action=operation_action,
|
|
1480
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1481
|
-
# result=result,
|
|
1482
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1483
|
-
# return result
|
|
1484
|
-
|
|
1485
|
-
# # HTTP Request
|
|
1486
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1487
|
-
# async with self._http_client_manager.get() as client:
|
|
1488
|
-
# # Define URL
|
|
1489
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/users/{parameters.user_id}"
|
|
1490
|
-
|
|
1491
|
-
# # Parse parameters to query params
|
|
1492
|
-
# params = UserOrganizationReadSingleQueryParameter.model_validate(
|
|
1493
|
-
# parameters.model_dump()
|
|
1494
|
-
# ).model_dump(exclude_none=True)
|
|
1495
|
-
|
|
1496
|
-
# # Create headers
|
|
1497
|
-
# base_headers = {
|
|
1498
|
-
# "Content-Type": "application/json",
|
|
1499
|
-
# "X-Operation_Id": str(operation_id),
|
|
1500
|
-
# }
|
|
1501
|
-
# if headers is not None:
|
|
1502
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1503
|
-
# else:
|
|
1504
|
-
# headers = base_headers
|
|
1505
|
-
|
|
1506
|
-
# # Create auth
|
|
1507
|
-
# token = None
|
|
1508
|
-
# if authentication.credentials.token is not None:
|
|
1509
|
-
# try:
|
|
1510
|
-
# token = reencode(
|
|
1511
|
-
# payload=authentication.credentials.token.payload,
|
|
1512
|
-
# key=self._private_key,
|
|
1513
|
-
# )
|
|
1514
|
-
# except Exception:
|
|
1515
|
-
# pass
|
|
1516
|
-
|
|
1517
|
-
# if (
|
|
1518
|
-
# token is None
|
|
1519
|
-
# and authorization is not None
|
|
1520
|
-
# and authorization.scheme == "Bearer"
|
|
1521
|
-
# ):
|
|
1522
|
-
# token = authorization.credentials
|
|
1523
|
-
|
|
1524
|
-
# if token is None:
|
|
1525
|
-
# token = self._credential_manager.token
|
|
1526
|
-
|
|
1527
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1528
|
-
|
|
1529
|
-
# # Send request and wait for response
|
|
1530
|
-
# response = await client.get(
|
|
1531
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1532
|
-
# )
|
|
1533
|
-
|
|
1534
|
-
# if response.is_success:
|
|
1535
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1536
|
-
# validated_response = SingleDataResponseSchema[
|
|
1537
|
-
# UserOrganizationDataSchema, None
|
|
1538
|
-
# ].model_validate(response.json())
|
|
1539
|
-
# data = DataPair[UserOrganizationDataSchema, None](
|
|
1540
|
-
# old=validated_response.data,
|
|
1541
|
-
# new=None,
|
|
1542
|
-
# )
|
|
1543
|
-
# result = ReadSingleResourceOperationResult[
|
|
1544
|
-
# UserOrganizationDataSchema, None
|
|
1545
|
-
# ](
|
|
1546
|
-
# data=data,
|
|
1547
|
-
# pagination=validated_response.pagination,
|
|
1548
|
-
# metadata=None,
|
|
1549
|
-
# other=None,
|
|
1550
|
-
# )
|
|
1551
|
-
# ReadSingleResourceOperationSchema[UserOrganizationDataSchema, None](
|
|
1552
|
-
# service_context=self._service_context,
|
|
1553
|
-
# id=operation_id,
|
|
1554
|
-
# context=operation_context,
|
|
1555
|
-
# timestamp=OperationTimestamp(
|
|
1556
|
-
# executed_at=executed_at,
|
|
1557
|
-
# completed_at=completed_at,
|
|
1558
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1559
|
-
# ),
|
|
1560
|
-
# summary="Successfully retrieved single organization user from http request",
|
|
1561
|
-
# request_context=request_context,
|
|
1562
|
-
# authentication=authentication,
|
|
1563
|
-
# action=operation_action,
|
|
1564
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1565
|
-
# result=result,
|
|
1566
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1567
|
-
|
|
1568
|
-
# if parameters.use_cache:
|
|
1569
|
-
# await self._redis.set(
|
|
1570
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1571
|
-
# )
|
|
1572
|
-
|
|
1573
|
-
# return result
|
|
1574
|
-
|
|
1575
|
-
# self._raise_resource_http_request_error(
|
|
1576
|
-
# response=response,
|
|
1577
|
-
# operation_id=operation_id,
|
|
1578
|
-
# operation_context=operation_context,
|
|
1579
|
-
# executed_at=executed_at,
|
|
1580
|
-
# operation_action=operation_action,
|
|
1581
|
-
# request_context=request_context,
|
|
1582
|
-
# authentication=authentication,
|
|
1583
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1584
|
-
# )
|
|
1585
|
-
|
|
1586
|
-
# async def read_organization_user_roles(
|
|
1587
|
-
# self,
|
|
1588
|
-
# operation_id: UUID,
|
|
1589
|
-
# request_context: RequestContext,
|
|
1590
|
-
# authentication: Authentication,
|
|
1591
|
-
# parameters: UserOrganizationRoleReadMultipleFromUserOrganizationParameter,
|
|
1592
|
-
# authorization: Optional[Authorization] = None,
|
|
1593
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1594
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
1595
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
1596
|
-
# ]:
|
|
1597
|
-
# """Retrieve organization user roles from MaleoIdentity"""
|
|
1598
|
-
# operation_action = ReadResourceOperationAction()
|
|
1599
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1600
|
-
|
|
1601
|
-
# # Get function identifier
|
|
1602
|
-
# func = self.__class__
|
|
1603
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1604
|
-
|
|
1605
|
-
# # Define arguments being used in this function
|
|
1606
|
-
# positional_arguments = []
|
|
1607
|
-
# keyword_arguments = {
|
|
1608
|
-
# "authentication": authentication.model_dump(
|
|
1609
|
-
# mode="json",
|
|
1610
|
-
# exclude={
|
|
1611
|
-
# "credentials": {
|
|
1612
|
-
# "token": {
|
|
1613
|
-
# "payload": {
|
|
1614
|
-
# "iat_dt",
|
|
1615
|
-
# "iat",
|
|
1616
|
-
# "exp_dt",
|
|
1617
|
-
# "exp",
|
|
1618
|
-
# }
|
|
1619
|
-
# }
|
|
1620
|
-
# }
|
|
1621
|
-
# },
|
|
1622
|
-
# ),
|
|
1623
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1624
|
-
# }
|
|
1625
|
-
|
|
1626
|
-
# # Define full function string
|
|
1627
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1628
|
-
|
|
1629
|
-
# # Define full cache key
|
|
1630
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1631
|
-
|
|
1632
|
-
# if parameters.use_cache:
|
|
1633
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1634
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1635
|
-
|
|
1636
|
-
# # Check redis for data
|
|
1637
|
-
# result_str = await self._redis.get(cache_key)
|
|
1638
|
-
|
|
1639
|
-
# if result_str is not None:
|
|
1640
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1641
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1642
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
1643
|
-
# ].model_validate(json.loads(result_str))
|
|
1644
|
-
# ReadMultipleResourceOperationSchema[
|
|
1645
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
1646
|
-
# ](
|
|
1647
|
-
# service_context=self._service_context,
|
|
1648
|
-
# id=operation_id,
|
|
1649
|
-
# context=operation_context,
|
|
1650
|
-
# timestamp=OperationTimestamp(
|
|
1651
|
-
# executed_at=executed_at,
|
|
1652
|
-
# completed_at=completed_at,
|
|
1653
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1654
|
-
# ),
|
|
1655
|
-
# summary="Successfully retrieved multiple organization user roles from cache",
|
|
1656
|
-
# request_context=request_context,
|
|
1657
|
-
# authentication=authentication,
|
|
1658
|
-
# action=operation_action,
|
|
1659
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1660
|
-
# result=result,
|
|
1661
|
-
# ).log(
|
|
1662
|
-
# self._logger, level=LogLevel.INFO
|
|
1663
|
-
# )
|
|
1664
|
-
# return result
|
|
1665
|
-
|
|
1666
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1667
|
-
# async with self._http_client_manager.get() as http_client:
|
|
1668
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/users/{parameters.user_id}/roles/"
|
|
1669
|
-
|
|
1670
|
-
# # Parse parameters to query params
|
|
1671
|
-
# params = UserOrganizationRoleReadMultipleFromUserOrganizationQueryParameter.model_validate(
|
|
1672
|
-
# parameters.model_dump()
|
|
1673
|
-
# ).model_dump(
|
|
1674
|
-
# exclude={"sort_columns", "date_filters"}, exclude_none=True
|
|
1675
|
-
# )
|
|
1676
|
-
|
|
1677
|
-
# # Create headers
|
|
1678
|
-
# base_headers = {
|
|
1679
|
-
# "Content-Type": "application/json",
|
|
1680
|
-
# "X-Operation_Id": str(operation_id),
|
|
1681
|
-
# }
|
|
1682
|
-
# if headers is not None:
|
|
1683
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1684
|
-
# else:
|
|
1685
|
-
# headers = base_headers
|
|
1686
|
-
|
|
1687
|
-
# # Create auth
|
|
1688
|
-
# token = None
|
|
1689
|
-
# if authentication.credentials.token is not None:
|
|
1690
|
-
# try:
|
|
1691
|
-
# token = reencode(
|
|
1692
|
-
# payload=authentication.credentials.token.payload,
|
|
1693
|
-
# key=self._private_key,
|
|
1694
|
-
# )
|
|
1695
|
-
# except Exception:
|
|
1696
|
-
# pass
|
|
1697
|
-
|
|
1698
|
-
# if (
|
|
1699
|
-
# token is None
|
|
1700
|
-
# and authorization is not None
|
|
1701
|
-
# and authorization.scheme == "Bearer"
|
|
1702
|
-
# ):
|
|
1703
|
-
# token = authorization.credentials
|
|
1704
|
-
|
|
1705
|
-
# if token is None:
|
|
1706
|
-
# token = self._credential_manager.token
|
|
1707
|
-
|
|
1708
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1709
|
-
|
|
1710
|
-
# # Send request and wait for response
|
|
1711
|
-
# response = await http_client.get(
|
|
1712
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1713
|
-
# )
|
|
1714
|
-
|
|
1715
|
-
# if response.is_success:
|
|
1716
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1717
|
-
# validated_response = MultipleDataResponseSchema[
|
|
1718
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
1719
|
-
# ].model_validate(response.json())
|
|
1720
|
-
# data = DataPair[List[UserOrganizationRoleDataSchema], None](
|
|
1721
|
-
# old=validated_response.data,
|
|
1722
|
-
# new=None,
|
|
1723
|
-
# )
|
|
1724
|
-
# result = ReadMultipleResourceOperationResult[
|
|
1725
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
1726
|
-
# ](
|
|
1727
|
-
# data=data,
|
|
1728
|
-
# pagination=validated_response.pagination,
|
|
1729
|
-
# metadata=None,
|
|
1730
|
-
# other=None,
|
|
1731
|
-
# )
|
|
1732
|
-
# ReadMultipleResourceOperationSchema[
|
|
1733
|
-
# UserOrganizationRoleDataSchema, StrictPagination, None
|
|
1734
|
-
# ](
|
|
1735
|
-
# service_context=self._service_context,
|
|
1736
|
-
# id=operation_id,
|
|
1737
|
-
# context=operation_context,
|
|
1738
|
-
# timestamp=OperationTimestamp(
|
|
1739
|
-
# executed_at=executed_at,
|
|
1740
|
-
# completed_at=completed_at,
|
|
1741
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1742
|
-
# ),
|
|
1743
|
-
# summary="Successfully retrieved multiple organization user roles from http request",
|
|
1744
|
-
# request_context=request_context,
|
|
1745
|
-
# authentication=authentication,
|
|
1746
|
-
# action=operation_action,
|
|
1747
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1748
|
-
# result=result,
|
|
1749
|
-
# ).log(
|
|
1750
|
-
# self._logger, level=LogLevel.INFO
|
|
1751
|
-
# )
|
|
1752
|
-
|
|
1753
|
-
# if parameters.use_cache:
|
|
1754
|
-
# await self._redis.set(
|
|
1755
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1756
|
-
# )
|
|
1757
|
-
|
|
1758
|
-
# return result
|
|
1759
|
-
|
|
1760
|
-
# self._raise_resource_http_request_error(
|
|
1761
|
-
# response=response,
|
|
1762
|
-
# operation_id=operation_id,
|
|
1763
|
-
# operation_context=operation_context,
|
|
1764
|
-
# executed_at=executed_at,
|
|
1765
|
-
# operation_action=operation_action,
|
|
1766
|
-
# request_context=request_context,
|
|
1767
|
-
# authentication=authentication,
|
|
1768
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1769
|
-
# )
|
|
1770
|
-
|
|
1771
|
-
# async def read_organization_user_role(
|
|
1772
|
-
# self,
|
|
1773
|
-
# operation_id: UUID,
|
|
1774
|
-
# request_context: RequestContext,
|
|
1775
|
-
# authentication: Authentication,
|
|
1776
|
-
# parameters: UserOrganizationRoleReadSingleParameter,
|
|
1777
|
-
# authorization: Optional[Authorization] = None,
|
|
1778
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
1779
|
-
# ) -> ReadSingleResourceOperationResult[UserOrganizationRoleDataSchema, None]:
|
|
1780
|
-
# """Retrieve organization user role from MaleoIdentity"""
|
|
1781
|
-
# operation_action = ReadResourceOperationAction()
|
|
1782
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
1783
|
-
|
|
1784
|
-
# # Get function identifier
|
|
1785
|
-
# func = self.__class__
|
|
1786
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
1787
|
-
|
|
1788
|
-
# # Define arguments being used in this function
|
|
1789
|
-
# positional_arguments = []
|
|
1790
|
-
# keyword_arguments = {
|
|
1791
|
-
# "authentication": authentication.model_dump(
|
|
1792
|
-
# mode="json",
|
|
1793
|
-
# exclude={
|
|
1794
|
-
# "credentials": {
|
|
1795
|
-
# "token": {
|
|
1796
|
-
# "payload": {
|
|
1797
|
-
# "iat_dt",
|
|
1798
|
-
# "iat",
|
|
1799
|
-
# "exp_dt",
|
|
1800
|
-
# "exp",
|
|
1801
|
-
# }
|
|
1802
|
-
# }
|
|
1803
|
-
# }
|
|
1804
|
-
# },
|
|
1805
|
-
# ),
|
|
1806
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
1807
|
-
# }
|
|
1808
|
-
|
|
1809
|
-
# # Define full function string
|
|
1810
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
1811
|
-
|
|
1812
|
-
# # Define full cache key
|
|
1813
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
1814
|
-
|
|
1815
|
-
# if parameters.use_cache:
|
|
1816
|
-
# # Cache operation
|
|
1817
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1818
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
1819
|
-
# # Check redis for data
|
|
1820
|
-
# result_str = await self._redis.get(cache_key)
|
|
1821
|
-
|
|
1822
|
-
# if result_str is not None:
|
|
1823
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1824
|
-
# result = ReadSingleResourceOperationResult[
|
|
1825
|
-
# UserOrganizationRoleDataSchema, None
|
|
1826
|
-
# ].model_validate(json.loads(result_str))
|
|
1827
|
-
# ReadSingleResourceOperationSchema[UserOrganizationRoleDataSchema, None](
|
|
1828
|
-
# service_context=self._service_context,
|
|
1829
|
-
# id=operation_id,
|
|
1830
|
-
# context=operation_context,
|
|
1831
|
-
# timestamp=OperationTimestamp(
|
|
1832
|
-
# executed_at=executed_at,
|
|
1833
|
-
# completed_at=completed_at,
|
|
1834
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1835
|
-
# ),
|
|
1836
|
-
# summary="Successfully retrieved single organization user role from cache",
|
|
1837
|
-
# request_context=request_context,
|
|
1838
|
-
# authentication=authentication,
|
|
1839
|
-
# action=operation_action,
|
|
1840
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1841
|
-
# result=result,
|
|
1842
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1843
|
-
# return result
|
|
1844
|
-
|
|
1845
|
-
# # HTTP Request
|
|
1846
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
1847
|
-
# async with self._http_client_manager.get() as client:
|
|
1848
|
-
# # Define URL
|
|
1849
|
-
# url = f"{self._url}/v1/{ORGANIZATION_RESOURCE.identifiers[0].url_slug}/{parameters.organization_id}/users/{parameters.user_id}/roles/{parameters.key}"
|
|
1850
|
-
|
|
1851
|
-
# # Parse parameters to query params
|
|
1852
|
-
# params = UserOrganizationRoleReadSingleQueryParameter.model_validate(
|
|
1853
|
-
# parameters.model_dump()
|
|
1854
|
-
# ).model_dump(exclude_none=True)
|
|
1855
|
-
|
|
1856
|
-
# # Create headers
|
|
1857
|
-
# base_headers = {
|
|
1858
|
-
# "Content-Type": "application/json",
|
|
1859
|
-
# "X-Operation_Id": str(operation_id),
|
|
1860
|
-
# }
|
|
1861
|
-
# if headers is not None:
|
|
1862
|
-
# headers = merge_dicts(base_headers, headers)
|
|
1863
|
-
# else:
|
|
1864
|
-
# headers = base_headers
|
|
1865
|
-
|
|
1866
|
-
# # Create auth
|
|
1867
|
-
# token = None
|
|
1868
|
-
# if authentication.credentials.token is not None:
|
|
1869
|
-
# try:
|
|
1870
|
-
# token = reencode(
|
|
1871
|
-
# payload=authentication.credentials.token.payload,
|
|
1872
|
-
# key=self._private_key,
|
|
1873
|
-
# )
|
|
1874
|
-
# except Exception:
|
|
1875
|
-
# pass
|
|
1876
|
-
|
|
1877
|
-
# if (
|
|
1878
|
-
# token is None
|
|
1879
|
-
# and authorization is not None
|
|
1880
|
-
# and authorization.scheme == "Bearer"
|
|
1881
|
-
# ):
|
|
1882
|
-
# token = authorization.credentials
|
|
1883
|
-
|
|
1884
|
-
# if token is None:
|
|
1885
|
-
# token = self._credential_manager.token
|
|
1886
|
-
|
|
1887
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
1888
|
-
|
|
1889
|
-
# # Send request and wait for response
|
|
1890
|
-
# response = await client.get(
|
|
1891
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
1892
|
-
# )
|
|
1893
|
-
|
|
1894
|
-
# if response.is_success:
|
|
1895
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
1896
|
-
# validated_response = SingleDataResponseSchema[
|
|
1897
|
-
# UserOrganizationRoleDataSchema, None
|
|
1898
|
-
# ].model_validate(response.json())
|
|
1899
|
-
# data = DataPair[UserOrganizationRoleDataSchema, None](
|
|
1900
|
-
# old=validated_response.data,
|
|
1901
|
-
# new=None,
|
|
1902
|
-
# )
|
|
1903
|
-
# result = ReadSingleResourceOperationResult[
|
|
1904
|
-
# UserOrganizationRoleDataSchema, None
|
|
1905
|
-
# ](
|
|
1906
|
-
# data=data,
|
|
1907
|
-
# pagination=validated_response.pagination,
|
|
1908
|
-
# metadata=None,
|
|
1909
|
-
# other=None,
|
|
1910
|
-
# )
|
|
1911
|
-
# ReadSingleResourceOperationSchema[UserOrganizationRoleDataSchema, None](
|
|
1912
|
-
# service_context=self._service_context,
|
|
1913
|
-
# id=operation_id,
|
|
1914
|
-
# context=operation_context,
|
|
1915
|
-
# timestamp=OperationTimestamp(
|
|
1916
|
-
# executed_at=executed_at,
|
|
1917
|
-
# completed_at=completed_at,
|
|
1918
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
1919
|
-
# ),
|
|
1920
|
-
# summary="Successfully retrieved single organization user role from http request",
|
|
1921
|
-
# request_context=request_context,
|
|
1922
|
-
# authentication=authentication,
|
|
1923
|
-
# action=operation_action,
|
|
1924
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1925
|
-
# result=result,
|
|
1926
|
-
# ).log(self._logger, level=LogLevel.INFO)
|
|
1927
|
-
|
|
1928
|
-
# if parameters.use_cache:
|
|
1929
|
-
# await self._redis.set(
|
|
1930
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
1931
|
-
# )
|
|
1932
|
-
|
|
1933
|
-
# return result
|
|
1934
|
-
|
|
1935
|
-
# self._raise_resource_http_request_error(
|
|
1936
|
-
# response=response,
|
|
1937
|
-
# operation_id=operation_id,
|
|
1938
|
-
# operation_context=operation_context,
|
|
1939
|
-
# executed_at=executed_at,
|
|
1940
|
-
# operation_action=operation_action,
|
|
1941
|
-
# request_context=request_context,
|
|
1942
|
-
# authentication=authentication,
|
|
1943
|
-
# resource=ORGANIZATION_RESOURCE,
|
|
1944
|
-
# )
|