InquiryPriceCreateInstance
1. 接口描述
调用本接口用于创建一台虚拟机实例询价。
2. 请求参数
以下请求参数列表仅列出了接口中需要的请求参数
zoneId
是
String
实例所属的可用区ID。
instanceChargeType
是
String
实例计费类型。
PREPAID:预付费,即包年包月。 POSTPAID:后付费。
trafficPackageSize
否
Float
流量包订购大小。
单位为TB。该值仅限当 internetChargeType
= ByTrafficPackage
生效且必填。
internetMaxBandwidthOut
否
Integer
公网出带宽上限。
单位:Mbps。
默认值:1Mbps。
不同机型带宽上限范围不一致,具体限制详见购买网络带宽。
3. 响应结果
4. 代码示例
1. 查询创建预付费实例的询价,带宽计费为固定带宽。
POST /api/v2/vm 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",
"imageId":"img-yKK4q6XybymPgfx7ynUUqC3N8",
"instanceChargeType":"PREPAID",
"internetChargeType":"ByBandwidth",
"instanceChargePrepaid":{
"period":1
},
"internetMaxBandwidthOut":1,
"systemDisk":{
"diskSize":10
}
}
Response:
{
"requestId":"T03681166-F646-4F6A-AE6E-6CFF08DE60B3",
"response":{
"requestId":"T03681166-F646-4F6A-AE6E-6CFF08DE60B3",
"instancePrice":{
"discount":95,
"discountPrice":13.3,
"originalPrice":14
},
"bandwidthPrice":[
{
"discount":95,
"discountPrice":3.8,
"originalPrice":4
}
],
"systemDiskPrice":{
"discount":96,
"discountPrice":0.48,
"originalPrice":0.5
}
}
}
2. 查询创建后付费实例的询价,带宽计费为固定带宽。
POST /api/v2/vm 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",
"imageId":"img-yKK4q6XybymPgfx7ynUUqC3N8",
"instanceChargeType":"POSTPAID",
"internetChargeType":"ByBandwidth",
"internetMaxBandwidthOut":1,
"systemDisk":{
"diskSize":10
}
}
Response:
{
"requestId": "T3105EE4C-30C5-4FF2-9A34-688C8455376D",
"response": {
"requestId": "T3105EE4C-30C5-4FF2-9A34-688C8455376D",
"instancePrice": {
"discount": 100.0,
"discountPrice": null,
"originalPrice": null,
"unitPrice": 0.13,
"discountUnitPrice": 0.13,
"chargeUnit": "HOUR",
"stepPrices": null
},
"systemDiskPrice": {
"discount": 100.0,
"discountPrice": null,
"originalPrice": null,
"unitPrice": 3.12,
"discountUnitPrice": 0.00625,
"chargeUnit": "HOUR",
"stepPrices": null
},
"bandwidthPrice": [
{
"discount": 100.0,
"discountPrice": null,
"originalPrice": null,
"unitPrice": 1.32,
"discountUnitPrice": 0.014,
"chargeUnit": "HOUR",
"stepPrices": null
}
]
}
}
3. 查询创建预付费实例的询价,带宽计费为流量包。
POST /api/v2/vm 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",
"imageId":"img-yKK4q6XybymPgfx7ynUUqC3N8",
"instanceChargeType":"PREPAID",
"internetChargeType":"ByTrafficPackage",
"trafficPackageSize":10,
"instanceChargePrepaid":{
"period":1
},
"internetMaxBandwidthOut":1,
"systemDisk":{
"diskSize":10
}
}
Response:
{
"requestId":"T70B50FA0-A8CB-4DC3-BA38-22E22AA9FB57",
"response":{
"requestId":"T70B50FA0-A8CB-4DC3-BA38-22E22AA9FB57",
"instancePrice":{
"discount":95,
"discountPrice":13.3,
"originalPrice":14
},
"bandwidthPrice":[
{
"discount":100,
"discountPrice":0,
"originalPrice":0
},
{
"discount":100,
"stepPrices":[
{
"stepStart":0,
"unitPrice":0.5,
"discountUnitPrice":0.5
}
]
}
],
"systemDiskPrice":{
"discount":96,
"discountPrice":0.48,
"originalPrice":0.5
}
}
}
5. 开发者工具
Zenlayer Cloud API 2.0 提供了配套的开发工具集(SDK),未来会陆续支持更多开发语言,方便快速接入和使用Zenlayer的产品和服务。
6. 错误码
下面包含业务逻辑中遇到的错误码,其他错误码见公共错误码
404
INVALID_ZONE_NOT_FOUND
指定的可用区不存在。
404
INVALID_INSTANCE_TYPE_NOT_FOUND
未找到指定的实例规格。
400
INVALID_INSTANCE_TYPE_ZONE_NO_SELL
指定实例规格在指定的 可用区未售卖
400
INVALID_INSTANCE_BANDWIDTH_ZONE_NO_SELL
指定的公网计费类型在所选的可用区不支持
400
INVALID_PARAMETER_TRAFFIC_PACKAGE
流量包大小参数不合法 。
400
INVALID_PARAMETER_TRAFFIC_PACKAGE_EXCEED
流量包大小超过了最大限制
最后更新于