Skip to content

Commit df6584e

Browse files
Reconnection management
1 parent e7fcbfb commit df6584e

10 files changed

Lines changed: 79 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ dist/
66
.ruff_cache/
77
.pytest_cache/
88
.venv/
9+
uv.lock
910
build/

linkedapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
from linkedapi.types import * # noqa: F403
6666
from linkedapi.types import __all__ as _types_all
6767

68-
__version__ = "1.0.2"
68+
__version__ = "1.0.3"
6969
PredefinedOperation = Operation
7070

7171
__all__ = [

linkedapi/admin/accounts.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
CancelConnectionSessionParams,
1212
ConnectionSessionResult,
1313
CreateConnectionSessionResult,
14+
CreateReconnectionSessionParams,
15+
CreateReconnectionSessionResult,
1416
DisconnectParams,
1517
GetConnectionSessionParams,
18+
ReparseAccountInfoParams,
19+
ReparseAccountInfoResult,
1620
RegenerateTokenParams,
1721
RegenerateTokenResult,
1822
)
@@ -30,6 +34,14 @@ def get_all(self) -> AccountsResult:
3034
def disconnect(self, params: DisconnectParams) -> None:
3135
self._post_void("/admin/accounts.disconnect", "Failed to disconnect account", params)
3236

37+
def reparse_account_info(self, params: ReparseAccountInfoParams) -> ReparseAccountInfoResult:
38+
return self._post_result(
39+
"/admin/accounts.reparseAccountInfo",
40+
ReparseAccountInfoResult,
41+
"Failed to reparse account info",
42+
params,
43+
)
44+
3345
def regenerate_identification_token(
3446
self,
3547
params: RegenerateTokenParams,
@@ -48,6 +60,17 @@ def create_connection_session(self) -> CreateConnectionSessionResult:
4860
"Failed to create connection session",
4961
)
5062

63+
def create_reconnection_session(
64+
self,
65+
params: CreateReconnectionSessionParams,
66+
) -> CreateReconnectionSessionResult:
67+
return self._post_result(
68+
"/admin/accounts.createReconnectionSession",
69+
CreateReconnectionSessionResult,
70+
"Failed to create reconnection session",
71+
params,
72+
)
73+
5174
def get_connection_session(
5275
self,
5376
params: GetConnectionSessionParams,

linkedapi/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"alreadyPending",
1010
"alreadyConnected",
1111
"emailRequired",
12+
"noteTooLong",
13+
"noteLimitExceeded",
1214
"requestNotAllowed",
1315
"notPending",
1416
"retrievingNotAllowed",
@@ -29,6 +31,8 @@
2931
"alreadyPending",
3032
"alreadyConnected",
3133
"emailRequired",
34+
"noteTooLong",
35+
"noteLimitExceeded",
3236
"requestNotAllowed",
3337
"notPending",
3438
"retrievingNotAllowed",

linkedapi/types/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
ConnectionSessionResult,
1313
ConnectionSessionStatus,
1414
CreateConnectionSessionResult,
15+
CreateReconnectionSessionParams,
16+
CreateReconnectionSessionResult,
1517
Currency,
1618
DeleteLimitEntry,
1719
DeleteLimitsParams,
@@ -26,6 +28,8 @@
2628
LimitUsage,
2729
LimitUsageResult,
2830
PendingConnectionSession,
31+
ReparseAccountInfoParams,
32+
ReparseAccountInfoResult,
2933
RegenerateTokenParams,
3034
RegenerateTokenResult,
3135
ResetLimitsParams,
@@ -228,6 +232,8 @@
228232
"ConversationPollResult",
229233
"ConversationType",
230234
"CreateConnectionSessionResult",
235+
"CreateReconnectionSessionParams",
236+
"CreateReconnectionSessionResult",
231237
"CreatePostAttachment",
232238
"CreatePostParams",
233239
"CreatePostResult",
@@ -312,6 +318,8 @@
312318
"ReactToPostParams",
313319
"Reaction",
314320
"ReactionType",
321+
"ReparseAccountInfoParams",
322+
"ReparseAccountInfoResult",
315323
"RegenerateTokenParams",
316324
"RegenerateTokenResult",
317325
"RemoveConnectionParams",

linkedapi/types/admin/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
ConnectionSessionResult,
88
ConnectionSessionStatus,
99
CreateConnectionSessionResult,
10+
CreateReconnectionSessionParams,
11+
CreateReconnectionSessionResult,
1012
DisconnectParams,
1113
GetConnectionSessionParams,
1214
PendingConnectionSession,
15+
ReparseAccountInfoParams,
16+
ReparseAccountInfoResult,
1317
RegenerateTokenParams,
1418
RegenerateTokenResult,
1519
)
@@ -59,6 +63,8 @@
5963
"ConnectionSessionResult",
6064
"ConnectionSessionStatus",
6165
"CreateConnectionSessionResult",
66+
"CreateReconnectionSessionParams",
67+
"CreateReconnectionSessionResult",
6268
"Currency",
6369
"DeleteLimitEntry",
6470
"DeleteLimitsParams",
@@ -73,6 +79,8 @@
7379
"LimitUsageResult",
7480
"LimitsResult",
7581
"PendingConnectionSession",
82+
"ReparseAccountInfoParams",
83+
"ReparseAccountInfoResult",
7684
"RegenerateTokenParams",
7785
"RegenerateTokenResult",
7886
"ResetLimitsParams",

