bw-essentials-core 0.1.10__tar.gz → 0.1.12__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.

Potentially problematic release.


This version of bw-essentials-core might be problematic. Click here for more details.

Files changed (36) hide show
  1. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/PKG-INFO +1 -1
  2. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/constants/services.py +1 -0
  3. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/api_client.py +13 -0
  4. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/broker.py +22 -1
  5. bw_essentials_core-0.1.12/bw_essentials/services/job_scheduler.py +60 -0
  6. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/user_app.py +22 -3
  7. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials_core.egg-info/PKG-INFO +1 -1
  8. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials_core.egg-info/SOURCES.txt +1 -0
  9. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/setup.py +1 -1
  10. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/README.md +0 -0
  11. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/__init__.py +0 -0
  12. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/constants/__init__.py +0 -0
  13. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/data_loch/__init__.py +0 -0
  14. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/data_loch/data_loch.py +0 -0
  15. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/email_client/__init__.py +0 -0
  16. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/email_client/email_client.py +0 -0
  17. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/notifications/__init__.py +0 -0
  18. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/notifications/teams_notification_schemas.py +0 -0
  19. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/notifications/teams_notifications.py +0 -0
  20. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/s3_utils/__init__.py +0 -0
  21. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/s3_utils/s3_utils.py +0 -0
  22. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/__init__.py +0 -0
  23. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/market_pricer.py +0 -0
  24. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/master_data.py +0 -0
  25. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/model_portfolio_reporting.py +0 -0
  26. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/notification.py +0 -0
  27. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/payment.py +0 -0
  28. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/portfolio_catalogue.py +0 -0
  29. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/portfolio_content.py +0 -0
  30. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/trade_placement.py +0 -0
  31. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/user_portfolio.py +0 -0
  32. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials/services/user_portfolio_reporting.py +0 -0
  33. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials_core.egg-info/dependency_links.txt +0 -0
  34. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials_core.egg-info/requires.txt +0 -0
  35. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/bw_essentials_core.egg-info/top_level.txt +0 -0
  36. {bw_essentials_core-0.1.10 → bw_essentials_core-0.1.12}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw-essentials-core
3
- Version: 0.1.10
3
+ Version: 0.1.12
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
@@ -20,6 +20,7 @@ class Services(Enum):
20
20
  PROMETHEUS_USER_APP = "Prometheus_User_App"
21
21
  PORTFOLIO_CATALOGUE = "Portfolio_Catalogue"
22
22
  PORTFOLIO_CONTENT = "Portfolio_Content"
23
+ JOB_SCHEDULER = "Job_Scheduler"
23
24
 
24
25
  class PortfolioStatus(Enum):
25
26
  """
@@ -80,6 +80,19 @@ class ApiClient:
80
80
  env_key = f"{service_name.upper()}_BASE_URL"
81
81
  return self._get_env_var(env_key)
82
82
 
83
+ def get_api_key(self, service_name: str) -> str:
84
+ """
85
+ Resolve the service API Key for a given service name using environment variables.
86
+
87
+ Args:
88
+ service_name (str): The logical name of the service.
89
+
90
+ Returns:
91
+ str: The resolved api key from the environment.
92
+ """
93
+ env_key = f"{service_name.upper()}_API_KEY"
94
+ return self._get_env_var(env_key)
95
+
83
96
  def set_tenant_id(self, tenant_id: str) -> None:
84
97
  """
85
98
  Set the tenant ID in the request headers.
@@ -62,7 +62,8 @@ class Broker(ApiClient):
62
62
  "authorised_holdings": "brokers/{}/holdings/authorise",
63
63
  "user_instructions": "brokers/{}/user/instructions",
64
64
  "details": "brokers/{}/trade/details",
65
- "surveillance_orders": "brokers/{}/surveillance/orders"
65
+ "surveillance_orders": "brokers/{}/surveillance/orders",
66
+ "profile": "brokers/{}/profile"
66
67
  }
67
68
 
