Encryptors 2.24__tar.gz → 2.26__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 (123) hide show
  1. {encryptors-2.24 → encryptors-2.26}/PKG-INFO +21 -1
  2. encryptors-2.26/README.md +17 -0
  3. {encryptors-2.24 → encryptors-2.26}/setup.py +3 -2
  4. {encryptors-2.24 → encryptors-2.26}/src/Encryptors.egg-info/PKG-INFO +21 -1
  5. {encryptors-2.24 → encryptors-2.26}/src/Encryptors.egg-info/SOURCES.txt +29 -22
  6. {encryptors-2.24 → encryptors-2.26}/src/Encryptors.egg-info/requires.txt +1 -0
  7. encryptors-2.26/src/Osdental/BlobStorage/Storage.py +50 -0
  8. encryptors-2.26/src/Osdental/Cli/__init__.py +505 -0
  9. encryptors-2.26/src/Osdental/Database/Connection.py +218 -0
  10. encryptors-2.26/src/Osdental/Database/UnitOfWork.py +44 -0
  11. encryptors-2.26/src/Osdental/Database/UowFactory.py +8 -0
  12. encryptors-2.26/src/Osdental/Decorators/AuditLog.py +158 -0
  13. encryptors-2.26/src/Osdental/Decorators/DecryptedData.py +139 -0
  14. encryptors-2.26/src/Osdental/Decorators/Grpc.py +55 -0
  15. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Decorators/Retry.py +3 -22
  16. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Decorators/SqlDataNormalizer.py +2 -35
  17. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Encryptor/Aes.py +32 -27
  18. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Encryptor/Argon2.py +5 -20
  19. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Encryptor/Bcrypt.py +4 -5
  20. encryptors-2.26/src/Osdental/Encryptor/Jwt.py +43 -0
  21. encryptors-2.26/src/Osdental/Encryptor/Rsa.py +58 -0
  22. encryptors-2.26/src/Osdental/Exception/ControlledException.py +189 -0
  23. encryptors-2.26/src/Osdental/ExternalHttp/Client.py +117 -0
  24. encryptors-2.26/src/Osdental/Grpc/Base/GrpcClientBase.py +61 -0
  25. encryptors-2.26/src/Osdental/Grpc/Client/PortalClient.py +44 -0
  26. encryptors-2.26/src/Osdental/Grpc/Generated/Common_pb2.py +40 -0
  27. encryptors-2.26/src/Osdental/Grpc/Generated/Common_pb2_grpc.py +24 -0
  28. encryptors-2.26/src/Osdental/Grpc/Generated/Portal_pb2.py +37 -0
  29. encryptors-2.26/src/Osdental/Grpc/Generated/Portal_pb2_grpc.py +140 -0
  30. encryptors-2.26/src/Osdental/Helpers/KeyVaultService.py +86 -0
  31. encryptors-2.26/src/Osdental/InternalHttp/Request.py +105 -0
  32. encryptors-2.26/src/Osdental/InternalHttp/Response.py +39 -0
  33. encryptors-2.26/src/Osdental/Messaging/AzureServiceBus.py +41 -0
  34. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Messaging/__init__.py +4 -0
  35. encryptors-2.26/src/Osdental/Models/CDataIntegration.py +41 -0
  36. encryptors-2.26/src/Osdental/Models/Catalog.py +19 -0
  37. encryptors-2.26/src/Osdental/Models/Legacy.py +52 -0
  38. encryptors-2.26/src/Osdental/Models/Response.py +20 -0
  39. encryptors-2.26/src/Osdental/Models/Token.py +43 -0
  40. encryptors-2.26/src/Osdental/RedisCache/Redis.py +108 -0
  41. encryptors-2.26/src/Osdental/RedisCache/__init__.py +0 -0
  42. encryptors-2.26/src/Osdental/ServicesBus/ServicesBus.py +26 -0
  43. encryptors-2.26/src/Osdental/ServicesBus/TaskQueue.py +52 -0
  44. encryptors-2.26/src/Osdental/ServicesBus/__init__.py +0 -0
  45. encryptors-2.26/src/Osdental/Shared/Config/__init__.py +15 -0
  46. encryptors-2.26/src/Osdental/Shared/Enums/GrahpqlOperation.py +5 -0
  47. encryptors-2.26/src/Osdental/Shared/Enums/__init__.py +0 -0
  48. encryptors-2.26/src/Osdental/Shared/Logger.py +17 -0
  49. encryptors-2.26/src/Osdental/Shared/Utils/__init__.py +0 -0
  50. encryptors-2.26/src/Osdental/Shared/__init__.py +0 -0
  51. encryptors-2.26/src/Osdental/Storage/AzureBlobStorage.py +83 -0
  52. encryptors-2.26/src/Osdental/__init__.py +0 -0
  53. encryptors-2.24/src/Osdental/Cli/__init__.py +0 -124
  54. encryptors-2.24/src/Osdental/Database/ISessionFactoryProvider.py +0 -8
  55. encryptors-2.24/src/Osdental/Database/SessionFactoryProvider.py +0 -8
  56. encryptors-2.24/src/Osdental/Database/__init__.py +0 -52
  57. encryptors-2.24/src/Osdental/Decorators/SecureResolver.py +0 -104
  58. encryptors-2.24/src/Osdental/Encryptor/Jwt.py +0 -26
  59. encryptors-2.24/src/Osdental/Encryptor/Rsa.py +0 -52
  60. encryptors-2.24/src/Osdental/Exception/ControlledException.py +0 -145
  61. encryptors-2.24/src/Osdental/Helpers/AuditDispatcher.py +0 -122
  62. encryptors-2.24/src/Osdental/Helpers/AuditLogHelper.py +0 -60
  63. encryptors-2.24/src/Osdental/Helpers/KeyVaultService.py +0 -36
  64. encryptors-2.24/src/Osdental/Helpers/MessageBus.py +0 -12
  65. encryptors-2.24/src/Osdental/Helpers/ShardedQueryExecutor.py +0 -107
  66. encryptors-2.24/src/Osdental/Messaging/AzureServiceBus.py +0 -57
  67. encryptors-2.24/src/Osdental/Middlewares/Security.py +0 -9
  68. encryptors-2.24/src/Osdental/Models/AuditConfig.py +0 -6
  69. encryptors-2.24/src/Osdental/Models/Encryptor.py +0 -12
  70. encryptors-2.24/src/Osdental/Models/GrpcResponse.py +0 -7
  71. encryptors-2.24/src/Osdental/Models/Legacy.py +0 -16
  72. encryptors-2.24/src/Osdental/Models/Response.py +0 -20
  73. encryptors-2.24/src/Osdental/Models/ShardResource.py +0 -31
  74. encryptors-2.24/src/Osdental/Models/Token.py +0 -23
  75. encryptors-2.24/src/Osdental/Models/_SecurityContext.py +0 -18
  76. encryptors-2.24/src/Osdental/Pipeline/GraphQLPayloadService.py +0 -25
  77. encryptors-2.24/src/Osdental/Pipeline/GraphQLRequestExtractor.py +0 -36
  78. encryptors-2.24/src/Osdental/Pipeline/Pipeline.py +0 -50
  79. encryptors-2.24/src/Osdental/Pipeline/TenantPolicy.py +0 -34
  80. encryptors-2.24/src/Osdental/Pipeline/TokenService.py +0 -32
  81. encryptors-2.24/src/Osdental/Pipeline/_Ports.py +0 -6
  82. encryptors-2.24/src/Osdental/RedisCache/Redis.py +0 -97
  83. encryptors-2.24/src/Osdental/Shared/Enums/GrahpqlOperation.py +0 -6
  84. encryptors-2.24/src/Osdental/Shared/Enums/ShardQueryPolicy.py +0 -5
  85. encryptors-2.24/src/Osdental/Shared/Logger.py +0 -3
  86. encryptors-2.24/src/Osdental/Storage/AzureBlobStorage.py +0 -79
  87. {encryptors-2.24 → encryptors-2.26}/setup.cfg +0 -0
  88. {encryptors-2.24 → encryptors-2.26}/src/Encryptors.egg-info/dependency_links.txt +0 -0
  89. {encryptors-2.24 → encryptors-2.26}/src/Encryptors.egg-info/entry_points.txt +0 -0
  90. {encryptors-2.24 → encryptors-2.26}/src/Encryptors.egg-info/top_level.txt +0 -0
  91. {encryptors-2.24/src/Osdental/Decorators → encryptors-2.26/src/Osdental/BlobStorage}/__init__.py +0 -0
  92. {encryptors-2.24/src/Osdental/Encryptor → encryptors-2.26/src/Osdental/Database}/__init__.py +0 -0
  93. {encryptors-2.24/src/Osdental/Exception → encryptors-2.26/src/Osdental/Decorators}/__init__.py +0 -0
  94. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Encryptor/Sha512.py +0 -0
  95. {encryptors-2.24/src/Osdental/Helpers → encryptors-2.26/src/Osdental/Encryptor}/__init__.py +0 -0
  96. {encryptors-2.24/src/Osdental/Middlewares → encryptors-2.26/src/Osdental/Exception}/__init__.py +0 -0
  97. {encryptors-2.24/src/Osdental/Models → encryptors-2.26/src/Osdental/ExternalHttp}/__init__.py +0 -0
  98. {encryptors-2.24/src/Osdental/Pipeline → encryptors-2.26/src/Osdental/Grpc/Base}/__init__.py +0 -0
  99. {encryptors-2.24/src/Osdental/RedisCache → encryptors-2.26/src/Osdental/Grpc/Client}/__init__.py +0 -0
  100. {encryptors-2.24/src/Osdental/Shared/Enums → encryptors-2.26/src/Osdental/Grpc/Generated}/__init__.py +0 -0
  101. {encryptors-2.24/src/Osdental/Shared/Utils → encryptors-2.26/src/Osdental/Grpc}/__init__.py +0 -0
  102. {encryptors-2.24/src/Osdental/Shared → encryptors-2.26/src/Osdental/Helpers}/__init__.py +0 -0
  103. {encryptors-2.24/src/Osdental → encryptors-2.26/src/Osdental/InternalHttp}/__init__.py +0 -0
  104. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Messaging/Kafka.py +0 -0
  105. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Messaging/RabbitMQ.py +0 -0
  106. /encryptors-2.24/README.md → /encryptors-2.26/src/Osdental/Models/__init__.py +0 -0
  107. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Enums/Code.py +0 -0
  108. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Enums/Constant.py +0 -0
  109. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Enums/FileType.py +0 -0
  110. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Enums/Message.py +0 -0
  111. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Enums/Profile.py +0 -0
  112. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/CaseConverter.py +0 -0
  113. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/CodeGenerator.py +0 -0
  114. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/DataUtils.py +0 -0
  115. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/DateUtils.py +0 -0
  116. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/FileMetaData.py +0 -0
  117. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/HashValidator.py +0 -0
  118. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/Mapper.py +0 -0
  119. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/PasswordGenerator.py +0 -0
  120. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/QueryGenerator.py +0 -0
  121. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Shared/Utils/TextProcessor.py +0 -0
  122. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Storage/S3Storage.py +0 -0
  123. {encryptors-2.24 → encryptors-2.26}/src/Osdental/Storage/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Encryptors
