maleo-foundation 0.2.74__tar.gz → 0.2.76__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 (129) hide show
  1. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/PKG-INFO +1 -1
  2. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/constants.py +5 -5
  3. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/enums.py +30 -7
  4. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/google/storage.py +39 -11
  5. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/service.py +19 -18
  6. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/responses.py +5 -0
  7. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/table.py +33 -7
  8. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation.egg-info/PKG-INFO +1 -1
  9. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/pyproject.toml +1 -1
  10. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/README.md +0 -0
  11. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/__init__.py +0 -0
  12. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/authentication.py +0 -0
  13. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/authorization.py +0 -0
  14. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/__init__.py +0 -0
  15. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/manager.py +0 -0
  16. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/__init__.py +0 -0
  17. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/encryption/__init__.py +0 -0
  18. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/encryption/aes.py +0 -0
  19. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/encryption/rsa.py +0 -0
  20. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/hash/__init__.py +0 -0
  21. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
  22. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/hash/hmac.py +0 -0
  23. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/hash/sha256.py +0 -0
  24. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/key.py +0 -0
  25. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/signature.py +0 -0
  26. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/client/services/token.py +0 -0
  27. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/__init__.py +0 -0
  28. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/client.py +0 -0
  29. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
  30. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
  31. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
  32. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/general.py +0 -0
  33. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/hash.py +0 -0
  34. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/key.py +0 -0
  35. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/repository.py +0 -0
  36. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/service.py +0 -0
  37. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/signature.py +0 -0
  38. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/expanded_types/token.py +0 -0
  39. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/extended_types.py +0 -0
  40. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/__init__.py +0 -0
  41. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/cache/__init__.py +0 -0
  42. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/cache/base.py +0 -0
  43. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/cache/redis.py +0 -0
  44. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/__init__.py +0 -0
  45. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/base.py +0 -0
  46. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/google/__init__.py +0 -0
  47. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/google/base.py +0 -0
  48. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/google/parameter.py +0 -0
  49. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/google/secret.py +0 -0
  50. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/client/maleo.py +0 -0
  51. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/db.py +0 -0
  52. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/managers/middleware.py +0 -0
  53. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/middlewares/authentication.py +0 -0
  54. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/middlewares/base.py +0 -0
  55. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/middlewares/cors.py +0 -0
  56. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/__init__.py +0 -0
  57. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/__init__.py +0 -0
  58. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/encryption.py +0 -0
  59. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/general.py +0 -0
  60. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/hash.py +0 -0
  61. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/key.py +0 -0
  62. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/parameter.py +0 -0
  63. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/result.py +0 -0
  64. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/signature.py +0 -0
  65. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/schemas/token.py +0 -0
  66. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/__init__.py +0 -0
  67. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  68. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/general/key.py +0 -0
  69. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/general/signature.py +0 -0
  70. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/general/token.py +0 -0
  71. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  72. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  73. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
  74. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
  75. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
  76. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  77. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
  78. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
  79. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
  80. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
  81. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/key.py +0 -0
  82. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  83. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  84. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  85. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  86. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  87. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  88. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  89. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  90. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
  91. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
  92. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
  93. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/hash.py +0 -0
  94. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/key.py +0 -0
  95. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  96. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  97. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  98. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  99. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/service/repository.py +0 -0
  100. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/signature.py +0 -0
  101. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/models/transfers/results/token.py +0 -0
  102. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/rest_controller_result.py +0 -0
  103. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/types.py +0 -0
  104. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/__init__.py +0 -0
  105. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/client.py +0 -0
  106. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/controller.py +0 -0
  107. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/dependencies/__init__.py +0 -0
  108. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/dependencies/auth.py +0 -0
  109. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/exceptions.py +0 -0
  110. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/extractor.py +0 -0
  111. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/formatter/__init__.py +0 -0
  112. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/formatter/case.py +0 -0
  113. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/__init__.py +0 -0
  114. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
  115. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/credential/google.py +0 -0
  116. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/json.py +0 -0
  117. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
  118. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
  119. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/loaders/yaml.py +0 -0
  120. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/logging.py +0 -0
  121. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/merger.py +0 -0
  122. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/query.py +0 -0
  123. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/repository.py +0 -0
  124. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation/utils/searcher.py +0 -0
  125. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation.egg-info/SOURCES.txt +0 -0
  126. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  127. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation.egg-info/requires.txt +0 -0
  128. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/maleo_foundation.egg-info/top_level.txt +0 -0
  129. {maleo_foundation-0.2.74 → maleo_foundation-0.2.76}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.74
3
+ Version: 0.2.76
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -11,16 +11,16 @@ ACCESS_TOKEN_DURATION_MINUTES:int = 5
11
11
  SORT_COLUMN_PATTERN = re.compile(r'^[a-z_]+\.(asc|desc)$')
