maleo-foundation 0.3.66__tar.gz → 0.3.68__tar.gz

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.
Files changed (150) hide show
  1. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/PKG-INFO +1 -1
  2. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/service.py +9 -0
  3. maleo_foundation-0.3.68/maleo_foundation/models/schemas/general.py +246 -0
  4. maleo_foundation-0.3.68/maleo_foundation/models/transfers/general/operation.py +51 -0
  5. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation.egg-info/PKG-INFO +1 -1
  6. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation.egg-info/SOURCES.txt +1 -0
  7. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/pyproject.toml +1 -1
  8. maleo_foundation-0.3.66/maleo_foundation/models/schemas/general.py +0 -113
  9. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/README.md +0 -0
  10. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/__init__.py +0 -0
  11. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/authentication.py +0 -0
  12. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/authorization.py +0 -0
  13. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/__init__.py +0 -0
  14. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/manager.py +0 -0
  15. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/__init__.py +0 -0
  16. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/encryption/__init__.py +0 -0
  17. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/encryption/aes.py +0 -0
  18. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/encryption/rsa.py +0 -0
  19. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/hash/__init__.py +0 -0
  20. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
  21. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/hash/hmac.py +0 -0
  22. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/hash/sha256.py +0 -0
  23. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/key.py +0 -0
  24. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/signature.py +0 -0
  25. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/client/services/token.py +0 -0
  26. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/constants.py +0 -0
  27. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/enums.py +0 -0
  28. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/__init__.py +0 -0
  29. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/client.py +0 -0
  30. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
  31. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
  32. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
  33. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/general.py +0 -0
  34. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/hash.py +0 -0
  35. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/key.py +0 -0
  36. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/service.py +0 -0
  37. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/signature.py +0 -0
  38. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/expanded_types/token.py +0 -0
  39. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/extended_types.py +0 -0
  40. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/__init__.py +0 -0
  41. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/cache.py +0 -0
  42. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/__init__.py +0 -0
  43. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/base.py +0 -0
  44. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/google/__init__.py +0 -0
  45. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/google/base.py +0 -0
  46. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/google/parameter.py +0 -0
  47. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/google/secret.py +0 -0
  48. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/google/storage.py +0 -0
  49. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/google/subscription.py +0 -0
  50. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/client/maleo.py +0 -0
  51. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/configuration.py +0 -0
  52. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/credential.py +0 -0
  53. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/db.py +0 -0
  54. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/managers/middleware.py +0 -0
  55. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/middlewares/authentication.py +0 -0
  56. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/middlewares/base.py +0 -0
  57. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/middlewares/cors.py +0 -0
  58. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/__init__.py +0 -0
  59. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/responses.py +0 -0
  60. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/__init__.py +0 -0
  61. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/encryption.py +0 -0
  62. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/hash.py +0 -0
  63. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/key.py +0 -0
  64. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/parameter.py +0 -0
  65. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/result.py +0 -0
  66. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/signature.py +0 -0
  67. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/schemas/token.py +0 -0
  68. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/table.py +0 -0
  69. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/__init__.py +0 -0
  70. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  71. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/__init__.py +0 -0
  72. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/cache/__init__.py +0 -0
  73. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/cache/redis.py +0 -0
  74. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/client/__init__.py +0 -0
  75. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/client/maleo.py +0 -0
  76. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/database.py +0 -0
  77. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/middleware.py +0 -0
  78. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/pubsub/__init__.py +0 -0
  79. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/pubsub/publisher.py +0 -0
  80. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/configurations/service.py +0 -0
  81. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/credentials.py +0 -0
  82. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/data.py +0 -0
  83. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/database.py +0 -0
  84. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/key.py +0 -0
  85. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/request.py +0 -0
  86. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/settings.py +0 -0
  87. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/signature.py +0 -0
  88. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/general/token.py +0 -0
  89. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  90. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  91. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
  92. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
  93. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
  94. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  95. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
  96. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
  97. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
  98. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
  99. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/key.py +0 -0
  100. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  101. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  102. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  103. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  104. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  105. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  106. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  107. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  108. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
  109. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
  110. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
  111. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/hash.py +0 -0
  112. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/key.py +0 -0
  113. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  114. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  115. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  116. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  117. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/signature.py +0 -0
  118. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/models/transfers/results/token.py +0 -0
  119. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/rest_controller_result.py +0 -0
  120. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/types.py +0 -0
  121. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/__init__.py +0 -0
  122. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/cache.py +0 -0
  123. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/client.py +0 -0
  124. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/controller.py +0 -0
  125. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/dependencies/__init__.py +0 -0
  126. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/dependencies/auth.py +0 -0
  127. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/dependencies/context.py +0 -0
  128. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/exceptions/__init__.py +0 -0
  129. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/exceptions/client.py +0 -0
  130. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/exceptions/request.py +0 -0
  131. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/exceptions/service.py +0 -0
  132. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/extractor.py +0 -0
  133. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/formatter/__init__.py +0 -0
  134. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/formatter/case.py +0 -0
  135. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/__init__.py +0 -0
  136. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
  137. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/credential/google.py +0 -0
  138. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/json.py +0 -0
  139. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
  140. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
  141. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/loaders/yaml.py +0 -0
  142. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/logging.py +0 -0
  143. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/merger.py +0 -0
  144. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/query.py +0 -0
  145. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/repository.py +0 -0
  146. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation/utils/searcher.py +0 -0
  147. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  148. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation.egg-info/requires.txt +0 -0
  149. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/maleo_foundation.egg-info/top_level.txt +0 -0
  150. {maleo_foundation-0.3.66 → maleo_foundation-0.3.68}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.3.66
