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,470 +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_registration_code import RESOURCE
|
|
49
|
-
# from maleo.identity.schemas.data.organization_registration_code import (
|
|
50
|
-
# OrganizationRegistrationCodeDataSchema,
|
|
51
|
-
# )
|
|
52
|
-
# from maleo.identity.schemas.parameter.client.organization_registration_code import (
|
|
53
|
-
# ReadMultipleParameter,
|
|
54
|
-
# ReadMultipleQueryParameter,
|
|
55
|
-
# )
|
|
56
|
-
# from maleo.identity.schemas.parameter.general.organization_registration_code import (
|
|
57
|
-
# ReadSingleParameter,
|
|
58
|
-
# )
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# class OrganizationRegistrationCodeClientService(MaleoClientService):
|
|
62
|
-
# def __init__(
|
|
63
|
-
# self,
|
|
64
|
-
# environment: Environment,
|
|
65
|
-
# key: str,
|
|
66
|
-
# url: str,
|
|
67
|
-
# operation_origin: OperationOriginSchema,
|
|
68
|
-
# logger: ClientLogger,
|
|
69
|
-
# credential_manager: CredentialManager,
|
|
70
|
-
# http_client_manager: HTTPClientManager,
|
|
71
|
-
# private_key: RsaKey,
|
|
72
|
-
# redis: Redis,
|
|
73
|
-
# redis_namespaces: RedisCacheNamespaces,
|
|
74
|
-
# service_context: ServiceContext,
|
|
75
|
-
# ):
|
|
76
|
-
# super().__init__(
|
|
77
|
-
# environment,
|
|
78
|
-
# key,
|
|
79
|
-
# url,
|
|
80
|
-
# operation_origin,
|
|
81
|
-
# logger,
|
|
82
|
-
# credential_manager,
|
|
83
|
-
# http_client_manager,
|
|
84
|
-
# private_key,
|
|
85
|
-
# redis,
|
|
86
|
-
# redis_namespaces,
|
|
87
|
-
# service_context,
|
|
88
|
-
# )
|
|
89
|
-
# # self._controllers = controllers
|
|
90
|
-
# self._namespace = self._redis_namespaces.create(
|
|
91
|
-
# self._key,
|
|
92
|
-
# RESOURCE.aggregate(),
|
|
93
|
-
# origin=self._CACHE_ORIGIN,
|
|
94
|
-
# layer=self._CACHE_LAYER,
|
|
95
|
-
# )
|
|
96
|
-
# self._default_operation_context = OperationContextSchema(
|
|
97
|
-
# origin=self._operation_origin,
|
|
98
|
-
# layer=OperationLayerSchema(type=self._OPERATION_LAYER_TYPE, details=None),
|
|
99
|
-
# target=OperationTargetSchema(
|
|
100
|
-
# type=self._OPERATION_TARGET_TYPE, details=None
|
|
101
|
-
# ),
|
|
102
|
-
# )
|
|
103
|
-
|
|
104
|
-
# async def read_organization_registration_codes(
|
|
105
|
-
# self,
|
|
106
|
-
# operation_id: UUID,
|
|
107
|
-
# request_context: RequestContext,
|
|
108
|
-
# authentication: Authentication,
|
|
109
|
-
# parameters: ReadMultipleParameter,
|
|
110
|
-
# authorization: Optional[Authorization] = None,
|
|
111
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
112
|
-
# ) -> ReadMultipleResourceOperationResult[
|
|
113
|
-
# OrganizationRegistrationCodeDataSchema, StrictPagination, None
|
|
114
|
-
# ]:
|
|
115
|
-
# """Retrieve organization registration codes from MaleoIdentity"""
|
|
116
|
-
# operation_action = ReadResourceOperationAction()
|
|
117
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
118
|
-
|
|
119
|
-
# # Get function identifier
|
|
120
|
-
# func = self.__class__
|
|
121
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
122
|
-
|
|
123
|
-
# # Define arguments being used in this function
|
|
124
|
-
# positional_arguments = []
|
|
125
|
-
# keyword_arguments = {
|
|
126
|
-
# "authentication": authentication.model_dump(
|
|
127
|
-
# mode="json",
|
|
128
|
-
# exclude={
|
|
129
|
-
# "credentials": {
|
|
130
|
-
# "token": {
|
|
131
|
-
# "payload": {
|
|
132
|
-
# "iat_dt",
|
|
133
|
-
# "iat",
|
|
134
|
-
# "exp_dt",
|
|
135
|
-
# "exp",
|
|
136
|
-
# }
|
|
137
|
-
# }
|
|
138
|
-
# }
|
|
139
|
-
# },
|
|
140
|
-
# ),
|
|
141
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
142
|
-
# }
|
|
143
|
-
|
|
144
|
-
# # Define full function string
|
|
145
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
146
|
-
|
|
147
|
-
# # Define full cache key
|
|
148
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
149
|
-
|
|
150
|
-
# if parameters.use_cache:
|
|
151
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
152
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
153
|
-
|
|
154
|
-
# # Check redis for data
|
|
155
|
-
# result_str = await self._redis.get(cache_key)
|
|
156
|
-
|
|
157
|
-
# if result_str is not None:
|
|
158
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
159
|
-
# result = ReadMultipleResourceOperationResult[
|
|
160
|
-
# OrganizationRegistrationCodeDataSchema, StrictPagination, None
|
|
161
|
-
# ].model_validate(json.loads(result_str))
|
|
162
|
-
# ReadMultipleResourceOperationSchema[
|
|
163
|
-
# OrganizationRegistrationCodeDataSchema, StrictPagination, None
|
|
164
|
-
# ](
|
|
165
|
-
# service_context=self._service_context,
|
|
166
|
-
# id=operation_id,
|
|
167
|
-
# context=operation_context,
|
|
168
|
-
# timestamp=OperationTimestamp(
|
|
169
|
-
# executed_at=executed_at,
|
|
170
|
-
# completed_at=completed_at,
|
|
171
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
172
|
-
# ),
|
|
173
|
-
# summary="Successfully retrieved multiple organization registration codes from cache",
|
|
174
|
-
# request_context=request_context,
|
|
175
|
-
# authentication=authentication,
|
|
176
|
-
# action=operation_action,
|
|
177
|
-
# resource=RESOURCE,
|
|
178
|
-
# result=result,
|
|
179
|
-
# ).log(
|
|
180
|
-
# self._logger, level=LogLevel.INFO
|
|
181
|
-
# )
|
|
182
|
-
# return result
|
|
183
|
-
|
|
184
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
185
|
-
# async with self._http_client_manager.get() as http_client:
|
|
186
|
-
# url = f"{self._url}/v1/{RESOURCE.identifiers[0].url_slug}/"
|
|
187
|
-
|
|
188
|
-
# # Parse parameters to query params
|
|
189
|
-
# params = ReadMultipleQueryParameter.model_validate(
|
|
190
|
-
# parameters.model_dump()
|
|
191
|
-
# ).model_dump(exclude={"sort_columns", "date_filters"}, exclude_none=True)
|
|
192
|
-
|
|
193
|
-
# # Create headers
|
|
194
|
-
# base_headers = {
|
|
195
|
-
# "Content-Type": "application/json",
|
|
196
|
-
# "X-Operation_Id": str(operation_id),
|
|
197
|
-
# }
|
|
198
|
-
# if headers is not None:
|
|
199
|
-
# headers = merge_dicts(base_headers, headers)
|
|
200
|
-
# else:
|
|
201
|
-
# headers = base_headers
|
|
202
|
-
|
|
203
|
-
# # Create auth
|
|
204
|
-
# token = None
|
|
205
|
-
# if authentication.credentials.token is not None:
|
|
206
|
-
# try:
|
|
207
|
-
# token = reencode(
|
|
208
|
-
# payload=authentication.credentials.token.payload,
|
|
209
|
-
# key=self._private_key,
|
|
210
|
-
# )
|
|
211
|
-
# except Exception:
|
|
212
|
-
# pass
|
|
213
|
-
|
|
214
|
-
# if (
|
|
215
|
-
# token is None
|
|
216
|
-
# and authorization is not None
|
|
217
|
-
# and authorization.scheme == "Bearer"
|
|
218
|
-
# ):
|
|
219
|
-
# token = authorization.credentials
|
|
220
|
-
|
|
221
|
-
# if token is None:
|
|
222
|
-
# token = self._credential_manager.token
|
|
223
|
-
|
|
224
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
225
|
-
|
|
226
|
-
# # Send request and wait for response
|
|
227
|
-
# response = await http_client.get(
|
|
228
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
229
|
-
# )
|
|
230
|
-
|
|
231
|
-
# if response.is_success:
|
|
232
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
233
|
-
# validated_response = MultipleDataResponseSchema[
|
|
234
|
-
# OrganizationRegistrationCodeDataSchema, StrictPagination, None
|
|
235
|
-
# ].model_validate(response.json())
|
|
236
|
-
# data = DataPair[List[OrganizationRegistrationCodeDataSchema], None](
|
|
237
|
-
# old=validated_response.data,
|
|
238
|
-
# new=None,
|
|
239
|
-
# )
|
|
240
|
-
# result = ReadMultipleResourceOperationResult[
|
|
241
|
-
# OrganizationRegistrationCodeDataSchema, StrictPagination, None
|
|
242
|
-
# ](
|
|
243
|
-
# data=data,
|
|
244
|
-
# pagination=validated_response.pagination,
|
|
245
|
-
# metadata=None,
|
|
246
|
-
# other=None,
|
|
247
|
-
# )
|
|
248
|
-
# ReadMultipleResourceOperationSchema[
|
|
249
|
-
# OrganizationRegistrationCodeDataSchema, StrictPagination, None
|
|
250
|
-
# ](
|
|
251
|
-
# service_context=self._service_context,
|
|
252
|
-
# id=operation_id,
|
|
253
|
-
# context=operation_context,
|
|
254
|
-
# timestamp=OperationTimestamp(
|
|
255
|
-
# executed_at=executed_at,
|
|
256
|
-
# completed_at=completed_at,
|
|
257
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
258
|
-
# ),
|
|
259
|
-
# summary="Successfully retrieved multiple organization registration codes from http request",
|
|
260
|
-
# request_context=request_context,
|
|
261
|
-
# authentication=authentication,
|
|
262
|
-
# action=operation_action,
|
|
263
|
-
# resource=RESOURCE,
|
|
264
|
-
# result=result,
|
|
265
|
-
# ).log(
|
|
266
|
-
# self._logger, level=LogLevel.INFO
|
|
267
|
-
# )
|
|
268
|
-
|
|
269
|
-
# if parameters.use_cache:
|
|
270
|
-
# await self._redis.set(
|
|
271
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
272
|
-
# )
|
|
273
|
-
|
|
274
|
-
# return result
|
|
275
|
-
|
|
276
|
-
# self._raise_resource_http_request_error(
|
|
277
|
-
# response=response,
|
|
278
|
-
# operation_id=operation_id,
|
|
279
|
-
# operation_context=operation_context,
|
|
280
|
-
# executed_at=executed_at,
|
|
281
|
-
# operation_action=operation_action,
|
|
282
|
-
# request_context=request_context,
|
|
283
|
-
# authentication=authentication,
|
|
284
|
-
# resource=RESOURCE,
|
|
285
|
-
# )
|
|
286
|
-
|
|
287
|
-
# async def read_organization_registration_code(
|
|
288
|
-
# self,
|
|
289
|
-
# operation_id: UUID,
|
|
290
|
-
# request_context: RequestContext,
|
|
291
|
-
# authentication: Authentication,
|
|
292
|
-
# parameters: ReadSingleParameter,
|
|
293
|
-
# authorization: Optional[Authorization] = None,
|
|
294
|
-
# headers: Optional[Dict[str, str]] = None,
|
|
295
|
-
# ) -> ReadSingleResourceOperationResult[
|
|
296
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
297
|
-
# ]:
|
|
298
|
-
# """Retrieve organization registration code from MaleoIdentity"""
|
|
299
|
-
# operation_action = ReadResourceOperationAction()
|
|
300
|
-
# executed_at = datetime.now(tz=timezone.utc)
|
|
301
|
-
|
|
302
|
-
# # Get function identifier
|
|
303
|
-
# func = self.__class__
|
|
304
|
-
# module, qualname = func.__module__, func.__qualname__
|
|
305
|
-
|
|
306
|
-
# # Define arguments being used in this function
|
|
307
|
-
# positional_arguments = []
|
|
308
|
-
# keyword_arguments = {
|
|
309
|
-
# "authentication": authentication.model_dump(
|
|
310
|
-
# mode="json",
|
|
311
|
-
# exclude={
|
|
312
|
-
# "credentials": {
|
|
313
|
-
# "token": {
|
|
314
|
-
# "payload": {
|
|
315
|
-
# "iat_dt",
|
|
316
|
-
# "iat",
|
|
317
|
-
# "exp_dt",
|
|
318
|
-
# "exp",
|
|
319
|
-
# }
|
|
320
|
-
# }
|
|
321
|
-
# }
|
|
322
|
-
# },
|
|
323
|
-
# ),
|
|
324
|
-
# "parameters": parameters.model_dump(mode="json"),
|
|
325
|
-
# }
|
|
326
|
-
|
|
327
|
-
# # Define full function string
|
|
328
|
-
# function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
329
|
-
|
|
330
|
-
# # Define full cache key
|
|
331
|
-
# cache_key = build_key(module, function, namespace=self._namespace)
|
|
332
|
-
|
|
333
|
-
# if parameters.use_cache:
|
|
334
|
-
# # Cache operation
|
|
335
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
336
|
-
# operation_context.target.type = OperationTarget.CACHE
|
|
337
|
-
# # Check redis for data
|
|
338
|
-
# result_str = await self._redis.get(cache_key)
|
|
339
|
-
|
|
340
|
-
# if result_str is not None:
|
|
341
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
342
|
-
# result = ReadSingleResourceOperationResult[
|
|
343
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
344
|
-
# ].model_validate(json.loads(result_str))
|
|
345
|
-
# ReadSingleResourceOperationSchema[
|
|
346
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
347
|
-
# ](
|
|
348
|
-
# service_context=self._service_context,
|
|
349
|
-
# id=operation_id,
|
|
350
|
-
# context=operation_context,
|
|
351
|
-
# timestamp=OperationTimestamp(
|
|
352
|
-
# executed_at=executed_at,
|
|
353
|
-
# completed_at=completed_at,
|
|
354
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
355
|
-
# ),
|
|
356
|
-
# summary="Successfully retrieved single organization registration code from cache",
|
|
357
|
-
# request_context=request_context,
|
|
358
|
-
# authentication=authentication,
|
|
359
|
-
# action=operation_action,
|
|
360
|
-
# resource=RESOURCE,
|
|
361
|
-
# result=result,
|
|
362
|
-
# ).log(
|
|
363
|
-
# self._logger, level=LogLevel.INFO
|
|
364
|
-
# )
|
|
365
|
-
# return result
|
|
366
|
-
|
|
367
|
-
# # HTTP Request
|
|
368
|
-
# operation_context = deepcopy(self._default_operation_context)
|
|
369
|
-
# async with self._http_client_manager.get() as client:
|
|
370
|
-
# # Define URL
|
|
371
|
-
# url = f"{self._url}/v1/{RESOURCE.identifiers[0].url_slug}/{parameters.identifier}/{parameters.value}"
|
|
372
|
-
|
|
373
|
-
# # Parse parameters to query params
|
|
374
|
-
# params = ReadSingleQueryParameterSchema.model_validate(
|
|
375
|
-
# parameters.model_dump()
|
|
376
|
-
# ).model_dump(exclude_none=True)
|
|
377
|
-
|
|
378
|
-
# # Create headers
|
|
379
|
-
# base_headers = {
|
|
380
|
-
# "Content-Type": "application/json",
|
|
381
|
-
# "X-Operation_Id": str(operation_id),
|
|
382
|
-
# }
|
|
383
|
-
# if headers is not None:
|
|
384
|
-
# headers = merge_dicts(base_headers, headers)
|
|
385
|
-
# else:
|
|
386
|
-
# headers = base_headers
|
|
387
|
-
|
|
388
|
-
# # Create auth
|
|
389
|
-
# token = None
|
|
390
|
-
# if authentication.credentials.token is not None:
|
|
391
|
-
# try:
|
|
392
|
-
# token = reencode(
|
|
393
|
-
# payload=authentication.credentials.token.payload,
|
|
394
|
-
# key=self._private_key,
|
|
395
|
-
# )
|
|
396
|
-
# except Exception:
|
|
397
|
-
# pass
|
|
398
|
-
|
|
399
|
-
# if (
|
|
400
|
-
# token is None
|
|
401
|
-
# and authorization is not None
|
|
402
|
-
# and authorization.scheme == "Bearer"
|
|
403
|
-
# ):
|
|
404
|
-
# token = authorization.credentials
|
|
405
|
-
|
|
406
|
-
# if token is None:
|
|
407
|
-
# token = self._credential_manager.token
|
|
408
|
-
|
|
409
|
-
# auth = BearerAuth(token) if token is not None else None
|
|
410
|
-
|
|
411
|
-
# # Send request and wait for response
|
|
412
|
-
# response = await client.get(
|
|
413
|
-
# url=url, params=params, headers=headers, auth=auth
|
|
414
|
-
# )
|
|
415
|
-
|
|
416
|
-
# if response.is_success:
|
|
417
|
-
# completed_at = datetime.now(tz=timezone.utc)
|
|
418
|
-
# validated_response = SingleDataResponseSchema[
|
|
419
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
420
|
-
# ].model_validate(response.json())
|
|
421
|
-
# data = DataPair[OrganizationRegistrationCodeDataSchema, None](
|
|
422
|
-
# old=validated_response.data,
|
|
423
|
-
# new=None,
|
|
424
|
-
# )
|
|
425
|
-
# result = ReadSingleResourceOperationResult[
|
|
426
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
427
|
-
# ](
|
|
428
|
-
# data=data,
|
|
429
|
-
# pagination=validated_response.pagination,
|
|
430
|
-
# metadata=None,
|
|
431
|
-
# other=None,
|
|
432
|
-
# )
|
|
433
|
-
# ReadSingleResourceOperationSchema[
|
|
434
|
-
# OrganizationRegistrationCodeDataSchema, None
|
|
435
|
-
# ](
|
|
436
|
-
# service_context=self._service_context,
|
|
437
|
-
# id=operation_id,
|
|
438
|
-
# context=operation_context,
|
|
439
|
-
# timestamp=OperationTimestamp(
|
|
440
|
-
# executed_at=executed_at,
|
|
441
|
-
# completed_at=completed_at,
|
|
442
|
-
# duration=(completed_at - executed_at).total_seconds(),
|
|
443
|
-
# ),
|
|
444
|
-
# summary="Successfully retrieved single organization registration code from http request",
|
|
445
|
-
# request_context=request_context,
|
|
446
|
-
# authentication=authentication,
|
|
447
|
-
# action=operation_action,
|
|
448
|
-
# resource=RESOURCE,
|
|
449
|
-
# result=result,
|
|
450
|
-
# ).log(
|
|
451
|
-
# self._logger, level=LogLevel.INFO
|
|
452
|
-
# )
|
|
453
|
-
|
|
454
|
-
# if parameters.use_cache:
|
|
455
|
-
# await self._redis.set(
|
|
456
|
-
# cache_key, result.model_dump_json(), Expiration.EXP_1WK
|
|
457
|
-
# )
|
|
458
|
-
|
|
459
|
-
# return result
|
|
460
|
-
|
|
461
|
-
# self._raise_resource_http_request_error(
|
|
462
|
-
# response=response,
|
|
463
|
-
# operation_id=operation_id,
|
|
464
|
-
# operation_context=operation_context,
|
|
465
|
-
# executed_at=executed_at,
|
|
466
|
-
# operation_action=operation_action,
|
|
467
|
-
# request_context=request_context,
|
|
468
|
-
# authentication=authentication,
|
|
469
|
-
# resource=RESOURCE,
|
|
470
|
-
# )
|