
# 分片变更预校验V3
#### 功能介绍
分片变更预校验
#### URI
POST /v3/{project_id}/instances/{instance_id}/databases/{db_name}/migration/precheck
表1路径参数 
| 参数          | 是否必选 | 参数类型   | 描述                       |
|:---|:---|:---|:---|
| project_id  | 是    | String | 租户在某一region下的project ID。 |
| instance_id | 是    | String | DDM实例ID                  |
| db_name     | 是    | String | 逻辑库名称                    |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                            |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。 通过调用IAM服务获取用户Token接口获取（响应消息头中X-Subject-Token的值）。 |
   
表3请求Body参数 
| 参数                      | 是否必选 | 参数类型                                                                | 描述                                                                                                            |
|:---|:---|:---|:---|
| data_nodes              | 是    | Array of [DataNode] objects | 变更后的数据节点信息。 变更后的分片数或数据节点数要比变更前多。          |
| new_shard_number        | 是    | String                                                              | 变更后的分片数量。 变更后的分片数或数据节点数要比变更前多。单实例最大分片数：64。 |
| switch_route_begin_time | 否    | String                                                              | 路由切换开始时间。                                                                                                     |
| switch_route_end_time   | 否    | String                                                              | 路由切换结束时间。                                                                                                     |
| is_exclusive            | 否    | Boolean                                                             | 是否独占。                                                                                                         |
   
 表4DataNode 
| 参数       | 是否必选 | 参数类型   | 描述      |
|:---|:---|:---|:---|
| id       | 是    | String | DN实例ID。 |
| user     | 是    | String | 数据库用户。  |
| password | 是    | String | 数据库密码。  |
   
#### 响应参数
**状态码：202**
表5响应Body参数 
| 参数                | 参数类型                                                                             | 描述         |
|:---|:---|:---|
| pre_check_results | Array of [PreCheckResult] objects | 关联的后端DN信息。 |
| job_id            | String                                                                           | 工作流ID。     |
   
 表6PreCheckResult 
| 参数                   | 参数类型   | 描述       |
|:---|:---|:---|
| name                 | String | 检查项名称。   |
| status               | String | 检查项结果。   |
| note                 | String | 检查项提示信息。 |
| handling_suggestion  | String | 处理建议。    |
| error_message        | String | 错误信息。    |
| error_detail_message | String | 详细错误信息。  |
   
**状态码：400**
表7响应Body参数 
| 参数         | 参数类型   | 描述    |
|:---|:---|:---|
| error_code | String | 错误码。  |
| error_msg  | String | 错误消息。 |
   
**状态码：500**
表8响应Body参数 
| 参数         | 参数类型   | 描述    |
|:---|:---|:---|
| error_code | String | 错误码。  |
| error_msg  | String | 错误消息。 |
   
#### 请求示例
```
{
  "new_shard_number" : 9,
  "data_nodes" : [ {
    "id" : "7edae0250ebc464897bd92b8d3e8b769in01",
    "user" : "root",
    "password" : "xxxxxx"
  } ]
}
```
#### 响应示例
**状态码：202**
```
{
  "job_id": "65c77858-e6a2-4694-8810-ab0b501b0003",
  "pre_check_results": [
    {
      "name": "Expire time of binlog in associated DN instances",
      "status": "SUCCESS",
      "note": "",
      "handling_suggestion": "Configuring shards require expiration of binlog more than 7 days(604800 seconds), please change binlog_expire_logs_seconds",
      "error_message": "",
      "error_detail_message": ""
    },
    {
      "name": "Tables with overwhelming table partitions",
      "status": "SUCCESS",
      "note": "",
      "handling_suggestion": "Every single row from source table will be recalculated and routed to all new partition table when shard number is changed. Because your partition table number will be overwhelming after configuring shard, shard configuring will take too long to finish. Please contact customer service.",
      "error_message": "",
      "error_detail_message": ""
    }
  ]
}
```
**状态码：400**
bad request
```
{
  "error_msg" : "Parameter error.",
  "error_code" : "DBS.280001"
}
```
**状态码：500**
server error
```
{
  "error_msg" : "Parameter error.",
  "error_code" : "DBS.280001"
}
```
#### 状态码
| 状态码 | 描述           |
|:---|:---|
| 202 | ok           |
| 400 | bad request  |
| 500 | server error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-ddm/ddm_api_01_0061.html)。
