文档

PurchaseReservedInstancesOffering - 购买一张预留实例券

更新时间:

调用PurchaseReservedInstancesOffering购买一张预留实例券。预留实例券可以自动匹配对应的ECS实例,抵扣按量付费实例账单。

接口说明

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用背景高亮的方式表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
ecs:PurchaseReservedInstancesOfferingWrite
  • ReservedInstance
    acs:ecs:{#regionId}:{#accountId}:reservedinstance/*
  • ecs:tag

请求参数

名称类型必填描述示例值
RegionIdstring

实例所属的地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

cn-hangzhou
Tagobject []

标签列表。

Keystring

预留实例券的标签键。N 的取值范围:1~20。一旦传入该值,则不允许为空字符串。最多支持 128 个字符,不能以aliyunacs:开头,不能包含http://或者https://

TestKey
Valuestring

预留实例券的标签值。N 的取值范围:1~20。一旦传入该值,则不允许为空字符串。最多支持 128 个字符,不能以aliyunacs:开头,不能包含http://或者https://

TestValue
ResourceGroupIdstring

资源组 ID。

rg-bp199lyny9b3****
ZoneIdstring

实例所属的可用区编号,当ScopeZone时必填。更多信息,请参见 DescribeZones 获取可用区列表。

cn-hangzhou-g
ReservedInstanceNamestring

预留实例券的名称。长度为 2~128 个英文或中文字符。必须以大小写字母或中文开头,不能以 http:// 和 https:// 开头。可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。

testReservedInstanceName
InstanceTypestring

实例的资源规格。更多信息,请参见实例规格族

ecs.g5.large
Scopestring

预留实例券的范围。取值范围:

  • Region:地域级别。
  • Zone:可用区级别。

默认值:Region。

Zone
InstanceAmountinteger

预留实例券可以同时匹配同规格按量付费实例的数量。取值范围:1~50。

例如,实例规格设置为 ecs.g5.large,预留实例数量设置为 3 时,该预留实例券就可以同时匹配 3 台规格为 ecs.g5.large 的按量付费实例。

3
OfferingTypestring

预留实例券的付款类型。取值范围:

  • No Upfront:零预付。
  • Partial Upfront:部分预付。
  • All Upfront:全预付。

默认值:All Upfront。

All Upfront
Descriptionstring

预留实例券的描述。长度为 2~256 个英文或中文字符,不能以 http://和 https://开头。

默认值:空。

testDescription
Platformstring

实例使用的镜像的操作系统类型。取值范围:

  • Windows:Windows Server 类型的操作系统。
  • Linux:Linux 及类 Unix 类型的操作系统。

默认值:Linux。

Linux
Periodinteger

购买预留实例券的时长。

  • PeriodUnitYear时,取值范围:1、3、5。

  • PeriodUnitMonth时,取值范围:1。

默认值:1。

1
PeriodUnitstring

购买预留实例券的时长单位。

取值范围:Year、Month。

默认值:Month。

Year
ClientTokenstring

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符,且不能超过 64 个字符。更多信息,请参见如何保证幂等性

123e4567-e89b-12d3-a456-426655440000
AutoRenewboolean

是否要自动续费。

true:自动续费。 false(默认):不自动续费。

true
AutoRenewPeriodinteger

每次自动续费的时长,单位为月。当参数 AutoRenew 取值 True 时,该参数才生效。

AutoRenewPeriod 取值范围:1,12,36,60。

当 PeriodUnit=Month, 默认值为 1。

当 PeriodUnit=Year,默认值为 12。

1

返回参数

名称类型描述示例值
object
RequestIdstring

请求 ID。

8C314443-AF0D-4766-9562-C83B7F1A3C8B
ReservedInstanceIdSetsarray

预留实例券 ID 列表。

string

预留实例券 ID。

ecsri-2ze53qonjqxg7r****

示例

正常返回示例

JSON格式

{
  "RequestId": "8C314443-AF0D-4766-9562-C83B7F1A3C8B",
  "ReservedInstanceIdSets": {
    "ReservedInstanceId": [
      "ecsri-2ze53qonjqxg7r****"
    ]
  }
}

错误码

HTTP status code错误码错误信息描述
400InvalidStartTime.ScopeNotMatchZonal reservedInstance not supported for scheduled creating.-
400InvalidInstanceType.ValueUnauthorizedThe specified InstanceType is not authorized.指定的实例规格未授权使用。
400InvalidDescription.MalformedThe specified parameter "Description" is not valid.指定的资源描述格式不合法。长度为2-256个字符,不能以http://和https://开头。
400InvalidParameter.ConflictThe specified region and cluster do not match.指定的地域与指定的集群不匹配。
400InvalidTagKey.MalformedThe specified Tag.n.Key is not valid.指定的标签键参数有误。
400RegionUnauthorized%s该地域未被授权。%s为变量,将根据调用API的实际情况动态返回错误信息。
400Zone.NotOnSale%s该可用区暂时关闭了售卖。%s为变量,将根据调用API的实际情况动态返回错误信息。
400InvalidPeriodUnit.ValueNotSupportedThe specified parameter PeriodUnit is not valid.参数 PeriodUnit 无效。
400InvalidTagValue.MalformedThe specified Tag.n.Value is not valid.指定的标签值参数有误。
400InvalidChargeType.ValueNotSupportedChargeType is not valid.该计费方式不支持,请您重新选择计费方式。
400InvalidParameter.ScopeThe specified parameter 'Scope' is invalid.-
400InvalidReservedInstanceStatus.ValueNotSupportedReservedInstance status is not supported.-
400InvalidReservedInstanceOfferingType.ValueNotSupportedThe OfferingType is not supported.-
400InvalidReservedInstanceOfferingClass.ValueNotSupportedThe OfferingClass is not supported.-
400MissingParameter.ZoneIdThe specified zoneId should be not empty.-
400MissingParameter.InstanceTypeThe instanceType should be not empty.-
400MissingParameter.ReservedInstanceIdThe ids of reservedInstance can not be empty.-
400MissingParameter.ReservedInstanceConfigurationThe configurations of reservedInstance can not be empty.-
400InvalidParameter.SplitOrMergeThe Many-to-many of modification is not supported.-
400MissingParameter.InstanceTypeAndAmountBothEmptyThe instanceType and amount can not be both empty.-
400InvalidReservedInstancePlatform.ValueNotSupportedThe Platform is not supported.-
400InvalidParameter.ReservedInstanceNameReservedInstanceName is invalid.-
400InvalidReservedInstanceZone.ValueNotSupportedThe zoneId is not exist.-
400OperationDeniedThe specified InstanceType or Zone is not authorized for current user.-
400InvalidInstanceType.ValueNotSupportedThe specified InstanceType beyond the permitted range.指定的实例规格不合法(超出可选范围)。
400InvalidInstanceType.ValueNotSupportedThe specified InstanceType does not exist or beyond the permitted range.您指定的实例规格不存在,或者您没有权限操作此规格的实例。
403OperationDeniedThe creation of Host to the specified Zone is not allowed.无法在指定可用区创建专用宿主机。
403OperationDenied.NoStockThe requested resource is sold out in the specified zone; try other types of resources or other regions and zones.库存不足。
403OperationDeniedSales of this resource are temporarily suspended in the specified region; please try again later.指定的地域暂时关闭了此资源的售卖,请稍后重试。
403NodeControllerUnavailableThe Node Controller is temporarily unavailable.节点控制器暂不可用。
403OperationDeniedThe resource is out of usage.该实例不在运行状态,请您启动实例或检查操作是否合理。
403InvalidParameter.ResourceOwnerAccountResourceOwnerAccount is Invalid.指定的 ResourceOwnerAccount 不合法。
403Zone.NotOpenThe specified zone is not granted to you to buy resources yet.用户未被授权购买指定的可用区的资源。
403Zone.NotOnSaleThe specified zone is not available for purchase.指定可用区已经售罄,请您更换实例规格或者更换地域创建。
403InvalidResourceType.NotSupported%s-
403InvalidParameter.NotMatch%s您输入的参数无效,请检查参数之间是否冲突。
403Account.ArrearageYour account has been in arrears.账户余额不足,请先充值再操作。
404InvalidZoneId.NotFoundThe ZoneId provided does not exist in our records.指定的可用区 ID 不存在。
404PaymentMethodNotFoundNo payment method has been registered on the account.账户尚未注册支付方式。
404InvalidZoneId.NotFoundThe specified ZoneId does not exist.指定的可用区 ID 不存在。
500InternalErrorThe request processing has failed due to some unknown error.内部错误,请重试。
500InternalError%s内部错误。
500InternalErrorThe request processing has failed due to some unknown error, exception or failure.内部错误,请重试。

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
2022-11-02OpenAPI 错误码发生变更、OpenAPI 入参发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 400 变更
    删除错误码:403
    删除错误码:404
    删除错误码:500
入参OpenAPI 入参发生变更
    新增入参:AutoRenew
    新增入参:AutoRenewPeriod
  • 本页导读 (1)
文档反馈