Creating a Comparison Task

Function

This API is used to create a comparison task

Constraints

In the current version, a comparison task can be created only when the MySQL DR task is in the DR progress. The parent task cannot call the API.

URI

POST /v3/{project_id}/jobs/create-compare-task

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

The content type.

The default value is application/json.

X-Auth-Token

Yes

String

User token obtained from IAM.

X-Language

No

String

Request language type

Default value: en-us

Values:

  • en-us

  • zh-cn

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

job_id

Yes

String

Task ID.

object_level_compare_type

No

String

Object-level comparison type. If the value is empty, the object-level comparison is not created. If both object_level_compare_type and data_level_compare_info are left empty, only the created comparison task list is queried.

Value:

  • objects

data_level_compare_info

No

CreateDataLevelCompareReq object

Data-level comparison information. If no data-level comparison is created, this parameter does not need to be transferred. If both object_level_compare_type and data_level_compare_info are left empty, only the created comparison task list is queried.

Table 4 CreateDataLevelCompareReq

Parameter

Mandatory

Type

Description

conflict_policy

Yes

String

Only one unfinished data-level comparison task can exist. This field determines how to process unfinished data-level comparison tasks. cancel: Cancel the task and create a new one. keep: Do not create a new task if the previous one is not complete.

Values:

  • cancel

  • keep

compare_type

Yes

String

Data-level comparison type. lines: indicates row comparison. contents: value comparison.

Values:

  • lines

  • contents

compare_mode

No

String

Data-level comparison mode. If the value is empty, the object information needs to be transferred in compare_object_infos or compare_object_infos_with_token. quick_comparison: indicates quick comparison, which can be used only by whitelisted users.

Default value: quick_comparison

Value:

  • quick_comparison

start_time

No

String

Start time of a comparison task. If the value is empty, the task is started immediately.

compare_object_infos

No

Array of CompareObjectInfo objects

Data-level comparison object. In non-quick comparison mode, either compare_object_infos or compare_object_infos_with_token must be specified based on the migration scenario.

compare_object_infos_with_token

No

Array of CompareObjectInfoWithToken objects

Object for data-level comparison (Cassandra DR only, with token information). In non-quick comparison mode, either compare_object_infos or compare_object_infos_with_token must be specified based on the migration scenario.

Table 5 CompareObjectInfo

Parameter

Mandatory

Type

Description

db_name

Yes

String

Database name.

table_name

No

Array of strings

List of table names in the database.

Table 6 CompareObjectInfoWithToken

Parameter

Mandatory

Type

Description

db_name

Yes

String

Database name.

table_name_with_token

No

Array of CompareTableInfoWithToken objects

List of tables (with tokens) in the database.

Table 7 CompareTableInfoWithToken

Parameter

Mandatory

Type

Description

table_name

Yes

String

Table name

min_token

No

String

Min token of a table.

max_token

No

String

Max token of a table.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

job_id

String

Task ID

object_level_compare_create_result

CreateCompareTaskResult object

Result of creating an object-level comparison task.

data_level_compare_create_result

CreateCompareTaskResult object

Result of creating a data-level comparison task.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

Table 9 CreateCompareTaskResult

Parameter

Type

Description

compare_task_id

String

After the comparison task is created, the ID of the comparison task is returned for querying the result of the comparison task.

error_code

String

Error code, which is optional and indicates the returned information about the failure status.

error_msg

String

Error message, which is optional and indicates the returned information about the failure status.

Example Request

Example of creating a comparison task:

https://{Endpoint}/v3/054ba152d480d55b2f5dc0069e7ddef0/jobs/create-compare-task
{
  "job_id" : "94800607-3cd8-4f7d-a340-63a10f8jb502",
  "object_level_compare_type" : "objects",
  "data_level_compare_info" : {
    "conflict_policy" : "keep",
    "compare_type" : "contents",
    "compare_mode" : null,
    "start_time" : null,
    "compare_object_infos" : [ {
      "db_name" : "may_5",
      "table_name" : [ "table_name_0", "table_name_1" ]
    } ]
  }
}

Example Response

Status code: 200

OK

{
  "job_id" : "94800607-3cd8-4f7d-a340-63a10f8jb502",
  "object_level_compare_create_result" : {
    "compare_task_id" : "dc1683d9-bdf2-4be9-967f-6ef0953369bc"
  },
  "data_level_compare_create_result" : {
    "compare_task_id" : "08cad1f8-9de2-42fa-b8ce-6c36daf730f6"
  }
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.