12
12
  DATE_FILTER_PATTERN = re.compile(r'^[a-z_]+(?:\|from::\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?(?:\|to::\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?$')
13
13
  STATUS_UPDATE_CRITERIAS:dict[
14
- BaseEnums.StatusUpdateAction,
14
+ BaseEnums.StatusUpdateType,
15
15
  BaseTypes.OptionalListOfStatuses
16
16
  ] = {
17
- BaseEnums.StatusUpdateAction.DELETE: None,
18
- BaseEnums.StatusUpdateAction.RESTORE: None,
19
- BaseEnums.StatusUpdateAction.DEACTIVATE: [
17
+ BaseEnums.StatusUpdateType.DELETE: None,
18
+ BaseEnums.StatusUpdateType.RESTORE: None,
19
+ BaseEnums.StatusUpdateType.DEACTIVATE: [
20
20
  BaseEnums.StatusType.INACTIVE,
21
21
  BaseEnums.StatusType.ACTIVE,
22
22
  ],
23
- BaseEnums.StatusUpdateAction.ACTIVATE: [
23
+ BaseEnums.StatusUpdateType.ACTIVATE: [
24
24
  BaseEnums.StatusType.INACTIVE,
25
25
  BaseEnums.StatusType.ACTIVE,
26
26
  ]
@@ -44,19 +44,25 @@ class BaseEnums:
44
44
  ASC = "asc"
45
45
  DESC = "desc"
46
46
 
47
- class StatusUpdateAction(StrEnum):
47
+ class TokenType(StrEnum):
48
+ REFRESH = "refresh"
49
+ ACCESS = "access"
50
+
51
+ class StatusUpdateType(StrEnum):
48
52
  ACTIVATE = "activate"
49
53
  DEACTIVATE = "deactivate"
50
54
  RESTORE = "restore"
51
55
  DELETE = "delete"
52
56
 
53
- class TokenType(StrEnum):
54
- REFRESH = "refresh"
55
- ACCESS = "access"
57
+ class UpdateType(StrEnum):
58
+ STATUS = "status"
59
+ DATA = "data"
56
60
 
57
61
  class OperationType(StrEnum):
58
62
  CREATE = "create"
59
63
  UPDATE = "update"
64
+ RESTORE = "restore"
65
+ DELETE = "delete"
60
66
 
61
67
  class IdentifierTypes(StrEnum):
62
68
  ID = "id"
@@ -144,6 +150,23 @@ class BaseEnums:
144
150
  TTL_12HR = int(12*60*60)
145
151
  TTL_1DY = int(1*24*60*60)
146
152
  TTL_3DY = int(3*24*60*60)
147
- TTL_1WK = int(1*24*60*60)
148
- TTL_2WK = int(2*24*60*60)
149
- TTL_1MO = int(1*30*24*60*60)
153
+ TTL_1WK = int(1*7*24*60*60)
154
+ TTL_2WK = int(2*7*24*60*60)
155
+ TTL_1MO = int(1*30*24*60*60)
156
+
157
+ class Expiration(IntEnum):
158
+ EXP_15SC = int(15)
159
+ EXP_30SC = int(30)
160
+ EXP_1MN = int(1*60)
161
+ EXP_5MN = int(5*60)
162
+ EXP_10MN = int(10*60)
163
+ EXP_15MN = int(15*60)
164
+ EXP_30MN = int(30*60)
165
+ EXP_1HR = int(1*60*60)
166
+ EXP_6HR = int(6*60*60)
167
+ EXP_12HR = int(12*60*60)
168
+ EXP_1DY = int(1*24*60*60)
169
+ EXP_3DY = int(3*24*60*60)
170
+ EXP_1WK = int(1*7*24*60*60)
171
+ EXP_2WK = int(2*7*24*60*60)
172
+ EXP_1MO = int(1*30*24*60*60)
@@ -3,7 +3,9 @@ from datetime import timedelta
3
3
  from google.cloud.storage import Bucket, Client
4
4
  from google.oauth2.service_account import Credentials
5
5
  from pathlib import Path
6
+ from redis.asyncio.client import Redis
6
7
  from typing import Optional, Union
8
+ from maleo_foundation.enums import BaseEnums
7
9
  from maleo_foundation.types import BaseTypes
8
10
  from maleo_foundation.utils.logging import SimpleConfig
9
11
  from .base import GoogleClientManager
@@ -15,7 +17,8 @@ class GoogleCloudStorage(GoogleClientManager):
15
17
  service_key:BaseTypes.OptionalString=None,
16
18
  credentials:Optional[Credentials]=None,
17
19
  credentials_path:Optional[Union[Path, str]]=None,
18
- bucket_name:BaseTypes.OptionalString = None
20
+ bucket_name:BaseTypes.OptionalString = None,
21
+ redis:Optional[Redis] = None
19
22
  ) -> None:
20
23
  key = "google-cloud-storage"
21
24
  name = "GoogleCloudStorage"
@@ -31,6 +34,7 @@ class GoogleCloudStorage(GoogleClientManager):
31
34
  raise ValueError(f"Bucket '{self._bucket_name}' does not exist.")
32
35
  self._root_location = service_key
33
36
  self._logger.info("Client manager initialized successfully")
37
+ self._redis = redis
34
38
 
35
39
  @property
36
40
  def bucket_name(self) -> str:
@@ -53,8 +57,9 @@ class GoogleCloudStorage(GoogleClientManager):
53
57
  location:str,
54
58
  content_type:Optional[str]=None,
55
59
  make_public:bool=False,
56
- expiration:timedelta=timedelta(minutes=15),
57
- root_location_override:BaseTypes.OptionalString=None
60
+ expiration:BaseEnums=BaseEnums.Expiration.EXP_15MN,
61
+ root_location_override:BaseTypes.OptionalString=None,
62
+ set_in_redis:bool=False
58
63
  ) -> str:
59
64
  """
60
65
  Upload a file to Google Cloud Storage.
@@ -69,9 +74,11 @@ class GoogleCloudStorage(GoogleClientManager):
69
74
  str: The public URL or blob path depending on `make_public`.
70
75
  """
71
76
  if root_location_override is None or (isinstance(root_location_override, str) and len(root_location_override) <= 0):
72
- blob = self._bucket.blob(f"{self._root_location}/{location}")
77
+ blob_name = f"{self._root_location}/{location}"
73
78
  else:
74
- blob = self._bucket.blob(f"{root_location_override}/{location}")
79
+ blob_name = f"{root_location_override}/{location}"
80
+
81
+ blob = self._bucket.blob(blob_name=blob_name)
75
82
  blob.upload_from_string(content, content_type=content_type)
76
83
 
77
84
  if make_public:
@@ -80,16 +87,24 @@ class GoogleCloudStorage(GoogleClientManager):
80
87
  else:
81
88
  url = blob.generate_signed_url(
82
89
  version="v4",
83
- expiration=expiration,
90
+ expiration=timedelta(seconds=int(expiration)),
84
91
  method="GET"
85
92
  )
93
+
94
+ if set_in_redis:
95
+ if make_public:
96
+ self._redis.set(f"{self.key}:{blob_name}", url)
97
+ else:
98
+ self._redis.set(f"{self.key}:{blob_name}", url, ex=int(expiration))
99
+
86
100
  return url
87
101
 
88
102
  def generate_signed_url(
89
103
  self,
90
104
  location:str,
91
- expiration:timedelta=timedelta(minutes=15),
92
- root_location_override:BaseTypes.OptionalString=None
105
+ expiration:BaseEnums=BaseEnums.Expiration.EXP_15MN,
106
+ root_location_override:BaseTypes.OptionalString=None,
107
+ use_redis:bool=False
93
108
  ) -> str:
94
109
  """
95
110
  generate signed URL of a file in the bucket based on its location.
@@ -104,16 +119,29 @@ class GoogleCloudStorage(GoogleClientManager):
104
119
  Raises:
105
120
  ValueError: If the file does not exist
106
121
  """
122
+ if use_redis and self._redis is None:
123
+ raise ValueError("Can not use redis. Redis is not initialized")
124
+
107
125
  if root_location_override is None or (isinstance(root_location_override, str) and len(root_location_override) <= 0):
108
- blob = self._bucket.blob(blob_name=f"{self._root_location}/{location}")
126
+ blob_name=f"{self._root_location}/{location}"
109
127
  else:
110
- blob = self._bucket.blob(blob_name=f"{root_location_override}/{location}")
128
+ blob_name=f"{root_location_override}/{location}"
129
+
130
+ blob = self._bucket.blob(blob_name=blob_name)
111
131
  if not blob.exists():
112
132
  raise ValueError(f"File '{location}' did not exists.")
113
133
 
134
+ if use_redis:
135
+ if self._redis is None:
136
+ raise ValueError("Can not use redis. Redis is not initialized")
137
+ url = self._redis.get(blob_name)
138
+ if url is not None:
139
+ return url
140
+
114
141
  url = blob.generate_signed_url(
115
142
  version="v4",
116
- expiration=expiration,
143
+ expiration=timedelta(seconds=int(expiration)),
117
144
  method="GET"
118
145
  )
146
+ self._redis.set(f"{self.key}:{blob_name}", url, ex=int(expiration))
119
147
  return url
@@ -152,12 +152,12 @@ class ServiceManager:
152
152
  self._log_config.google_cloud_logging = None
153
153
  self._load_google_credentials()
154
154
  self._initialize_secret_manager()
155
- self._initialize_cloud_storage()
156
155
  self._load_maleo_credentials()
157
156
  self._load_configs()
158
157
  self._load_keys()
159
158
  self._initialize_loggers()
160
159
  self._initialize_cache()
160
+ self._initialize_cloud_storage()
161
161
  self._initialize_db()
162
162
  self._initialize_foundation()
163
163
 
@@ -187,23 +187,6 @@ class ServiceManager:
187
187
  def secret_manager(self) -> GoogleSecretManager:
188
188
  return self._secret_manager
189
189
 
190
- def _initialize_cloud_storage(self) -> None:
191
- environment = (
192
- BaseEnums.EnvironmentType.STAGING
193
- if self._settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
194
- else self._settings.ENVIRONMENT
195
- )
196
- self._cloud_storage = GoogleCloudStorage(
197
- log_config=self._log_config,
198
- service_key=self._settings.SERVICE_KEY,
199
- bucket_name=f"maleo-suite-{environment}",
200
- credentials=self._google_credentials
201
- )
202
-
203
- @property
204
- def cloud_storage(self) -> GoogleCloudStorage:
205
- return self._cloud_storage
206
-
207
190
  def _load_maleo_credentials(self) -> None:
208
191
  environment = (
209
192
  BaseEnums.EnvironmentType.STAGING
@@ -348,6 +331,24 @@ class ServiceManager:
348
331
  def cache(self) -> CacheManagers:
349
332
  return self._cache
350
333
 
334
+ def _initialize_cloud_storage(self) -> None:
335
+ environment = (
336
+ BaseEnums.EnvironmentType.STAGING
337
+ if self._settings.ENVIRONMENT == BaseEnums.EnvironmentType.LOCAL
338
+ else self._settings.ENVIRONMENT
339
+ )
340
+ self._cloud_storage = GoogleCloudStorage(
341
+ log_config=self._log_config,
342
+ service_key=self._settings.SERVICE_KEY,
343
+ bucket_name=f"maleo-suite-{environment}",
344
+ credentials=self._google_credentials,
345
+ redis=self._redis
346
+ )
347
+
348
+ @property
349
+ def cloud_storage(self) -> GoogleCloudStorage:
350
+ return self._cloud_storage
351
+
351
352
  def _initialize_db(self) -> None:
352
353
  self._database = DatabaseManager(
353
354
  metadata=self._db_metadata,
@@ -19,6 +19,11 @@ class BaseResponses:
19
19
  message:str = "Invalid expand"
20
20
  description:str = "Invalid expand field(s) configuration are given. Check 'other' for more information."
21
21
 
22
+ class InvalidParameter(BadRequest):
23
+ code:str = "MAL-IPR-001"
24
+ message:str = "Invalid parameters"
25
+ description:str = "Invalid parameters and/or parameters combinations is given. Check 'other' for more information."
26
+
22
27
  class InvalidSystemRole(BadRequest):
23
28
  code:str = "MAL-ISR-001"
24
29
  message:str = "Invalid system role"
@@ -11,12 +11,7 @@ class BaseTable:
11
11
  def __tablename__(cls) -> str:
12
12
  return CaseFormatter.to_snake_case(cls.__name__)
13
13
 
14
- #* ----- ----- Common columns definition ----- ----- *#
15
-
16
- #* Identifiers
17
- id = Column(Integer, primary_key=True)
18
- uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
19
-
14
+ class DataMixin:
20
15
  #* Timestamps
21
16
  created_at = Column(
22
17
  TIMESTAMP(timezone=True),
@@ -43,4 +38,35 @@ class BaseTable:
43
38
  Enum(BaseEnums.StatusType, name="statustype"),
44
39
  default=BaseEnums.StatusType.ACTIVE,
45
40
  nullable=False
46
- )
41
+ )
42
+
43
+ class DataIdentifiers:
44
+ #* Identifiers
45
+ id = Column(Integer, primary_key=True)
46
+ uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
47
+
48
+ class DataTable(
49
+ DataMixin,
50
+ DataIdentifiers
51
+ ): pass
52
+
53
+ class AccessIdentifiers:
54
+ #* Identifiers
55
+ access_id = Column(Integer, primary_key=True)
56
+ access_uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
57
+ accessed_at = Column(
58
+ TIMESTAMP(timezone=True),
59
+ server_default=func.now(),
60
+ nullable=False
61
+ )
62
+ accessed_by = Column(Integer, default=0, nullable=False)
63
+
64
+ class AccessMixin:
65
+ id = Column(Integer)
66
+ uuid = Column(UUID)
67
+
68
+ class AccessTable(
69
+ DataMixin,
70
+ AccessMixin,
71
+ AccessIdentifiers
72
+ ): pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.74
3
+ Version: 0.2.76
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.2.74"
7
+ version = "0.2.76"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }