finatic-server-python 1.0.6__py3-none-any.whl → 1.0.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: finatic-server-python
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: Python SDK for Finatic Server API
5
5
  Project-URL: Homepage, https://github.com/FinaticORG/FinaticServerSDK-Python
6
6
  Project-URL: Documentation, https://docs.finatic.com/python
@@ -82,7 +82,7 @@ async def main() -> None:
82
82
  # After account.grant.created, start a session for that portal user, then read.
83
83
  portal_user_id = "user-from-connect-onSuccess"
84
84
  authed = await finatic.v1.start_session(user_id=portal_user_id)
85
- if not authed.get("session_id"):
85
+ if not authed.get("authenticated"):
86
86
  raise RuntimeError(authed.get("error") or "Authenticated session start failed")
87
87
  accounts = await finatic.v1.list_accounts(include_sync_status=True)
88
88
  if accounts.get("errors"):
@@ -111,6 +111,13 @@ Connect UI lives in **FinaticConnect**. This SDK does not open an iframe.
111
111
 
112
112
  Wait for HTTPS webhook `account.grant.created` (or poll `list_accounts` on an ACTIVE session) before account-scoped reads.
113
113
 
114
+ `start_session()` reports transport/session-start completion in `success` and
115
+ account readiness separately in `authenticated`. Account reads require
116
+ `authenticated=true`, which is returned only for an `active` session carrying
117
+ the server-authoritative `user_id`. The result also exposes `status`,
118
+ `provided_user_id_rejected`, and `portal_connection_management_pending` for
119
+ portal-flow handling.
120
+
114
121
  ## Trading
115
122
 
116
123
  Fetch the broker schema, then send an idempotent command:
@@ -2,13 +2,13 @@ finatic_server/__init__.py,sha256=4kk4SVN6YPa8g371MGc7jWoypOAn9YGwBDvJqLvQeqM,95
2
2
  finatic_server_python/__init__.py,sha256=LB4GcHvm7rEvldM1iqzVqYrJ4WDSQR5-AEd5Kj3uDLw,1082
3
3
  src/.openapi-generator-ignore,sha256=43VbPbcl7Kuqn8_Q0-Yt8syPgWNXrnOzS7qiFkxJw8Y,677
4
4
  src/FinaticServer.py,sha256=5FqaZEm21BNZeos-QMCTPDv3rWq4XWr9DGUU7K7M53k,238
5
- src/FinaticServerCore.py,sha256=hsunqG9ligZGEdqnkma1mki7TwHiEY7JRaQ0qJCwtaI,2704
6
- src/__init__.py,sha256=JjSrGrR3toIfaKHY2vrCO1uVP5ovh82dT4x4r9-dlAQ,980
5
+ src/FinaticServerCore.py,sha256=ecah0NDKHeO1d0sobe5Gpc8LZXjUz4p7ry5_L_3Q1os,2939
6
+ src/__init__.py,sha256=BS5vPhm0su2ol_CIzfLL6VhvbReGY6OIt_AYaDZJzPc,1205
7
7
  src/config.py,sha256=X10rF_jr-VlwiTAaHNIJZJ97q4932PoRKZW-P90j44M,2412
8
8
  src/finatic_fdx_typed_dicts.py,sha256=qI--a06hO53Lm0TMlHaLckMynhCcbaXh77hslyx1gd8,6383
9
9
  src/finatic_fdx_types.py,sha256=GXZi1ALPsn3p4XgRYb1wf_cIjjux_GzjQPNAXkZ9mRU,1865
10
10
  src/types.py,sha256=qYKqx95w5CjiXzMLk-GnojxQ8qsKxrMaY_XKiO7l49Q,712
11
- src/v1.py,sha256=VOto5gwBHwymbOYi3MlDSQC_Avp4nTm-yWyh5WxEMkI,28220
11
+ src/v1.py,sha256=C24MnPABmWFFHbi3f__62T5Dmj-NHkKBOxwZQjIXFlc,30336
12
12
  src/internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  src/openapi/.openapi-generator-ignore,sha256=43VbPbcl7Kuqn8_Q0-Yt8syPgWNXrnOzS7qiFkxJw8Y,677
14
14
  src/openapi/path_bootstrap.py,sha256=ywVDEDRhAEs9aqmchRETHPOONaGg5lV4U05CDsaMyxY,622
@@ -153,7 +153,6 @@ src/openapi/finatic_server/models/finatic_response_fdx_broker_order.py,sha256=0e
153
153
  src/openapi/finatic_server/models/finatic_response_fdx_broker_order_command_result.py,sha256=LV7v3Rj5lCfggpiwmlS5nmROVIL-hRgX6nqOvB1uROk,4046
154
154
  src/openapi/finatic_server/models/finatic_response_fdx_consent_grant.py,sha256=aufgX-guN_ZyyKf7-t3_tOztDaILE0_z45xe-PyABVM,4812
155
155
  src/openapi/finatic_server/models/finatic_response_fdx_webhook_subscription.py,sha256=SJKv6Lh1GSPz2jIk7iHrCXNL4oYjSP5IOoogMep51q4,4870
156
- src/openapi/finatic_server/models/finatic_response_link_user_to_mcp_session_response.py,sha256=sJsi_M5JRT7QA1YMt_M5vd2UR4wbiBHOZ_2dqCKGINM,4324
157
156
  src/openapi/finatic_server/models/finatic_response_link_user_to_session_response.py,sha256=uv4fGADv-NEIpstcmyRYY0-aDyqZANVuNpKmhfxdDB8,4299
158
157
  src/openapi/finatic_server/models/finatic_response_list_connector_list_item.py,sha256=MPX8o2sWFh-cNAUneKhbKXMBDN-_4JgxmIfKdrOj5TE,4266
159
158
  src/openapi/finatic_server/models/finatic_response_list_dict_str_any.py,sha256=4zGdF9lIZZ6Ild3ISr7L4zvNimqfvS0RKhA7Wn44skk,3941
@@ -199,13 +198,10 @@ src/openapi/finatic_server/models/instrumentid.py,sha256=nPGVRvLB47eSxlUPPswL0ku
199
198
  src/openapi/finatic_server/models/ioctif.py,sha256=hwzXHfJQyvqPigpg0i7m6QTBRhs83ZKV3jKj3-iqUrc,2755
200
199
  src/openapi/finatic_server/models/lastsyncedat.py,sha256=wJY9Umjb3MSmIqmwN90fR6v3OqiAEzLrXd92o10CCSk,4913
201
200
  src/openapi/finatic_server/models/limitprice.py,sha256=IKn9lxNP_q5bkY4pH8M4gWXxjqO9jiOl-VkYaIwzSGU,4895
202
- src/openapi/finatic_server/models/link_user_to_mcp_session_request.py,sha256=imVwvKJUbYAR_s1TFJy4aE1xiEG3_Zbgxv_KEp2-wGI,2595
203
- src/openapi/finatic_server/models/link_user_to_mcp_session_response.py,sha256=vFRUBaDIL6zITSP4zd2IbK6W0DnSIc-n_QMEuWZ53SI,2772
204
201
  src/openapi/finatic_server/models/link_user_to_session_response.py,sha256=pfDkGaNvzsMqpiq9-iay9YOEoceHeUM2bduOPi41xts,2971
205
202
  src/openapi/finatic_server/models/location_inner.py,sha256=v_PaJLz7NhhvY-WVwbJuxgO_R0aQlJUzr5iD_3L1s2g,4754
206
203
  src/openapi/finatic_server/models/maintenancemargin.py,sha256=ufuaGoa9Dcbk17NpUofi5q6DnVugGILyOWcQtb6JIHA,5002
207
204
  src/openapi/finatic_server/models/marketvalue.py,sha256=aPw6o99eHFA5G0xjd2poXCF-w25Dnb0KHxymKnNh1Wk,4909
208
- src/openapi/finatic_server/models/mcp_bootstrap_request.py,sha256=DN6f-e-EuUoNmilvXFnhp_6Hx1FTyTRt8KIzLuLzHZg,2794
209
205
  src/openapi/finatic_server/models/mt_connect_request.py,sha256=s3ACqF8EqtN514orVIcwAM-KUJcSe-Ngd3AZ-SKhFj4,3928
210
206
  src/openapi/finatic_server/models/multi_step_auth_response.py,sha256=nm8gR41I5e4S5tHVpxdC9J2N5H7XZBPapIvePZDmGEQ,4092
211
207
  src/openapi/finatic_server/models/netliquidationvalue.py,sha256=kvK_DDPsEpMvXw-joAZ0NO6LwbCprWoZNknZ6ZuvLLo,5015
@@ -345,7 +341,6 @@ src/openapi/finatic_server/models/success_payload_fdx_broker_order.py,sha256=EFx
345
341
  src/openapi/finatic_server/models/success_payload_fdx_broker_order_command_result.py,sha256=-Aj3uAGSpcpx-Q7U7OLuRfZmGhfWvWSkkpiLjShpIeM,3472
