tapdata-sdk 0.1.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.
- tapdata_sdk-0.1.0/LICENSE +21 -0
- tapdata_sdk-0.1.0/MANIFEST.in +7 -0
- tapdata_sdk-0.1.0/PKG-INFO +344 -0
- tapdata_sdk-0.1.0/README.md +307 -0
- tapdata_sdk-0.1.0/pyproject.toml +75 -0
- tapdata_sdk-0.1.0/requirements.txt +2 -0
- tapdata_sdk-0.1.0/setup.cfg +4 -0
- tapdata_sdk-0.1.0/tapdata_sdk/__init__.py +55 -0
- tapdata_sdk-0.1.0/tapdata_sdk/client.py +492 -0
- tapdata_sdk-0.1.0/tapdata_sdk/enums.py +58 -0
- tapdata_sdk-0.1.0/tapdata_sdk/exceptions.py +31 -0
- tapdata_sdk-0.1.0/tapdata_sdk/models.py +168 -0
- tapdata_sdk-0.1.0/tapdata_sdk/utils.py +110 -0
- tapdata_sdk-0.1.0/tapdata_sdk.egg-info/PKG-INFO +344 -0
- tapdata_sdk-0.1.0/tapdata_sdk.egg-info/SOURCES.txt +16 -0
- tapdata_sdk-0.1.0/tapdata_sdk.egg-info/dependency_links.txt +1 -0
- tapdata_sdk-0.1.0/tapdata_sdk.egg-info/requires.txt +11 -0
- tapdata_sdk-0.1.0/tapdata_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 doubled
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tapdata_sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python client library for interacting with Tapdata API
|
|
5
|
+
Author-email: doubled <309294891@qq.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lddlww/tapdata_sdk
|
|
8
|
+
Project-URL: Documentation, https://github.com/lddlww/tapdata_sdk#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/lddlww/tapdata_sdk
|
|
10
|
+
Project-URL: Issues, https://github.com/lddlww/tapdata_sdk/issues
|
|
11
|
+
Keywords: tapdata,api,client,sdk,data-integration
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.7
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.25.0
|
|
27
|
+
Requires-Dist: pycryptodome>=3.10.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
33
|
+
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
35
|
+
Requires-Dist: types-requests>=2.25.0; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# Tapdata Python SDK
|
|
39
|
+
|
|
40
|
+
A Python client library for interacting with Tapdata API.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- 🔐 Complete authentication support
|
|
45
|
+
- 📦 Type-safe data models
|
|
46
|
+
- 🎯 Clean API interface
|
|
47
|
+
- 🔄 Connection and task management
|
|
48
|
+
- 📊 Task log queries
|
|
49
|
+
- ⚠️ Detailed error handling
|
|
50
|
+
- 📝 Comprehensive documentation and type hints
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install tapdata_sdk
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or install from source:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/lddlww/tapdata_sdk.git
|
|
62
|
+
cd tapdata-sdk
|
|
63
|
+
pip install -e .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Basic Usage
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from tapdata_sdk import TapdataClient
|
|
72
|
+
|
|
73
|
+
# Initialize client
|
|
74
|
+
client = TapdataClient("http://localhost:3030")
|
|
75
|
+
|
|
76
|
+
# Login
|
|
77
|
+
client.login("admin@test.com", "password")
|
|
78
|
+
|
|
79
|
+
# Query connections
|
|
80
|
+
connections = client.connections.list()
|
|
81
|
+
for conn in connections:
|
|
82
|
+
print(f"{conn.name}: {conn.status}")
|
|
83
|
+
|
|
84
|
+
# Query tasks
|
|
85
|
+
tasks = client.tasks.list()
|
|
86
|
+
for task in tasks:
|
|
87
|
+
print(f"{task.name}: {task.status}")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Connection Management
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from tapdata_sdk import ConnectionType, DatabaseType, Status
|
|
94
|
+
|
|
95
|
+
# Query source connections
|
|
96
|
+
source_connections = client.connections.list_source()
|
|
97
|
+
|
|
98
|
+
# Query MySQL connections
|
|
99
|
+
mysql_connections = client.connections.list_mysql()
|
|
100
|
+
|
|
101
|
+
# Query valid connections
|
|
102
|
+
valid_connections = client.connections.list_valid()
|
|
103
|
+
|
|
104
|
+
# Filter using enum types
|
|
105
|
+
connections = client.connections.list(
|
|
106
|
+
connection_type=ConnectionType.SOURCE,
|
|
107
|
+
database_type=DatabaseType.MYSQL,
|
|
108
|
+
status=Status.COMPLETE
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Get single connection details
|
|
112
|
+
connection = client.connections.get("connection_id")
|
|
113
|
+
print(connection.endpoint)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Task Management
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# Query running tasks
|
|
120
|
+
running_tasks = client.tasks.list_running()
|
|
121
|
+
|
|
122
|
+
# Query tasks with specific status
|
|
123
|
+
tasks = client.tasks.list(status=Status.RUNNING)
|
|
124
|
+
|
|
125
|
+
# Get task details
|
|
126
|
+
task = client.tasks.get("task_id")
|
|
127
|
+
|
|
128
|
+
# Start task
|
|
129
|
+
client.tasks.start("task_id")
|
|
130
|
+
|
|
131
|
+
# Stop task
|
|
132
|
+
client.tasks.stop("task_id")
|
|
133
|
+
|
|
134
|
+
# Reset task
|
|
135
|
+
client.tasks.reset("task_id")
|
|
136
|
+
|
|
137
|
+
# Delete task
|
|
138
|
+
client.tasks.delete("task_id")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Query Task Logs
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
import time
|
|
145
|
+
|
|
146
|
+
# Get logs from the last hour
|
|
147
|
+
end_time = int(time.time() * 1000)
|
|
148
|
+
start_time = end_time - 3600000 # One hour ago
|
|
149
|
+
|
|
150
|
+
logs = client.tasks.get_logs(
|
|
151
|
+
task_id="task_id",
|
|
152
|
+
task_record_id="record_id",
|
|
153
|
+
start=start_time,
|
|
154
|
+
end=end_time,
|
|
155
|
+
page=1,
|
|
156
|
+
page_size=20
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Error Handling
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from tapdata_sdk import (
|
|
164
|
+
TapdataError,
|
|
165
|
+
TapdataAuthError,
|
|
166
|
+
TapdataTimeoutError,
|
|
167
|
+
TapdataConnectionError
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
try:
|
|
171
|
+
client.login("admin@test.com", "wrong_password")
|
|
172
|
+
except TapdataAuthError as e:
|
|
173
|
+
print(f"Authentication failed: {e.message}")
|
|
174
|
+
except TapdataTimeoutError as e:
|
|
175
|
+
print(f"Request timeout: {e.message}")
|
|
176
|
+
except TapdataConnectionError as e:
|
|
177
|
+
print(f"Connection error: {e.message}")
|
|
178
|
+
except TapdataError as e:
|
|
179
|
+
print(f"API error: {e.message}")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Advanced Configuration
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
# Custom timeout and SSL verification
|
|
186
|
+
client = TapdataClient(
|
|
187
|
+
base_url="https://api.tapdata.io",
|
|
188
|
+
timeout=60, # 60 second timeout
|
|
189
|
+
verify_ssl=False # Disable SSL verification (not recommended in production)
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# Use existing access_token
|
|
193
|
+
client = TapdataClient(
|
|
194
|
+
base_url="http://localhost:3030",
|
|
195
|
+
access_token="your-existing-token"
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Check authentication status
|
|
199
|
+
if client.is_authenticated():
|
|
200
|
+
print("Authenticated")
|
|
201
|
+
|
|
202
|
+
# Logout
|
|
203
|
+
client.logout()
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## API Reference
|
|
207
|
+
|
|
208
|
+
### TapdataClient
|
|
209
|
+
|
|
210
|
+
Main client class providing authentication and sub-client access.
|
|
211
|
+
|
|
212
|
+
**Parameters:**
|
|
213
|
+
- `base_url` (str): API base URL
|
|
214
|
+
- `access_token` (str, optional): Access token
|
|
215
|
+
- `timeout` (int): Request timeout in seconds, default 30
|
|
216
|
+
- `verify_ssl` (bool): Whether to verify SSL certificate, default True
|
|
217
|
+
|
|
218
|
+
**Methods:**
|
|
219
|
+
- `login(email, password, secret)`: User login
|
|
220
|
+
- `logout()`: Logout
|
|
221
|
+
- `is_authenticated()`: Check if authenticated
|
|
222
|
+
- `get_timestamp()`: Get server timestamp
|
|
223
|
+
|
|
224
|
+
**Properties:**
|
|
225
|
+
- `connections`: ConnectionClient instance
|
|
226
|
+
- `tasks`: TaskClient instance
|
|
227
|
+
|
|
228
|
+
### ConnectionClient
|
|
229
|
+
|
|
230
|
+
Connection management client.
|
|
231
|
+
|
|
232
|
+
**Methods:**
|
|
233
|
+
- `list(connection_type, database_type, status, skip, limit)`: Query connection list
|
|
234
|
+
- `get(connection_id)`: Get single connection
|
|
235
|
+
- `list_source()`: Get all source connections
|
|
236
|
+
- `list_target()`: Get all target connections
|
|
237
|
+
- `list_mysql()`: Get all MySQL connections
|
|
238
|
+
- `list_clickhouse()`: Get all ClickHouse connections
|
|
239
|
+
- `list_mongodb()`: Get all MongoDB connections
|
|
240
|
+
- `list_valid()`: Get all valid connections
|
|
241
|
+
- `list_invalid()`: Get all invalid connections
|
|
242
|
+
|
|
243
|
+
### TaskClient
|
|
244
|
+
|
|
245
|
+
Task management client.
|
|
246
|
+
|
|
247
|
+
**Methods:**
|
|
248
|
+
- `list(status, skip, limit)`: Query task list
|
|
249
|
+
- `get(task_id)`: Get single task
|
|
250
|
+
- `list_running()`: Get all running tasks
|
|
251
|
+
- `start(task_id)`: Start task
|
|
252
|
+
- `stop(task_id)`: Stop task
|
|
253
|
+
- `reset(task_id)`: Reset task
|
|
254
|
+
- `delete(task_id)`: Delete task
|
|
255
|
+
- `get_logs(task_id, task_record_id, start, end, page, page_size, levels)`: Get task logs
|
|
256
|
+
|
|
257
|
+
### Enum Types
|
|
258
|
+
|
|
259
|
+
```python
|
|
260
|
+
from tapdata_sdk import ConnectionType, DatabaseType, Status, LogLevel
|
|
261
|
+
|
|
262
|
+
# Connection types
|
|
263
|
+
ConnectionType.SOURCE
|
|
264
|
+
ConnectionType.TARGET
|
|
265
|
+
|
|
266
|
+
# Database types
|
|
267
|
+
DatabaseType.MYSQL
|
|
268
|
+
DatabaseType.CLICKHOUSE
|
|
269
|
+
DatabaseType.MONGODB
|
|
270
|
+
DatabaseType.POSTGRESQL
|
|
271
|
+
DatabaseType.ORACLE
|
|
272
|
+
DatabaseType.SQLSERVER
|
|
273
|
+
|
|
274
|
+
# Status
|
|
275
|
+
Status.RUNNING
|
|
276
|
+
Status.COMPLETE
|
|
277
|
+
Status.ERROR
|
|
278
|
+
# ... more statuses
|
|
279
|
+
|
|
280
|
+
# Log levels
|
|
281
|
+
LogLevel.INFO
|
|
282
|
+
LogLevel.WARN
|
|
283
|
+
LogLevel.ERROR
|
|
284
|
+
LogLevel.DEBUG
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Development
|
|
288
|
+
|
|
289
|
+
### Setup Development Environment
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# Clone repository
|
|
293
|
+
git clone <repository-url>
|
|
294
|
+
cd tapdata-sdk
|
|
295
|
+
|
|
296
|
+
# Create virtual environment
|
|
297
|
+
python -m venv venv
|
|
298
|
+
source venv/bin/activate # Linux/Mac
|
|
299
|
+
# or
|
|
300
|
+
venv\Scripts\activate # Windows
|
|
301
|
+
|
|
302
|
+
# Install dependencies
|
|
303
|
+
pip install -e ".[dev]"
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Run Tests
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
pytest tests/
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Code Formatting
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
black tapdata_sdk/
|
|
316
|
+
isort tapdata_sdk/
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Changelog
|
|
320
|
+
|
|
321
|
+
### v0.2.0 (2024-01-29)
|
|
322
|
+
- ✨ Refactored code architecture with modular design
|
|
323
|
+
- 📦 Added data model classes (Connection, Task, TaskLog)
|
|
324
|
+
- 🎯 Improved enum types using Python Enum
|
|
325
|
+
- 🔧 Optimized error handling with multiple exception types
|
|
326
|
+
- 📝 Enhanced documentation and type hints
|
|
327
|
+
- 🏗️ Separated client responsibilities (ConnectionClient, TaskClient)
|
|
328
|
+
- 🔐 Improved authentication flow
|
|
329
|
+
- 📊 Optimized logging
|
|
330
|
+
|
|
331
|
+
### v0.1.0
|
|
332
|
+
- 🎉 Initial release
|
|
333
|
+
|
|
334
|
+
## License
|
|
335
|
+
|
|
336
|
+
MIT License
|
|
337
|
+
|
|
338
|
+
## Contributing
|
|
339
|
+
|
|
340
|
+
Issues and Pull Requests are welcome!
|
|
341
|
+
|
|
342
|
+
## Support
|
|
343
|
+
|
|
344
|
+
For questions, please submit an Issue or contact the maintainers.
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Tapdata Python SDK
|
|
2
|
+
|
|
3
|
+
A Python client library for interacting with Tapdata API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔐 Complete authentication support
|
|
8
|
+
- 📦 Type-safe data models
|
|
9
|
+
- 🎯 Clean API interface
|
|
10
|
+
- 🔄 Connection and task management
|
|
11
|
+
- 📊 Task log queries
|
|
12
|
+
- ⚠️ Detailed error handling
|
|
13
|
+
- 📝 Comprehensive documentation and type hints
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install tapdata_sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or install from source:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/lddlww/tapdata_sdk.git
|
|
25
|
+
cd tapdata-sdk
|
|
26
|
+
pip install -e .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from tapdata_sdk import TapdataClient
|
|
35
|
+
|
|
36
|
+
# Initialize client
|
|
37
|
+
client = TapdataClient("http://localhost:3030")
|
|
38
|
+
|
|
39
|
+
# Login
|
|
40
|
+
client.login("admin@test.com", "password")
|
|
41
|
+
|
|
42
|
+
# Query connections
|
|
43
|
+
connections = client.connections.list()
|
|
44
|
+
for conn in connections:
|
|
45
|
+
print(f"{conn.name}: {conn.status}")
|
|
46
|
+
|
|
47
|
+
# Query tasks
|
|
48
|
+
tasks = client.tasks.list()
|
|
49
|
+
for task in tasks:
|
|
50
|
+
print(f"{task.name}: {task.status}")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Connection Management
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from tapdata_sdk import ConnectionType, DatabaseType, Status
|
|
57
|
+
|
|
58
|
+
# Query source connections
|
|
59
|
+
source_connections = client.connections.list_source()
|
|
60
|
+
|
|
61
|
+
# Query MySQL connections
|
|
62
|
+
mysql_connections = client.connections.list_mysql()
|
|
63
|
+
|
|
64
|
+
# Query valid connections
|
|
65
|
+
valid_connections = client.connections.list_valid()
|
|
66
|
+
|
|
67
|
+
# Filter using enum types
|
|
68
|
+
connections = client.connections.list(
|
|
69
|
+
connection_type=ConnectionType.SOURCE,
|
|
70
|
+
database_type=DatabaseType.MYSQL,
|
|
71
|
+
status=Status.COMPLETE
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Get single connection details
|
|
75
|
+
connection = client.connections.get("connection_id")
|
|
76
|
+
print(connection.endpoint)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Task Management
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
# Query running tasks
|
|
83
|
+
running_tasks = client.tasks.list_running()
|
|
84
|
+
|
|
85
|
+
# Query tasks with specific status
|
|
86
|
+
tasks = client.tasks.list(status=Status.RUNNING)
|
|
87
|
+
|
|
88
|
+
# Get task details
|
|
89
|
+
task = client.tasks.get("task_id")
|
|
90
|
+
|
|
91
|
+
# Start task
|
|
92
|
+
client.tasks.start("task_id")
|
|
93
|
+
|
|
94
|
+
# Stop task
|
|
95
|
+
client.tasks.stop("task_id")
|
|
96
|
+
|
|
97
|
+
# Reset task
|
|
98
|
+
client.tasks.reset("task_id")
|
|
99
|
+
|
|
100
|
+
# Delete task
|
|
101
|
+
client.tasks.delete("task_id")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Query Task Logs
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import time
|
|
108
|
+
|
|
109
|
+
# Get logs from the last hour
|
|
110
|
+
end_time = int(time.time() * 1000)
|
|
111
|
+
start_time = end_time - 3600000 # One hour ago
|
|
112
|
+
|
|
113
|
+
logs = client.tasks.get_logs(
|
|
114
|
+
task_id="task_id",
|
|
115
|
+
task_record_id="record_id",
|
|
116
|
+
start=start_time,
|
|
117
|
+
end=end_time,
|
|
118
|
+
page=1,
|
|
119
|
+
page_size=20
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Error Handling
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from tapdata_sdk import (
|
|
127
|
+
TapdataError,
|
|
128
|
+
TapdataAuthError,
|
|
129
|
+
TapdataTimeoutError,
|
|
130
|
+
TapdataConnectionError
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
try:
|
|
134
|
+
client.login("admin@test.com", "wrong_password")
|
|
135
|
+
except TapdataAuthError as e:
|
|
136
|
+
print(f"Authentication failed: {e.message}")
|
|
137
|
+
except TapdataTimeoutError as e:
|
|
138
|
+
print(f"Request timeout: {e.message}")
|
|
139
|
+
except TapdataConnectionError as e:
|
|
140
|
+
print(f"Connection error: {e.message}")
|
|
141
|
+
except TapdataError as e:
|
|
142
|
+
print(f"API error: {e.message}")
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Advanced Configuration
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
# Custom timeout and SSL verification
|
|
149
|
+
client = TapdataClient(
|
|
150
|
+
base_url="https://api.tapdata.io",
|
|
151
|
+
timeout=60, # 60 second timeout
|
|
152
|
+
verify_ssl=False # Disable SSL verification (not recommended in production)
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Use existing access_token
|
|
156
|
+
client = TapdataClient(
|
|
157
|
+
base_url="http://localhost:3030",
|
|
158
|
+
access_token="your-existing-token"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Check authentication status
|
|
162
|
+
if client.is_authenticated():
|
|
163
|
+
print("Authenticated")
|
|
164
|
+
|
|
165
|
+
# Logout
|
|
166
|
+
client.logout()
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## API Reference
|
|
170
|
+
|
|
171
|
+
### TapdataClient
|
|
172
|
+
|
|
173
|
+
Main client class providing authentication and sub-client access.
|
|
174
|
+
|
|
175
|
+
**Parameters:**
|
|
176
|
+
- `base_url` (str): API base URL
|
|
177
|
+
- `access_token` (str, optional): Access token
|
|
178
|
+
- `timeout` (int): Request timeout in seconds, default 30
|
|
179
|
+
- `verify_ssl` (bool): Whether to verify SSL certificate, default True
|
|
180
|
+
|
|
181
|
+
**Methods:**
|
|
182
|
+
- `login(email, password, secret)`: User login
|
|
183
|
+
- `logout()`: Logout
|
|
184
|
+
- `is_authenticated()`: Check if authenticated
|
|
185
|
+
- `get_timestamp()`: Get server timestamp
|
|
186
|
+
|
|
187
|
+
**Properties:**
|
|
188
|
+
- `connections`: ConnectionClient instance
|
|
189
|
+
- `tasks`: TaskClient instance
|
|
190
|
+
|
|
191
|
+
### ConnectionClient
|
|
192
|
+
|
|
193
|
+
Connection management client.
|
|
194
|
+
|
|
195
|
+
**Methods:**
|
|
196
|
+
- `list(connection_type, database_type, status, skip, limit)`: Query connection list
|
|
197
|
+
- `get(connection_id)`: Get single connection
|
|
198
|
+
- `list_source()`: Get all source connections
|
|
199
|
+
- `list_target()`: Get all target connections
|
|
200
|
+
- `list_mysql()`: Get all MySQL connections
|
|
201
|
+
- `list_clickhouse()`: Get all ClickHouse connections
|
|
202
|
+
- `list_mongodb()`: Get all MongoDB connections
|
|
203
|
+
- `list_valid()`: Get all valid connections
|
|
204
|
+
- `list_invalid()`: Get all invalid connections
|
|
205
|
+
|
|
206
|
+
### TaskClient
|
|
207
|
+
|
|
208
|
+
Task management client.
|
|
209
|
+
|
|
210
|
+
**Methods:**
|
|
211
|
+
- `list(status, skip, limit)`: Query task list
|
|
212
|
+
- `get(task_id)`: Get single task
|
|
213
|
+
- `list_running()`: Get all running tasks
|
|
214
|
+
- `start(task_id)`: Start task
|
|
215
|
+
- `stop(task_id)`: Stop task
|
|
216
|
+
- `reset(task_id)`: Reset task
|
|
217
|
+
- `delete(task_id)`: Delete task
|
|
218
|
+
- `get_logs(task_id, task_record_id, start, end, page, page_size, levels)`: Get task logs
|
|
219
|
+
|
|
220
|
+
### Enum Types
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from tapdata_sdk import ConnectionType, DatabaseType, Status, LogLevel
|
|
224
|
+
|
|
225
|
+
# Connection types
|
|
226
|
+
ConnectionType.SOURCE
|
|
227
|
+
ConnectionType.TARGET
|
|
228
|
+
|
|
229
|
+
# Database types
|
|
230
|
+
DatabaseType.MYSQL
|
|
231
|
+
DatabaseType.CLICKHOUSE
|
|
232
|
+
DatabaseType.MONGODB
|
|
233
|
+
DatabaseType.POSTGRESQL
|
|
234
|
+
DatabaseType.ORACLE
|
|
235
|
+
DatabaseType.SQLSERVER
|
|
236
|
+
|
|
237
|
+
# Status
|
|
238
|
+
Status.RUNNING
|
|
239
|
+
Status.COMPLETE
|
|
240
|
+
Status.ERROR
|
|
241
|
+
# ... more statuses
|
|
242
|
+
|
|
243
|
+
# Log levels
|
|
244
|
+
LogLevel.INFO
|
|
245
|
+
LogLevel.WARN
|
|
246
|
+
LogLevel.ERROR
|
|
247
|
+
LogLevel.DEBUG
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Development
|
|
251
|
+
|
|
252
|
+
### Setup Development Environment
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Clone repository
|
|
256
|
+
git clone <repository-url>
|
|
257
|
+
cd tapdata-sdk
|
|
258
|
+
|
|
259
|
+
# Create virtual environment
|
|
260
|
+
python -m venv venv
|
|
261
|
+
source venv/bin/activate # Linux/Mac
|
|
262
|
+
# or
|
|
263
|
+
venv\Scripts\activate # Windows
|
|
264
|
+
|
|
265
|
+
# Install dependencies
|
|
266
|
+
pip install -e ".[dev]"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Run Tests
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
pytest tests/
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Code Formatting
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
black tapdata_sdk/
|
|
279
|
+
isort tapdata_sdk/
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Changelog
|
|
283
|
+
|
|
284
|
+
### v0.2.0 (2024-01-29)
|
|
285
|
+
- ✨ Refactored code architecture with modular design
|
|
286
|
+
- 📦 Added data model classes (Connection, Task, TaskLog)
|
|
287
|
+
- 🎯 Improved enum types using Python Enum
|
|
288
|
+
- 🔧 Optimized error handling with multiple exception types
|
|
289
|
+
- 📝 Enhanced documentation and type hints
|
|
290
|
+
- 🏗️ Separated client responsibilities (ConnectionClient, TaskClient)
|
|
291
|
+
- 🔐 Improved authentication flow
|
|
292
|
+
- 📊 Optimized logging
|
|
293
|
+
|
|
294
|
+
### v0.1.0
|
|
295
|
+
- 🎉 Initial release
|
|
296
|
+
|
|
297
|
+
## License
|
|
298
|
+
|
|
299
|
+
MIT License
|
|
300
|
+
|
|
301
|
+
## Contributing
|
|
302
|
+
|
|
303
|
+
Issues and Pull Requests are welcome!
|
|
304
|
+
|
|
305
|
+
## Support
|
|
306
|
+
|
|
307
|
+
For questions, please submit an Issue or contact the maintainers.
|