3
+ Version: 0.3.68
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -1,5 +1,6 @@
1
1
  from fastapi import FastAPI, APIRouter
2
2
  from fastapi.exceptions import RequestValidationError
3
+ from google.cloud import pubsub_v1
3
4
  from google.oauth2.service_account import Credentials
4
5
  from redis.asyncio.client import Redis
5
6
  from redis.exceptions import RedisError
@@ -72,6 +73,7 @@ class ServiceManager:
72
73
  self._load_keys()
73
74
  self._initialize_loggers()
74
75
  self._initialize_database()
76
+ self._initialize_publisher()
75
77
  self._initialize_foundation()
76
78
 
77
79
  @property
@@ -224,6 +226,13 @@ class ServiceManager:
224
226
  def database(self) -> DatabaseManager:
225
227
  return self._database
226
228
 
229
+ def _initialize_publisher(self) -> None:
230
+ self._publisher = pubsub_v1.PublisherClient()
231
+
232
+ @property
233
+ def publisher(self) -> pubsub_v1.PublisherClient:
234
+ return self._publisher
235
+
227
236
  def _initialize_foundation(self) -> None:
228
237
  self._foundation = MaleoFoundationClientManager(
229
238
  log_config=self._log_config, service_key=self._settings.SERVICE_KEY
@@ -0,0 +1,246 @@
1
+ from __future__ import annotations
2
+ from datetime import datetime, timezone
3
+ from pydantic import BaseModel, Field, model_validator
4
+ from typing import Any, Optional, Self
5
+ from uuid import UUID
6
+ from maleo_foundation.enums import BaseEnums
7
+ from maleo_foundation.types import BaseTypes
8
+
9
+
10
+ class BaseGeneralSchemas:
11
+ class DateFilter(BaseModel):
12
+ name: str = Field(..., description="Column name.")
13
+ from_date: BaseTypes.OptionalDatetime = Field(None, description="From date.")
14
+ to_date: BaseTypes.OptionalDatetime = Field(None, description="To date.")
15
+
16
+ class SortColumn(BaseModel):
17
+ name: str = Field(..., description="Column name.")
18
+ order: BaseEnums.SortOrder = Field(..., description="Sort order.")
19
+
20
+ class SimplePagination(BaseModel):
21
+ page: int = Field(1, ge=1, description="Page number, must be >= 1.")
22
+ limit: int = Field(
23
+ 10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100."
24
+ )
25
+
26
+ # * ----- ----- ----- Operation ----- ----- ----- *#
27
+ class OperationArguments(BaseModel):
28
+ positional: BaseTypes.ListOfAny = Field([], description="Positional arguments")
29
+ keyword: BaseTypes.StringToAnyDict = Field({}, description="Keyword arguments")
30
+
31
+ class OperationContext(BaseModel):
32
+ origin: BaseEnums.OperationOrigin = Field(..., description="Operation's origin")
33
+ client_key: BaseTypes.OptionalString = Field(None, description="Client's key")
34
+ layer: BaseEnums.OperationLayer = Field(..., description="Operation's layer")
35
+ target: Optional[BaseEnums.OperationTarget] = Field(
36
+ None, description="Operation's target (optional)"
37
+ )
38
+ environment: Optional[BaseEnums.EnvironmentType] = Field(
39
+ None, description="Operation's target's environment (optional)"
40
+ )
41
+ target_name: BaseTypes.OptionalString = Field(
42
+ None, description="Operation's target's name (optional)"
43
+ )
44
+ target_resource: BaseTypes.OptionalString = Field(
45
+ None, description="Operation's target's resource (optional)"
46
+ )
47
+
48
+ class OperationMetadata(BaseModel):
49
+ type: BaseEnums.OperationType = Field(..., description="Operation's type")
50
+ create_type: Optional[BaseEnums.CreateType] = Field(
51
+ None, description="Create type (optional)"
52
+ )
53
+ update_type: Optional[BaseEnums.UpdateType] = Field(
54
+ None, description="Update type (optional)"
55
+ )
56
+ status_update_type: Optional[BaseEnums.StatusUpdateType] = Field(
57
+ None, description="Status update type (optional)"
58
+ )
59
+ summary: BaseTypes.OptionalString = Field(
60
+ None, description="Summary (optional)"
61
+ )
62
+
63
+ @model_validator(mode="after")
64
+ def validate_operation_types(self) -> Self:
65
+ # Validate create operation type
66
+ if self.type is BaseEnums.OperationType.CREATE:
67
+ if self.create_type is None:
68
+ raise ValueError(
69
+ "'create_type' must have value if 'type' is 'create'"
70
+ )
71
+ if self.create_type not in BaseEnums.CreateType:
72
+ raise ValueError(
73
+ f"'create_type' must be one of {[e.value for e in BaseEnums.CreateType]}"
74
+ )
75
+
76
+ # Validate update operation type
77
+ if self.type is BaseEnums.OperationType.UPDATE:
78
+ if self.update_type is None:
79
+ raise ValueError(
80
+ "'update_type' must have value if 'type' is 'update'"
81
+ )
82
+ if self.update_type not in BaseEnums.UpdateType:
83
+ raise ValueError(
84
+ f"'update_type' must be one of {[e.value for e in BaseEnums.UpdateType]}"
85
+ )
86
+ if self.update_type is BaseEnums.UpdateType.STATUS:
87
+ if self.status_update_type is None:
88
+ raise ValueError(
89
+ "'status_update_type' must have value if 'update_type' is 'status'"
90
+ )
91
+ if self.status_update_type not in BaseEnums.StatusUpdateType:
92
+ raise ValueError(
93
+ f"'status_update_type' must be one of {[e.value for e in BaseEnums.StatusUpdateType]}"
94
+ )
95
+
96
+ return self
97
+
98
+ class OperationServiceContext(BaseModel):
99
+ key: BaseEnums.Service = Field(..., description="Service's key")
100
+ environment: BaseEnums.EnvironmentType = Field(
101
+ ..., description="Service's environment"
102
+ )
103
+
104
+ class OperationTimestamps(BaseModel):
105
+ started_at: BaseTypes.OptionalDatetime = Field(
106
+ None, description="Started at timestamp (Optional)"
107
+ )
108
+ finished_at: BaseTypes.OptionalDatetime = Field(
109
+ None, description="Finished at timestamp (Optional)"
110
+ )
111
+ duration: float = Field(0, description="Operation duration")
112
+
113
+ @model_validator(mode="after")
114
+ def calculate_duration(self) -> Self:
115
+ if self.started_at is not None and self.finished_at is not None:
116
+ self.duration = (self.finished_at - self.started_at).total_seconds()
117
+
118
+ return self
119
+
120
+ class OperationResult(BaseModel):
121
+ success: bool = Field(..., description="Success status")
122
+ code: BaseTypes.OptionalString = Field(None, description="Optional result code")
123
+ message: BaseTypes.OptionalString = Field(None, description="Optional message")
124
+ description: BaseTypes.OptionalString = Field(
125
+ None, description="Optional description"
126
+ )
127
+ data: Any = Field(..., description="Data")
128
+ metadata: BaseTypes.OptionalAny = Field(None, description="Optional metadata")
129
+ other: BaseTypes.OptionalAny = Field(
130
+ None, description="Optional other information"
131
+ )
132
+
133
+ class DatabaseOperationContext(BaseModel):
134
+ database: str = Field(..., description="Database name")
135
+ environment: BaseEnums.EnvironmentType = Field(
136
+ ..., description="Database environment"
137
+ )
138
+ table: str = Field(..., description="Table name")
139
+
140
+ class DatabaseOperationResult(BaseModel):
141
+ data_id: int = Field(..., ge=1, description="Data's ID")
142
+ old_data: BaseTypes.OptionalStringToAnyDict = Field(
143
+ None, description="Old data"
144
+ )
145
+ new_data: BaseTypes.OptionalStringToAnyDict = Field(
146
+ None, description="New data"
147
+ )
148
+
149
+ @model_validator(mode="after")
150
+ def validate_data(self) -> Self:
151
+ if self.old_data is None and self.new_data is None:
152
+ raise ValueError("Either 'old_data' or 'new_data' must have value")
153
+ return self
154
+
155
+ # * ----- ----- ----- Data ----- ----- ----- *#
156
+ class Identifiers(BaseModel):
157
+ id: int = Field(..., ge=1, description="Data's ID, must be >= 1.")
158
+ uuid: UUID = Field(..., description="Data's UUID.")
159
+
160
+ class EssentialTimestamps(BaseModel):
161
+ created_at: datetime = Field(..., description="Data's created_at timestamp")
162
+ updated_at: datetime = Field(..., description="Data's updated_at timestamp")
163
+
164
+ class StatusTimestamps(BaseModel):
165
+ deleted_at: BaseTypes.OptionalDatetime = Field(
166
+ ..., description="Data's deleted_at timestamp"
167
+ )
168
+ restored_at: BaseTypes.OptionalDatetime = Field(
169
+ ..., description="Data's restored_at timestamp"
170
+ )
171
+ deactivated_at: BaseTypes.OptionalDatetime = Field(
172
+ ..., description="Data's deactivated_at timestamp"
173
+ )
174
+ activated_at: datetime = Field(..., description="Data's activated_at timestamp")
175
+
176
+ class Timestamps(StatusTimestamps, EssentialTimestamps):
177
+ pass
178
+
179
+ class Status(BaseModel):
180
+ status: BaseEnums.StatusType = Field(..., description="Data's status")
181
+
182
+ class DataMixin(Status, Timestamps, Identifiers):
183
+ pass
184
+
185
+ class IsDefault(BaseModel):
186
+ is_default: BaseTypes.OptionalBoolean = Field(
187
+ None, description="Whether data is default"
188
+ )
189
+
190
+ class IsRoot(BaseModel):
191
+ is_root: BaseTypes.OptionalBoolean = Field(
192
+ None, description="Whether data is root"
193
+ )
194
+
195
+ class IsParent(BaseModel):
196
+ is_parent: BaseTypes.OptionalBoolean = Field(
197
+ None, description="Whether data is parent"
198
+ )
199
+
200
+ class IsChild(BaseModel):
201
+ is_child: BaseTypes.OptionalBoolean = Field(
202
+ None, description="Whether data is child"
203
+ )
204
+
205
+ class IsLeaf(BaseModel):
206
+ is_leaf: BaseTypes.OptionalBoolean = Field(
207
+ None, description="Whether data is leaf"
208
+ )
209
+
210
+ class Order(BaseModel):
211
+ order: BaseTypes.OptionalInteger = Field(..., description="Data's order")
212
+
213
+ class Code(BaseModel):
214
+ code: str = Field(..., description="Data's code")
215
+
216
+ class Key(BaseModel):
217
+ key: str = Field(..., description="Data's key")
218
+
219
+ class Name(BaseModel):
220
+ name: str = Field(..., description="Data's name")
221
+
222
+ class Secret(BaseModel):
223
+ secret: UUID = Field(..., description="Data's secret")
224
+
225
+ # * ----- ----- ----- RSA Key ----- ----- ----- *#
226
+ class PrivateKey(BaseModel):
227
+ private_key: str = Field(..., description="Private key in str format.")
228
+
229
+ class PublicKey(BaseModel):
230
+ public_key: str = Field(..., description="Public key in str format.")
231
+
232
+ class KeyPair(PublicKey, PrivateKey):
233
+ pass
234
+
235
+ class RSAKeys(BaseModel):
236
+ password: str = Field(..., description="Key's password")
237
+ private: str = Field(..., description="Private key")
238
+ public: str = Field(..., description="Public key")
239
+
240
+ class AccessedAt(BaseModel):
241
+ accessed_at: datetime = Field(
242
+ datetime.now(tz=timezone.utc), description="Accessed at"
243
+ )
244
+
245
+ class AccessedBy(BaseModel):
246
+ accessed_by: int = Field(0, ge=0, description="Accessed by")
@@ -0,0 +1,51 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Optional
3
+ from .request import RequestContext
4
+ from maleo_foundation.authentication import Authentication
5
+ from maleo_foundation.authorization import Authorization
6
+ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
7
+
8
+
9
+ class Operation(BaseModel):
10
+ request_context: RequestContext = Field(..., description="Request context")
11
+ authentication: Authentication = Field(..., description="Authentication")
12
+ authorization: Optional[Authorization] = Field(None, description="Authorization")
13
+ service: BaseGeneralSchemas.OperationServiceContext = Field(
14
+ ..., description="Service's context"
15
+ )
16
+ timestamps: BaseGeneralSchemas.OperationTimestamps = Field(
17
+ ..., description="Operation's timestamps"
18
+ )
19
+ context: BaseGeneralSchemas.OperationContext = Field(
20
+ ..., description="Operation's context"
21
+ )
22
+ metadata: BaseGeneralSchemas.OperationMetadata = Field(
23
+ ..., description="Operation's metadata"
24
+ )
25
+ arguments: BaseGeneralSchemas.OperationArguments = Field(
26
+ ..., description="Operation's arguments"
27
+ )
28
+ result: BaseGeneralSchemas.OperationResult = Field(
29
+ ..., description="Database operation's result"
30
+ )
31
+
32
+
33
+ class DatabaseOperation(BaseModel):
34
+ request_context: RequestContext = Field(..., description="Request context")
35
+ authentication: Authentication = Field(..., description="Authentication")
36
+ authorization: Optional[Authorization] = Field(None, description="Authorization")
37
+ service: BaseGeneralSchemas.OperationServiceContext = Field(
38
+ ..., description="Service's context"
39
+ )
40
+ timestamps: BaseGeneralSchemas.OperationTimestamps = Field(
41
+ ..., description="Operation's timestamps"
42
+ )
43
+ context: BaseGeneralSchemas.DatabaseOperationContext = Field(
44
+ ..., description="Database operation's context"
45
+ )
46
+ metadata: BaseGeneralSchemas.OperationMetadata = Field(
47
+ ..., description="Operation's metadata"
48
+ )
49
+ result: BaseGeneralSchemas.DatabaseOperationResult = Field(
50
+ ..., description="Database operation's result"
51
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.3.66
3
+ Version: 0.3.68
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -74,6 +74,7 @@ maleo_foundation/models/transfers/general/credentials.py
74
74
  maleo_foundation/models/transfers/general/data.py
75
75
  maleo_foundation/models/transfers/general/database.py
76
76
  maleo_foundation/models/transfers/general/key.py
77
+ maleo_foundation/models/transfers/general/operation.py
77
78
  maleo_foundation/models/transfers/general/request.py
78
79
  maleo_foundation/models/transfers/general/settings.py
79
80
  maleo_foundation/models/transfers/general/signature.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.3.66"
7
+ version = "0.3.68"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -1,113 +0,0 @@
1
- from __future__ import annotations
2
- from datetime import datetime, timezone
3
- from pydantic import BaseModel, Field
4
- from uuid import UUID
5
- from maleo_foundation.enums import BaseEnums
6
- from maleo_foundation.types import BaseTypes
7
-
8
-
9
- class BaseGeneralSchemas:
10
- class DateFilter(BaseModel):
11
- name: str = Field(..., description="Column name.")
12
- from_date: BaseTypes.OptionalDatetime = Field(None, description="From date.")
13
- to_date: BaseTypes.OptionalDatetime = Field(None, description="To date.")
14
-
15
- class SortColumn(BaseModel):
16
- name: str = Field(..., description="Column name.")
17
- order: BaseEnums.SortOrder = Field(..., description="Sort order.")
18
-
19
- class SimplePagination(BaseModel):
20
- page: int = Field(1, ge=1, description="Page number, must be >= 1.")
21
- limit: int = Field(
22
- 10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100."
23
- )
24
-
25
- # * ----- ----- ----- Data ----- ----- ----- *#
26
- class Identifiers(BaseModel):
27
- id: int = Field(..., ge=1, description="Data's ID, must be >= 1.")
28
- uuid: UUID = Field(..., description="Data's UUID.")
29
-
30
- class EssentialTimestamps(BaseModel):
31
- created_at: datetime = Field(..., description="Data's created_at timestamp")
32
- updated_at: datetime = Field(..., description="Data's updated_at timestamp")
33
-
34
- class StatusTimestamps(BaseModel):
35
- deleted_at: BaseTypes.OptionalDatetime = Field(
36
- ..., description="Data's deleted_at timestamp"
37
- )
38
- restored_at: BaseTypes.OptionalDatetime = Field(
39
- ..., description="Data's restored_at timestamp"
40
- )
41
- deactivated_at: BaseTypes.OptionalDatetime = Field(
42
- ..., description="Data's deactivated_at timestamp"
43
- )
44
- activated_at: datetime = Field(..., description="Data's activated_at timestamp")
45
-
46
- class Timestamps(StatusTimestamps, EssentialTimestamps):
47
- pass
48
-
49
- class Status(BaseModel):
50
- status: BaseEnums.StatusType = Field(..., description="Data's status")
51
-
52
- class IsDefault(BaseModel):
53
- is_default: BaseTypes.OptionalBoolean = Field(
54
- None, description="Whether data is default"
55
- )
56
-
57
- class IsRoot(BaseModel):
58
- is_root: BaseTypes.OptionalBoolean = Field(
59
- None, description="Whether data is root"
60
- )
61
-
62
- class IsParent(BaseModel):
63
- is_parent: BaseTypes.OptionalBoolean = Field(
64
- None, description="Whether data is parent"
65
- )
66
-
67
- class IsChild(BaseModel):
68
- is_child: BaseTypes.OptionalBoolean = Field(
69
- None, description="Whether data is child"
70
- )
71
-
72
- class IsLeaf(BaseModel):
73
- is_leaf: BaseTypes.OptionalBoolean = Field(
74
- None, description="Whether data is leaf"
75
- )
76
-
77
- class Order(BaseModel):
78
- order: BaseTypes.OptionalInteger = Field(..., description="Data's order")
79
-
80
- class Code(BaseModel):
81
- code: str = Field(..., description="Data's code")
82
-
83
- class Key(BaseModel):
84
- key: str = Field(..., description="Data's key")
85
-
86
- class Name(BaseModel):
87
- name: str = Field(..., description="Data's name")
88
-
89
- class Secret(BaseModel):
90
- secret: UUID = Field(..., description="Data's secret")
91
-
92
- # * ----- ----- ----- RSA Key ----- ----- ----- *#
93
- class PrivateKey(BaseModel):
94
- private_key: str = Field(..., description="Private key in str format.")
95
-
96
- class PublicKey(BaseModel):
97
- public_key: str = Field(..., description="Public key in str format.")
98
-
99
- class KeyPair(PublicKey, PrivateKey):
100
- pass
101
-
102
- class RSAKeys(BaseModel):
103
- password: str = Field(..., description="Key's password")
104
- private: str = Field(..., description="Private key")
105
- public: str = Field(..., description="Public key")
106
-
107
- class AccessedAt(BaseModel):
108
- accessed_at: datetime = Field(
109
- datetime.now(tz=timezone.utc), description="Accessed at"
110
- )
111
-
112
- class AccessedBy(BaseModel):
113
- accessed_by: int = Field(0, ge=0, description="Accessed by")