tapdata-sdk 0.1.0__tar.gz → 0.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tapdata_sdk
3
- Version: 0.1.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 tapdata_sdk
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 tapdata-sdk
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 (2024-01-29)
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
@@ -15,14 +15,14 @@ A Python client library for interacting with Tapdata API.
15
15
  ## Installation
16
16
 
17
17
  ```bash
18
- pip install tapdata_sdk
18
+ pip install tapdata-sdk
19
19
  ```
20
20
 
21
21
  Or install from source:
22
22
 
23
23
  ```bash
24
24
  git clone https://github.com/lddlww/tapdata_sdk.git
25
- cd tapdata-sdk
25
+ cd tapdata_sdk
26
26
  pip install -e .
27
27
  ```
28
28
 
@@ -48,6 +48,10 @@ for conn in connections:
48
48
  tasks = client.tasks.list()
49
49
  for task in tasks:
50
50
  print(f"{task.name}: {task.status}")
51
+
52
+ # Get Table Relation
53
+ table_relation = client.tasks.get_table_relation(task_id='xxx')
54
+ print(f"{table_relation.table_name_relation}")
51
55
  ```
52
56
 
53
57
  ### Connection Management
@@ -280,8 +284,10 @@ isort tapdata_sdk/
280
284
  ```
281
285
 
282
286
  ## Changelog
287
+ ### v0.3.0 (2026-02-03)
288
+ - ✨ added TaskDetail and TaskRelation function
283
289
 
284
- ### v0.2.0 (2024-01-29)
290
+ ### v0.2.0 (2026-01-29)
285
291
  - ✨ Refactored code architecture with modular design
286
292
  - 📦 Added data model classes (Connection, Task, TaskLog)
287
293
  - 🎯 Improved enum types using Python Enum
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tapdata_sdk"
7
- version = "0.1.0"
7
+ version = "0.3.0"
8
8
  description = "A Python client library for interacting with Tapdata API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -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,
@@ -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"""
@@ -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.1.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 tapdata_sdk
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 tapdata-sdk
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 (2024-01-29)
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
File without changes
File without changes
File without changes