3
- Version: 2.24
3
+ Version: 2.26
4
4
  Summary: End-to-end algorithm library
5
5
  Author: OSDental LLC
6
6
  Author-email: support@osdental.ai
@@ -42,6 +42,7 @@ Requires-Dist: SQLAlchemy==2.0.36
42
42
  Requires-Dist: starlette==0.41.3
43
43
  Requires-Dist: tenacity==9.1.2
44
44
  Requires-Dist: typing_extensions==4.15.0
45
+ Requires-Dist: tzlocal==5.2
45
46
  Requires-Dist: urllib3==2.3.0
46
47
  Requires-Dist: redis==5.2.1
47
48
  Requires-Dist: colorlog==6.9.0
@@ -57,7 +58,26 @@ Requires-Dist: gunicorn==23.0.0
57
58
  Dynamic: author
58
59
  Dynamic: author-email
59
60
  Dynamic: classifier
61
+ Dynamic: description
60
62
  Dynamic: description-content-type
61
63
  Dynamic: requires-dist
62
64
  Dynamic: requires-python
63
65
  Dynamic: summary
66
+
67
+ # osdental-library
68
+
69
+ `osdental-library` is a versatile and easy-to-use library for handling common tasks related to **encryption**, **hashing**, and **JWT token management**. Ideal for projects that require a secure and efficient approach to handling sensitive data.
70
+
71
+ ## Features
72
+
73
+ - Generation and validation of **hashes** using modern algorithms.
74
+ - Encryption and decryption of data using secure keys.
75
+ - Creation and verification of **JWT tokens** for authentication and authorization.
76
+ - Implementations that are easy to integrate into any Python project.
77
+
78
+ ## Installation
79
+
80
+ You can easily install `osdental-library` using `pip`:
81
+
82
+ ```bash
83
+ pip install osdental-library
@@ -0,0 +1,17 @@
1
+ # osdental-library
2
+
3
+ `osdental-library` is a versatile and easy-to-use library for handling common tasks related to **encryption**, **hashing**, and **JWT token management**. Ideal for projects that require a secure and efficient approach to handling sensitive data.
4
+
5
+ ## Features
6
+
7
+ - Generation and validation of **hashes** using modern algorithms.
8
+ - Encryption and decryption of data using secure keys.
9
+ - Creation and verification of **JWT tokens** for authentication and authorization.
10
+ - Implementations that are easy to integrate into any Python project.
11
+
12
+ ## Installation
13
+
14
+ You can easily install `osdental-library` using `pip`:
15
+
16
+ ```bash
17
+ pip install osdental-library
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="Encryptors",
5
- version="2.24",
5
+ version="2.26",
6
6
  author="OSDental LLC",