linkedapi/types/admin/accounts.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020
class AdminAccount(LinkedApiModel):
2121
id: str | None = None
2222
name: str | None = None
23+
url: str | None = None
24+
avatar_url: str | None = None
25+
headline: str | None = None
2326
country_code: str | None = None
2427
identification_token: str | None = None
2528
status: AdminAccountStatus | None = None
2629
connected_at: str | None = None
30+
reconnection_session_id: str | None = None
31+
reconnection_link: str | None = None
2732

2833

2934
class PendingConnectionSession(LinkedApiModel):
@@ -40,6 +45,14 @@ class DisconnectParams(LinkedApiModel):
4045
account_id: str
4146

4247

48+
class ReparseAccountInfoParams(LinkedApiModel):
49+
account_id: str
50+
51+
52+
class ReparseAccountInfoResult(LinkedApiModel):
53+
workflow_id: str | None = None
54+
55+
4356
class RegenerateTokenParams(LinkedApiModel):
4457
account_id: str
4558

@@ -53,6 +66,15 @@ class CreateConnectionSessionResult(LinkedApiModel):
5366
connection_link: str | None = None
5467

5568

69+
class CreateReconnectionSessionParams(LinkedApiModel):
70+
account_id: str
71+
72+
73+
class CreateReconnectionSessionResult(LinkedApiModel):
74+
reconnection_session_id: str | None = None
75+
reconnection_link: str | None = None
76+
77+
5678
class GetConnectionSessionParams(LinkedApiModel):
5779
session_id: str
5880

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "linkedapi"
7-
version = "1.0.2"
7+
version = "1.0.3"
88
description = "Official synchronous Python SDK for Linked API."
99
readme = "README.md"
1010
requires-python = ">=3.10"

tests/test_admin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
AdminConfig,
99
AdminHttpClient,
1010
CancelConnectionSessionParams,
11+
CreateReconnectionSessionParams,
1112
DeleteLimitEntry,
1213
DeleteLimitsParams,
1314
DisconnectParams,
1415
GetConnectionSessionParams,
1516
GetLimitsParams,
1617
GetLimitsUsageParams,
1718
LinkedApiAdmin,
19+
ReparseAccountInfoParams,
1820
RegenerateTokenParams,
1921
ResetLimitsParams,
2022
SetLimitEntry,
@@ -65,8 +67,13 @@ def test_admin_methods_use_node_paths(requests_mock: requests_mock.Mocker) -> No
6567
("/admin/subscription.cancel", {"cancelAtDate": "2026-01-01"}),
6668
("/admin/accounts.getAll", {"accounts": [], "pendingConnectionSessions": []}),
6769
("/admin/accounts.disconnect", None),
70+
("/admin/accounts.reparseAccountInfo", {"workflowId": "workflow-1"}),
6871
("/admin/accounts.regenerateIdentificationToken", {"token": "new"}),
6972
("/admin/accounts.createConnectionSession", {"sessionId": "s1", "connectionLink": "u"}),
73+
(
74+
"/admin/accounts.createReconnectionSession",
75+
{"reconnectionSessionId": "s2", "reconnectionLink": "u2"},
76+
),
7077
(
7178
"/admin/accounts.getConnectionSession",
7279
{"session": {"sessionId": "s1", "status": "pending", "type": "connect"}},
@@ -95,8 +102,10 @@ def test_admin_methods_use_node_paths(requests_mock: requests_mock.Mocker) -> No
95102
admin.subscription.cancel()
96103
admin.accounts.get_all()
97104
admin.accounts.disconnect(DisconnectParams(account_id="a1"))
105+
admin.accounts.reparse_account_info(ReparseAccountInfoParams(account_id="a1"))
98106
admin.accounts.regenerate_identification_token(RegenerateTokenParams(account_id="a1"))
99107
admin.accounts.create_connection_session()
108+
admin.accounts.create_reconnection_session(CreateReconnectionSessionParams(account_id="a1"))
100109
admin.accounts.get_connection_session(GetConnectionSessionParams(session_id="s1"))
101110
admin.accounts.cancel_connection_session(CancelConnectionSessionParams(session_id="s1"))
102111
admin.limits.get_defaults()

tests/test_errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def test_error_type_sets_match_node_contract() -> None:
3535
"alreadyPending",
3636
"alreadyConnected",
3737
"emailRequired",
38+
"noteTooLong",
39+
"noteLimitExceeded",
3840
"requestNotAllowed",
3941
"notPending",
4042
"retrievingNotAllowed",

0 commit comments

Comments
 (0)