346
342
  src/openapi/finatic_server/models/success_payload_fdx_consent_grant.py,sha256=eHU7_FAPScxcVHUYGjgWso8rxtoPw9-cyYljTodTlpE,4117
347
343
  src/openapi/finatic_server/models/success_payload_fdx_webhook_subscription.py,sha256=8K8npr-nr9GjoNzR6bXff9XK9D1WqgTf6a6-jzjmoMY,4175
348
- src/openapi/finatic_server/models/success_payload_link_user_to_mcp_session_response.py,sha256=Berrpl9QRzPxwO64WqjM37eYpJbS_L9nU44EjZpchhA,3629
349
344
  src/openapi/finatic_server/models/success_payload_link_user_to_session_response.py,sha256=40mmKfG3BsvZnuxjoiE8l_9O_Jd8dBW1eeRBoHiXOsg,3604
350
345
  src/openapi/finatic_server/models/success_payload_list_connector_list_item.py,sha256=pR0wwbTD-iel_bIo62rcpAzdy4L07NMGDWyxnMl1AI8,3736
351
346
  src/openapi/finatic_server/models/success_payload_list_dict_str_any.py,sha256=1AKVPSVGvaexyAFPHZl9RZEurFaeeB_9PyJKd8Dpxxc,3090
@@ -449,7 +444,7 @@ src/utils/request_id.py,sha256=R_Gcyc5rih7_keAruJHW0bg0Y0MCqQNsUgkZ4C_9sRc,200
449
444
  src/utils/url_utils.py,sha256=dtxaFEF6Li_lQ7ft0BEDsbyYUDcNXUN4WO_yVAG5MJ8,5051
450
445
  src/utils/validation.py,sha256=ODt5raui4KVH1Iz_-Tt8-VKEw-yUzIZg6o93iWLwRj0,1263
451
446
  src/wrappers/__init__.py,sha256=8puRg8uOrUR42gCwCtW5zkOtCDbgyMpZSMi2iz2bPcU,123
452
- finatic_server_python-1.0.6.dist-info/METADATA,sha256=UdC63o4AMFNgGS5YDzLknB4K5ZnnRx-j7J1xknc84lk,7725
453
- finatic_server_python-1.0.6.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
454
- finatic_server_python-1.0.6.dist-info/licenses/LICENSE,sha256=hE35tOCe7uZCeYglYc-sjRSjad4jPyB3i53-QW1YfLk,3590
455
- finatic_server_python-1.0.6.dist-info/RECORD,,
447
+ finatic_server_python-1.0.8.dist-info/METADATA,sha256=iKF00nhRfksr5nN_kfRarJZzSxrUVP_pj5uEGDY-u1A,8124
448
+ finatic_server_python-1.0.8.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
449
+ finatic_server_python-1.0.8.dist-info/licenses/LICENSE,sha256=hE35tOCe7uZCeYglYc-sjRSjad4jPyB3i53-QW1YfLk,3590
450
+ finatic_server_python-1.0.8.dist-info/RECORD,,
src/FinaticServerCore.py CHANGED
@@ -74,6 +74,11 @@ class FinaticServer:
74
74
  "/api/v1/session/init + /start responses."
75
75
  )
76
76
  raise ValueError(str(error_message))
77
+ if user_id is not None and not session_result.get("authenticated"):
78
+ raise ValueError(
79
+ "Session initialization failed: requested user identity was not "
80
+ "authenticated."
81
+ )
77
82
  if not instance.v1.get_session_id():
78
83
  raise ValueError("Session initialization failed: missing session_id.")
79
84
  return instance
src/__init__.py CHANGED
@@ -7,11 +7,6 @@ try:
7
7
  except ModuleNotFoundError:
8
8
  pass
9
9
 
10
- try:
11
- from .v1 import AccountOrderCommand, V1Client
12
- except ModuleNotFoundError:
13
- pass
14
-
15
10
  try:
16
11
  from .finatic_fdx_types import (
17
12
  AccountOrderPayload,
@@ -39,3 +34,15 @@ try:
39
34
  from finatic_server import * # type: ignore[F401,F403]
40
35
  except ModuleNotFoundError:
41
36
  pass
37
+
38
+ # Bind the hand-written facade exports after the generated wildcard import so
39
+ # generated model names cannot replace the public v1 contract aliases.
40
+ try:
41
+ from .v1 import (
42
+ AccountOrderCommand,
43
+ SessionStartResult,
44
+ SessionStatus,
45
+ V1Client,
46
+ )
47
+ except ModuleNotFoundError:
48
+ pass
src/v1.py CHANGED
@@ -10,7 +10,7 @@ import inspect
10
10
  import json
11
11
  from collections.abc import Mapping
12
12
  from dataclasses import dataclass
13
- from typing import Any, Literal, cast
13
+ from typing import Any, Literal, TypedDict, cast
14
14
  from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
15
15
 
16
16
  from finatic_server.api_client import ApiClient
@@ -34,6 +34,36 @@ from .utils.url_utils import (
34
34
  )
35
35
 
36
36
  Environment = str
37
+ SessionStatus = Literal[
38
+ "pending",
39
+ "authenticating",
40
+ "active",
41
+ "completed",
42
+ "expired",
43
+ ]
44
+ _SESSION_STATUSES: set[str] = {
45
+ "pending",
46
+ "authenticating",
47
+ "active",
48
+ "completed",
49
+ "expired",
50
+ }
51
+
52
+
53
+ class SessionStartResult(TypedDict):
54
+ """Normalized result for every public session-start attempt."""
55
+
56
+ success: bool
57
+ session_id: str | None
58
+ company_id: str | None
59
+ error: str | None
60
+ status: SessionStatus | None
61
+ user_id: str | None
62
+ provided_user_id_rejected: bool
63
+ portal_connection_management_pending: bool
64
+ authenticated: bool
65
+
66
+
37
67
  _ERROR_CODE_BY_STATUS = {
38
68
  400: "VALIDATION",
39
69
  401: "AUTHENTICATION",
@@ -73,6 +103,39 @@ def _read_session_field(data: dict[str, Any] | None, keys: tuple[str, ...]) -> s
73
103
  return ""
74
104
 
75
105
 
106
+ def _read_session_status(
107
+ data: dict[str, Any] | None, keys: tuple[str, ...]
108
+ ) -> SessionStatus | None:
109
+ value = _read_session_field(data, keys)
110
+ if value not in _SESSION_STATUSES:
111
+ return None
112
+ return cast(SessionStatus, value)
113
+
114
+
115
+ def _read_session_bool(data: dict[str, Any] | None, keys: tuple[str, ...]) -> bool:
116
+ if not data:
117
+ return False
118
+ for key in keys:
119
+ if key in data:
120
+ value = data[key]
121
+ return value if type(value) is bool else False
122
+ return False
123
+
124
+
125
+ def _failed_session_start(error: str) -> SessionStartResult:
126
+ return {
127
+ "success": False,
128
+ "session_id": None,
129
+ "company_id": None,
130
+ "error": error,
131
+ "status": None,
132
+ "user_id": None,
133
+ "provided_user_id_rejected": False,
134
+ "portal_connection_management_pending": False,
135
+ "authenticated": False,
136
+ }
137
+
138
+
76
139
  def _append_query_param(url: str, name: str, value: str) -> str:
77
140
  parsed = urlparse(url)
78
141
  query_params = parse_qs(parsed.query)
@@ -100,6 +163,8 @@ class V1Client:
100
163
  self.authorization: str | None = None
101
164
  self.csrf_token: str | None = None
102
165
  self.user_id: str | None = None
166
+ self.session_status: SessionStatus | None = None
167
+ self.authenticated = False
103
168
 
104
169
  def set_environment(self, environment: Environment) -> None:
105
170
  """Set the public v1 environment for subsequent requests."""
@@ -129,7 +194,7 @@ class V1Client:
129
194
  return self.user_id
130
195
 
131
196
  def is_authed(self) -> bool:
132
- return bool(self.user_id)
197
+ return self.authenticated
133
198
 
134
199
  async def init_session(self, api_key: str | None = None) -> FinaticResponse:
135
200
  return await self._request(
@@ -170,38 +235,24 @@ class V1Client:
170
235
  *,
171
236
  one_time_token: str | None = None,
172
237
  user_id: str | None = None,
173
- ) -> dict[str, Any]:
238
+ ) -> SessionStartResult:
174
239
  if not one_time_token:
175
240
  if not self.api_key:
176
- return {
177
- "success": False,
178
- "session_id": None,
179
- "company_id": None,
180
- "error": "API key is required in the constructor.",
181
- }
241
+ return _failed_session_start("API key is required in the constructor.")
182
242
  try:
183
- token = await self.get_token()
184
- started = await self._start_session_with_token(token, user_id)
185
- return {
186
- "success": True,
187
- "session_id": started["session_id"],
188
- "company_id": started["company_id"],
189
- "error": None,
190
- }
243
+ one_time_token = await self.get_token()
191
244
  except Exception as error:
192
- return {
193
- "success": False,
194
- "session_id": None,
195
- "company_id": None,
196
- "error": str(error),
197
- }
198
- return await self._start_session_with_token(one_time_token, user_id)
245
+ return _failed_session_start(str(error))
246
+ try:
247
+ return await self._start_session_with_token(one_time_token, user_id)
248
+ except Exception as error:
249
+ return _failed_session_start(str(error))
199
250
 
200
251
  async def _start_session_with_token(
201
252
  self,
202
253
  one_time_token: str,
203
254
  user_id: str | None = None,
204
- ) -> dict[str, str]:
255
+ ) -> SessionStartResult:
205
256
  body = {"user_id": user_id} if user_id else None
