# InquiryPriceCreateInstance

## 1. 接口描述

本接口(InquiryPriceCreateInstance)用于创建虚拟机实例询价。

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称               | 必选 | 类型                                                                                                                | 描述                                                                                                                     |
| ------------------ | -- | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| zoneId             | 是  | String                                                                                                            | 可用区ID。                                                                                                                 |
| instanceType       | 是  | String                                                                                                            | <p>实例机型。</p><p>具体取值可通过调用接口<a href="describezoneinstanceconfiginfos">DescribeZoneInstanceConfigInfos</a>来获得最新的规格表。</p>  |
| internetChargeType | 是  | [InternetChargeType](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#internetchargetype) | 公网IP的网络计费类型。                                                                                                           |
| instanceCount      | 是  | Integer                                                                                                           | <p>实例数量。</p><p>可选值范围：\[1, 100]</p><p>默认值：1</p>                                                                         |
| systemDisk         | 是  | [SystemDisk](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#systemdisk)                 | 系统盘相关信息。                                                                                                               |
| eipV4Type \[已废弃]   | 否  | [EipNetworkType](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#eipnetworktype)         | <p>公网IPv4的线路类型。</p><p>目前不支持三线IP(<code>ThreeLine</code>)。</p><p>已废弃，请使用<code>networkLineType</code>。</p>                |
| networkLineType    | 否  | [NetworkLineType](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#networklinetype)       | <p>公网IPv4的线路类型。</p><p>目前不支持三线IP(<code>ThreeLine</code>)。</p>                                                           |
| trafficPackageSize | 否  | Float                                                                                                             | <p>流量包订购大小。</p><p>单位为TB。</p><p>该值必须在<code>internetChargeType = ByTrafficPackage</code>时才会生效。</p><p>可选值范围：\[0.0, +)</p> |
| bandwidth          | 否  | Integer                                                                                                           | <p>公网出带宽上限。</p><p>单位：Mbps。</p><p>可选值范围：\[1, +)</p>                                                                     |
| dataDisk           | 否  | [DataDisk](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#datadisk)                     | 数据盘相关信息。                                                                                                               |

## 3. 响应结果

| 参数名称               | 类型                                                                                              | 描述                                                       |
| ------------------ | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| requestId          | String                                                                                          | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| specPrice          | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | 规格的价格。                                                   |
| gpuPrice           | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | GPU规格的价格。                                                |
| ipv4Price          | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | 公网IPv4的保留价格。                                             |
| ipv4BandwidthPrice | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | 公网IPv4的带宽价格。                                             |
| ipv6Price          | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | IPv6的价格。                                                 |
| ipv6BandwidthPrice | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | IPv6的带宽价格。                                               |
| systemDiskPrice    | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | 系统盘的价格。                                                  |
| dataDiskPrice      | [PriceItem](https://docs.console.zenlayer.com/api-reference/cn/compute/datastructure#priceitem) | 数据盘的价格。                                                  |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1. 查询实例的询价，带宽计费为固定带宽。**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: InquiryPriceCreateInstance
<Common Request Params>

Request：
{
  "zoneId":"SAO-A",
  "instanceType":"c.1c2g",
  "networkLineType": "PremiumBGP",
  "internetChargeType":"ByBandwidth",
  "bandwidth":1,
  "instanceCount": 1,
  "systemDisk":{
    "diskSize":10
  }
}

Response：
{
  "requestId":"T03681166-F646-4F6A-AE6E-6CFF08DE60B3",
  "response":{
      "requestId":"T03681166-F646-4F6A-AE6E-6CFF08DE60B3",
      "specPrice": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "gpuPrice": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "ipv4Price": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "ipv6Price": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "ipv4BandwidthPrice": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "ipv6BandwidthPrice": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "systemDiskPrice": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      },
      "dataDiskPrice": {
          "discount": 95.0,
          "discountPrice": 1444.0,
          "originalPrice": 1520.0,
          "unitPrice": null,
          "discountUnitPrice": null,
          "chargeUnit": null,
          "stepPrices": null
      }
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](https://docs.console.zenlayer.com/api-reference/cn/api-introduction/toolkit)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](https://docs.console.zenlayer.com/api-reference/cn/api-introduction/instruction/commonerrorcode)

| HTTP状态码 | 错误码                                              | 说明            |
| ------- | ------------------------------------------------ | ------------- |
| 400     | INVALID\_DISK\_CATEGORY\_TYPE                    | 云盘的类型不合法。     |
| 404     | INVALID\_INSTANCE\_TYPE\_NOT\_FOUND              | 实例规格不存在。      |
| 404     | INVALID\_ZONE\_NOT\_FOUND                        | 可用区不存在。       |
| 400     | OPERATION\_DENIED\_EIP\_UNSUPPORT\_NETWORK\_TYPE | EIP网络计费方式不支持。 |
