
# 创建实例 - CreateInstance
#### 功能介绍
创建实例(要求账号有支付权限，若没有支付权限，仍然会生成订单，但不会自动支付)
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-aad/aad_02_0007.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-aad/abcd.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                 | 访问级别  | 资源类型（\*为必须） | 条件键                   | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | aad:instance:create | Write | instance \* | g:EnterpriseProjectId | -  | -      |
     
  
 
#### URI
POST /v2/aad/instance
#### 请求参数
表1请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述           |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | token        |
| Content-Type | 是    | String | Content-Type |
   
表2请求Body参数 
| 参数                             | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                     |
|:---|:---|:---|:---|
| ip_type                        | 是    | Integer | ip类型：0-IPV4,1-IPV6。当resource_region为asia_pacific时，ip_type仅支持0-IPV4。                                                                                                                                                                                    |
| resource_region                | 是    | String  | 资源区域：north_china-华北、east_china-华东、asia_pacific-亚太。                                                                                                                                                                                                     |
| basic_bandwidth                | 否    | Integer | 保底带宽。当resource_region为north_china、east_china时，basic_bandwidth不可为空；当resource_region为asia_pacific时，basic_bandwidth必须为空。                                                                                                                                  |
| elastic_bandwidth              | 否    | Integer | 弹性带宽。当resource_region为north_china、east_china时，elastic_bandwidth不可为空；当resource_region为asia_pacific时，elastic_bandwidth必须为空。                                                                                                                              |
| protection_package             | 否    | String  | 防护套餐：basic-保险防护，unlimited-无限防护。当resource_region为asia_pacific时，protection_package不可为空，当resource_region不为asia_pacific时，protection_package必须为空。                                                                                                           |
| instance_access_type           | 是    | String  | 实例接入类型：0-网站类，1-IP接入。                                                                                                                                                                                                                                   |
| protected_domain               | 否    | Integer | 防护域名数，步长为5。当instance_access_type为1-IP接入时，protected_domain必须为空，当instance_access_type为0-网站类时，protected_domain不可为空；当resource_region为north_china、east_china时，protected_domain取值范围\[50,500\]，当resource_region为asia_pacific时，protected_domain取值范围\[10,200\]。 |
| forwarding_rule                | 否    | Integer | 转发规则数，步长为5。当instance_access_type为1-IP接入时，forwarding_rule不可为空，当instance_access_type为0-网站类时，forwarding_rule必须为空；当resource_region为north_china、east_china时，forwarding_rule取值范围\[50,500\]，当resource_region为asia_pacific时，forwarding_rule取值范围\[5,200\]。      |
| basic_qps                      | 否    | Integer | 业务qps。当instance_access_type为1-IP接入时，basic_qps必须为空，当instance_access_type为0-网站类时，basic_qps不可为空；当resource_region为north_china、east_china时，basic_qps取值范围\[3000,100000\]，当resource_region为asia_pacific时，basic_qps取值范围\[1000,100000\]。                        |
| duration                       | 是    | Integer | 订购时长, 月：1,2,3,4,5,6,7,8,9个月，年：1年。                                                                                                                                                                                                                      |
| amount                         | 是    | Integer | 购买数量。                                                                                                                                                                                                                                                  |
| instance_name                  | 是    | String  | 实例名称。一次创建多个实例时，系统会自动在实例名后增加后缀，例如：CAD-0001。                                                                                                                                                                                                             |
| service_bandwidth              | 是    | Integer | 业务带宽。                                                                                                                                                                                                                                                  |
| period_type                    | 是    | Integer | 订购周期类型：2：月；3：年。                                                                                                                                                                                                                                        |
| enterprise_project_id          | 否    | String  | 企业项目id。                                                                                                                                                                                                                                                |
| elastic_service_bandwidth_type | 否    | Integer | 弹性业务带宽类型, 置空表示不开启，2-日95，3-月95。当resource_region为north_china、east_china时，仅支持月95。                                                                                                                                                                         |
| elastic_service_bandwidth      | 否    | Integer | 弹性业务带宽增加值                                                                                                                                                                                                                                              |
   
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数       | 参数类型   | 描述   |
|:---|:---|:---|
| order_id | String | 订单id |
   
**状态码：400**
表4响应Body参数 
| 参数                | 参数类型   | 描述   |
|:---|:---|:---|
| error_code        | String | 错误码  |
| error_description | String | 错误描述 |
   
#### 请求示例
```
POST https://{endpoint}/v2/aad/instance
{
  "ip_type" : 0,
  "resource_region" : "north_china",
  "basic_bandwidth" : 10,
  "forwarding_rule" : 50,
  "duration" : 1,
  "amount" : 1,
  "elastic_bandwidth" : 100,
  "service_bandwidth" : 100,
  "instance_access_type" : "1",
  "period_type" : 2,
  "instance_name" : "实例",
  "enterprise_project_id" : "0"
}
```
#### 响应示例
**状态码：200**
创建实例结果
```
{
  "order_id" : "CS26030216302XMM0"
}
```
#### 状态码
| 状态码 | 描述             |
|:---|:---|
| 200 | 创建实例结果         |
| 400 | Error response |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-aad/ErrorCode.html)。