68
69
  def authenticate(self, broker_name: str, user_id: str, entity_id: str,
@@ -118,6 +119,26 @@ class Broker(ApiClient):
118
119
  logger.info(f"{response =}")
119
120
  return response["data"]["balance"]
120
121
 
122
+ def get_profile(self, broker_name: str, user_id: str) -> dict:
123
+ """
124
+ Fetch user profile from the broker service.
125
+
126
+ Args:
127
+ broker_name (str): Broker name.
128
+ user_id (str): User ID.
129
+
130
+ Returns:
131
+ Dict: User Profile.
132
+ """
133
+ logger.info(f"In - get_profile {user_id =}")
134
+ response = self._get(
135
+ url=self.base_url,
136
+ endpoint=self.urls["profile"].format(broker_name),
137
+ params={"user_id": user_id}
138
+ )
139
+ logger.info(f"{response =}")
140
+ return response["data"]
141
+
121
142
  def get_holdings(self, broker_name: str, user_id: str) -> list:
122
143
  """
123
144
  Fetch user holdings from the broker service.
@@ -0,0 +1,60 @@
1
+ import logging
2
+ from bw_essentials.constants.services import Services
3
+ from bw_essentials.services.api_client import ApiClient
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ class JobScheduler(ApiClient):
9
+ """
10
+ Class for making API calls to the Job Scheduler Service.
11
+
12
+ Args:
13
+ user (str): The user for whom the API calls are being made.
14
+ """
15
+
16
+ def __init__(self, user):
17
+ """
18
+ Initialize the Job Scheduler object.
19
+
20
+ Args:
21
+ user (str): The user for whom the API calls are being made.
22
+ """
23
+ super().__init__(user)
24
+ self.base_url = self.get_base_url(Services.JOB_SCHEDULER.value)
25
+ self.api_key = self.get_api_key(Services.JOB_SCHEDULER.value)
26
+ self.name = Services.JOB_SCHEDULER.value
27
+ self.urls = {
28
+ "process_user_profile": "taskmanager/process/user-portfolios/"
29
+ }
30
+
31
+ def _headers(self):
32
+ """
33
+ Prepares headers for API calls.
34
+
35
+ Returns:
36
+ dict: Headers
37
+ """
38
+ return {
39
+ 'Content-Type': 'application/json',
40
+ 'x-api-key': self.api_key
41
+ }
42
+
43
+ def process_user_profile(self, data):
44
+ """
45
+ Send a request to process a user profile.
46
+
47
+ This method prepares the required headers and sends a POST request
48
+ to the `process_user_profile` endpoint with the provided user data.
49
+
50
+ Args:
51
+ data (dict): A dictionary containing user profile information
52
+ to be sent in the request body.
53
+
54
+ Returns:
55
+ None: The method does not return a value.
56
+ """
57
+ logger.info(f"In - process_user_profile {self.user =}")
58
+ self.headers = self._headers()
59
+ self._post(url=self.base_url, endpoint=self.urls.get('process_user_profile'), json=data)
60
+ logger.info(f"Out - process_user_profile")
@@ -34,16 +34,20 @@ class PrometheusUserApp(ApiClient):
34
34
  urls (Dict[str, str]): A dictionary of endpoint path templates
35
35
  """
36
36
 
37
- def __init__(self, service_user: str):
37
+ def __init__(self, service_user: str, tenant_id: str = None):
38
38
  """
39
- Initialize the PrometheusUserApp client with the given service user.
39
+ Initialize the PrometheusUserApp client with the given service user and tenant id.
40
40
 
41
41
  Args:
42
42
  service_user (str): Username or service identifier for authentication.
43
+ tenant_id (str, optional): Tenant identifier for multi-tenant usage.
44
+ Defaults to None if not applicable.
43
45
  """
44
46
  super().__init__(user=service_user)
45
47
  self.base_url = self.get_base_url(Services.PROMETHEUS_USER_APP.value)
48
+ self.api_key = self.get_api_key(Services.PROMETHEUS_USER_APP.value)
46
49
  self.name = Services.PROMETHEUS_USER_APP.value
50
+ self.tenant_id = tenant_id
47
51
  self.urls = {
48
52
  "user_details": "user/details",
49
53
  "profile": "user/profile",
@@ -60,6 +64,20 @@ class PrometheusUserApp(ApiClient):
60
64
  "sso": "user/{}/sso"
61
65
  }
62
66
 
67
+
68
+ def _headers(self):
69
+ """
70
+ Prepares headers for API calls.
71
+
72
+ Returns:
73
+ dict: Headers
74
+ """
75
+ return {
76
+ 'Content-Type': 'application/json',
77
+ **({'X-Tenant-ID': self.tenant_id} if self.tenant_id else {}),
78
+ 'x-api-key': self.api_key
79
+ }
80
+
63
81
  def get_user_details(self, user_id: str) -> Optional[Dict[str, Any]]:
64
82
  """
65
83
  Fetch detailed user information by user ID.
@@ -71,10 +89,11 @@ class PrometheusUserApp(ApiClient):
71
89
  Optional[Dict[str, Any]]: Parsed user data if found, else None.
72
90
  """
73
91
  logger.info("Fetching user details for user_id=%s", user_id)
92
+ self.headers = self._headers()
74
93
  response = self._get(
75
94
  endpoint=self.urls["user_details"],
76
95
  url=self.base_url,
77
- params={'user_id': user_id}
96
+ params={'user_id': user_id},
78
97
  )
79
98
  return response.get('data')
80
99
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw-essentials-core
3
- Version: 0.1.10
3
+ Version: 0.1.12
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
@@ -15,6 +15,7 @@ bw_essentials/s3_utils/s3_utils.py
15
15
  bw_essentials/services/__init__.py
16
16
  bw_essentials/services/api_client.py
17
17
  bw_essentials/services/broker.py
18
+ bw_essentials/services/job_scheduler.py
18
19
  bw_essentials/services/market_pricer.py
19
20
  bw_essentials/services/master_data.py
20
21
  bw_essentials/services/model_portfolio_reporting.py
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
10
10
 
11
11
  setup(
12
12
  name="bw-essentials-core",
13
- version="0.1.10",
13
+ version="0.1.12",
14
14
  author="InvestorAI",
15
15
  author_email="support+tech@investorai.in",
16
16
  description="Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.",