7
7
  author_email="support@osdental.ai",
8
8
  description="End-to-end algorithm library",
@@ -19,7 +19,7 @@ setup(
19
19
  install_requires=[
20
20
  "aiohttp==3.11.12",
21
21
  "annotated-types==0.7.0",
22
- "anyio==4.7.0",
22
+ "anyio==4.7.0",
23
23
  "ariadne==0.26.2",
24
24
  "azure-core==1.32.0",
25
25
  "azure-servicebus==7.13.0",
@@ -50,6 +50,7 @@ setup(
50
50
  "starlette==0.41.3",
51
51
  "tenacity==9.1.2",
52
52
  "typing_extensions==4.15.0",
53
+ "tzlocal==5.2",
53
54
  "urllib3==2.3.0",
54
55
  "redis==5.2.1",
55
56
  "colorlog==6.9.0",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Encryptors
3
- Version: 2.24
3
+ Version: 2.26
4
4
  Summary: End-to-end algorithm library
5
5
  Author: OSDental LLC
6
6
  Author-email: support@osdental.ai
@@ -42,6 +42,7 @@ Requires-Dist: SQLAlchemy==2.0.36
42
42
  Requires-Dist: starlette==0.41.3
43
43
  Requires-Dist: tenacity==9.1.2
44
44
  Requires-Dist: typing_extensions==4.15.0
45
+ Requires-Dist: tzlocal==5.2
45
46
  Requires-Dist: urllib3==2.3.0
46
47
  Requires-Dist: redis==5.2.1
47
48
  Requires-Dist: colorlog==6.9.0
@@ -57,7 +58,26 @@ Requires-Dist: gunicorn==23.0.0
57
58
  Dynamic: author
58
59
  Dynamic: author-email
59
60
  Dynamic: classifier
61
+ Dynamic: description
60
62
  Dynamic: description-content-type
61
63
  Dynamic: requires-dist
62
64
  Dynamic: requires-python
63
65
  Dynamic: summary
66
+
67
+ # osdental-library
68
+
69
+ `osdental-library` is a versatile and easy-to-use library for handling common tasks related to **encryption**, **hashing**, and **JWT token management**. Ideal for projects that require a secure and efficient approach to handling sensitive data.
70
+
71
+ ## Features
72
+
73
+ - Generation and validation of **hashes** using modern algorithms.
74
+ - Encryption and decryption of data using secure keys.
75
+ - Creation and verification of **JWT tokens** for authentication and authorization.
76
+ - Implementations that are easy to integrate into any Python project.
77
+
78
+ ## Installation
79
+
80
+ You can easily install `osdental-library` using `pip`:
81
+
82
+ ```bash
83
+ pip install osdental-library
@@ -7,12 +7,17 @@ src/Encryptors.egg-info/entry_points.txt
7
7
  src/Encryptors.egg-info/requires.txt
8
8
  src/Encryptors.egg-info/top_level.txt
9
9
  src/Osdental/__init__.py
10
+ src/Osdental/BlobStorage/Storage.py
11
+ src/Osdental/BlobStorage/__init__.py
10
12
  src/Osdental/Cli/__init__.py
11
- src/Osdental/Database/ISessionFactoryProvider.py
12
- src/Osdental/Database/SessionFactoryProvider.py
13
+ src/Osdental/Database/Connection.py
14
+ src/Osdental/Database/UnitOfWork.py
15
+ src/Osdental/Database/UowFactory.py
13
16
  src/Osdental/Database/__init__.py
17
+ src/Osdental/Decorators/AuditLog.py
18
+ src/Osdental/Decorators/DecryptedData.py
19
+ src/Osdental/Decorators/Grpc.py
14
20
  src/Osdental/Decorators/Retry.py
15
- src/Osdental/Decorators/SecureResolver.py
16
21
  src/Osdental/Decorators/SqlDataNormalizer.py
17
22
  src/Osdental/Decorators/__init__.py
18
23
  src/Osdental/Encryptor/Aes.py
@@ -24,45 +29,47 @@ src/Osdental/Encryptor/Sha512.py
24
29
  src/Osdental/Encryptor/__init__.py
25
30
  src/Osdental/Exception/ControlledException.py
26
31
  src/Osdental/Exception/__init__.py
27
- src/Osdental/Helpers/AuditDispatcher.py
28
- src/Osdental/Helpers/AuditLogHelper.py
32
+ src/Osdental/ExternalHttp/Client.py
33
+ src/Osdental/ExternalHttp/__init__.py
34
+ src/Osdental/Grpc/__init__.py
35
+ src/Osdental/Grpc/Base/GrpcClientBase.py
36
+ src/Osdental/Grpc/Base/__init__.py
37
+ src/Osdental/Grpc/Client/PortalClient.py
38
+ src/Osdental/Grpc/Client/__init__.py
39
+ src/Osdental/Grpc/Generated/Common_pb2.py
40
+ src/Osdental/Grpc/Generated/Common_pb2_grpc.py
41
+ src/Osdental/Grpc/Generated/Portal_pb2.py
42
+ src/Osdental/Grpc/Generated/Portal_pb2_grpc.py
43
+ src/Osdental/Grpc/Generated/__init__.py
29
44
  src/Osdental/Helpers/KeyVaultService.py
30
- src/Osdental/Helpers/MessageBus.py
31
- src/Osdental/Helpers/ShardedQueryExecutor.py
32
45
  src/Osdental/Helpers/__init__.py
46
+ src/Osdental/InternalHttp/Request.py
47
+ src/Osdental/InternalHttp/Response.py
48
+ src/Osdental/InternalHttp/__init__.py
33
49
  src/Osdental/Messaging/AzureServiceBus.py
34
50
  src/Osdental/Messaging/Kafka.py
35
51
  src/Osdental/Messaging/RabbitMQ.py
36
52
  src/Osdental/Messaging/__init__.py
37
- src/Osdental/Middlewares/Security.py
38
- src/Osdental/Middlewares/__init__.py
39
- src/Osdental/Models/AuditConfig.py
40
- src/Osdental/Models/Encryptor.py
41
- src/Osdental/Models/GrpcResponse.py
53
+ src/Osdental/Models/CDataIntegration.py
54
+ src/Osdental/Models/Catalog.py
42
55
  src/Osdental/Models/Legacy.py
43
56
  src/Osdental/Models/Response.py
44
- src/Osdental/Models/ShardResource.py
45
57
  src/Osdental/Models/Token.py
46
- src/Osdental/Models/_SecurityContext.py
47
58
  src/Osdental/Models/__init__.py
48
- src/Osdental/Pipeline/GraphQLPayloadService.py
49
- src/Osdental/Pipeline/GraphQLRequestExtractor.py
50
- src/Osdental/Pipeline/Pipeline.py
51
- src/Osdental/Pipeline/TenantPolicy.py
52
- src/Osdental/Pipeline/TokenService.py
53
- src/Osdental/Pipeline/_Ports.py
54
- src/Osdental/Pipeline/__init__.py
55
59
  src/Osdental/RedisCache/Redis.py
56
60
  src/Osdental/RedisCache/__init__.py
61
+ src/Osdental/ServicesBus/ServicesBus.py
62
+ src/Osdental/ServicesBus/TaskQueue.py
63
+ src/Osdental/ServicesBus/__init__.py
57
64
  src/Osdental/Shared/Logger.py
58
65
  src/Osdental/Shared/__init__.py
66
+ src/Osdental/Shared/Config/__init__.py
59
67
  src/Osdental/Shared/Enums/Code.py
60
68
  src/Osdental/Shared/Enums/Constant.py
61
69
  src/Osdental/Shared/Enums/FileType.py
62
70
  src/Osdental/Shared/Enums/GrahpqlOperation.py
63
71
  src/Osdental/Shared/Enums/Message.py
64
72
  src/Osdental/Shared/Enums/Profile.py
65
- src/Osdental/Shared/Enums/ShardQueryPolicy.py
66
73
  src/Osdental/Shared/Enums/__init__.py
67
74
  src/Osdental/Shared/Utils/CaseConverter.py
68
75
  src/Osdental/Shared/Utils/CodeGenerator.py
@@ -31,6 +31,7 @@ SQLAlchemy==2.0.36
31
31
  starlette==0.41.3
32
32
  tenacity==9.1.2
33
33
  typing_extensions==4.15.0
34
+ tzlocal==5.2
34
35
  urllib3==2.3.0
35
36
  redis==5.2.1
36
37
  colorlog==6.9.0
@@ -0,0 +1,50 @@
1
+ from azure.storage.blob.aio import BlobServiceClient
2
+ from Osdental.Shared.Logger import logger
3
+ from Osdental.Shared.Config import Config
4
+
5
+ class BlobStorage:
6
+
7
+ @staticmethod
8
+ async def get_file(file_path:str) -> bytes | None:
9
+ """ Download a file from blob storage """
10
+ try:
11
+ blob_service_client = BlobServiceClient.from_connection_string(Config.BLOB_CONNECTION_STRING)
12
+ async with blob_service_client:
13
+ container_client = blob_service_client.get_container_client(Config.BLOB_CONTAINER_NAME)
14
+ blob_client = container_client.get_blob_client(file_path)
15
+ blob_data = await blob_client.download_blob()
16
+ file_bytes = await blob_data.readall()
17
+ return file_bytes
18
+ except Exception as e:
19
+ logger.error(f'Unexpected blob storage error when retrieving file: {str(e)}')
20
+ return None
21
+
22
+ @staticmethod
23
+ async def store_file(file_bytes:bytes, file_path:str) -> bool:
24
+ """ Upload a file to blob storage """
25
+ try:
26
+ blob_service_client = BlobServiceClient.from_connection_string(Config.BLOB_CONNECTION_STRING)
27
+ async with blob_service_client:
28
+ container_client = blob_service_client.get_container_client(Config.BLOB_CONTAINER_NAME)
29
+ blob_client = container_client.get_blob_client(file_path)
30
+ await blob_client.upload_blob(file_bytes, overwrite=True)
31
+
32
+ return True
33
+ except Exception as e:
34
+ logger.error(f'Unexpected blob storage error when saving file: {str(e)}')
35
+ return False
36
+
37
+ @staticmethod
38
+ async def delete_file(file_path:str) -> bool:
39
+ """ Delete a file from blob storage """
40
+ try:
41
+ blob_service_client = BlobServiceClient.from_connection_string(Config.BLOB_CONNECTION_STRING)
42
+ async with blob_service_client:
43
+ container_client = blob_service_client.get_container_client(Config.BLOB_CONTAINER_NAME)
44
+ blob_client = container_client.get_blob_client(file_path)
45
+ await blob_client.delete_blob()
46
+
47
+ return True
48
+ except Exception as e:
49
+ logger.error(f'Unexpected blob storage error when deleting file: {str(e)}')
50
+ return False