
# 创建恢复
#### 功能介绍
使用备份进行恢复。
#### URI
- URI POST https://{endpoint}/v1/{project_id}/restores
  
- 参数说明
  表1参数说明 
  | 参数         | 是否必选 | 参数类型   | 描述                                                                                                                               |
  |:---|:---|:---|:---|
  | project_id | 是    | String | 项目ID。 获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-csbs/zh-cn_topic_0136033750.html)。 |
     
  
 
#### 请求
- 要素说明
  表2要素说明 
  | 参数      | 是否必选 | 参数类型        | 描述   |
  |:---|:---|:---|:---|
  | restore | 是    | restore_req | 恢复请求 |
     
  
- restore_req 字段数据结构说明
  表3restore_req 字段数据结构说明 
  | 参数             | 是否必选 | 参数类型          | 描述                                                                    |
  |:---|:---|:---|:---|
  | checkpoint_id  | 是    | String        | 备份记录ID                                                                |
  | parameters     | 是    | restore_param | 恢复参数                                                                  |
  | provider_id    | 是    | String        | 备份提供商ID，当前取值固定值：fc4d5750-22e7-4798-8a46-f48f62c4c1da。用于区分备份对象是服务器或磁盘。 |
  | restore_target | 否    | String        | 恢复目标                                                                  |
     
  
- restore_param 字段数据结构说明
  表4restore_param 字段数据结构说明 
  | 参数                 | 是否必选 | 参数类型           | 描述        |
  |:---|:---|:---|:---|
  | checkpoint_item_id | 是    | String         | 备份ID      |
  | power_on           | 是    | Boolean        | 恢复后是否立即开机 |
  | targets            | 是    | restore_target | 恢复目标      |
     
  
- restore_target 字段数据结构说明
  表5restore_target 字段数据结构说明 
  | 参数        | 是否必选 | 参数类型                           | 描述          |
  |:---|:---|:---|:---|
  | server_id | 是    | String                         | 恢复的目标云主机ID  |
  | volumes   | 是    | List\<restore_volume_mapping\> | 卷备份与目标卷关系列表 |
     
  
- restore_volume_mapping 字段数据结构说明
  表6restore_volume_mapping 字段数据结构说明 
  | 参数        | 是否必选 | 参数类型   | 描述      |
  |:---|:---|:---|:---|
  | backup_id | 是    | String | 卷备份ID   |
  | volume_id | 是    | String | 恢复目标卷ID |
     
  
- 请求样例
  ```
  POST https://{endpoint}/v1/{project_id}/restores
  {
    "restore" : {
      "provider_id" : "fc4d5750-22e7-4798-8a46-f48f62c4c1da",
      "checkpoint_id" : "a2b9fb53-2770-4fcd-9bad-6cadd56e6c09",
      "parameters" : {
        "checkpoint_item_id" : "504b7d59-c361-411f-9ed3-814f35d08e3d",
        "power_on" : true,
        "targets" : {
          "server_id" : "f45c477a-57e5-465f-999f-d845083962db",
          "volumes" : [ {
            "backup_id" : "bc118c24-3234-4afd-8423-d66d3d677649",
            "volume_id" : "ee27f809-6fb5-40ae-ac46-c932bb4ee8fe"
          }]
        }
      }
    }
  }
  ```
  
 
#### 响应
- 要素说明
  表7要素说明 
  | 参数      | 参数类型         | 描述   |
  |:---|:---|:---|
  | restore | restore_resp | 恢复响应 |
     
  
- restore_resp 字段数据结构说明
  表8restore_resp 字段数据结构说明 
  | 参数               | 参数类型          | 描述                                                                    |
  |:---|:---|:---|
  | id               | String        | 恢复ID                                                                  |
  | checkpoint_id    | String        | 备份记录ID                                                                |
  | parameters       | restore_param | 恢复参数                                                                  |
  | project_id       | String        | 项目ID                                                                  |
  | provider_id      | String        | 备份提供商ID，当前取值固定值：fc4d5750-22e7-4798-8a46-f48f62c4c1da。用于区分备份对象是服务器或磁盘。 |
  | resources_reason | Dict          | 资源恢复失败原因                                                              |
  | resources_status | Dict          | 资源状态，恢复时资源状态，如：available                                              |
  | restore_target   | String        | 恢复目标                                                                  |
  | status           | String        | 状态                                                                    |
     
  
- restore_param 字段数据结构说明
  表9restore_param 字段数据结构说明 
  | 参数                 | 参数类型           | 描述      |
  |:---|:---|:---|
  | checkpoint_item_id | String         | 备份ID    |
  | power_on           | Boolean        | 恢复后是否开机 |
  | targets            | restore_target | 恢复目标    |
     
  
- restore_target 字段数据结构说明
  表10restore_target 字段数据结构说明 
  | 参数        | 参数类型                           | 描述          |
  |:---|:---|:---|
  | server_id | String                         | 恢复的目标云主机ID  |
  | volumes   | List\<restore_volume_mapping\> | 卷备份与目标卷关系列表 |
     
  
- restore_volume_mapping 字段数据结构说明
  表11restore_volume_mapping 字段数据结构说明 
  | 参数        | 参数类型   | 描述      |
  |:---|:---|:---|
  | backup_id | String | 卷备份ID   |
  | volume_id | String | 恢复目标卷ID |
     
  
- 响应样例
  ```
  {
    "restore" : {
      "restore_target" : "http://192.168.1.2:35357/v2.0/",
      "status" : "in_progress",
      "provider_id" : "fc4d5750-22e7-4798-8a46-f48f62c4c1da",
      "resources_status" : in_progress,
      "parameters" : {
        "power_on" : true,
        "targets" : {
          "server_id" : "f45c477a-57e5-465f-999f-d845083962db",
          "volumes" : [ {
            "backup_id" : "bc118c24-3234-4afd-8423-d66d3d677649",
            "volume_id" : "ee27f809-6fb5-40ae-ac46-c932bb4ee8fe"
          } ]
        },
        "checkpoint_item_id" : "504b7d59-c361-411f-9ed3-814f35d08e3d"
      },
      "checkpoint_id" : "a2b9fb53-2770-4fcd-9bad-6cadd56e6c09",
      "project_id" : "b942cc8342734d15bcb246babb1953cf",
      "id" : "d3a54e80-6483-485d-98f6-c0409e6f2e0a",
      "resources_reason" : { }
    }
  }
  ```
  
 
#### 状态码
- 正常
  
  | 状态码 | 说明 |
  |:---|:---|
  | 200 | OK |
     
  
- 异常
  
  | 状态码 | 说明      |
  |:---|:---|
  | 400 | 请求参数不合法 |
  | 401 | 鉴权失败    |
  | 403 | 没有操作权限  |
  | 404 | 请求对象不存在 |
  | 500 | 服务内部错误  |
  | 503 | 服务不可用   |
     
  
 
#### 错误码
请参考[错误码](https://support.huaweicloud.com/api-csbs/zh-cn_topic_0071888297.html)。
