tapdata-sdk 0.1.0__py3-none-any.whl → 0.3.0__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.
- tapdata_sdk/__init__.py +1 -1
- tapdata_sdk/client.py +23 -1
- tapdata_sdk/models.py +50 -1
- {tapdata_sdk-0.1.0.dist-info → tapdata_sdk-0.3.0.dist-info}/METADATA +10 -4
- tapdata_sdk-0.3.0.dist-info/RECORD +11 -0
- tapdata_sdk-0.1.0.dist-info/RECORD +0 -11
- {tapdata_sdk-0.1.0.dist-info → tapdata_sdk-0.3.0.dist-info}/WHEEL +0 -0
- {tapdata_sdk-0.1.0.dist-info → tapdata_sdk-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {tapdata_sdk-0.1.0.dist-info → tapdata_sdk-0.3.0.dist-info}/top_level.txt +0 -0
tapdata_sdk/__init__.py
CHANGED
|
@@ -20,7 +20,7 @@ Examples:
|
|
|
20
20
|
>>> client.tasks.stop(tasks[0].id)
|
|
21
21
|
"""
|
|
22
22
|
from .client import TapdataClient, ConnectionClient, TaskClient
|
|
23
|
-
from .models import Connection, Task, TaskLog
|
|
23
|
+
from .models import Connection, Task, TaskLog, TaskDetail, TaskRelation
|
|
24
24
|
from .enums import ConnectionType, DatabaseType, Status, LogLevel
|
|
25
25
|
from .exceptions import (
|
|
26
26
|
TapdataError,
|
tapdata_sdk/client.py
CHANGED
|
@@ -14,7 +14,7 @@ from .exceptions import (
|
|
|
14
14
|
TapdataError,
|
|
15
15
|
TapdataTimeoutError,
|
|
16
16
|
)
|
|
17
|
-
from .models import Connection, Task, TaskDetail, TaskLog
|
|
17
|
+
from .models import Connection, Task, TaskDetail, TaskLog, TaskRelation
|
|
18
18
|
from .utils import rc4_encrypt, gen_sign, build_filter
|
|
19
19
|
from .enums import ConnectionType, DatabaseType, Status, LogLevel
|
|
20
20
|
|
|
@@ -363,6 +363,28 @@ class TaskClient:
|
|
|
363
363
|
"""
|
|
364
364
|
resp = self.client._request("GET", f"/api/Task/{task_id}")
|
|
365
365
|
return TaskDetail.from_dict(resp["data"])
|
|
366
|
+
|
|
367
|
+
def get_table_relation(self, task_id: str) -> TaskRelation:
|
|
368
|
+
"""
|
|
369
|
+
Get Task Table Name Relation
|
|
370
|
+
|
|
371
|
+
Args:
|
|
372
|
+
task_id: Unique identifier for the task
|
|
373
|
+
|
|
374
|
+
Returns:
|
|
375
|
+
TaskRelation
|
|
376
|
+
"""
|
|
377
|
+
task_detail = self.get(task_id)
|
|
378
|
+
|
|
379
|
+
relation = TaskRelation.from_dict(task_detail.to_dict())
|
|
380
|
+
|
|
381
|
+
if relation.source_connection_id:
|
|
382
|
+
relation.source_conn = self.client.connections.get(relation.source_connection_id)
|
|
383
|
+
|
|
384
|
+
if relation.target_connection_id:
|
|
385
|
+
relation.target_conn = self.client.connections.get(relation.target_connection_id)
|
|
386
|
+
|
|
387
|
+
return relation
|
|
366
388
|
|
|
367
389
|
def list_running(self) -> List[Task]:
|
|
368
390
|
"""Get all running tasks"""
|
tapdata_sdk/models.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Data model definitions"""
|
|
2
2
|
from dataclasses import dataclass
|
|
3
|
-
from typing import Optional, List
|
|
3
|
+
from typing import Optional, List, Dict
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
@dataclass
|
|
@@ -124,6 +124,55 @@ class TaskDetail:
|
|
|
124
124
|
"nodes": self.nodes
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
@dataclass
|
|
128
|
+
class TaskRelation:
|
|
129
|
+
"""
|
|
130
|
+
Task connection relationship mapping model
|
|
131
|
+
"""
|
|
132
|
+
source_connection_id: Optional[str] = None
|
|
133
|
+
target_connection_id: Optional[str] = None
|
|
134
|
+
table_name_relation: Optional[Dict[str, str]] = None
|
|
135
|
+
source_conn: Optional[Connection] = None
|
|
136
|
+
target_conn: Optional[Connection] = None
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def from_dict(cls, data: dict) -> "TaskRelation":
|
|
140
|
+
"""
|
|
141
|
+
Create TaskRelation from task detail dictionary
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
data: Raw task data from API (containing 'dag' and 'nodes')
|
|
145
|
+
"""
|
|
146
|
+
nodes = data.get("nodes", [])
|
|
147
|
+
|
|
148
|
+
if len(nodes) < 2:
|
|
149
|
+
return cls()
|
|
150
|
+
|
|
151
|
+
source_node = nodes[0]
|
|
152
|
+
target_node = nodes[-1]
|
|
153
|
+
|
|
154
|
+
relations = {}
|
|
155
|
+
for obj in target_node.get("syncObjects", []):
|
|
156
|
+
if "tableNameRelation" in obj:
|
|
157
|
+
relations.update(obj["tableNameRelation"])
|
|
158
|
+
|
|
159
|
+
return cls(
|
|
160
|
+
source_connection_id=source_node.get("connectionId"),
|
|
161
|
+
target_connection_id=target_node.get("connectionId"),
|
|
162
|
+
table_name_relation=relations
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
def to_dict(self) -> dict:
|
|
166
|
+
"""
|
|
167
|
+
Convert to dictionary including nested connection details
|
|
168
|
+
"""
|
|
169
|
+
return {
|
|
170
|
+
"source_connection_id": self.source_connection_id,
|
|
171
|
+
"target_connection_id": self.target_connection_id,
|
|
172
|
+
"table_name_relation": self.table_name_relation,
|
|
173
|
+
"source": self.source_conn.to_dict() if self.source_conn else None,
|
|
174
|
+
"target": self.target_conn.to_dict() if self.target_conn else None
|
|
175
|
+
}
|
|
127
176
|
|
|
128
177
|
@dataclass
|
|
129
178
|
class TaskLog:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tapdata_sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A Python client library for interacting with Tapdata API
|
|
5
5
|
Author-email: doubled <309294891@qq.com>
|
|
6
6
|
License: MIT
|
|
@@ -52,14 +52,14 @@ A Python client library for interacting with Tapdata API.
|
|
|
52
52
|
## Installation
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
pip install
|
|
55
|
+
pip install tapdata-sdk
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Or install from source:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
61
|
git clone https://github.com/lddlww/tapdata_sdk.git
|
|
62
|
-
cd
|
|
62
|
+
cd tapdata_sdk
|
|
63
63
|
pip install -e .
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -85,6 +85,10 @@ for conn in connections:
|
|
|
85
85
|
tasks = client.tasks.list()
|
|
86
86
|
for task in tasks:
|
|
87
87
|
print(f"{task.name}: {task.status}")
|
|
88
|
+
|
|
89
|
+
# Get Table Relation
|
|
90
|
+
table_relation = client.tasks.get_table_relation(task_id='xxx')
|
|
91
|
+
print(f"{table_relation.table_name_relation}")
|
|
88
92
|
```
|
|
89
93
|
|
|
90
94
|
### Connection Management
|
|
@@ -317,8 +321,10 @@ isort tapdata_sdk/
|
|
|
317
321
|
```
|
|
318
322
|
|
|
319
323
|
## Changelog
|
|
324
|
+
### v0.3.0 (2026-02-03)
|
|
325
|
+
- ✨ added TaskDetail and TaskRelation function
|
|
320
326
|
|
|
321
|
-
### v0.2.0 (
|
|
327
|
+
### v0.2.0 (2026-01-29)
|
|
322
328
|
- ✨ Refactored code architecture with modular design
|
|
323
329
|
- 📦 Added data model classes (Connection, Task, TaskLog)
|
|
324
330
|
- 🎯 Improved enum types using Python Enum
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
tapdata_sdk/__init__.py,sha256=aJPKZC_GByqMDTowZN02kW1UvaMm4_gOZ0uvRDs5-Os,1358
|
|
2
|
+
tapdata_sdk/client.py,sha256=SJ6pTHJUmpkBHT1YnijHUzkzCs0miQsoAocjIWBmkL4,14543
|
|
3
|
+
tapdata_sdk/enums.py,sha256=ywCPyswMdbISvuII9Lv7QSmwHUbfqsQB3mK_UPV7C9A,1160
|
|
4
|
+
tapdata_sdk/exceptions.py,sha256=Edm1P6Aghb7wJhUOubYU9JuxcQrfI_WGn3wnX4ukH7Y,627
|
|
5
|
+
tapdata_sdk/models.py,sha256=3WMU3KPYaZorM8f5BE_IG3bQiTjYeFhE0oc8ZsgAr7A,6217
|
|
6
|
+
tapdata_sdk/utils.py,sha256=ojPuW9YwW7dkb0nLJ46_IgMbOzor7DtppYDBuN4nCiY,2682
|
|
7
|
+
tapdata_sdk-0.3.0.dist-info/licenses/LICENSE,sha256=g3faROod99RM6X9tAOfJ_7LsPxI1sOISYpIy2w9VexQ,1064
|
|
8
|
+
tapdata_sdk-0.3.0.dist-info/METADATA,sha256=qEaWfiU2x2bzRT4gAJOgYvfNG_gQP2i6ukZzwGGXtoA,8139
|
|
9
|
+
tapdata_sdk-0.3.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
tapdata_sdk-0.3.0.dist-info/top_level.txt,sha256=YNIwm3uNhULMB32qsLcj-zAoL5yYMKWJbXnstNsIYNk,12
|
|
11
|
+
tapdata_sdk-0.3.0.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
tapdata_sdk/__init__.py,sha256=DCbgmv3TOkTHR69LFEJ3Y9Oxm9WfUBQUhyqUMyySSVk,1332
|
|
2
|
-
tapdata_sdk/client.py,sha256=yx6W2iVnE_3b8ybguRevr3Oid2dUs73XPLZyu-KVyjw,13888
|
|
3
|
-
tapdata_sdk/enums.py,sha256=ywCPyswMdbISvuII9Lv7QSmwHUbfqsQB3mK_UPV7C9A,1160
|
|
4
|
-
tapdata_sdk/exceptions.py,sha256=Edm1P6Aghb7wJhUOubYU9JuxcQrfI_WGn3wnX4ukH7Y,627
|
|
5
|
-
tapdata_sdk/models.py,sha256=elJxe-6IzSCOpSLCQroUGec4dBgjyf2PU7LHo9O_yQ8,4601
|
|
6
|
-
tapdata_sdk/utils.py,sha256=ojPuW9YwW7dkb0nLJ46_IgMbOzor7DtppYDBuN4nCiY,2682
|
|
7
|
-
tapdata_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=g3faROod99RM6X9tAOfJ_7LsPxI1sOISYpIy2w9VexQ,1064
|
|
8
|
-
tapdata_sdk-0.1.0.dist-info/METADATA,sha256=d477QW0uSb5KbHfEO99E_02ZaVTPak9M0dp-JDhDR6k,7933
|
|
9
|
-
tapdata_sdk-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
-
tapdata_sdk-0.1.0.dist-info/top_level.txt,sha256=YNIwm3uNhULMB32qsLcj-zAoL5yYMKWJbXnstNsIYNk,12
|
|
11
|
-
tapdata_sdk-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|