bw-essentials-core 0.2.1__tar.gz → 0.2.3__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.
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/PKG-INFO +1 -1
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/constants/services.py +1 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/gunicorn.py +79 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/api_client.py +29 -1
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/payment.py +0 -13
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/portfolio_product.py +68 -0
- bw_essentials_core-0.2.3/bw_essentials/services/reporting.py +1938 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials_core.egg-info/PKG-INFO +1 -1
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials_core.egg-info/SOURCES.txt +2 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/setup.py +1 -1
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_portfolio_product.py +70 -0
- bw_essentials_core-0.2.3/tests/test_reporting.py +779 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/README.md +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/EventNotification/EventBridgePublisher.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/EventNotification/NotificationType.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/EventNotification/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/EventNotification/models/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/EventNotification/models/notification_type.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/constants/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/data_loch/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/data_loch/data_loch.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/email_client/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/email_client/email_client.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/logging/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/logging/_config.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/logging/_context.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/logging/_correlation.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/logging/_processors.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/logging/_redaction.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/middlewares/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/middlewares/fastapi/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/middlewares/fastapi/exception.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/middlewares/fastapi/request.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/fcm/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/fcm/client.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/fcm/exceptions.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/fcm/payload_builder.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/fcm/response.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/fcm/settings.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/teams_notification_schemas.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/notifications/teams_notifications.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_body.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/celery.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/client_hooks.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/config.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/deps.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/exceptions.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/lifecycle.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/log_processor.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/logging_bridge.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/metric_export.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/propagation.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/provider.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/span_export.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/span_policies.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/_core/state.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/boundaries.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/context.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/django/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/django/errors.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/django/middleware.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/django/otel.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/fastapi/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/fastapi/body.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/fastapi/otel.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/logging.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/services.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/py.typed +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/redaction/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/redaction/cap.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/redaction/engine.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/redaction/keys.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/redaction/lexer.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/redaction/patterns.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/s3_utils/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/s3_utils/s3_utils.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/broker.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/compliance.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/job_scheduler.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/market_pricer.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/master_data.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/model_portfolio_reporting.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/notification.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/notification_finn.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/portfolio_business.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/portfolio_catalogue.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/portfolio_content.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/rebalancing_business.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/trade_placement.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/user_app.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/user_portfolio.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/user_portfolio_business.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/user_portfolio_reporting.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/user_referrals.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/tools/__init__.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/tools/manifest_lint.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/tools/secret_grep.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials_core.egg-info/dependency_links.txt +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials_core.egg-info/entry_points.txt +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials_core.egg-info/requires.txt +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials_core.egg-info/top_level.txt +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/setup.cfg +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_api_client_errors.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_api_client_logging.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_api_client_retries.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_broker_reconciliation.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_client_body_logging.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_compliance.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_django_observability.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_event_bridge_publisher.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_fcm_platform_config.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_master_data_trading_calendar.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_notification_finn.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_notification_service.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_observability_import.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_payment.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_pii_response_log_redaction.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_portfolio_business.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_portfolio_business_service_contracts.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_portfolio_catalogue.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_rebalancing_business.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_user_app.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_user_portfolio.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_user_portfolio_business.py +0 -0
- {bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/tests/test_user_portfolio_reporting.py +0 -0
|
@@ -18,6 +18,7 @@ class Services(Enum):
|
|
|
18
18
|
NOTIFICATION_FINN = 'Notification_Finn'
|
|
19
19
|
USER_REPORTING = 'User_Reporting'
|
|
20
20
|
PAYMENT = 'Payment'
|
|
21
|
+
REPORTING = 'Reporting'
|
|
21
22
|
MODEL_PORTFOLIO = "Model_Portfolio"
|
|
22
23
|
PROMETHEUS_USER_APP = "Prometheus_User_App"
|
|
23
24
|
PORTFOLIO_CATALOGUE = "Portfolio_Catalogue"
|
{bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/observability/gunicorn.py
RENAMED
|
@@ -41,6 +41,7 @@ def _post_worker_init(worker: Any) -> None:
|
|
|
41
41
|
from bw_essentials.observability.django.otel import init_otel
|
|
42
42
|
|
|
43
43
|
init_otel()
|
|
44
|
+
_reload_django_middleware(worker)
|
|
44
45
|
return
|
|
45
46
|
|
|
46
47
|
if _fastapi_loaded():
|
|
@@ -140,6 +141,84 @@ def _fastapi_loaded() -> bool:
|
|
|
140
141
|
return "fastapi" in sys.modules
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def _reload_django_middleware(worker: Any) -> None:
|
|
145
|
+
"""Add late OTel instrumentation to Gunicorn's already-loaded handler."""
|
|
146
|
+
from django.conf import settings
|
|
147
|
+
from django.core.handlers.base import BaseHandler
|
|
148
|
+
from opentelemetry.instrumentation.django import DjangoInstrumentor
|
|
149
|
+
from opentelemetry.instrumentation.django.middleware.otel_middleware import (
|
|
150
|
+
_DjangoMiddleware,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
middleware_path = DjangoInstrumentor._opentelemetry_middleware
|
|
154
|
+
if middleware_path not in getattr(settings, "MIDDLEWARE", ()):
|
|
155
|
+
return
|
|
156
|
+
|
|
157
|
+
handler = _find_django_handler(worker, BaseHandler)
|
|
158
|
+
if handler is None:
|
|
159
|
+
_warn_once(
|
|
160
|
+
"OpenTelemetry instrumented Django after its WSGI handler was loaded, "
|
|
161
|
+
"but the Gunicorn worker does not expose that handler; call init_otel() "
|
|
162
|
+
"before get_wsgi_application()"
|
|
163
|
+
)
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
if _callable_contains_instance(handler._middleware_chain, _DjangoMiddleware):
|
|
167
|
+
return
|
|
168
|
+
handler.load_middleware()
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _find_django_handler(worker: Any, handler_type: type) -> Any | None:
|
|
172
|
+
candidates = (
|
|
173
|
+
getattr(worker, "wsgi", None),
|
|
174
|
+
getattr(getattr(worker, "app", None), "callable", None),
|
|
175
|
+
)
|
|
176
|
+
for candidate in candidates:
|
|
177
|
+
current = candidate
|
|
178
|
+
seen: set[int] = set()
|
|
179
|
+
for _ in range(5):
|
|
180
|
+
if isinstance(current, handler_type):
|
|
181
|
+
return current
|
|
182
|
+
if current is None or id(current) in seen:
|
|
183
|
+
break
|
|
184
|
+
seen.add(id(current))
|
|
185
|
+
current = next(
|
|
186
|
+
(
|
|
187
|
+
nested
|
|
188
|
+
for attribute in ("application", "app", "wsgi_application")
|
|
189
|
+
if (nested := getattr(current, attribute, None)) is not None
|
|
190
|
+
and nested is not current
|
|
191
|
+
),
|
|
192
|
+
None,
|
|
193
|
+
)
|
|
194
|
+
return None
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _callable_contains_instance(root: Any, instance_type: type) -> bool:
|
|
198
|
+
"""Inspect Django's closure-based middleware chain without invoking it."""
|
|
199
|
+
pending = [root]
|
|
200
|
+
seen: set[int] = set()
|
|
201
|
+
while pending:
|
|
202
|
+
current = pending.pop()
|
|
203
|
+
if current is None or id(current) in seen:
|
|
204
|
+
continue
|
|
205
|
+
seen.add(id(current))
|
|
206
|
+
if isinstance(current, instance_type):
|
|
207
|
+
return True
|
|
208
|
+
bound_to = getattr(current, "__self__", None)
|
|
209
|
+
if bound_to is not None:
|
|
210
|
+
pending.append(bound_to)
|
|
211
|
+
nested_response = getattr(current, "get_response", None)
|
|
212
|
+
if nested_response is not None:
|
|
213
|
+
pending.append(nested_response)
|
|
214
|
+
for cell in getattr(current, "__closure__", ()) or ():
|
|
215
|
+
try:
|
|
216
|
+
pending.append(cell.cell_contents)
|
|
217
|
+
except ValueError:
|
|
218
|
+
pass
|
|
219
|
+
return False
|
|
220
|
+
|
|
221
|
+
|
|
143
222
|
def _warn_once(message: str) -> None:
|
|
144
223
|
pid = os.getpid()
|
|
145
224
|
if pid in _WARNED_PIDS:
|
|
@@ -19,7 +19,7 @@ import threading
|
|
|
19
19
|
import time
|
|
20
20
|
from importlib.util import module_from_spec, spec_from_file_location
|
|
21
21
|
from typing import Any, Dict, Optional
|
|
22
|
-
from urllib.parse import urlsplit
|
|
22
|
+
from urllib.parse import quote, urlsplit
|
|
23
23
|
|
|
24
24
|
import httpx
|
|
25
25
|
import requests
|
|
@@ -261,6 +261,34 @@ class ApiClient:
|
|
|
261
261
|
path = parsed.path or "/"
|
|
262
262
|
return path
|
|
263
263
|
|
|
264
|
+
@staticmethod
|
|
265
|
+
def _path_segment(value: Any) -> str:
|
|
266
|
+
"""Validate and percent-encode one path segment.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
value: String or integer identifier to place in a URL path.
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
The identifier converted to text and percent-encoded as one path
|
|
273
|
+
segment.
|
|
274
|
+
|
|
275
|
+
Raises:
|
|
276
|
+
TypeError: If ``value`` is a boolean or is not a string/integer.
|
|
277
|
+
ValueError: If the text is blank or contains a slash.
|
|
278
|
+
|
|
279
|
+
Encoding the complete value prevents reserved characters from
|
|
280
|
+
changing route structure while retaining the shared client's integer
|
|
281
|
+
compatibility for services that use numeric identifiers.
|
|
282
|
+
"""
|
|
283
|
+
if isinstance(value, bool) or not isinstance(value, (str, int)):
|
|
284
|
+
raise TypeError("path segment must be a string or integer")
|
|
285
|
+
text = str(value)
|
|
286
|
+
if not text.strip():
|
|
287
|
+
raise ValueError("path segment must not be blank")
|
|
288
|
+
if "/" in text:
|
|
289
|
+
raise ValueError("path segment must not contain a slash")
|
|
290
|
+
return quote(text, safe="")
|
|
291
|
+
|
|
264
292
|
def _build_http_error_message(self, response: requests.Response | None) -> str:
|
|
265
293
|
"""Compose a generic HTTP error message omitting endpoint details."""
|
|
266
294
|
if response is None:
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import Any, Dict, Mapping, Optional
|
|
5
|
-
from urllib.parse import quote
|
|
6
5
|
|
|
7
6
|
from bw_essentials.services.api_client import ApiClient
|
|
8
7
|
from bw_essentials.constants.services import Services
|
|
@@ -90,18 +89,6 @@ class Payment(ApiClient):
|
|
|
90
89
|
"""
|
|
91
90
|
return {key: value for key, value in filters.items() if value is not None}
|
|
92
91
|
|
|
93
|
-
@staticmethod
|
|
94
|
-
def _path_segment(value: Any) -> str:
|
|
95
|
-
"""Validate and percent-encode one string or integer path segment."""
|
|
96
|
-
if isinstance(value, bool) or not isinstance(value, (str, int)):
|
|
97
|
-
raise TypeError("path segment must be a string or integer")
|
|
98
|
-
text = str(value)
|
|
99
|
-
if not text.strip():
|
|
100
|
-
raise ValueError("path segment must not be blank")
|
|
101
|
-
if "/" in text:
|
|
102
|
-
raise ValueError("path segment must not contain a slash")
|
|
103
|
-
return quote(text, safe="")
|
|
104
|
-
|
|
105
92
|
# --- subscriptions -------------------------------------------------------------------
|
|
106
93
|
|
|
107
94
|
def get_subscriptions(self, user_id: Optional[str] = None, *,
|
{bw_essentials_core-0.2.1 → bw_essentials_core-0.2.3}/bw_essentials/services/portfolio_product.py
RENAMED
|
@@ -434,6 +434,30 @@ class PortfolioProduct(ApiClient):
|
|
|
434
434
|
"put", self.urls["rebalance"], json={"rebalance_id": rebalance_id}
|
|
435
435
|
)
|
|
436
436
|
|
|
437
|
+
def delete_rebalance(self, rebalance_id: str | int) -> Any:
|
|
438
|
+
"""DELETE ``catalogue/rebalance/<rebalance_id>`` and confirm deletion.
|
|
439
|
+
|
|
440
|
+
The server atomically hard-deletes the record's constituents and the
|
|
441
|
+
record itself. It returns 404 when the record is missing and 409 when
|
|
442
|
+
the record is older than the server's undo window, which defaults to
|
|
443
|
+
600 seconds.
|
|
444
|
+
|
|
445
|
+
Args:
|
|
446
|
+
rebalance_id: String or integer rebalance identifier.
|
|
447
|
+
|
|
448
|
+
Returns:
|
|
449
|
+
The literal server value ``Deleted Successfully`` on success.
|
|
450
|
+
|
|
451
|
+
Raises:
|
|
452
|
+
requests.HTTPError: If the service rejects the request, including
|
|
453
|
+
404 for a missing record or 409 outside the undo window.
|
|
454
|
+
KeyError: If the response omits ``data``.
|
|
455
|
+
TypeError: If the identifier is not a string or integer.
|
|
456
|
+
ValueError: If the identifier is blank or contains ``/``.
|
|
457
|
+
"""
|
|
458
|
+
identifier = self._path_segment(rebalance_id)
|
|
459
|
+
return self._call("delete", f'{self.urls["rebalance"]}/{identifier}')
|
|
460
|
+
|
|
437
461
|
def create_subscription_plan(
|
|
438
462
|
self, plan: Mapping[str, Any], *, analyst: Any
|
|
439
463
|
) -> Any:
|
|
@@ -742,6 +766,26 @@ class PortfolioProduct(ApiClient):
|
|
|
742
766
|
identifier = self._path_segment(basket_id)
|
|
743
767
|
return self._call("put", f'{self.urls["basket"]}/{identifier}/activate')
|
|
744
768
|
|
|
769
|
+
def get_basket(self, basket_id: str | int) -> Any:
|
|
770
|
+
"""GET ``catalogue/basket/<basket_id>`` and return one basket.
|
|
771
|
+
|
|
772
|
+
Args:
|
|
773
|
+
basket_id: String or integer basket identifier.
|
|
774
|
+
|
|
775
|
+
Returns:
|
|
776
|
+
One basket with every model field, including ``analyst`` and
|
|
777
|
+
``broker``. The server returns 404 when the basket is missing.
|
|
778
|
+
|
|
779
|
+
Raises:
|
|
780
|
+
requests.HTTPError: If the service rejects the request, including
|
|
781
|
+
404 when the basket is missing.
|
|
782
|
+
KeyError: If the response omits ``data``.
|
|
783
|
+
TypeError: If the identifier is not a string or integer.
|
|
784
|
+
ValueError: If the identifier is blank or contains ``/``.
|
|
785
|
+
"""
|
|
786
|
+
identifier = self._path_segment(basket_id)
|
|
787
|
+
return self._call("get", f'{self.urls["basket"]}/{identifier}')
|
|
788
|
+
|
|
745
789
|
def deactivate_basket(self, basket_id: str | int) -> Any:
|
|
746
790
|
"""PUT ``catalogue/basket/<basket_id>/deactivate`` without a body.
|
|
747
791
|
|
|
@@ -760,6 +804,30 @@ class PortfolioProduct(ApiClient):
|
|
|
760
804
|
identifier = self._path_segment(basket_id)
|
|
761
805
|
return self._call("put", f'{self.urls["basket"]}/{identifier}/deactivate')
|
|
762
806
|
|
|
807
|
+
def delete_basket(self, basket_id: str | int) -> Any:
|
|
808
|
+
"""DELETE ``catalogue/basket/<basket_id>`` and confirm deletion.
|
|
809
|
+
|
|
810
|
+
The server atomically hard-deletes the record's constituents and the
|
|
811
|
+
record itself. It returns 404 when the record is missing and 409 when
|
|
812
|
+
the record is older than the server's undo window, which defaults to
|
|
813
|
+
600 seconds.
|
|
814
|
+
|
|
815
|
+
Args:
|
|
816
|
+
basket_id: String or integer basket identifier.
|
|
817
|
+
|
|
818
|
+
Returns:
|
|
819
|
+
The literal server value ``Deleted Successfully`` on success.
|
|
820
|
+
|
|
821
|
+
Raises:
|
|
822
|
+
requests.HTTPError: If the service rejects the request, including
|
|
823
|
+
404 for a missing record or 409 outside the undo window.
|
|
824
|
+
KeyError: If the response omits ``data``.
|
|
825
|
+
TypeError: If the identifier is not a string or integer.
|
|
826
|
+
ValueError: If the identifier is blank or contains ``/``.
|
|
827
|
+
"""
|
|
828
|
+
identifier = self._path_segment(basket_id)
|
|
829
|
+
return self._call("delete", f'{self.urls["basket"]}/{identifier}')
|
|
830
|
+
|
|
763
831
|
def get_model_history(
|
|
764
832
|
self, model: Any, *, status: Any = None, sort: Any = None
|
|
765
833
|
) -> Any:
|