206
257
  response = await self._request(
207
258
  "POST",
@@ -220,15 +271,40 @@ class V1Client:
220
271
  company_id = _read_session_field(session_data_dict, ("company_id", "companyId"))
221
272
  csrf_token = _read_session_field(session_data_dict, ("csrf_token", "csrfToken"))
222
273
  response_user_id = _read_session_field(session_data_dict, ("user_id", "userId"))
274
+ status = _read_session_status(session_data_dict, ("status",))
275
+ provided_user_id_rejected = _read_session_bool(
276
+ session_data_dict,
277
+ ("provided_user_id_rejected", "providedUserIdRejected"),
278
+ )
279
+ portal_connection_management_pending = _read_session_bool(
280
+ session_data_dict,
281
+ (
282
+ "portal_connection_management_pending",
283
+ "portalConnectionManagementPending",
284
+ ),
285
+ )
286
+ authenticated = status == "active" and bool(response_user_id)
223
287
 
224
288
  if session_id and company_id:
225
289
  self.set_session_context(session_id, company_id, csrf_token=csrf_token)
226
290
 
227
- final_user_id = response_user_id or user_id
228
- if final_user_id:
229
- self.user_id = final_user_id
291
+ self.session_status = status
292
+ self.authenticated = authenticated
293
+ self.user_id = response_user_id if authenticated else None
230
294
 
231
- return {"session_id": session_id, "company_id": company_id}
295
+ return {
296
+ "success": True,
297
+ "session_id": session_id or None,
298
+ "company_id": company_id or None,
299
+ "error": None,
300
+ "status": status,
301
+ "user_id": response_user_id or None,
302
+ "provided_user_id_rejected": provided_user_id_rejected,
303
+ "portal_connection_management_pending": (
304
+ portal_connection_management_pending
305
+ ),
306
+ "authenticated": authenticated,
307
+ }
232
308
 
233
309
  async def get_portal_url(
234
310
  self,
@@ -1,111 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Finatic FastAPI Backend
5
-
6
- FinaticAPI REST API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional
22
- from finatic_server.models.success_payload_link_user_to_mcp_session_response import SuccessPayloadLinkUserToMCPSessionResponse
23
- from typing import Optional, Set
24
- from typing_extensions import Self
25
- from pydantic_core import to_jsonable_python
26
-
27
- class FinaticResponseLinkUserToMCPSessionResponse(BaseModel):
28
- """
29
- FinaticResponseLinkUserToMCPSessionResponse
30
- """ # noqa: E501
31
- error: Optional[Dict[str, Any]] = Field(default=None, description="Optional error object with message, code, status, and details")
32
- success: Optional[SuccessPayloadLinkUserToMCPSessionResponse] = Field(default=None, description="Success payload containing data and optional meta. None when error is present.")
33
- trace_id: Optional[StrictStr] = Field(default='', description="Request trace identifier for tracking and debugging. Auto-generated if not provided.")
34
- warning: Optional[List[Dict[str, Any]]] = Field(default=None, description="Optional array of warning objects")
35
- __properties: ClassVar[List[str]] = ["error", "success", "trace_id", "warning"]
36
-
37
- model_config = ConfigDict(
38
- validate_by_name=True,
39
- validate_by_alias=True,
40
- validate_assignment=True,
41
- protected_namespaces=(),
42
- )
43
-
44
-
45
- def to_str(self) -> str:
46
- """Returns the string representation of the model using alias"""
47
- return pprint.pformat(self.model_dump(by_alias=True))
48
-
49
- def to_json(self) -> str:
50
- """Returns the JSON representation of the model using alias"""
51
- return json.dumps(to_jsonable_python(self.to_dict()))
52
-
53
- @classmethod
54
- def from_json(cls, json_str: str) -> Optional[Self]:
55
- """Create an instance of FinaticResponseLinkUserToMCPSessionResponse from a JSON string"""
56
- return cls.from_dict(json.loads(json_str))
57
-
58
- def to_dict(self) -> Dict[str, Any]:
59
- """Return the dictionary representation of the model using alias.
60
-
61
- This has the following differences from calling pydantic's
62
- `self.model_dump(by_alias=True)`:
63
-
64
- * `None` is only added to the output dict for nullable fields that
65
- were set at model initialization. Other fields with value `None`
66
- are ignored.
67
- """
68
- excluded_fields: Set[str] = set([
69
- ])
70
-
71
- _dict = self.model_dump(
72
- by_alias=True,
73
- exclude=excluded_fields,
74
- exclude_none=True,
75
- )
76
- # override the default output from pydantic by calling `to_dict()` of success
77
- if self.success:
78
- _dict['success'] = self.success.to_dict()
79
- # set to None if error (nullable) is None
80
- # and model_fields_set contains the field
81
- if self.error is None and "error" in self.model_fields_set:
82
- _dict['error'] = None
83
-
84
- # set to None if success (nullable) is None
85
- # and model_fields_set contains the field
86
- if self.success is None and "success" in self.model_fields_set:
87
- _dict['success'] = None
88
-
89
- # set to None if warning (nullable) is None
90
- # and model_fields_set contains the field
91
- if self.warning is None and "warning" in self.model_fields_set:
92
- _dict['warning'] = None
93
-
94
- return _dict
95
-
96
- @classmethod
97
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98
- """Create an instance of FinaticResponseLinkUserToMCPSessionResponse from a dict"""
99
- if obj is None:
100
- return None
101
-
102
- if not isinstance(obj, dict):
103
- return cls.model_validate(obj)
104
-
105
- _obj = cls.model_validate({
106
- "error": obj.get("error"),
107
- "success": SuccessPayloadLinkUserToMCPSessionResponse.from_dict(obj["success"]) if obj.get("success") is not None else None,
108
- "trace_id": obj.get("trace_id") if obj.get("trace_id") is not None else '',
109
- "warning": obj.get("warning")
110
- })
111
- return _obj
@@ -1,88 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Finatic FastAPI Backend
5
-
6
- FinaticAPI REST API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, StrictStr
21
- from typing import Any, ClassVar, Dict, List
22
- from typing import Optional, Set
23
- from typing_extensions import Self
24
- from pydantic_core import to_jsonable_python
25
-
26
- class LinkUserToMCPSessionRequest(BaseModel):
27
- """
28
- Request model for linking user to MCP session.
29
- """ # noqa: E501
30
- link_context_id: StrictStr
31
- user_id: StrictStr
32
- __properties: ClassVar[List[str]] = ["link_context_id", "user_id"]
33
-
34
- model_config = ConfigDict(
35
- validate_by_name=True,
36
- validate_by_alias=True,
37
- validate_assignment=True,
38
- protected_namespaces=(),
39
- )
40
-
41
-
42
- def to_str(self) -> str:
43
- """Returns the string representation of the model using alias"""
44
- return pprint.pformat(self.model_dump(by_alias=True))
45
-
46
- def to_json(self) -> str:
47
- """Returns the JSON representation of the model using alias"""
48
- return json.dumps(to_jsonable_python(self.to_dict()))
49
-
50
- @classmethod
51
- def from_json(cls, json_str: str) -> Optional[Self]:
52
- """Create an instance of LinkUserToMCPSessionRequest from a JSON string"""
53
- return cls.from_dict(json.loads(json_str))
54
-
55
- def to_dict(self) -> Dict[str, Any]:
56
- """Return the dictionary representation of the model using alias.
57
-
58
- This has the following differences from calling pydantic's
59
- `self.model_dump(by_alias=True)`:
60
-
61
- * `None` is only added to the output dict for nullable fields that
62
- were set at model initialization. Other fields with value `None`
63
- are ignored.
64
- """
65
- excluded_fields: Set[str] = set([
66
- ])
67
-
68
- _dict = self.model_dump(
69
- by_alias=True,
70
- exclude=excluded_fields,
71
- exclude_none=True,
72
- )
73
- return _dict
74
-
75
- @classmethod
76
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
- """Create an instance of LinkUserToMCPSessionRequest from a dict"""
78
- if obj is None:
79
- return None
80
-
81
- if not isinstance(obj, dict):
82
- return cls.model_validate(obj)
83
-
84
- _obj = cls.model_validate({
85
- "link_context_id": obj.get("link_context_id"),
86
- "user_id": obj.get("user_id")
87
- })
88
- return _obj
@@ -1,90 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Finatic FastAPI Backend
5
-
6
- FinaticAPI REST API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional
22
- from typing import Optional, Set
23
- from typing_extensions import Self
24
- from pydantic_core import to_jsonable_python
25
-
26
- class LinkUserToMCPSessionResponse(BaseModel):
27
- """
28
- MCP link completion response model.
29
- """ # noqa: E501
30
- linked_user_id: StrictStr
31
- mcp_session_id: StrictStr
32
- success: Optional[StrictBool] = True
33
- __properties: ClassVar[List[str]] = ["linked_user_id", "mcp_session_id", "success"]
34
-
35
- model_config = ConfigDict(
36
- validate_by_name=True,
37
- validate_by_alias=True,
38
- validate_assignment=True,
39
- protected_namespaces=(),
40
- )
41
-
42
-
43
- def to_str(self) -> str:
44
- """Returns the string representation of the model using alias"""
45
- return pprint.pformat(self.model_dump(by_alias=True))
46
-
47
- def to_json(self) -> str:
48
- """Returns the JSON representation of the model using alias"""
49
- return json.dumps(to_jsonable_python(self.to_dict()))
50
-
51
- @classmethod
52
- def from_json(cls, json_str: str) -> Optional[Self]:
53
- """Create an instance of LinkUserToMCPSessionResponse from a JSON string"""
54
- return cls.from_dict(json.loads(json_str))
55
-
56
- def to_dict(self) -> Dict[str, Any]:
57
- """Return the dictionary representation of the model using alias.
58
-
59
- This has the following differences from calling pydantic's
60
- `self.model_dump(by_alias=True)`:
61
-
62
- * `None` is only added to the output dict for nullable fields that
63
- were set at model initialization. Other fields with value `None`
64
- are ignored.
65
- """
66
- excluded_fields: Set[str] = set([
67
- ])
68
-
69
- _dict = self.model_dump(
70
- by_alias=True,
71
- exclude=excluded_fields,
72
- exclude_none=True,
73
- )
74
- return _dict
75
-
76
- @classmethod
77
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78
- """Create an instance of LinkUserToMCPSessionResponse from a dict"""
79
- if obj is None:
80
- return None
81
-
82
- if not isinstance(obj, dict):
83
- return cls.model_validate(obj)
84
-
85
- _obj = cls.model_validate({
86
- "linked_user_id": obj.get("linked_user_id"),
87
- "mcp_session_id": obj.get("mcp_session_id"),
88
- "success": obj.get("success") if obj.get("success") is not None else True
89
- })
90
- return _obj
@@ -1,91 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Finatic FastAPI Backend
5
-
6
- FinaticAPI REST API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional
22
- from typing import Optional, Set
23
- from typing_extensions import Self
24
- from pydantic_core import to_jsonable_python
25
-
26
- class MCPBootstrapRequest(BaseModel):
27
- """
28
- Request model for MCP bearer bootstrap.
29
- """ # noqa: E501
30
- scopes: Optional[List[StrictStr]] = Field(default=None, description="Optional MCP scopes to request. Defaults to all supported scopes.")
31
- __properties: ClassVar[List[str]] = ["scopes"]
32
-
33
- model_config = ConfigDict(
34
- validate_by_name=True,
35
- validate_by_alias=True,
36
- validate_assignment=True,
37
- protected_namespaces=(),
38
- )
39
-
40
-
41
- def to_str(self) -> str:
42
- """Returns the string representation of the model using alias"""
43
- return pprint.pformat(self.model_dump(by_alias=True))
44
-
45
- def to_json(self) -> str:
46
- """Returns the JSON representation of the model using alias"""
47
- return json.dumps(to_jsonable_python(self.to_dict()))
48
-
49
- @classmethod
50
- def from_json(cls, json_str: str) -> Optional[Self]:
51
- """Create an instance of MCPBootstrapRequest from a JSON string"""
52
- return cls.from_dict(json.loads(json_str))
53
-
54
- def to_dict(self) -> Dict[str, Any]:
55
- """Return the dictionary representation of the model using alias.
56
-
57
- This has the following differences from calling pydantic's
58
- `self.model_dump(by_alias=True)`:
59
-
60
- * `None` is only added to the output dict for nullable fields that
61
- were set at model initialization. Other fields with value `None`
62
- are ignored.
63
- """
64
- excluded_fields: Set[str] = set([
65
- ])
66
-
67
- _dict = self.model_dump(
68
- by_alias=True,
69
- exclude=excluded_fields,
70
- exclude_none=True,
71
- )
72
- # set to None if scopes (nullable) is None
73
- # and model_fields_set contains the field
74
- if self.scopes is None and "scopes" in self.model_fields_set:
75
- _dict['scopes'] = None
76
-
77
- return _dict
78
-
79
- @classmethod
80
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81
- """Create an instance of MCPBootstrapRequest from a dict"""
82
- if obj is None:
83
- return None
84
-
85
- if not isinstance(obj, dict):
86
- return cls.model_validate(obj)
87
-
88
- _obj = cls.model_validate({
89
- "scopes": obj.get("scopes")
90
- })
91
- return _obj
@@ -1,104 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Finatic FastAPI Backend
5
-
6
- FinaticAPI REST API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
- import pprint
17
- import re # noqa: F401
18
- import json
19
-
20
- from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
- from typing import Any, ClassVar, Dict, List, Optional
22
- from finatic_server.models.link_user_to_mcp_session_response import LinkUserToMCPSessionResponse
23
- from typing import Optional, Set
24
- from typing_extensions import Self
25
- from pydantic_core import to_jsonable_python
26
-
27
- class SuccessPayloadLinkUserToMCPSessionResponse(BaseModel):
28
- """
29
- SuccessPayloadLinkUserToMCPSessionResponse
30
- """ # noqa: E501
31
- id: Optional[StrictStr] = Field(default=None, alias="_id")
32
- data: Optional[LinkUserToMCPSessionResponse] = Field(default=None, description="The response data (None when error is present)")
33
- meta: Optional[Dict[str, Any]] = Field(default=None, description="Optional metadata (pagination, etc.)")
34
- __properties: ClassVar[List[str]] = ["_id", "data", "meta"]
35
-
36
- model_config = ConfigDict(
37
- validate_by_name=True,
38
- validate_by_alias=True,
39
- validate_assignment=True,
40
- protected_namespaces=(),
41
- )
42
-
43
-
44
- def to_str(self) -> str:
45
- """Returns the string representation of the model using alias"""
46
- return pprint.pformat(self.model_dump(by_alias=True))
47
-
48
- def to_json(self) -> str:
49
- """Returns the JSON representation of the model using alias"""
50
- return json.dumps(to_jsonable_python(self.to_dict()))
51
-
52
- @classmethod
53
- def from_json(cls, json_str: str) -> Optional[Self]:
54
- """Create an instance of SuccessPayloadLinkUserToMCPSessionResponse from a JSON string"""
55
- return cls.from_dict(json.loads(json_str))
56
-
57
- def to_dict(self) -> Dict[str, Any]:
58
- """Return the dictionary representation of the model using alias.
59
-
60
- This has the following differences from calling pydantic's
61
- `self.model_dump(by_alias=True)`:
62
-
63
- * `None` is only added to the output dict for nullable fields that
64
- were set at model initialization. Other fields with value `None`
65
- are ignored.
66
- """
67
- excluded_fields: Set[str] = set([
68
- ])
69
-
70
- _dict = self.model_dump(
71
- by_alias=True,
72
- exclude=excluded_fields,
73
- exclude_none=True,
74
- )
75
- # override the default output from pydantic by calling `to_dict()` of data
76
- if self.data:
77
- _dict['data'] = self.data.to_dict()
78
- # set to None if data (nullable) is None
79
- # and model_fields_set contains the field
80
- if self.data is None and "data" in self.model_fields_set:
81
- _dict['data'] = None
82
-
83
- # set to None if meta (nullable) is None
84
- # and model_fields_set contains the field
85
- if self.meta is None and "meta" in self.model_fields_set:
86
- _dict['meta'] = None
87
-
88
- return _dict
89
-
90
- @classmethod
91
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
- """Create an instance of SuccessPayloadLinkUserToMCPSessionResponse from a dict"""
93
- if obj is None:
94
- return None
95
-
96
- if not isinstance(obj, dict):
97
- return cls.model_validate(obj)
98
-
99
- _obj = cls.model_validate({
100
- "_id": obj.get("_id"),
101
- "data": LinkUserToMCPSessionResponse.from_dict(obj["data"]) if obj.get("data") is not None else None,
102
- "meta": obj.get("meta")
103
- })
104
- return _obj