bw-essentials-core 0.1.1__py3-none-any.whl → 0.1.3__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 bw-essentials-core might be problematic. Click here for more details.

@@ -279,3 +279,19 @@ class DataLoch:
279
279
  prefix = f"{branch}/{server_path}"
280
280
  self.s3.delete_files_by_prefix(repository, prefix)
281
281
  logger.info(f"Deleted all files under prefix {prefix}")
282
+
283
+ def delete_single_file(self, repository: str, branch: str, server_path: str) -> None:
284
+ """
285
+ Delete a single file at the specified path in a LakeFS branch.
286
+
287
+ Args:
288
+ repository (str): The name of the LakeFS repository.
289
+ branch (str): The name of the branch within the repository.
290
+ server_path (str): The file path (relative to the branch) to delete.
291
+ """
292
+ full_path = f"{branch}/{server_path}"
293
+ logger.info(f"Attempting to delete file at path: {full_path} in repository: {repository}")
294
+
295
+ self.s3.delete_file(repository, full_path)
296
+
297
+ logger.info(f"Successfully deleted file: {full_path} from repository: {repository}")
@@ -28,10 +28,11 @@ class NotificationService(ApiClient):
28
28
  self.name = Services.NOTIFICATION.value
29
29
  self.base_url = self.get_base_url(self.name)
30
30
  self.urls = {
31
- "whatsapp": "whatsapp"
31
+ "whatsapp": "whatsapp",
32
+ "email": "email"
32
33
  }
33
34
 
34
- def _whatsapp(self, title, template, platform, params, to, user_id):
35
+ def _whatsapp(self, title, template, platform, params, to, user_id) -> None:
35
36
  """
36
37
  Sends a WhatsApp notification.
37
38
 
@@ -66,12 +67,77 @@ class NotificationService(ApiClient):
66
67
  resp_data = self._post(url=self.base_url, endpoint=self.urls.get('whatsapp'), data=payload)
67
68
  logger.info(f"Whatsapp response {resp_data =}")
68
69
 
69
- def send_whatsapp(self, template, title, params, to, user_id):
70
- logger.info(f"In - send_whatsapp_notification {user_id =} {title = } {params = } {to = }")
70
+ def send_whatsapp(self, template, title, params, to, user_id) -> None:
71
+ """
72
+
73
+ Args:
74
+ template (str): Template for the WhatsApp message.
75
+ title (str): Title of the notification.
76
+ params: Parameters for the notification message.
77
+ to (str): Recipient's whatsapp number.
78
+ user_id (str): The ID of the user receiving the notification.
71
79
 
