-
Notifications
You must be signed in to change notification settings - Fork 5
/
dts_client.py
548 lines (453 loc) · 23.7 KB
/
dts_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# -*- coding: utf8 -*-
# Copyright (c) 2017-2021 THL A29 Limited, a Tencent company. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.common.abstract_client import AbstractClient
from tencentcloud.dts.v20180330 import models
class DtsClient(AbstractClient):
_apiVersion = '2018-03-30'
_endpoint = 'dts.tencentcloudapi.com'
_service = 'dts'
def ActivateSubscribe(self, request):
"""This API is used to configure a data subscription, which can be called only for subscription instances in unconfigured status.
:param request: Request instance for ActivateSubscribe.
:type request: :class:`tencentcloud.dts.v20180330.models.ActivateSubscribeRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ActivateSubscribeResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ActivateSubscribe", params, headers=headers)
response = json.loads(body)
model = models.ActivateSubscribeResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CompleteMigrateJob(self, request):
"""This API (CompleteMigrateJob) is used to complete a data migration task.
For tasks in incremental migration mode, you need to call this API before migration gets ready, so as to stop migrating incremental data.
If the task status queried through the (DescribeMigrateJobs) API is ready (status=8), you can call this API to complete the migration task.
:param request: Request instance for CompleteMigrateJob.
:type request: :class:`tencentcloud.dts.v20180330.models.CompleteMigrateJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.CompleteMigrateJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CompleteMigrateJob", params, headers=headers)
response = json.loads(body)
model = models.CompleteMigrateJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CreateMigrateCheckJob(self, request):
"""This API is used to create a migration check task.
Before migration, you should call this API to create a check. Migration will start only if the check succeeds. You can view the check result through the `DescribeMigrateCheckJob` API.
After successful check, if the migration task needs to be modified, a new check task should be created and migration will begin only after the new check succeeds.
For a finance zone link, use the domain name https://dts.ap-shenzhen-fsi.tencentcloudapi.com.
:param request: Request instance for CreateMigrateCheckJob.
:type request: :class:`tencentcloud.dts.v20180330.models.CreateMigrateCheckJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.CreateMigrateCheckJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CreateMigrateCheckJob", params, headers=headers)
response = json.loads(body)
model = models.CreateMigrateCheckJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CreateMigrateJob(self, request):
"""This API (CreateMigrateJob) is used to create a data migration task.
For a finance zone linkage, please use the domain name dts.ap-shenzhen-fsi.tencentcloudapi.com.
:param request: Request instance for CreateMigrateJob.
:type request: :class:`tencentcloud.dts.v20180330.models.CreateMigrateJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.CreateMigrateJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CreateMigrateJob", params, headers=headers)
response = json.loads(body)
model = models.CreateMigrateJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def CreateSubscribe(self, request):
"""This API is used to create a data subscription instance.
:param request: Request instance for CreateSubscribe.
:type request: :class:`tencentcloud.dts.v20180330.models.CreateSubscribeRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.CreateSubscribeResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("CreateSubscribe", params, headers=headers)
response = json.loads(body)
model = models.CreateSubscribeResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DeleteMigrateJob(self, request):
"""This API (DeleteMigrationJob) is used to delete a data migration task. If the task status queried through the DescribeMigrateJobs API is checking (status=3), running (status=7), ready (status=8), canceling (status=11), or completing (status=12), the task cannot be deleted.
:param request: Request instance for DeleteMigrateJob.
:type request: :class:`tencentcloud.dts.v20180330.models.DeleteMigrateJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DeleteMigrateJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DeleteMigrateJob", params, headers=headers)
response = json.loads(body)
model = models.DeleteMigrateJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeAsyncRequestInfo(self, request):
"""This API is used to query the execution result of a task.
:param request: Request instance for DescribeAsyncRequestInfo.
:type request: :class:`tencentcloud.dts.v20180330.models.DescribeAsyncRequestInfoRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DescribeAsyncRequestInfoResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeAsyncRequestInfo", params, headers=headers)
response = json.loads(body)
model = models.DescribeAsyncRequestInfoResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeMigrateCheckJob(self, request):
"""This API is used to get the check result and query check status and progress after a check is created.
If the check succeeds, you can call the StartMigrateJob API to start migration.
If the check fails, the reason can be queried. Please modify the migration configuration or adjust relevant parameters of the source/target instances through the ModifyMigrateJob API based on the error message.
:param request: Request instance for DescribeMigrateCheckJob.
:type request: :class:`tencentcloud.dts.v20180330.models.DescribeMigrateCheckJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DescribeMigrateCheckJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeMigrateCheckJob", params, headers=headers)
response = json.loads(body)
model = models.DescribeMigrateCheckJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeMigrateJobs(self, request):
"""This API is used to query data migration tasks.
For a finance zone linkage, please use the domain name https://dts.ap-shenzhen-fsi.tencentcloudapi.com.
:param request: Request instance for DescribeMigrateJobs.
:type request: :class:`tencentcloud.dts.v20180330.models.DescribeMigrateJobsRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DescribeMigrateJobsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeMigrateJobs", params, headers=headers)
response = json.loads(body)
model = models.DescribeMigrateJobsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeRegionConf(self, request):
"""This API is used to query the purchasable subscription instance regions.
:param request: Request instance for DescribeRegionConf.
:type request: :class:`tencentcloud.dts.v20180330.models.DescribeRegionConfRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DescribeRegionConfResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeRegionConf", params, headers=headers)
response = json.loads(body)
model = models.DescribeRegionConfResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeSubscribeConf(self, request):
"""This API is used to query the subscription instance configuration.
:param request: Request instance for DescribeSubscribeConf.
:type request: :class:`tencentcloud.dts.v20180330.models.DescribeSubscribeConfRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DescribeSubscribeConfResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeSubscribeConf", params, headers=headers)
response = json.loads(body)
model = models.DescribeSubscribeConfResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def DescribeSubscribes(self, request):
"""This API is used to get the information list of data subscription instances. Pagination is enabled by default with 20 results returned each time.
:param request: Request instance for DescribeSubscribes.
:type request: :class:`tencentcloud.dts.v20180330.models.DescribeSubscribesRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.DescribeSubscribesResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("DescribeSubscribes", params, headers=headers)
response = json.loads(body)
model = models.DescribeSubscribesResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def IsolateSubscribe(self, request):
"""This API is used to isolate an hourly billed subscription instance. After this API is called, the instance will become unavailable and billing will stop for it.
:param request: Request instance for IsolateSubscribe.
:type request: :class:`tencentcloud.dts.v20180330.models.IsolateSubscribeRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.IsolateSubscribeResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("IsolateSubscribe", params, headers=headers)
response = json.loads(body)
model = models.IsolateSubscribeResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ModifyMigrateJob(self, request):
"""This API (ModifyMigrateJob) is used to modify a data migration task.
If the status of a migration task is creating (status=1), check succeeded (status=4), check failed (status=5), or migration failed (status=10), this API can be called to modify the task, but the type of the source and target instances and the region of the target instance cannot be modified.
For a finance zone linkage, please use the domain name dts.ap-shenzhen-fsi.tencentcloudapi.com.
:param request: Request instance for ModifyMigrateJob.
:type request: :class:`tencentcloud.dts.v20180330.models.ModifyMigrateJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ModifyMigrateJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ModifyMigrateJob", params, headers=headers)
response = json.loads(body)
model = models.ModifyMigrateJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ModifySubscribeConsumeTime(self, request):
"""This API is used to modify the consumption time point of a data subscription channel.
:param request: Request instance for ModifySubscribeConsumeTime.
:type request: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeConsumeTimeRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeConsumeTimeResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ModifySubscribeConsumeTime", params, headers=headers)
response = json.loads(body)
model = models.ModifySubscribeConsumeTimeResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ModifySubscribeName(self, request):
"""This API is used to rename a data subscription instance.
:param request: Request instance for ModifySubscribeName.
:type request: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeNameRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeNameResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ModifySubscribeName", params, headers=headers)
response = json.loads(body)
model = models.ModifySubscribeNameResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ModifySubscribeObjects(self, request):
"""This API is used to modify the subscription rule of a data subscription channel.
:param request: Request instance for ModifySubscribeObjects.
:type request: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeObjectsRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeObjectsResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ModifySubscribeObjects", params, headers=headers)
response = json.loads(body)
model = models.ModifySubscribeObjectsResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ModifySubscribeVipVport(self, request):
"""This API is used to modify the IP and port number of a data subscription instance.
:param request: Request instance for ModifySubscribeVipVport.
:type request: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeVipVportRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ModifySubscribeVipVportResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ModifySubscribeVipVport", params, headers=headers)
response = json.loads(body)
model = models.ModifySubscribeVipVportResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def OfflineIsolatedSubscribe(self, request):
"""This API is used to deactivate an isolated data subscription instance.
:param request: Request instance for OfflineIsolatedSubscribe.
:type request: :class:`tencentcloud.dts.v20180330.models.OfflineIsolatedSubscribeRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.OfflineIsolatedSubscribeResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("OfflineIsolatedSubscribe", params, headers=headers)
response = json.loads(body)
model = models.OfflineIsolatedSubscribeResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def ResetSubscribe(self, request):
"""This API is used to reset a data subscription instance. Once reset, an activated instance can be bound to other database instances through the `ActivateSubscribe` API.
:param request: Request instance for ResetSubscribe.
:type request: :class:`tencentcloud.dts.v20180330.models.ResetSubscribeRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.ResetSubscribeResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("ResetSubscribe", params, headers=headers)
response = json.loads(body)
model = models.ResetSubscribeResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def StartMigrateJob(self, request):
"""This API (StartMigrationJob) is used to start a migration task. After the API is called, non-scheduled migration tasks will start the migration immediately, while scheduled tasks will start the countdown.
Before calling this API, be sure to use the CreateMigrateCheckJob API to check the data migration task, which can be started only if its status queried through the DescribeMigrateJobs API is check succeeded (status=4).
:param request: Request instance for StartMigrateJob.
:type request: :class:`tencentcloud.dts.v20180330.models.StartMigrateJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.StartMigrateJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("StartMigrateJob", params, headers=headers)
response = json.loads(body)
model = models.StartMigrateJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))
def StopMigrateJob(self, request):
"""This API (StopMigrateJob) is used to cancel a data migration task.
During migration, this API can be used to cancel migration if the task status queried through the DescribeMigrateJobs API is running (status=7) or ready (status=8), and the migration task will fail.
:param request: Request instance for StopMigrateJob.
:type request: :class:`tencentcloud.dts.v20180330.models.StopMigrateJobRequest`
:rtype: :class:`tencentcloud.dts.v20180330.models.StopMigrateJobResponse`
"""
try:
params = request._serialize()
headers = request.headers
body = self.call("StopMigrateJob", params, headers=headers)
response = json.loads(body)
model = models.StopMigrateJobResponse()
model._deserialize(response["Response"])
return model
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(type(e).__name__, str(e))