本接口的主要功能是通过修改实例规格、数量、可用区等预留实例券的配置来对预留实例券进行拆分、合并或范围变更操作。
接口说明
本接口为异步接口,接口调用成功后会返回新产生的预留实例券 ID,原来的预留实例券会进入更新中状态,最终变为失效状态,与此同时,会有一张创建中状态的预留实例券产生,最终变为已生效状态,您可以通过 DescribeReservedInstances 进行查询。
- 预留实例券只有在已生效状态下才可以修改配置。
- 请确保修改配置前后预留实例券的计算力不会改变,否则修改请求会失败。
- 预留实例券的拆分、合并、范围变更不能同时进行。
更多信息,请参见拆分、合并或修改预留实例券。
请求示例
- 拆分:将一张杭州地域、实例规格为 ecs.g5.xlarge、匹配数量为 2 的预留实例券拆分为两张实例规格为 ecs.g5.large、匹配数量为 1 的预留实例券。
"RegionId":"cn-hangzhou", //设置地域为杭州
"ReservedInstanceId":["ecsri-bp1hd03e9uv19e75****"], //需要拆分的预留实例券 ID
"Configuration":[
  {
    "ReservedInstanceName":"testReservedInstanceName1", //修改后的预留实例券名称
    "InstanceType":"ecs.g5.large", //设置修改后的实例规格
    "Scope":"Region", //预留实例券的范围不可改变
    "InstanceAmount":1 //表示预留实例券可以同时匹配同规格按量付费实例的数量为 1 台
  },
  {
    "ReservedInstanceName":"testReservedInstanceName2",
    "InstanceType":"ecs.g5.large",
    "Scope":"Region",
    "InstanceAmount":1
  }
]
- 合并:将两张杭州地域可用区 H 、实例规格为 ecs.g5.xlarge、匹配数量为 4 的预留实例券合并为一张实例规格为 ecs.g5.4xlarge、匹配数量为 2 的预留实例券。
"RegionId":"cn-hangzhou", //设置地域为杭州
"ReservedInstanceId":["ecsri-bp1hd03e9uv16b75****",""ecsri-bp1hd03e9uv16b76****""], //需要合并的预留实例券 ID
"Configuration":[
  {
    "ReservedInstanceName":"testReservedInstanceName", //修改后的预留实例券名称
    "InstanceType":"ecs.g5.4xlarge", //设置修改后的实例规格
    "Scope":"Zone", //预留实例券的范围不可改变
    "ZoneId":"cn-hangzhou-h", //
    "InstanceAmount":2 //表示预留实例券可以同时匹配同规格按量付费实例的数量为 2 台
  }
]
- 变更范围:将一张杭州地域可用区 H 、实例规格为 ecs.g5.xlarge、匹配数量为 6 的预留实例券变更为一张杭州地域、实例规格为 ecs.g5.2xlarge、匹配数量为 3 的预留实例券。
"RegionId":"cn-hangzhou", //设置地域为杭州
"ReservedInstanceId":["ecsri-bp1hd03e9uv16b77****"], //需要变更范围的预留实例券 ID
"Configuration":[
  {
    "ReservedInstanceName":"testReservedInstanceName", //变更范围后的预留实例券名称
    "InstanceType":"ecs.g5.2xlarge", //设置修改后的实例规格
    "Scope":"Region", //变更后预留实例券的范围
    "InstanceAmount":3 //表示预留实例券可以同时匹配同规格按量付费实例的数量为 3 台
  }
]
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
授权信息
下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:
- 操作:是指具体的权限点。
- 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
- 资源类型:是指操作中支持授权的资源类型。具体说明如下:- 对于必选的资源类型,用前面加 * 表示。
- 对于不支持资源级授权的操作,用全部资源表示。
 