80
+ Returns:
81
+ None
82
+ """
83
+ logger.info(f"In - send_whatsapp_notification {user_id =} {title = } {params = } {to = }")
72
84
  self._whatsapp(title=title,
73
85
  template=template,
74
86
  platform=self._get_env_var(NotificationService.PLATFORM),
75
87
  params=params,
76
88
  to=to,
77
89
  user_id=user_id)
90
+
91
+ def _email(self, title: str, content: str, platform: str, to: str, user_id: str) -> None:
92
+ """
93
+ Sends an email notification using the internal notification service.
94
+
95
+ Args:
96
+ title (str): The subject or title of the email.
97
+ content (str): The HTML or plain text body of the email.
98
+ platform (str): The platform identifier from which the email is sent (e.g., 'prometheus').
99
+ to (str): Recipient's email address.
100
+ user_id (str): The ID of the user for tracking or logging purposes.
101
+
102
+ Returns:
103
+ None
104
+
105
+ """
106
+ logger.info(f"In - email {user_id =}, {to =}, {title =}, {platform =}, {content =}")
107
+ payload = {
108
+ "to": to,
109
+ "userId": user_id,
110
+ "platform": platform,
111
+ "title": title,
112
+ "content": content
113
+ }
114
+ logger.info(f"email {payload =}")
115
+ headers = {
116
+ 'api-key': self._get_env_var(NotificationService.NOTIFICATION_API_KEY),
117
+ 'Content-Type': 'application/json'
118
+ }
119
+ self.set_headers(headers)
120
+ resp_data = self._post(url=self.base_url, endpoint=self.urls.get('email'), json=payload)
121
+ logger.info(f"Email response {resp_data =}")
122
+
123
+ def send_email(self, title: str, content: str, to: str, user_id: str) -> None:
124
+ """
125
+ Sends an email notification to the specified recipient.
126
+
127
+ Args:
128
+ title (str): The subject or title of the email.
129
+ content (str): The HTML or plain text content of the email.
130
+ to (str): The recipient's email address.
131
+ user_id (str): The ID of the user associated with the notification.
132
+
133
+ Returns:
134
+ None
135
+ """
136
+ logger.info(f"In - send_email {user_id =}, {title =}, {to =}")
137
+ self._email(
138
+ title=title,
139
+ content=content,
140
+ platform=self._get_env_var(NotificationService.PLATFORM),
141
+ to=to,
142
+ user_id=user_id
143
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw-essentials-core
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.
5
5
  Author: InvestorAI
6
6
  Author-email: support+tech@investorai.in
@@ -2,7 +2,7 @@ bw_essentials/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  bw_essentials/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  bw_essentials/constants/services.py,sha256=ymvYcXjJpWQoGnnCnqURhQao61QJAMM-g9sJCx_Y8s4,561
4
4
  bw_essentials/data_loch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- bw_essentials/data_loch/data_loch.py,sha256=Ae3WIywFawThKcpsnf8nC8ldI9ARrSNqz8e5b6sINwY,11006
5
+ bw_essentials/data_loch/data_loch.py,sha256=iJO0oPhZyQjoUZOaeBP1nsbuc5iR9ZNWoAXj2pGEpT8,11716
6
6
  bw_essentials/email_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  bw_essentials/email_client/email_client.py,sha256=_LzDWUJUkNTSn3C5v0-jjW-Ls537xt493lkcD4noQXY,9116
8
8
  bw_essentials/notifications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -16,12 +16,12 @@ bw_essentials/services/broker.py,sha256=As-VT1MxkCD9p-13dQJDwf0_aEJVA6H0wNqL-EYH
16
16
  bw_essentials/services/market_pricer.py,sha256=Qc9lxzAjhefAvjyEKsBPDu60bF6_61cnSpZNfjGMyDg,11755
17
17
  bw_essentials/services/master_data.py,sha256=2o_r2gdhIKBeTFgn5IIY-becgCEpYBymO4BKmixdV1g,11987
18
18
  bw_essentials/services/model_portfolio_reporting.py,sha256=iOtm4gyfU8P7C0R1gp6gUJI4ZRxJD5K2GLOalI_gToM,3249
19
- bw_essentials/services/notification.py,sha256=OQD-rB7FaqcoyjRgFyl2pgeXWIgtYcUhRs_4uT1Em9A,2634
19
+ bw_essentials/services/notification.py,sha256=q4jIZzIWIHvn-XaIIbkEjjhkYUV8ZGQWUXaY4NNRFgI,5078
20
20
  bw_essentials/services/trade_placement.py,sha256=PrzeU2XXC9HF1IQ1dMDM_ZHxmC491sOl-JbA6GWPwII,20772
21
21
  bw_essentials/services/user_app.py,sha256=_Y2NgDq6kEoco7ZRJ3-MMYJ-K2HGStJoFoeGOH_HotQ,11107
22
22
  bw_essentials/services/user_portfolio.py,sha256=_5M6yPfQt4MXedINBawEoPkb_o7IGzxPeHkvZkoQm8k,16191
23
23
  bw_essentials/services/user_portfolio_reporting.py,sha256=QaZzcw912Uos5ZafEaxLXDmCyetTFiVX3at3cTAv6MA,6003
24
- bw_essentials_core-0.1.1.dist-info/METADATA,sha256=c5-YYlMERt3ZzOLmu4hp78zV1t5bNCawWyWh6BIGY7o,7501
25
- bw_essentials_core-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- bw_essentials_core-0.1.1.dist-info/top_level.txt,sha256=gDc5T_y5snwKGXDQUusEus-FEt0RFwG644Yn_58wQOQ,14
27
- bw_essentials_core-0.1.1.dist-info/RECORD,,
24
+ bw_essentials_core-0.1.3.dist-info/METADATA,sha256=r5Fy1wGySkKAZ54fmubQEK1EKc50kjoKw9MvnZIGPbw,7501
25
+ bw_essentials_core-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
+ bw_essentials_core-0.1.3.dist-info/top_level.txt,sha256=gDc5T_y5snwKGXDQUusEus-FEt0RFwG644Yn_58wQOQ,14
27
+ bw_essentials_core-0.1.3.dist-info/RECORD,,