创建预留实例券
更新时间:2026-06-22
该接口用于创建预留实例券。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
请求结构
Plain Text
1POST /v{version}/instance/reserved/create HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "reservedInstanceName" : reservedInstanceName,
7 "scope" : scope,
8 "zoneName" : zoneName,
9 "spec" : spec,
10 "offeringType" : offeringType,
11 "instanceCount" : instanceCount,
12 "reservedInstanceCount" : reservedInstanceCount,
13 "reservedInstanceTime" : reservedInstanceTime,
14 "reservedInstanceTimeUnit" : reservedInstanceTimeUnit,
15 "autoRenew" : autoRenew,
16 "autoRenewTimeUnit" : autoRenewTimeUnit,
17 "autoRenewTime" : autoRenewTime,
18 "effectiveTime" : effectiveTime,
19 "tags" : [
20 {
21 "tagKey" : tagKey,
22 "tagValue" : tagValue
23 }
24 ],
25 "ticketId" : ticketId,
26 "ehcClusterId" : ehcClusterId
27}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号。 |
| reservedInstanceName | String | 否 | RequestBody参数 | 预留实例券名称,规则:支持大小写字母、数字、中文以及-_ /.特殊字符,必须以中文或字母开头,长度1-65,可重复;客户未命名的情况下自动命名:reservedInstance-${随机生成},同样遵循以上命名规则 |
| scope | String | 否 | RequestBody参数 | 实例券的可用范围;默认:AZ |
| zoneName | String | 是 | RequestBody参数 | 可用区,例如cn-bj-a |
| spec | String | 是 | RequestBody参数 | 实例规格,例如bcc.g4.c2m8 |
| offeringType | String | 是 | RequestBody参数 | 默认值全预付:FullyPrepay |
| instanceCount | int | 否 | RequestBody参数 | 实例数量,默认为1,不可变更 |
| reservedInstanceCount | int | 否 | RequestBody参数 | 预留实例券数量,默认1,不能超过配额,默认配额20,若需要更多配额,请联系工单(可链接)申请 |
| reservedInstanceTime | int | 是 | RequestBody参数 | 预留实例券购买时长,支持3,6,9,12,24,36个月 |
| reservedInstanceTimeUnit | String | 否 | RequestBody参数 | 预留实例券购买时长单位,默认为month,不可变更 |
| autoRenew | Boolean | 否 | RequestBody参数 | 自动续费开关,默认为false |
| autoRenewTimeUnit | String | 否 | RequestBody参数 | 预留实例券自动续费时长单位,默认为month,不可变更 |
| autoRenewTime | int | 否 | RequestBody参数 | 预留实例券自动续费时长,支持3,6,9,12,24,36个月,autoRenew为true时,必选且必须与reservedInstanceTime一致 |
| effectiveTime | String | 否 | RequestBody参数 | 生效时间,默认立即生效;自定义生效时间,最长不能超过1天。且只能设置为15min为间隔的整点(比如:10:00、10:15、10:30、10:45、11:00) |
| tags | List<TagModel> | 否 | RequestBody参数 | 待创建的标签列表 |
| ticketId | String | 否 | RequestBody参数 | 代金券id |
| ehcClusterId | String | 否 | RequestBody参数 | 创建roce预留实例券时可选参数,若为空则使用默认EHC集群 |
返回头域
除公共头域,无其它特殊头域。
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| orderId | String | 创建预留实例券的订单号 |
| reservedInstanceIds | List<String> | 预留实例券的id集合 |
错误码
| 错误码 | 错误描述 | HTTP状态码 | 中文解释 |
|---|---|---|---|
| BadRequest | request is invalid | 400 | 请求参数无效 |
请求示例
Plain Text
1POST /v2/instance/reserved/create HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4
5{
6 "reservedInstanceName": "test",
7 "scope": "AZ",
8 "zoneName": "cn-bj-a",
9 "spec": "bcc.g4.c2m8",
10 "offeringType": "FullyPrepay",
11 "instanceCount": 1,
12 "reservedInstanceCount": 1,
13 "reservedInstanceTime": 12,
14 "reservedInstanceTimeUnit": "month",
15 "autoRenewTimeUnit": "month",
16 "autoRenewTime": 12,
17 "autoRenew": true,
18 "effectiveTime": "2023-05-22T21:00:00Z",
19 "tags": [
20 {
21 "tagKey": "test",
22 "tagValue": "test"
23 }
24 ],
25 "ticketId": ""
26}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Wed, 03 Dec 2014 06:42:19 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6
7{
8 "reservedInstanceIds": [
9 "test_f0c549b9614f"
10 ],
11 "orderId": "orderId"
12}
评价此篇文章
