maleo-metadata-client 0.0.4__py3-none-any.whl → 0.0.5__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 +6 -128
- maleo/metadata/client/services/blood_type.py +279 -305
- maleo_metadata_client-0.0.5.dist-info/METADATA +139 -0
- maleo_metadata_client-0.0.5.dist-info/RECORD +9 -0
- maleo_metadata_client-0.0.5.dist-info/licenses/LICENSE +57 -0
- maleo/metadata/client/services/gender.py +0 -375
- maleo/metadata/client/services/medical_role.py +0 -400
- maleo/metadata/client/services/organization_type.py +0 -380
- maleo/metadata/client/services/service.py +0 -374
- maleo/metadata/client/services/system_role.py +0 -378
- maleo/metadata/client/services/user_type.py +0 -378
- maleo_metadata_client-0.0.4.dist-info/METADATA +0 -39
- maleo_metadata_client-0.0.4.dist-info/RECORD +0 -14
- {maleo_metadata_client-0.0.4.dist-info → maleo_metadata_client-0.0.5.dist-info}/WHEEL +0 -0
- {maleo_metadata_client-0.0.4.dist-info → maleo_metadata_client-0.0.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maleo-metadata-client
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: MaleoMetadata client package
|
|
5
|
+
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: aioredis>=2.0.1
|
|
11
|
+
Requires-Dist: annotated-types>=0.7.0
|
|
12
|
+
Requires-Dist: anyio>=4.11.0
|
|
13
|
+
Requires-Dist: async-timeout>=5.0.1
|
|
14
|
+
Requires-Dist: bcrypt>=5.0.0
|
|
15
|
+
Requires-Dist: black>=25.9.0
|
|
16
|
+
Requires-Dist: cachetools>=6.2.0
|
|
17
|
+
Requires-Dist: certifi>=2025.10.5
|
|
18
|
+
Requires-Dist: cffi>=2.0.0
|
|
19
|
+
Requires-Dist: cfgv>=3.4.0
|
|
20
|
+
Requires-Dist: charset-normalizer>=3.4.3
|
|
21
|
+
Requires-Dist: click>=8.3.0
|
|
22
|
+
Requires-Dist: colorama>=0.4.6
|
|
23
|
+
Requires-Dist: cryptography>=46.0.2
|
|
24
|
+
Requires-Dist: distlib>=0.4.0
|
|
25
|
+
Requires-Dist: dnspython>=2.8.0
|
|
26
|
+
Requires-Dist: elastic-transport>=9.1.0
|
|
27
|
+
Requires-Dist: elasticsearch>=9.1.1
|
|
28
|
+
Requires-Dist: fastapi>=0.118.0
|
|
29
|
+
Requires-Dist: filelock>=3.19.1
|
|
30
|
+
Requires-Dist: google-api-core>=2.25.2
|
|
31
|
+
Requires-Dist: google-auth>=2.41.1
|
|
32
|
+
Requires-Dist: google-cloud-appengine-logging>=1.6.2
|
|
33
|
+
Requires-Dist: google-cloud-audit-log>=0.3.2
|
|
34
|
+
Requires-Dist: google-cloud-core>=2.4.3
|
|
35
|
+
Requires-Dist: google-cloud-logging>=3.12.1
|
|
36
|
+
Requires-Dist: google-cloud-pubsub>=2.31.1
|
|
37
|
+
Requires-Dist: google-cloud-secret-manager>=2.24.0
|
|
38
|
+
Requires-Dist: google-cloud-storage>=3.4.0
|
|
39
|
+
Requires-Dist: google-crc32c>=1.7.1
|
|
40
|
+
Requires-Dist: google-resumable-media>=2.7.2
|
|
41
|
+
Requires-Dist: googleapis-common-protos>=1.70.0
|
|
42
|
+
Requires-Dist: greenlet>=3.2.4
|
|
43
|
+
Requires-Dist: grpc-google-iam-v1>=0.14.2
|
|
44
|
+
Requires-Dist: grpcio>=1.75.1
|
|
45
|
+
Requires-Dist: grpcio-status>=1.75.1
|
|
46
|
+
Requires-Dist: h11>=0.16.0
|
|
47
|
+
Requires-Dist: httpcore>=1.0.9
|
|
48
|
+
Requires-Dist: httpx>=0.28.1
|
|
49
|
+
Requires-Dist: identify>=2.6.15
|
|
50
|
+
Requires-Dist: idna>=3.10
|
|
51
|
+
Requires-Dist: importlib_metadata>=8.7.0
|
|
52
|
+
Requires-Dist: iniconfig>=2.1.0
|
|
53
|
+
Requires-Dist: maleo-crypto>=0.0.17
|
|
54
|
+
Requires-Dist: maleo-database>=0.0.85
|
|
55
|
+
Requires-Dist: maleo-enums>=0.0.27
|
|
56
|
+
Requires-Dist: maleo-google>=0.0.71
|
|
57
|
+
Requires-Dist: maleo-infra>=0.0.85
|
|
58
|
+
Requires-Dist: maleo-logging>=0.0.27
|
|
59
|
+
Requires-Dist: maleo-managers>=0.0.65
|
|
60
|
+
Requires-Dist: maleo-metadata>=0.2.99
|
|
61
|
+
Requires-Dist: maleo-middlewares>=0.0.71
|
|
62
|
+
Requires-Dist: maleo-schemas>=0.1.1
|
|
63
|
+
Requires-Dist: maleo-types>=0.0.7
|
|
64
|
+
Requires-Dist: maleo-utils>=0.0.27
|
|
65
|
+
Requires-Dist: motor>=3.7.1
|
|
66
|
+
Requires-Dist: mypy_extensions>=1.1.0
|
|
67
|
+
Requires-Dist: nodeenv>=1.9.1
|
|
68
|
+
Requires-Dist: opentelemetry-api>=1.37.0
|
|
69
|
+
Requires-Dist: opentelemetry-sdk>=1.37.0
|
|
70
|
+
Requires-Dist: opentelemetry-semantic-conventions>=0.58b0
|
|
71
|
+
Requires-Dist: packaging>=25.0
|
|
72
|
+
Requires-Dist: pathspec>=0.12.1
|
|
73
|
+
Requires-Dist: platformdirs>=4.4.0
|
|
74
|
+
Requires-Dist: pluggy>=1.6.0
|
|
75
|
+
Requires-Dist: pre_commit>=4.3.0
|
|
76
|
+
Requires-Dist: proto-plus>=1.26.1
|
|
77
|
+
Requires-Dist: protobuf>=6.32.1
|
|
78
|
+
Requires-Dist: psutil>=7.1.0
|
|
79
|
+
Requires-Dist: pyasn1>=0.6.1
|
|
80
|
+
Requires-Dist: pyasn1_modules>=0.4.2
|
|
81
|
+
Requires-Dist: pycparser>=2.23
|
|
82
|
+
Requires-Dist: pycryptodome>=3.23.0
|
|
83
|
+
Requires-Dist: pydantic>=2.11.10
|
|
84
|
+
Requires-Dist: pydantic-settings>=2.11.0
|
|
85
|
+
Requires-Dist: pydantic_core>=2.33.2
|
|
86
|
+
Requires-Dist: Pygments>=2.19.2
|
|
87
|
+
Requires-Dist: PyJWT>=2.10.1
|
|
88
|
+
Requires-Dist: pymongo>=4.15.2
|
|
89
|
+
Requires-Dist: pytest>=8.4.2
|
|
90
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
91
|
+
Requires-Dist: python-dotenv>=1.1.1
|
|
92
|
+
Requires-Dist: pytokens>=0.1.10
|
|
93
|
+
Requires-Dist: PyYAML>=6.0.3
|
|
94
|
+
Requires-Dist: redis>=6.4.0
|
|
95
|
+
Requires-Dist: requests>=2.32.5
|
|
96
|
+
Requires-Dist: rsa>=4.9.1
|
|
97
|
+
Requires-Dist: six>=1.17.0
|
|
98
|
+
Requires-Dist: sniffio>=1.3.1
|
|
99
|
+
Requires-Dist: SQLAlchemy>=2.0.43
|
|
100
|
+
Requires-Dist: starlette>=0.48.0
|
|
101
|
+
Requires-Dist: typing-inspection>=0.4.2
|
|
102
|
+
Requires-Dist: typing_extensions>=4.15.0
|
|
103
|
+
Requires-Dist: ua-parser>=1.0.1
|
|
104
|
+
Requires-Dist: ua-parser-builtins>=0.18.0.post1
|
|
105
|
+
Requires-Dist: urllib3>=2.5.0
|
|
106
|
+
Requires-Dist: user-agents>=2.2.0
|
|
107
|
+
Requires-Dist: virtualenv>=20.34.0
|
|
108
|
+
Requires-Dist: zipp>=3.23.0
|
|
109
|
+
Dynamic: license-file
|
|
110
|
+
|
|
111
|
+
# README #
|
|
112
|
+
|
|
113
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
114
|
+
|
|
115
|
+
### What is this repository for? ###
|
|
116
|
+
|
|
117
|
+
* Quick summary
|
|
118
|
+
* Version
|
|
119
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
120
|
+
|
|
121
|
+
### How do I get set up? ###
|
|
122
|
+
|
|
123
|
+
* Summary of set up
|
|
124
|
+
* Configuration
|
|
125
|
+
* Dependencies
|
|
126
|
+
* Database configuration
|
|
127
|
+
* How to run tests
|
|
128
|
+
* Deployment instructions
|
|
129
|
+
|
|
130
|
+
### Contribution guidelines ###
|
|
131
|
+
|
|
132
|
+
* Writing tests
|
|
133
|
+
* Code review
|
|
134
|
+
* Other guidelines
|
|
135
|
+
|
|
136
|
+
### Who do I talk to? ###
|
|
137
|
+
|
|
138
|
+
* Repo owner or admin
|
|
139
|
+
* Other community or team contact
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
maleo/metadata/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
maleo/metadata/client/manager.py,sha256=KAkjNC0ds8bCVB6KxB24iR0oDXywmjvFT7Ti-6wvy1s,623
|
|
3
|
+
maleo/metadata/client/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
maleo/metadata/client/services/blood_type.py,sha256=-6Km5e1r2lnClCoOpU9K1va9R_Jsxl8s88HbltNNPnQ,15423
|
|
5
|
+
maleo_metadata_client-0.0.5.dist-info/licenses/LICENSE,sha256=aftGsecnk7TWVX-7KW94FqK4Syy6YSZ8PZEF7EcIp3M,2621
|
|
6
|
+
maleo_metadata_client-0.0.5.dist-info/METADATA,sha256=bJgm7RLDdwAMNZjKmIZTLwTc7QS8heU524lqMYnR20M,4305
|
|
7
|
+
maleo_metadata_client-0.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
maleo_metadata_client-0.0.5.dist-info/top_level.txt,sha256=3Tpd1siVsfYoeI9FEOJNYnffx_shzZ3wsPpTvz5bljc,6
|
|
9
|
+
maleo_metadata_client-0.0.5.dist-info/RECORD,,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Proprietary Software License
|
|
2
|
+
|
|
3
|
+
**Copyright (c) 2025 Agra Bima Yuda / Nexmedis**
|
|
4
|
+
|
|
5
|
+
## License Grant
|
|
6
|
+
|
|
7
|
+
This software and associated documentation files (the "Software") are proprietary and confidential to Agra Bima Yuda and/or Nexmedis ("Licensor"). All rights reserved.
|
|
8
|
+
|
|
9
|
+
## Restrictions
|
|
10
|
+
|
|
11
|
+
**NO PERMISSION** is granted to any person to:
|
|
12
|
+
|
|
13
|
+
1. **Use** the Software for any purpose without explicit written permission from the Licensor
|
|
14
|
+
2. **Copy, modify, merge, publish, distribute, sublicense, or sell** copies of the Software
|
|
15
|
+
3. **Reverse engineer, decompile, or disassemble** the Software
|
|
16
|
+
4. **Create derivative works** based upon the Software
|
|
17
|
+
5. **Remove or alter** any proprietary notices, labels, or marks on the Software
|
|
18
|
+
|
|
19
|
+
## Permitted Use
|
|
20
|
+
|
|
21
|
+
Use of this Software is permitted only under the following conditions:
|
|
22
|
+
|
|
23
|
+
1. **Authorized Users**: Only individuals or entities explicitly authorized by the Licensor in writing
|
|
24
|
+
2. **Internal Use Only**: The Software may only be used for internal business purposes of the authorized entity
|
|
25
|
+
3. **No Redistribution**: The Software may not be shared, distributed, or made available to any third party
|
|
26
|
+
|
|
27
|
+
## Ownership
|
|
28
|
+
|
|
29
|
+
The Software is and remains the exclusive property of the Licensor. This license does not grant any ownership rights in the Software.
|
|
30
|
+
|
|
31
|
+
## Confidentiality
|
|
32
|
+
|
|
33
|
+
The Software contains proprietary and confidential information. Recipients agree to:
|
|
34
|
+
|
|
35
|
+
1. Maintain the confidentiality of the Software
|
|
36
|
+
2. Use the same degree of care to protect the Software as they use for their own confidential information, but no less than reasonable care
|
|
37
|
+
3. Not disclose the Software to any third party without prior written consent
|
|
38
|
+
|
|
39
|
+
## Termination
|
|
40
|
+
|
|
41
|
+
This license is effective until terminated. The Licensor may terminate this license at any time without notice. Upon termination, all rights granted herein cease immediately, and the recipient must destroy all copies of the Software.
|
|
42
|
+
|
|
43
|
+
## Disclaimer of Warranty
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
46
|
+
|
|
47
|
+
## Limitation of Liability
|
|
48
|
+
|
|
49
|
+
IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
50
|
+
|
|
51
|
+
## Governing Law
|
|
52
|
+
|
|
53
|
+
This license shall be governed by and construed in accordance with the laws of Indonesia, without regard to its conflict of law provisions.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
For licensing inquiries, contact: agra@nexmedis.com
|
|
@@ -1,375 +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, Literal, Optional, Union, overload
|
|
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.cardinality import Cardinality
|
|
11
|
-
from maleo.soma.enums.environment import Environment
|
|
12
|
-
from maleo.soma.enums.expiration import Expiration
|
|
13
|
-
from maleo.soma.enums.logging import LogLevel
|
|
14
|
-
from maleo.soma.enums.operation import OperationTarget
|
|
15
|
-
from maleo.soma.managers.client.maleo import MaleoClientService
|
|
16
|
-
from maleo.soma.managers.client.http import HTTPClientManager
|
|
17
|
-
from maleo.soma.managers.credential import CredentialManager
|
|
18
|
-
from maleo.soma.schemas.authentication import OptionalAuthentication
|
|
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 FlexiblePagination
|
|
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.metadata.constants.gender import RESOURCE
|
|
49
|
-
from maleo.metadata.schemas.data.gender import GenderDataSchema
|
|
50
|
-
from maleo.metadata.schemas.parameter.client.gender import (
|
|
51
|
-
ReadMultipleParameter,
|
|
52
|
-
ReadMultipleQueryParameter,
|
|
53
|
-
)
|
|
54
|
-
from maleo.metadata.schemas.parameter.general.gender import ReadSingleParameter
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class GenderClientService(MaleoClientService):
|
|
58
|
-
def __init__(
|
|
59
|
-
self,
|
|
60
|
-
environment: Environment,
|
|
61
|
-
key: str,
|
|
62
|
-
url: str,
|
|
63
|
-
operation_origin: OperationOriginSchema,
|
|
64
|
-
logger: ClientLogger,
|
|
65
|
-
credential_manager: CredentialManager,
|
|
66
|
-
http_client_manager: HTTPClientManager,
|
|
67
|
-
private_key: RsaKey,
|
|
68
|
-
redis: Redis,
|
|
69
|
-
redis_namespaces: RedisCacheNamespaces,
|
|
70
|
-
service_context: ServiceContext,
|
|
71
|
-
):
|
|
72
|
-
super().__init__(
|
|
73
|
-
environment,
|
|
74
|
-
key,
|
|
75
|
-
url,
|
|
76
|
-
operation_origin,
|
|
77
|
-
logger,
|
|
78
|
-
credential_manager,
|
|
79
|
-
http_client_manager,
|
|
80
|
-
private_key,
|
|
81
|
-
redis,
|
|
82
|
-
redis_namespaces,
|
|
83
|
-
service_context,
|
|
84
|
-
)
|
|
85
|
-
self._namespace = self._redis_namespaces.create(
|
|
86
|
-
self._key,
|
|
87
|
-
RESOURCE.aggregate(),
|
|
88
|
-
origin=self._CACHE_ORIGIN,
|
|
89
|
-
layer=self._CACHE_LAYER,
|
|
90
|
-
)
|
|
91
|
-
self._default_operation_context = OperationContextSchema(
|
|
92
|
-
origin=self._operation_origin,
|
|
93
|
-
layer=OperationLayerSchema(type=self._OPERATION_LAYER_TYPE, details=None),
|
|
94
|
-
target=OperationTargetSchema(
|
|
95
|
-
type=self._OPERATION_TARGET_TYPE, details=None
|
|
96
|
-
),
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
@overload
|
|
100
|
-
async def read(
|
|
101
|
-
self,
|
|
102
|
-
cardinality: Literal[Cardinality.MULTIPLE],
|
|
103
|
-
*,
|
|
104
|
-
operation_id: UUID,
|
|
105
|
-
request_context: RequestContext,
|
|
106
|
-
authentication: OptionalAuthentication,
|
|
107
|
-
parameters: ReadMultipleParameter,
|
|
108
|
-
headers: Optional[Dict[str, str]] = None,
|
|
109
|
-
) -> ReadMultipleResourceOperationResult[
|
|
110
|
-
GenderDataSchema, FlexiblePagination, None
|
|
111
|
-
]: ...
|
|
112
|
-
@overload
|
|
113
|
-
async def read(
|
|
114
|
-
self,
|
|
115
|
-
cardinality: Literal[Cardinality.SINGLE],
|
|
116
|
-
*,
|
|
117
|
-
operation_id: UUID,
|
|
118
|
-
request_context: RequestContext,
|
|
119
|
-
authentication: OptionalAuthentication,
|
|
120
|
-
parameters: ReadSingleParameter,
|
|
121
|
-
headers: Optional[Dict[str, str]] = None,
|
|
122
|
-
) -> ReadSingleResourceOperationResult[GenderDataSchema, None]: ...
|
|
123
|
-
async def read(
|
|
124
|
-
self,
|
|
125
|
-
cardinality: Cardinality,
|
|
126
|
-
*,
|
|
127
|
-
operation_id: UUID,
|
|
128
|
-
request_context: RequestContext,
|
|
129
|
-
authentication: OptionalAuthentication,
|
|
130
|
-
parameters: Union[ReadMultipleParameter, ReadSingleParameter],
|
|
131
|
-
headers: Optional[Dict[str, str]] = None,
|
|
132
|
-
) -> Union[
|
|
133
|
-
ReadMultipleResourceOperationResult[GenderDataSchema, FlexiblePagination, None],
|
|
134
|
-
ReadSingleResourceOperationResult[GenderDataSchema, None],
|
|
135
|
-
]:
|
|
136
|
-
operation_action = ReadResourceOperationAction()
|
|
137
|
-
executed_at = datetime.now(tz=timezone.utc)
|
|
138
|
-
|
|
139
|
-
# Get function identifier
|
|
140
|
-
func = self.__class__
|
|
141
|
-
module, qualname = func.__module__, func.__qualname__
|
|
142
|
-
|
|
143
|
-
# Define arguments being used in this function
|
|
144
|
-
positional_arguments = [cardinality]
|
|
145
|
-
keyword_arguments = {
|
|
146
|
-
"authentication": authentication.model_dump(
|
|
147
|
-
mode="json",
|
|
148
|
-
exclude={
|
|
149
|
-
"credentials": {
|
|
150
|
-
"token": {
|
|
151
|
-
"payload": {
|
|
152
|
-
"iat_dt",
|
|
153
|
-
"iat",
|
|
154
|
-
"exp_dt",
|
|
155
|
-
"exp",
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
),
|
|
161
|
-
"parameters": parameters.model_dump(mode="json"),
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
# Define full function string
|
|
165
|
-
function = f"{qualname}({json.dumps(positional_arguments)}|{json.dumps(keyword_arguments)})"
|
|
166
|
-
|
|
167
|
-
# Define full cache key
|
|
168
|
-
cache_key = build_key(module, function, namespace=self._namespace)
|
|
169
|
-
|
|
170
|
-
if parameters.use_cache:
|
|
171
|
-
operation_context = deepcopy(self._default_operation_context)
|
|
172
|
-
operation_context.target.type = OperationTarget.CACHE
|
|
173
|
-
|
|
174
|
-
# Check redis for data
|
|
175
|
-
result_str = await self._redis.get(cache_key)
|
|
176
|
-
|
|
177
|
-
if result_str is not None:
|
|
178
|
-
completed_at = datetime.now(tz=timezone.utc)
|
|
179
|
-
|
|
180
|
-
if isinstance(parameters, ReadMultipleParameter):
|
|
181
|
-
result = ReadMultipleResourceOperationResult[
|
|
182
|
-
GenderDataSchema, FlexiblePagination, None
|
|
183
|
-
].model_validate(json.loads(result_str))
|
|
184
|
-
ReadMultipleResourceOperationSchema[
|
|
185
|
-
OptionalAuthentication,
|
|
186
|
-
GenderDataSchema,
|
|
187
|
-
FlexiblePagination,
|
|
188
|
-
None,
|
|
189
|
-
](
|
|
190
|
-
service_context=self._service_context,
|
|
191
|
-
id=operation_id,
|
|
192
|
-
context=operation_context,
|
|
193
|
-
timestamp=OperationTimestamp(
|
|
194
|
-
executed_at=executed_at,
|
|
195
|
-
completed_at=completed_at,
|
|
196
|
-
duration=(completed_at - executed_at).total_seconds(),
|
|
197
|
-
),
|
|
198
|
-
summary="Successfully retrieved multiple genders from cache",
|
|
199
|
-
request_context=request_context,
|
|
200
|
-
authentication=authentication,
|
|
201
|
-
action=operation_action,
|
|
202
|
-
resource=RESOURCE,
|
|
203
|
-
result=result,
|
|
204
|
-
).log(
|
|
205
|
-
self._logger, LogLevel.INFO
|
|
206
|
-
)
|
|
207
|
-
elif isinstance(parameters, ReadSingleParameter):
|
|
208
|
-
result = ReadSingleResourceOperationResult[
|
|
209
|
-
GenderDataSchema, None
|
|
210
|
-
].model_validate(json.loads(result_str))
|
|
211
|
-
ReadSingleResourceOperationSchema[
|
|
212
|
-
OptionalAuthentication, GenderDataSchema, None
|
|
213
|
-
](
|
|
214
|
-
service_context=self._service_context,
|
|
215
|
-
id=operation_id,
|
|
216
|
-
context=operation_context,
|
|
217
|
-
timestamp=OperationTimestamp(
|
|
218
|
-
executed_at=executed_at,
|
|
219
|
-
completed_at=completed_at,
|
|
220
|
-
duration=(completed_at - executed_at).total_seconds(),
|
|
221
|
-
),
|
|
222
|
-
summary="Successfully retrieved single gender from cache",
|
|
223
|
-
request_context=request_context,
|
|
224
|
-
authentication=authentication,
|
|
225
|
-
action=operation_action,
|
|
226
|
-
resource=RESOURCE,
|
|
227
|
-
result=result,
|
|
228
|
-
).log(
|
|
229
|
-
self._logger, LogLevel.INFO
|
|
230
|
-
)
|
|
231
|
-
return result
|
|
232
|
-
|
|
233
|
-
operation_context = deepcopy(self._default_operation_context)
|
|
234
|
-
async with self._http_client_manager.get() as http_client:
|
|
235
|
-
# Create headers
|
|
236
|
-
base_headers = {
|
|
237
|
-
"content-type": "application/json",
|
|
238
|
-
"x-operation-id": str(operation_id),
|
|
239
|
-
}
|
|
240
|
-
if headers is not None:
|
|
241
|
-
headers = merge_dicts(base_headers, headers)
|
|
242
|
-
else:
|
|
243
|
-
headers = base_headers
|
|
244
|
-
|
|
245
|
-
# Create auth
|
|
246
|
-
token = None
|
|
247
|
-
if authentication.credentials.token is not None:
|
|
248
|
-
try:
|
|
249
|
-
token = reencode(
|
|
250
|
-
payload=authentication.credentials.token.payload,
|
|
251
|
-
key=self._private_key,
|
|
252
|
-
)
|
|
253
|
-
except Exception:
|
|
254
|
-
pass
|
|
255
|
-
|
|
256
|
-
auth = BearerAuth(token) if token is not None else None
|
|
257
|
-
|
|
258
|
-
if isinstance(parameters, ReadMultipleParameter):
|
|
259
|
-
# Define URL
|
|
260
|
-
url = f"{self._url}/v1/{RESOURCE.identifiers[0].url_slug}/"
|
|
261
|
-
|
|
262
|
-
# Parse parameters to query params
|
|
263
|
-
params = ReadMultipleQueryParameter.model_validate(
|
|
264
|
-
parameters.model_dump()
|
|
265
|
-
).model_dump(
|
|
266
|
-
exclude={"sort_columns", "date_filters"}, exclude_none=True
|
|
267
|
-
)
|
|
268
|
-
elif isinstance(parameters, ReadSingleParameter):
|
|
269
|
-
# Define URL
|
|
270
|
-
url = f"{self._url}/v1/{RESOURCE.identifiers[0].url_slug}/{parameters.identifier}/{parameters.value}"
|
|
271
|
-
|
|
272
|
-
# Parse parameters to query params
|
|
273
|
-
params = ReadSingleQueryParameterSchema.model_validate(
|
|
274
|
-
parameters.model_dump()
|
|
275
|
-
).model_dump(exclude_none=True)
|
|
276
|
-
|
|
277
|
-
# Send request and wait for response
|
|
278
|
-
response = await http_client.get(
|
|
279
|
-
url=url, params=params, headers=headers, auth=auth
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
if response.is_success:
|
|
283
|
-
completed_at = datetime.now(tz=timezone.utc)
|
|
284
|
-
|
|
285
|
-
if isinstance(parameters, ReadMultipleParameter):
|
|
286
|
-
validated_response = MultipleDataResponseSchema[
|
|
287
|
-
GenderDataSchema, FlexiblePagination, None
|
|
288
|
-
].model_validate(response.json())
|
|
289
|
-
data = DataPair[List[GenderDataSchema], None](
|
|
290
|
-
old=validated_response.data,
|
|
291
|
-
new=None,
|
|
292
|
-
)
|
|
293
|
-
result = ReadMultipleResourceOperationResult[
|
|
294
|
-
GenderDataSchema, FlexiblePagination, None
|
|
295
|
-
](
|
|
296
|
-
data=data,
|
|
297
|
-
pagination=validated_response.pagination,
|
|
298
|
-
metadata=None,
|
|
299
|
-
other=None,
|
|
300
|
-
)
|
|
301
|
-
ReadMultipleResourceOperationSchema[
|
|
302
|
-
OptionalAuthentication,
|
|
303
|
-
GenderDataSchema,
|
|
304
|
-
FlexiblePagination,
|
|
305
|
-
None,
|
|
306
|
-
](
|
|
307
|
-
service_context=self._service_context,
|
|
308
|
-
id=operation_id,
|
|
309
|
-
context=operation_context,
|
|
310
|
-
timestamp=OperationTimestamp(
|
|
311
|
-
executed_at=executed_at,
|
|
312
|
-
completed_at=completed_at,
|
|
313
|
-
duration=(completed_at - executed_at).total_seconds(),
|
|
314
|
-
),
|
|
315
|
-
summary="Successfully retrieved multiple genders from http request",
|
|
316
|
-
request_context=request_context,
|
|
317
|
-
authentication=authentication,
|
|
318
|
-
action=operation_action,
|
|
319
|
-
resource=RESOURCE,
|
|
320
|
-
result=result,
|
|
321
|
-
).log(
|
|
322
|
-
self._logger, level=LogLevel.INFO
|
|
323
|
-
)
|
|
324
|
-
elif isinstance(parameters, ReadSingleParameter):
|
|
325
|
-
validated_response = SingleDataResponseSchema[
|
|
326
|
-
GenderDataSchema, None
|
|
327
|
-
].model_validate(response.json())
|
|
328
|
-
data = DataPair[GenderDataSchema, None](
|
|
329
|
-
old=validated_response.data,
|
|
330
|
-
new=None,
|
|
331
|
-
)
|
|
332
|
-
result = ReadSingleResourceOperationResult[GenderDataSchema, None](
|
|
333
|
-
data=data,
|
|
334
|
-
pagination=validated_response.pagination,
|
|
335
|
-
metadata=None,
|
|
336
|
-
other=None,
|
|
337
|
-
)
|
|
338
|
-
ReadSingleResourceOperationSchema[
|
|
339
|
-
OptionalAuthentication, GenderDataSchema, None
|
|
340
|
-
](
|
|
341
|
-
service_context=self._service_context,
|
|
342
|
-
id=operation_id,
|
|
343
|
-
context=operation_context,
|
|
344
|
-
timestamp=OperationTimestamp(
|
|
345
|
-
executed_at=executed_at,
|
|
346
|
-
completed_at=completed_at,
|
|
347
|
-
duration=(completed_at - executed_at).total_seconds(),
|
|
348
|
-
),
|
|
349
|
-
summary="Successfully retrieved single gender from http request",
|
|
350
|
-
request_context=request_context,
|
|
351
|
-
authentication=authentication,
|
|
352
|
-
action=operation_action,
|
|
353
|
-
resource=RESOURCE,
|
|
354
|
-
result=result,
|
|
355
|
-
).log(
|
|
356
|
-
self._logger, level=LogLevel.INFO
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
if parameters.use_cache:
|
|
360
|
-
await self._redis.set(
|
|
361
|
-
cache_key, result.model_dump_json(), Expiration.EXP_1MO.value
|
|
362
|
-
)
|
|
363
|
-
|
|
364
|
-
return result
|
|
365
|
-
|
|
366
|
-
self._raise_resource_http_request_error(
|
|
367
|
-
response=response,
|
|
368
|
-
operation_id=operation_id,
|
|
369
|
-
operation_context=operation_context,
|
|
370
|
-
executed_at=executed_at,
|
|
371
|
-
operation_action=operation_action,
|
|
372
|
-
request_context=request_context,
|
|
373
|
-
authentication=authentication,
|
|
374
|
-
resource=RESOURCE,
|
|
375
|
-
)
|