- 条件关键字:是指云产品自身定义的条件关键字。
- 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
| 操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 | 
|---|---|---|---|---|
| ecs:ModifyReservedInstances | update | *ReservedInstance acs:ecs:{#regionId}:{#accountId}:reservedinstance/{#reservedinstanceId} | 
 | 无 | 
请求参数
| 名称 | 类型 | 必填 | 描述 | 示例值 | 
|---|---|---|---|---|
| RegionId | string | 是 | 预留实例券所属的地域 ID。 您可以调用 DescribeRegions 获取最新的阿里云地域列表。 | cn-hangzhou | 
| ReservedInstanceId | array | 是 | 预留实例券 ID 数组。数组长度:1~20。 | |
| string | 是 | 预留实例券 ID。 | ecsri-bp15xx2**** | |
| Configuration | array<object> | 否 | 预留实例券的配置信息数组。数组长度:1~100。 | |
| object | 否 | 预留实例券的配置信息。 | ||
| ReservedInstanceName | string | 否 | 预留实例券的名称。 长度为 2~128 个英文或中文字符。必须以大小写字母或中文开头,不能以 http://和 https://开头。可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。 | testReservedInstanceName | 
| ZoneId | string | 否 | cn-hangzhou-i | |
| Scope | string | 是 | 预留实例券的范围。取值范围: 
 默认值:Region。 | Zone | 
| InstanceType | string | 是 | 预留实例券可以匹配的实例规格。 说明 
适用的实例规格持续更新,详情请参见预留实例券概述。
 | ecs.c5.4xlarge | 
| InstanceAmount | integer | 是 | 预留实例券可以同时匹配同规格按量付费实例的数量。取值范围:≥1。 | 1 | 
返回参数
示例
正常返回示例
JSON格式
{
  "RequestId": "ED9E4A5F-FF4D-4C96-BE80-6B4227060DD7",
  "ReservedInstanceIdSets": {
    "ReservedInstanceId": [
      "ecsri-bp1cx3****"
    ]
  }
}错误码
| HTTP status code | 错误码 | 错误信息 | 描述 | 
|---|---|---|---|
| 400 | InvalidInstanceType.ValueUnauthorized | The specified InstanceType is not authorized. | 指定的实例规格未授权使用。 | 
| 400 | InvalidParameter.Conflict | The specified region and cluster do not match. | 指定的地域与指定的集群不匹配。 | 
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | 指定的标签键参数有误。 | 
| 400 | InvalidPeriodUnit.ValueNotSupported | The specified parameter PeriodUnit is not valid. | 参数 PeriodUnit 无效。 | 
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | 指定的标签值参数有误。 | 
| 400 | InvalidChargeType.ValueNotSupported | ChargeType is not valid. | 该计费方式不支持,请您重新选择计费方式。 | 
| 400 | OperationDenied | The specified InstanceType or Zone is not authorized for current user. | - | 
| 403 | OperationDenied.NoStock | The requested resource is sold out in the specified zone; try other types of resources or other regions and zones. | 库存不足。 | 
| 403 | OperationDenied | Sales of this resource are temporarily suspended in the specified region; please try again later. | 指定的地域暂时关闭了此资源的售卖,请稍后重试。 | 
| 403 | NodeControllerUnavailable | The Node Controller is temporarily unavailable. | 节点控制器暂不可用。 | 
| 403 | OperationDenied | The resource is out of usage. | 资源库存不足。 | 
| 403 | InvalidParameter.ResourceOwnerAccount | ResourceOwnerAccount is Invalid. | 指定的 ResourceOwnerAccount 不合法。 | 
| 403 | Zone.NotOpen | The specified zone is not granted to you to buy resources yet. | 用户未被授权购买指定的可用区的资源。 | 
| 403 | Zone.NotOnSale | The specified zone is not available for purchase. | 指定可用区已经售罄,请您更换实例规格或者更换地域创建。 | 
| 403 | Account.Arrearage | Your account has been in arrears. | 账户余额不足,请先充值再操作。 | 
| 403 | InvalidReservedInstanceName.Malformed | The specified parameter ReservedInstanceName is invalid. | - | 
| 403 | InvalidParameter.Scope | The specified parameter 'Scope' is invalid. | - | 
| 403 | InvalidReservedInstanceStatus.ValueNotSupported | ReservedInstance status is not supported. | - | 
| 403 | InvalidReservedInstanceOfferingType.ValueNotSupported | The OfferingType is not supported. | - | 
| 403 | InvalidReservedInstanceOfferingClass.ValueNotSupported | The OfferingClass is not supported. | - | 
| 403 | MissingParameter.ZoneId | The specified zoneId should be not empty. | - | 
| 403 | MissingParameter.InstanceType | The instanceType should be not empty. | - | 
| 403 | MissingParameter.ReservedInstanceId | The ids of reservedInstance can not be empty. | - | 
| 403 | MissingParameter.ReservedInstanceConfiguration | The configurations of reservedInstance can not be empty. | - | 
| 403 | InvalidParameter.SplitOrMerge | The Many-to-many of modification is not supported. | - | 
| 403 | MissingParameter.InstanceTypeAndAmountBothEmpty | The instanceType and amount can not be both empty. | - | 
| 403 | InvalidReservedInstancePlatform.ValueNotSupported | The Platform is not supported. | - | 
| 403 | InvalidParameter.ReservedInstanceName | The reservedInstanceName is invalid. | reservedInstanceName字段值不合法 | 
| 403 | InvalidReservedInstanceZone.ValueNotSupported | The zoneId is not exist. | - | 
| 403 | InvalidParameter.ValueNotSupported | The instanceTypeFamily of the instance to be changed must be consistent. | - | 
| 403 | InvalidParameter.ValueNotSupported | The expiration time of the instance to be changed must be consistent. | - | 
| 403 | InvalidParameter.ValueNotSupported | The factor of instanceType is not equal. | - | 
| 403 | InvalidParameter.ValueNotSupported | The offeringClass of instance is not same. | - | 
| 403 | InvalidParameter.ValueNotSupported | The offeringType of instance is not same. | - | 
| 403 | IncorrectInstanceStatus | The status of specified reservedInstance must be active. | 预留实例券状态不正确导致续费失败 | 
| 403 | IncorrectInstanceStatus | The current status of the resource does not support this operation. | 该资源目前的状态不支持此操作。 | 
| 403 | InvalidPlatform.ValueNotSupported | The platform of reservedInstance is invalid. | - | 
| 403 | InvalidScope.ValueNotSupported | The scope of reservedInstance is invalid. The valid value is Zone or Region. | - | 
| 403 | InvalidConfiguration.ValueNotSupported | The modification Configuration should not be empty. | - | 
| 403 | InvalidZoneId.ValueNotSupported | The specified zoneId should be same. | - | 
| 403 | InvalidParameter | The parameter is invalid.Please check it. | - | 
| 403 | InvalidInstanceAmount.ValueNotSupported | The instanceAmount is invalid. | - | 
| 403 | OperationDenied.OnlyModifyName | It is not allowed to modify the ReservedInstanceName only. | 不允许只修改预留实例券的名称。 | 
| 403 | InvalidReservedInstanceId.NotFound | The specified parameter ReservedInstanceId is invalid. | - | 
| 404 | InvalidZoneId.NotFound | The ZoneId provided does not exist in our records. | 指定的可用区 ID 不存在。 | 
| 404 | InvalidZoneId.NotFound | The specified ZoneId does not exist. | 指定的可用区 ID 不存在。 | 
| 500 | InternalError | The request processing has failed due to some unknown error. | 内部错误,请重试。 | 
访问错误中心查看更多错误码。
变更历史
| 变更时间 | 变更内容概要 | 操作 | 
|---|---|---|
| 2024-12-26 | OpenAPI 错误码发生变更 | 查看变更详情 | 
| 2023-07-28 | OpenAPI 描述信息更新、OpenAPI 错误码发生变更 | 查看变更详情 | 
| 2023-05-09 | OpenAPI 错误码发生变更 | 查看变更详情 | 
