maleo-metadata-client 0.0.14__py3-none-any.whl → 0.0.22__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of maleo-metadata-client might be problematic. Click here for more details.
- maleo/metadata/client/manager.py +9 -0
- maleo/metadata/client/services/blood_type.py +25 -25
- maleo/metadata/client/services/gender.py +25 -25
- maleo/metadata/client/services/medical_role.py +35 -35
- maleo/metadata/client/services/medical_service.py +25 -25
- maleo/metadata/client/services/organization_role.py +304 -0
- maleo/metadata/client/services/organization_type.py +25 -27
- maleo/metadata/client/services/service.py +25 -25
- maleo/metadata/client/services/system_role.py +25 -25
- maleo/metadata/client/services/user_type.py +25 -25
- {maleo_metadata_client-0.0.14.dist-info → maleo_metadata_client-0.0.22.dist-info}/METADATA +36 -36
- maleo_metadata_client-0.0.22.dist-info/RECORD +17 -0
- maleo_metadata_client-0.0.14.dist-info/RECORD +0 -16
- {maleo_metadata_client-0.0.14.dist-info → maleo_metadata_client-0.0.22.dist-info}/WHEEL +0 -0
- {maleo_metadata_client-0.0.14.dist-info → maleo_metadata_client-0.0.22.dist-info}/licenses/LICENSE +0 -0
- {maleo_metadata_client-0.0.14.dist-info → maleo_metadata_client-0.0.22.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from copy import deepcopy
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from typing import Literal, overload
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
from maleo.client.maleo.config import MaleoMetadataClientConfig
|
|
7
|
+
from maleo.client.maleo.service import MaleoClientService
|
|
8
|
+
from maleo.database.enums import Connection
|
|
9
|
+
from maleo.database.utils import build_cache_key
|
|
10
|
+
from maleo.enums.cardinality import Cardinality
|
|
11
|
+
from maleo.enums.connection import Header
|
|
12
|
+
from maleo.logging.enums import Level
|
|
13
|
+
from maleo.metadata.constants.organization_role import ORGANIZATION_ROLE_RESOURCE
|
|
14
|
+
from maleo.metadata.schemas.organization_role import (
|
|
15
|
+
ReadMultipleParameter,
|
|
16
|
+
ReadSingleParameter,
|
|
17
|
+
StandardOrganizationRoleSchema,
|
|
18
|
+
FullOrganizationRoleSchema,
|
|
19
|
+
)
|
|
20
|
+
from maleo.metadata.enums.organization_role import Granularity, IdentifierType
|
|
21
|
+
from maleo.metadata.utils.organization_role import get_schema_model
|
|
22
|
+
from maleo.schemas.connection import ConnectionContext
|
|
23
|
+
from maleo.schemas.exception.factory import Factory as MaleoExceptionFactory
|
|
24
|
+
from maleo.schemas.operation.action.resource import ReadResourceOperationAction
|
|
25
|
+
from maleo.schemas.operation.enums import OperationType, Target
|
|
26
|
+
from maleo.schemas.operation.mixins import Timestamp
|
|
27
|
+
from maleo.schemas.operation.resource import (
|
|
28
|
+
ReadMultipleResourceOperation,
|
|
29
|
+
ReadSingleResourceOperation,
|
|
30
|
+
)
|
|
31
|
+
from maleo.schemas.pagination import StrictPagination
|
|
32
|
+
from maleo.schemas.response import (
|
|
33
|
+
MultipleDataResponse,
|
|
34
|
+
ReadMultipleDataResponse,
|
|
35
|
+
SingleDataResponse,
|
|
36
|
+
ReadSingleDataResponse,
|
|
37
|
+
)
|
|
38
|
+
from maleo.schemas.security.authorization import (
|
|
39
|
+
OptAnyAuthorization,
|
|
40
|
+
AnyAuthorization,
|
|
41
|
+
Factory as AuthorizationFactory,
|
|
42
|
+
)
|
|
43
|
+
from maleo.schemas.security.impersonation import OptImpersonation
|
|
44
|
+
from maleo.types.dict import OptStrToStrDict
|
|
45
|
+
from maleo.utils.merger import merge_dicts
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class OrganizationRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
49
|
+
resource = ORGANIZATION_ROLE_RESOURCE
|
|
50
|
+
|
|
51
|
+
@overload
|
|
52
|
+
async def read(
|
|
53
|
+
self,
|
|
54
|
+
cardinality: Literal[Cardinality.MULTIPLE],
|
|
55
|
+
granularity: Literal[Granularity.STANDARD],
|
|
56
|
+
*,
|
|
57
|
+
operation_id: UUID,
|
|
58
|
+
resource_operation_action: ReadResourceOperationAction,
|
|
59
|
+
connection_context: ConnectionContext,
|
|
60
|
+
authorization: AnyAuthorization,
|
|
61
|
+
impersonation: OptImpersonation = None,
|
|
62
|
+
parameters: ReadMultipleParameter,
|
|
63
|
+
headers: OptStrToStrDict = None,
|
|
64
|
+
) -> ReadMultipleDataResponse[StandardOrganizationRoleSchema, StrictPagination, None]: ...
|
|
65
|
+
@overload
|
|
66
|
+
async def read(
|
|
67
|
+
self,
|
|
68
|
+
cardinality: Literal[Cardinality.MULTIPLE],
|
|
69
|
+
granularity: Literal[Granularity.FULL],
|
|
70
|
+
*,
|
|
71
|
+
operation_id: UUID,
|
|
72
|
+
resource_operation_action: ReadResourceOperationAction,
|
|
73
|
+
connection_context: ConnectionContext,
|
|
74
|
+
authorization: AnyAuthorization,
|
|
75
|
+
impersonation: OptImpersonation = None,
|
|
76
|
+
parameters: ReadMultipleParameter,
|
|
77
|
+
headers: OptStrToStrDict = None,
|
|
78
|
+
) -> ReadMultipleDataResponse[FullOrganizationRoleSchema, StrictPagination, None]: ...
|
|
79
|
+
@overload
|
|
80
|
+
async def read(
|
|
81
|
+
self,
|
|
82
|
+
cardinality: Literal[Cardinality.SINGLE],
|
|
83
|
+
granularity: Literal[Granularity.STANDARD],
|
|
84
|
+
*,
|
|
85
|
+
operation_id: UUID,
|
|
86
|
+
resource_operation_action: ReadResourceOperationAction,
|
|
87
|
+
connection_context: ConnectionContext,
|
|
88
|
+
authorization: AnyAuthorization,
|
|
89
|
+
impersonation: OptImpersonation = None,
|
|
90
|
+
parameters: ReadSingleParameter,
|
|
91
|
+
headers: OptStrToStrDict = None,
|
|
92
|
+
) -> ReadSingleDataResponse[StandardOrganizationRoleSchema, None]: ...
|
|
93
|
+
@overload
|
|
94
|
+
async def read(
|
|
95
|
+
self,
|
|
96
|
+
cardinality: Literal[Cardinality.SINGLE],
|
|
97
|
+
granularity: Literal[Granularity.FULL],
|
|
98
|
+
*,
|
|
99
|
+
operation_id: UUID,
|
|
100
|
+
resource_operation_action: ReadResourceOperationAction,
|
|
101
|
+
connection_context: ConnectionContext,
|
|
102
|
+
authorization: AnyAuthorization,
|
|
103
|
+
impersonation: OptImpersonation = None,
|
|
104
|
+
parameters: ReadSingleParameter,
|
|
105
|
+
headers: OptStrToStrDict = None,
|
|
106
|
+
) -> ReadSingleDataResponse[FullOrganizationRoleSchema, None]: ...
|
|
107
|
+
async def read(
|
|
108
|
+
self,
|
|
109
|
+
cardinality: Cardinality,
|
|
110
|
+
granularity: Granularity,
|
|
111
|
+
*,
|
|
112
|
+
operation_id: UUID,
|
|
113
|
+
resource_operation_action: ReadResourceOperationAction,
|
|
114
|
+
connection_context: ConnectionContext,
|
|
115
|
+
authorization: OptAnyAuthorization = None,
|
|
116
|
+
impersonation: OptImpersonation = None,
|
|
117
|
+
parameters: ReadMultipleParameter | ReadSingleParameter,
|
|
118
|
+
headers: OptStrToStrDict = None,
|
|
119
|
+
) -> (
|
|
120
|
+
ReadMultipleDataResponse[StandardOrganizationRoleSchema, StrictPagination, None]
|
|
121
|
+
| ReadMultipleDataResponse[FullOrganizationRoleSchema, StrictPagination, None]
|
|
122
|
+
| ReadSingleDataResponse[StandardOrganizationRoleSchema, None]
|
|
123
|
+
| ReadSingleDataResponse[FullOrganizationRoleSchema, None]
|
|
124
|
+
):
|
|
125
|
+
redis_client = self._redis.manager.client.get(Connection.ASYNC)
|
|
126
|
+
data_model_cls = get_schema_model(granularity)
|
|
127
|
+
|
|
128
|
+
executed_at = datetime.now(tz=timezone.utc)
|
|
129
|
+
|
|
130
|
+
# Define arguments being used in this function
|
|
131
|
+
positional_arguments = [cardinality, granularity]
|
|
132
|
+
keyword_arguments = {
|
|
133
|
+
"authorization": (
|
|
134
|
+
authorization.model_dump(mode="json")
|
|
135
|
+
if authorization is not None
|
|
136
|
+
else None
|
|
137
|
+
),
|
|
138
|
+
"parameters": parameters.model_dump(mode="json"),
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# Define full function string
|
|
142
|
+
ext = f"({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
143
|
+
|
|
144
|
+
# Define full cache_key
|
|
145
|
+
cache_key = build_cache_key(ext, namespace=self._namespace)
|
|
146
|
+
|
|
147
|
+
if parameters.use_cache:
|
|
148
|
+
# Initialize cache operation context
|
|
149
|
+
operation_context = deepcopy(self._operation_context)
|
|
150
|
+
operation_context.target.type = Target.CACHE
|
|
151
|
+
|
|
152
|
+
redis_response_str = await redis_client.get(cache_key)
|
|
153
|
+
|
|
154
|
+
if redis_response_str is not None:
|
|
155
|
+
operation_timestamp = Timestamp.completed_now(executed_at)
|
|
156
|
+
if cardinality is Cardinality.MULTIPLE:
|
|
157
|
+
response = ReadMultipleDataResponse[
|
|
158
|
+
data_model_cls, StrictPagination, None
|
|
159
|
+
].model_validate_json(redis_response_str)
|
|
160
|
+
ReadMultipleResourceOperation[
|
|
161
|
+
data_model_cls, StrictPagination, None
|
|
162
|
+
](
|
|
163
|
+
application_context=self._application_context,
|
|
164
|
+
id=operation_id,
|
|
165
|
+
context=operation_context,
|
|
166
|
+
action=resource_operation_action,
|
|
167
|
+
resource=self.resource,
|
|
168
|
+
timestamp=operation_timestamp,
|
|
169
|
+
summary=f"Successfully retrieved {cardinality} {granularity} organization roles from cache",
|
|
170
|
+
connection_context=connection_context,
|
|
171
|
+
authentication=None,
|
|
172
|
+
authorization=authorization,
|
|
173
|
+
impersonation=impersonation,
|
|
174
|
+
response=response,
|
|
175
|
+
).log(
|
|
176
|
+
self._logger, Level.INFO
|
|
177
|
+
)
|
|
178
|
+
elif cardinality is Cardinality.SINGLE:
|
|
179
|
+
response = ReadSingleDataResponse[
|
|
180
|
+
data_model_cls, None
|
|
181
|
+
].model_validate_json(redis_response_str)
|
|
182
|
+
ReadSingleResourceOperation[data_model_cls, None](
|
|
183
|
+
application_context=self._application_context,
|
|
184
|
+
id=operation_id,
|
|
185
|
+
context=operation_context,
|
|
186
|
+
action=resource_operation_action,
|
|
187
|
+
resource=self.resource,
|
|
188
|
+
timestamp=operation_timestamp,
|
|
189
|
+
summary=f"Successfully retrieved {cardinality} {granularity} organization role from cache",
|
|
190
|
+
connection_context=connection_context,
|
|
191
|
+
authentication=None,
|
|
192
|
+
authorization=authorization,
|
|
193
|
+
impersonation=impersonation,
|
|
194
|
+
response=response,
|
|
195
|
+
).log(self._logger, Level.INFO)
|
|
196
|
+
|
|
197
|
+
return response # type: ignore
|
|
198
|
+
|
|
199
|
+
operation_context = deepcopy(self._operation_context)
|
|
200
|
+
operation_context.target.type = Target.MICROSERVICE
|
|
201
|
+
|
|
202
|
+
async with self._http_client_manager.get() as http_client:
|
|
203
|
+
base_headers = {
|
|
204
|
+
Header.CONTENT_TYPE.value: "application/json",
|
|
205
|
+
Header.X_OPERATION_ID.value: str(operation_id),
|
|
206
|
+
}
|
|
207
|
+
if impersonation is not None:
|
|
208
|
+
base_headers[Header.X_USER_ID.value] = str(impersonation.user_id)
|
|
209
|
+
if impersonation.organization_id is not None:
|
|
210
|
+
base_headers[Header.X_ORGANIZATION_ID.value] = str(
|
|
211
|
+
impersonation.organization_id
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
if headers is not None:
|
|
215
|
+
headers = merge_dicts(base_headers, headers)
|
|
216
|
+
else:
|
|
217
|
+
headers = base_headers
|
|
218
|
+
|
|
219
|
+
if authorization is not None:
|
|
220
|
+
auth = AuthorizationFactory.httpx_auth(
|
|
221
|
+
scheme=authorization.scheme, authorization=authorization.credentials
|
|
222
|
+
)
|
|
223
|
+
else:
|
|
224
|
+
auth = None
|
|
225
|
+
|
|
226
|
+
if isinstance(parameters, ReadMultipleParameter):
|
|
227
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/"
|
|
228
|
+
elif isinstance(parameters, ReadSingleParameter):
|
|
229
|
+
if parameters.identifier_type is IdentifierType.ID:
|
|
230
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_value}"
|
|
231
|
+
else:
|
|
232
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_type}/{parameters.identifier_value}"
|
|
233
|
+
|
|
234
|
+
params = parameters.to_query_params()
|
|
235
|
+
|
|
236
|
+
response = await http_client.get(
|
|
237
|
+
url, params=params, headers=headers, auth=auth
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
operation_timestamp = Timestamp.completed_now(executed_at)
|
|
241
|
+
|
|
242
|
+
if response.is_error:
|
|
243
|
+
raise MaleoExceptionFactory.from_httpx(
|
|
244
|
+
response,
|
|
245
|
+
operation_type=OperationType.REQUEST,
|
|
246
|
+
application_context=self._application_context,
|
|
247
|
+
operation_id=operation_id,
|
|
248
|
+
operation_context=operation_context,
|
|
249
|
+
operation_action=resource_operation_action,
|
|
250
|
+
operation_timestamp=operation_timestamp,
|
|
251
|
+
connection_context=connection_context,
|
|
252
|
+
authentication=None,
|
|
253
|
+
authorization=authorization,
|
|
254
|
+
impersonation=impersonation,
|
|
255
|
+
logger=self._logger,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
if isinstance(parameters, ReadMultipleParameter):
|
|
259
|
+
validated_response = MultipleDataResponse[
|
|
260
|
+
data_model_cls, StrictPagination, None
|
|
261
|
+
].model_validate(response.json())
|
|
262
|
+
service_response = ReadMultipleDataResponse[
|
|
263
|
+
data_model_cls, StrictPagination, None
|
|
264
|
+
].new(
|
|
265
|
+
data=validated_response.data,
|
|
266
|
+
pagination=validated_response.pagination,
|
|
267
|
+
)
|
|
268
|
+
ReadMultipleResourceOperation[data_model_cls, StrictPagination, None](
|
|
269
|
+
application_context=self._application_context,
|
|
270
|
+
id=operation_id,
|
|
271
|
+
context=operation_context,
|
|
272
|
+
action=resource_operation_action,
|
|
273
|
+
resource=ORGANIZATION_ROLE_RESOURCE,
|
|
274
|
+
timestamp=operation_timestamp,
|
|
275
|
+
summary=f"Successfully retrieved multiple {granularity} organization roles from microservice",
|
|
276
|
+
connection_context=connection_context,
|
|
277
|
+
authentication=None,
|
|
278
|
+
authorization=authorization,
|
|
279
|
+
impersonation=impersonation,
|
|
280
|
+
response=service_response,
|
|
281
|
+
).log(self._logger, Level.INFO)
|
|
282
|
+
elif isinstance(parameters, ReadSingleParameter):
|
|
283
|
+
validated_response = SingleDataResponse[
|
|
284
|
+
data_model_cls, None
|
|
285
|
+
].model_validate(response.json())
|
|
286
|
+
service_response = ReadSingleDataResponse[data_model_cls, None].new(
|
|
287
|
+
data=validated_response.data,
|
|
288
|
+
)
|
|
289
|
+
ReadSingleResourceOperation[data_model_cls, None](
|
|
290
|
+
application_context=self._application_context,
|
|
291
|
+
id=operation_id,
|
|
292
|
+
context=operation_context,
|
|
293
|
+
action=resource_operation_action,
|
|
294
|
+
resource=ORGANIZATION_ROLE_RESOURCE,
|
|
295
|
+
timestamp=operation_timestamp,
|
|
296
|
+
summary=f"Successfully retrieved single {granularity} organization role from microservice",
|
|
297
|
+
connection_context=connection_context,
|
|
298
|
+
authentication=None,
|
|
299
|
+
authorization=authorization,
|
|
300
|
+
impersonation=impersonation,
|
|
301
|
+
response=service_response,
|
|
302
|
+
).log(self._logger, Level.INFO)
|
|
303
|
+
|
|
304
|
+
return service_response # type: ignore
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from copy import deepcopy
|
|
3
3
|
from datetime import datetime, timezone
|
|
4
|
-
from typing import Literal,
|
|
4
|
+
from typing import Literal, overload
|
|
5
5
|
from uuid import UUID
|
|
6
6
|
from maleo.client.maleo.config import MaleoMetadataClientConfig
|
|
7
7
|
from maleo.client.maleo.service import MaleoClientService
|
|
@@ -36,12 +36,12 @@ from maleo.schemas.response import (
|
|
|
36
36
|
ReadSingleDataResponse,
|
|
37
37
|
)
|
|
38
38
|
from maleo.schemas.security.authorization import (
|
|
39
|
-
|
|
39
|
+
OptAnyAuthorization,
|
|
40
40
|
AnyAuthorization,
|
|
41
41
|
Factory as AuthorizationFactory,
|
|
42
42
|
)
|
|
43
|
-
from maleo.schemas.security.impersonation import
|
|
44
|
-
from maleo.types.dict import
|
|
43
|
+
from maleo.schemas.security.impersonation import OptImpersonation
|
|
44
|
+
from maleo.types.dict import OptStrToStrDict
|
|
45
45
|
from maleo.utils.merger import merge_dicts
|
|
46
46
|
|
|
47
47
|
|
|
@@ -58,9 +58,9 @@ class OrganizationTypeClientService(MaleoClientService[MaleoMetadataClientConfig
|
|
|
58
58
|
resource_operation_action: ReadResourceOperationAction,
|
|
59
59
|
connection_context: ConnectionContext,
|
|
60
60
|
authorization: AnyAuthorization,
|
|
61
|
-
impersonation:
|
|
61
|
+
impersonation: OptImpersonation = None,
|
|
62
62
|
parameters: ReadMultipleParameter,
|
|
63
|
-
headers:
|
|
63
|
+
headers: OptStrToStrDict = None,
|
|
64
64
|
) -> ReadMultipleDataResponse[
|
|
65
65
|
StandardOrganizationTypeSchema, StrictPagination, None
|
|
66
66
|
]: ...
|
|
@@ -74,9 +74,9 @@ class OrganizationTypeClientService(MaleoClientService[MaleoMetadataClientConfig
|
|
|
74
74
|
resource_operation_action: ReadResourceOperationAction,
|
|
75
75
|
connection_context: ConnectionContext,
|
|
76
76
|
authorization: AnyAuthorization,
|
|
77
|
-
impersonation:
|
|
77
|
+
impersonation: OptImpersonation = None,
|
|
78
78
|
parameters: ReadMultipleParameter,
|
|
79
|
-
headers:
|
|
79
|
+
headers: OptStrToStrDict = None,
|
|
80
80
|
) -> ReadMultipleDataResponse[
|
|
81
81
|
FullOrganizationTypeSchema, StrictPagination, None
|
|
82
82
|
]: ...
|
|
@@ -90,9 +90,9 @@ class OrganizationTypeClientService(MaleoClientService[MaleoMetadataClientConfig
|
|
|
90
90
|
resource_operation_action: ReadResourceOperationAction,
|
|
91
91
|
connection_context: ConnectionContext,
|
|
92
92
|
authorization: AnyAuthorization,
|
|
93
|
-
impersonation:
|
|
93
|
+
impersonation: OptImpersonation = None,
|
|
94
94
|
parameters: ReadSingleParameter,
|
|
95
|
-
headers:
|
|
95
|
+
headers: OptStrToStrDict = None,
|
|
96
96
|
) -> ReadSingleDataResponse[StandardOrganizationTypeSchema, None]: ...
|
|
97
97
|
@overload
|
|
98
98
|
async def read(
|
|
@@ -104,9 +104,9 @@ class OrganizationTypeClientService(MaleoClientService[MaleoMetadataClientConfig
|
|
|
104
104
|
resource_operation_action: ReadResourceOperationAction,
|
|
105
105
|
connection_context: ConnectionContext,
|
|
106
106
|
authorization: AnyAuthorization,
|
|
107
|
-
impersonation:
|
|
107
|
+
impersonation: OptImpersonation = None,
|
|
108
108
|
parameters: ReadSingleParameter,
|
|
109
|
-
headers:
|
|
109
|
+
headers: OptStrToStrDict = None,
|
|
110
110
|
) -> ReadSingleDataResponse[FullOrganizationTypeSchema, None]: ...
|
|
111
111
|
async def read(
|
|
112
112
|
self,
|
|
@@ -116,18 +116,16 @@ class OrganizationTypeClientService(MaleoClientService[MaleoMetadataClientConfig
|
|
|
116
116
|
operation_id: UUID,
|
|
117
117
|
resource_operation_action: ReadResourceOperationAction,
|
|
118
118
|
connection_context: ConnectionContext,
|
|
119
|
-
authorization:
|
|
120
|
-
impersonation:
|
|
121
|
-
parameters:
|
|
122
|
-
headers:
|
|
123
|
-
) ->
|
|
124
|
-
ReadMultipleDataResponse[
|
|
125
|
-
|
|
126
|
-
]
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
ReadSingleDataResponse[FullOrganizationTypeSchema, None],
|
|
130
|
-
]:
|
|
119
|
+
authorization: OptAnyAuthorization = None,
|
|
120
|
+
impersonation: OptImpersonation = None,
|
|
121
|
+
parameters: ReadMultipleParameter | ReadSingleParameter,
|
|
122
|
+
headers: OptStrToStrDict = None,
|
|
123
|
+
) -> (
|
|
124
|
+
ReadMultipleDataResponse[StandardOrganizationTypeSchema, StrictPagination, None]
|
|
125
|
+
| ReadMultipleDataResponse[FullOrganizationTypeSchema, StrictPagination, None]
|
|
126
|
+
| ReadSingleDataResponse[StandardOrganizationTypeSchema, None]
|
|
127
|
+
| ReadSingleDataResponse[FullOrganizationTypeSchema, None]
|
|
128
|
+
):
|
|
131
129
|
redis_client = self._redis.manager.client.get(Connection.ASYNC)
|
|
132
130
|
data_model_cls = get_schema_model(granularity)
|
|
133
131
|
|
|
@@ -232,10 +230,10 @@ class OrganizationTypeClientService(MaleoClientService[MaleoMetadataClientConfig
|
|
|
232
230
|
if isinstance(parameters, ReadMultipleParameter):
|
|
233
231
|
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/"
|
|
234
232
|
elif isinstance(parameters, ReadSingleParameter):
|
|
235
|
-
if parameters.
|
|
236
|
-
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.
|
|
233
|
+
if parameters.identifier_type is IdentifierType.ID:
|
|
234
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_value}"
|
|
237
235
|
else:
|
|
238
|
-
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.
|
|
236
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_type}/{parameters.identifier_value}"
|
|
239
237
|
|
|
240
238
|
params = parameters.to_query_params()
|
|
241
239
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from copy import deepcopy
|
|
3
3
|
from datetime import datetime, timezone
|
|
4
|
-
from typing import Literal,
|
|
4
|
+
from typing import Literal, overload
|
|
5
5
|
from uuid import UUID
|
|
6
6
|
from maleo.client.maleo.config import MaleoMetadataClientConfig
|
|
7
7
|
from maleo.client.maleo.service import MaleoClientService
|
|
@@ -36,12 +36,12 @@ from maleo.schemas.response import (
|
|
|
36
36
|
ReadSingleDataResponse,
|
|
37
37
|
)
|
|
38
38
|
from maleo.schemas.security.authorization import (
|
|
39
|
-
|
|
39
|
+
OptAnyAuthorization,
|
|
40
40
|
AnyAuthorization,
|
|
41
41
|
Factory as AuthorizationFactory,
|
|
42
42
|
)
|
|
43
|
-
from maleo.schemas.security.impersonation import
|
|
44
|
-
from maleo.types.dict import
|
|
43
|
+
from maleo.schemas.security.impersonation import OptImpersonation
|
|
44
|
+
from maleo.types.dict import OptStrToStrDict
|
|
45
45
|
from maleo.utils.merger import merge_dicts
|
|
46
46
|
|
|
47
47
|
|
|
@@ -58,9 +58,9 @@ class ServiceClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
58
58
|
resource_operation_action: ReadResourceOperationAction,
|
|
59
59
|
connection_context: ConnectionContext,
|
|
60
60
|
authorization: AnyAuthorization,
|
|
61
|
-
impersonation:
|
|
61
|
+
impersonation: OptImpersonation = None,
|
|
62
62
|
parameters: ReadMultipleParameter,
|
|
63
|
-
headers:
|
|
63
|
+
headers: OptStrToStrDict = None,
|
|
64
64
|
) -> ReadMultipleDataResponse[StandardServiceSchema, StrictPagination, None]: ...
|
|
65
65
|
@overload
|
|
66
66
|
async def read(
|
|
@@ -72,9 +72,9 @@ class ServiceClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
72
72
|
resource_operation_action: ReadResourceOperationAction,
|
|
73
73
|
connection_context: ConnectionContext,
|
|
74
74
|
authorization: AnyAuthorization,
|
|
75
|
-
impersonation:
|
|
75
|
+
impersonation: OptImpersonation = None,
|
|
76
76
|
parameters: ReadMultipleParameter,
|
|
77
|
-
headers:
|
|
77
|
+
headers: OptStrToStrDict = None,
|
|
78
78
|
) -> ReadMultipleDataResponse[FullServiceSchema, StrictPagination, None]: ...
|
|
79
79
|
@overload
|
|
80
80
|
async def read(
|
|
@@ -86,9 +86,9 @@ class ServiceClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
86
86
|
resource_operation_action: ReadResourceOperationAction,
|
|
87
87
|
connection_context: ConnectionContext,
|
|
88
88
|
authorization: AnyAuthorization,
|
|
89
|
-
impersonation:
|
|
89
|
+
impersonation: OptImpersonation = None,
|
|
90
90
|
parameters: ReadSingleParameter,
|
|
91
|
-
headers:
|
|
91
|
+
headers: OptStrToStrDict = None,
|
|
92
92
|
) -> ReadSingleDataResponse[StandardServiceSchema, None]: ...
|
|
93
93
|
@overload
|
|
94
94
|
async def read(
|
|
@@ -100,9 +100,9 @@ class ServiceClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
100
100
|
resource_operation_action: ReadResourceOperationAction,
|
|
101
101
|
connection_context: ConnectionContext,
|
|
102
102
|
authorization: AnyAuthorization,
|
|
103
|
-
impersonation:
|
|
103
|
+
impersonation: OptImpersonation = None,
|
|
104
104
|
parameters: ReadSingleParameter,
|
|
105
|
-
headers:
|
|
105
|
+
headers: OptStrToStrDict = None,
|
|
106
106
|
) -> ReadSingleDataResponse[FullServiceSchema, None]: ...
|
|
107
107
|
async def read(
|
|
108
108
|
self,
|
|
@@ -112,16 +112,16 @@ class ServiceClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
112
112
|
operation_id: UUID,
|
|
113
113
|
resource_operation_action: ReadResourceOperationAction,
|
|
114
114
|
connection_context: ConnectionContext,
|
|
115
|
-
authorization:
|
|
116
|
-
impersonation:
|
|
117
|
-
parameters:
|
|
118
|
-
headers:
|
|
119
|
-
) ->
|
|
120
|
-
ReadMultipleDataResponse[StandardServiceSchema, StrictPagination, None]
|
|
121
|
-
ReadMultipleDataResponse[FullServiceSchema, StrictPagination, None]
|
|
122
|
-
ReadSingleDataResponse[StandardServiceSchema, None]
|
|
123
|
-
ReadSingleDataResponse[FullServiceSchema, None]
|
|
124
|
-
|
|
115
|
+
authorization: OptAnyAuthorization = None,
|
|
116
|
+
impersonation: OptImpersonation = None,
|
|
117
|
+
parameters: ReadMultipleParameter | ReadSingleParameter,
|
|
118
|
+
headers: OptStrToStrDict = None,
|
|
119
|
+
) -> (
|
|
120
|
+
ReadMultipleDataResponse[StandardServiceSchema, StrictPagination, None]
|
|
121
|
+
| ReadMultipleDataResponse[FullServiceSchema, StrictPagination, None]
|
|
122
|
+
| ReadSingleDataResponse[StandardServiceSchema, None]
|
|
123
|
+
| ReadSingleDataResponse[FullServiceSchema, None]
|
|
124
|
+
):
|
|
125
125
|
redis_client = self._redis.manager.client.get(Connection.ASYNC)
|
|
126
126
|
data_model_cls = get_schema_model(granularity)
|
|
127
127
|
|
|
@@ -226,10 +226,10 @@ class ServiceClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
226
226
|
if isinstance(parameters, ReadMultipleParameter):
|
|
227
227
|
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/"
|
|
228
228
|
elif isinstance(parameters, ReadSingleParameter):
|
|
229
|
-
if parameters.
|
|
230
|
-
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.
|
|
229
|
+
if parameters.identifier_type is IdentifierType.ID:
|
|
230
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_value}"
|
|
231
231
|
else:
|
|
232
|
-
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.
|
|
232
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_type}/{parameters.identifier_value}"
|
|
233
233
|
|
|
234
234
|
params = parameters.to_query_params()
|
|
235
235
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from copy import deepcopy
|
|
3
3
|
from datetime import datetime, timezone
|
|
4
|
-
from typing import Literal,
|
|
4
|
+
from typing import Literal, overload
|
|
5
5
|
from uuid import UUID
|
|
6
6
|
from maleo.client.maleo.config import MaleoMetadataClientConfig
|
|
7
7
|
from maleo.client.maleo.service import MaleoClientService
|
|
@@ -36,12 +36,12 @@ from maleo.schemas.response import (
|
|
|
36
36
|
ReadSingleDataResponse,
|
|
37
37
|
)
|
|
38
38
|
from maleo.schemas.security.authorization import (
|
|
39
|
-
|
|
39
|
+
OptAnyAuthorization,
|
|
40
40
|
AnyAuthorization,
|
|
41
41
|
Factory as AuthorizationFactory,
|
|
42
42
|
)
|
|
43
|
-
from maleo.schemas.security.impersonation import
|
|
44
|
-
from maleo.types.dict import
|
|
43
|
+
from maleo.schemas.security.impersonation import OptImpersonation
|
|
44
|
+
from maleo.types.dict import OptStrToStrDict
|
|
45
45
|
from maleo.utils.merger import merge_dicts
|
|
46
46
|
|
|
47
47
|
|
|
@@ -58,9 +58,9 @@ class SystemRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
58
58
|
resource_operation_action: ReadResourceOperationAction,
|
|
59
59
|
connection_context: ConnectionContext,
|
|
60
60
|
authorization: AnyAuthorization,
|
|
61
|
-
impersonation:
|
|
61
|
+
impersonation: OptImpersonation = None,
|
|
62
62
|
parameters: ReadMultipleParameter,
|
|
63
|
-
headers:
|
|
63
|
+
headers: OptStrToStrDict = None,
|
|
64
64
|
) -> ReadMultipleDataResponse[StandardSystemRoleSchema, StrictPagination, None]: ...
|
|
65
65
|
@overload
|
|
66
66
|
async def read(
|
|
@@ -72,9 +72,9 @@ class SystemRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
72
72
|
resource_operation_action: ReadResourceOperationAction,
|
|
73
73
|
connection_context: ConnectionContext,
|
|
74
74
|
authorization: AnyAuthorization,
|
|
75
|
-
impersonation:
|
|
75
|
+
impersonation: OptImpersonation = None,
|
|
76
76
|
parameters: ReadMultipleParameter,
|
|
77
|
-
headers:
|
|
77
|
+
headers: OptStrToStrDict = None,
|
|
78
78
|
) -> ReadMultipleDataResponse[FullSystemRoleSchema, StrictPagination, None]: ...
|
|
79
79
|
@overload
|
|
80
80
|
async def read(
|
|
@@ -86,9 +86,9 @@ class SystemRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
86
86
|
resource_operation_action: ReadResourceOperationAction,
|
|
87
87
|
connection_context: ConnectionContext,
|
|
88
88
|
authorization: AnyAuthorization,
|
|
89
|
-
impersonation:
|
|
89
|
+
impersonation: OptImpersonation = None,
|
|
90
90
|
parameters: ReadSingleParameter,
|
|
91
|
-
headers:
|
|
91
|
+
headers: OptStrToStrDict = None,
|
|
92
92
|
) -> ReadSingleDataResponse[StandardSystemRoleSchema, None]: ...
|
|
93
93
|
@overload
|
|
94
94
|
async def read(
|
|
@@ -100,9 +100,9 @@ class SystemRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
100
100
|
resource_operation_action: ReadResourceOperationAction,
|
|
101
101
|
connection_context: ConnectionContext,
|
|
102
102
|
authorization: AnyAuthorization,
|
|
103
|
-
impersonation:
|
|
103
|
+
impersonation: OptImpersonation = None,
|
|
104
104
|
parameters: ReadSingleParameter,
|
|
105
|
-
headers:
|
|
105
|
+
headers: OptStrToStrDict = None,
|
|
106
106
|
) -> ReadSingleDataResponse[FullSystemRoleSchema, None]: ...
|
|
107
107
|
async def read(
|
|
108
108
|
self,
|
|
@@ -112,16 +112,16 @@ class SystemRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
112
112
|
operation_id: UUID,
|
|
113
113
|
resource_operation_action: ReadResourceOperationAction,
|
|
114
114
|
connection_context: ConnectionContext,
|
|
115
|
-
authorization:
|
|
116
|
-
impersonation:
|
|
117
|
-
parameters:
|
|
118
|
-
headers:
|
|
119
|
-
) ->
|
|
120
|
-
ReadMultipleDataResponse[StandardSystemRoleSchema, StrictPagination, None]
|
|
121
|
-
ReadMultipleDataResponse[FullSystemRoleSchema, StrictPagination, None]
|
|
122
|
-
ReadSingleDataResponse[StandardSystemRoleSchema, None]
|
|
123
|
-
ReadSingleDataResponse[FullSystemRoleSchema, None]
|
|
124
|
-
|
|
115
|
+
authorization: OptAnyAuthorization = None,
|
|
116
|
+
impersonation: OptImpersonation = None,
|
|
117
|
+
parameters: ReadMultipleParameter | ReadSingleParameter,
|
|
118
|
+
headers: OptStrToStrDict = None,
|
|
119
|
+
) -> (
|
|
120
|
+
ReadMultipleDataResponse[StandardSystemRoleSchema, StrictPagination, None]
|
|
121
|
+
| ReadMultipleDataResponse[FullSystemRoleSchema, StrictPagination, None]
|
|
122
|
+
| ReadSingleDataResponse[StandardSystemRoleSchema, None]
|
|
123
|
+
| ReadSingleDataResponse[FullSystemRoleSchema, None]
|
|
124
|
+
):
|
|
125
125
|
redis_client = self._redis.manager.client.get(Connection.ASYNC)
|
|
126
126
|
data_model_cls = get_schema_model(granularity)
|
|
127
127
|
|
|
@@ -226,10 +226,10 @@ class SystemRoleClientService(MaleoClientService[MaleoMetadataClientConfig]):
|
|
|
226
226
|
if isinstance(parameters, ReadMultipleParameter):
|
|
227
227
|
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/"
|
|
228
228
|
elif isinstance(parameters, ReadSingleParameter):
|
|
229
|
-
if parameters.
|
|
230
|
-
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.
|
|
229
|
+
if parameters.identifier_type is IdentifierType.ID:
|
|
230
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_value}"
|
|
231
231
|
else:
|
|
232
|
-
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.
|
|
232
|
+
url = f"{self._config.url}/v1/{self.resource.identifiers[-1].slug}/{parameters.identifier_type}/{parameters.identifier_value}"
|
|
233
233
|
|
|
234
234
|
params = parameters.to_query_params()
|
|
235
235
|
|