文档

ModifyInstanceChargeType - 修改付费实例类型

更新时间:

调用ModifyInstanceChargeType更换一台或者多台ECS实例的计费方式。支持在按量付费实例和包年包月实例间相互转换,同时可以将实例挂载的所有按量付费云盘转换为包年包月云盘。

接口说明

请确保在使用该接口前,您已充分了解云服务器 ECS的计费方式和产品定价。

调用该接口时,您需要注意:

  • 目标实例的状态必须为运行中Running)或者已停止Stopped),并且无欠费的情况下才能修改计费方式。
  • 更换计费方式后,默认自动扣费。您需要确保账户余额充足,否则会生成异常订单,此时只能作废订单。如果您的账户余额不足,可以将参数AutoPay置为false,此时会生成正常的未支付订单,您可以登录 ECS 管理控制台支付。
  • 包年包月转按量付费
    • 是否支持包年包月转按量付费功能,是根据您的云服务器使用情况而定的。

    • 包年包月实例转按量实例的时候,新计费方式将覆盖实例的整个生命周期。您会收到修改前后的实例计费的价格差退款,退还到您的原付款渠道中,已使用的代金券将不退回。更多信息,请参见退款规则

    • 退款规则:您在一个月内能自由操作的退款额度有限且不累计,消耗完退款额度后,只能等待次月转换计费方式。一次转换计费消耗的退款额度公式为vCPU 数 *(退款天数*24±浮动小时数)

  • 按量付费转包年包月
    • 支持将实例挂载的所有按量付费数据盘同时转换为包年包月数据盘。
    • 如果按量付费实例已经设置了释放时间,则不能调用该接口。

调试

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

授权信息

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

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

请求参数

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

实例 ID。取值可以由多台实例 ID 组成一个 JSON 数组,最多支持 20 个 ID,ID 之间用半角逗号(,)隔开。

["i-bp67acfmxazb4p****","i-bp67acfmxazb4d****"]
RegionIdstring

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

cn-hangzhou
Periodinteger

包年包月续费时长。如果 ECS 实例的宿主机为专有宿主机 DDH,则取值范围不能超过专有宿主机的订阅时长。取值范围:

  • PeriodUnit=Week时,Period取值:1、2、3、4。
  • PeriodUnit=Month时,Period取值:1、2、3、4、5、6、7、8、9、12、24、36、48、60。
1
PeriodUnitstring

续费时长的时间单位,即参数Period的单位。取值范围:

  • Week:周。
  • Month:月。

默认值为 Month。

Month
IncludeDataDisksboolean

是否将实例挂载的所有按量付费数据盘一起转换为包年包月数据盘。

默认值为 false。

false
DryRunboolean

是否只预检此次请求。取值范围:

  • true:发送检查请求,不会查询资源状况。检查项包括 AccessKey 是否有效、RAM 用户的授权情况和是否填写了必需参数。如果检查不通过,则返回对应错误。如果检查通过,会返回错误码DryRunOperation

  • false:发送正常请求,通过检查后返回 2XX 的 HTTP 状态码并直接查询资源状况。

默认值为 false。

false
AutoPayboolean

是否自动支付。取值范围:

  • true:自动支付。您需要确保账户余额充足,如果账户余额不足会生成异常订单,只能作废订单。

  • false:只生成订单不扣费。

默认值为 true。

说明 如果您的支付方式余额不足,可以将参数 AutoPay 设置为 false,此时会生成未支付订单,您可以登录 ECS 管理控制台自行支付。
false
InstanceChargeTypestring

实例需要修改的目标计费方式。取值范围:

  • PrePaid:将按量付费实例转换为包年包月实例。

  • PostPaid:将包年包月实例转换为按量付费实例。

默认值为 PrePaid。

PrePaid
ClientTokenstring

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

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

包年包月转换为按量计费时,是否返回订单费用详情。

默认值为 false。

false

返回参数

名称类型描述示例值
object
OrderIdstring

生成的订单 ID。

20413515388****
RequestIdstring

请求 ID。

B61C08E5-403A-46A2-96C1-F7B1216DB10C
FeeOfInstancesobject []

订单费用详情。

InstanceIdstring

实例 ID。

i-bp67acfmxazb4p****
Currencystring

账单费用货币单位。

中国站:CNY。

国际站:USD。

CNY
Feestring

费用数值。

0

示例

正常返回示例

JSON格式

{
  "OrderId": "20413515388****",
  "RequestId": "B61C08E5-403A-46A2-96C1-F7B1216DB10C",
  "FeeOfInstances": {
    "FeeOfInstance": [
      {
        "InstanceId": "i-bp67acfmxazb4p****",
        "Currency": "CNY",
        "Fee": "0"
      }
    ]
  }
}

错误码

HTTP status code错误码错误信息描述
400InvalidInstance.UnpaidOrder%s-
400ThrottlingRequest was denied due to request throttling, try again later.-
400InstanceHasProcessingConvertOrder%s-
400InvalidParameter.InstanceIdsThe specified InstanceIds are invalid.指定的实例无效。
400InvalidParameter%s无效的参数。
400InvalidStatus.ValueNotSupported%s该资源当前的状态不支持此操作。
400InvalidInstanceChargeType.ValueNotSupported%s暂不支持此付款类型,请核对相关信息后重试。
400InvalidSpotStrategyThe specified spotStrategy is not valid.指定的 SpotStrategy 参数无效。
400ExpiredInstanceThe specified instance has expired.指定的实例已过期。
400InstancesIdQuotaExceedThe maximum number of Instances is exceeded.超过了实例数的上限。
400InvalidClientToken.ValueNotSupportedThe ClientToken provided is invalid.指定的 ClientToken 不合法。
400InvalidInstance.UnpaidOrderThe specified instance has unpaid order.指定的实例有未支付的订单,请您先支付再进行操作。
400InvalidInternetChargeType.ValueNotSupported%s暂不支持指定的网络计费方式,请确认相关参数是否正确。
400ReleaseTimeHaveBeenSetThe specified instance has been set released time.指定的实例已设置释放时间。
400ThrottlingRequest was denied due to request throttling, please try again after 5 minutes.您当前的请求被流控,请5分钟后重试。
400Throttling%s请求被流控。
400QuotaExceed.AfterpayInstanceThe maximum number of Pay-As-You-Go instances is exceeded: %s.-
400InvalidParameter.Bandwidth%s指定的带宽无效,请检查参数是否正确。
400QuotaExceed.RufundVcpuThe maximum number of refund vcpu is exceeded: %s.-
400InvalidPeriod.UnitMismatchThe specified Period must be correlated with the PeriodUnit.指定的时长必须与 PeriodUnit 关联。
400InvalidImageType.NotSupported%s指定的镜像类型无效,请查询本地域是否支持此镜像类型。
400InvalidPeriod.ExceededDedicatedHostInstance expired date can't exceed dedicated host expired date.-
400InvalidMarketImageChargeType.NotSupportThe specified chargeType of marketImage is unsupported.暂不支持该市场镜像的付费类型。
400InvalidSystemDiskCategory.ValueNotSupported%s当前操作不支持此系统磁盘类型。
400InvalidAccountStatus.PayAmountLimitExceededYour account is being restricted, due to no default payment method is set or you has not being authorized.-
400InvalidInstance.NotFoundSystemDiskThe specified instance has no system disk.指定的实例没有挂载系统盘。请确保指定的实例已挂载了系统盘。您可以调用 DescribeInstances 查询指定实例的信息。
400AccountForbidden.ProductCreationLimitedThe commodity must be officially operated by Aliyun and in pay-as-you-go billing method.集团上云客户只能购买按量付费的 ECS,且不能购买第三方的商品比如由镜像市场提供的镜像。请检查参数,传入符合条件的参数重试。
400Invalid.PrivatePoolOptions.MatchCriteriaTarget mode does not support this operation.Target模式不支持本次操作。
400InvalidPeriodThe specified period is not valid.指定的时段不合法。
400DISK_IN_DEDICATED_BLOCK_STORAGE_CLUSTERThe disk in dedicated block storage cluster is not allowed to do this operation.-
400NoPermission.PriceThe operation requires price permission. Please either apply for permission from your main account, or set the parameter AutoPay as true.-
400NoPermission.RefundThe operation requires refund permission. Please apply for permission from your main account.-
403InvalidInstance.TempBandwidthUpgradeCannot switch to Pay-As-You-Go during the period of temporary bandwidth upgrade.实例在临时带宽升级期间不能转换为按量付费。
403InvalidInstanceType.ValueNotSupportedThe specified InstanceType does not exist or beyond the permitted range.您指定的实例规格不存在,或者您没有权限操作此规格的实例。
403InstanceType.Offline%s实例规格因停售、供货不足等原因,不支持该操作。
403InvalidAccountStatus.NotEnoughBalanceYour account does not have enough balance.账号余额不足,请您先充值再进行该操作。
403Account.ArrearageYour account has an outstanding payment.您的账号存在未支付的款项。
403InvalidParameter.NotMatch%s您输入的参数无效,请检查参数之间是否冲突。
403InvalidAction%s操作无效。
403QuotaExceed.PostPaidDiskLiving postPaid disks quota exceeded.按量付费磁盘数量已超出允许数量。
403ImageNotSupportInstanceTypeThe specified instanceType is not supported by instance with marketplace image.指定的市场镜像不支持该实例规格。
403InvalidInstanceType.PhasedOutThis instanceType is no longer offered.您指定的实例规格已下线不再出售。
403RealNameAuthenticationErrorYour account has not passed the real-name authentication yet.您的阿里云账号尚未通过实名认证,请先实名认证后再操作。
403InvalidOperation.NotSupportInstance on dedicated host not support modify charge type.-
403QuotaExceed.ElasticQuotaNo additional quota is available for the specified ECS instance type.您在当前地域选择的实例规格所要创建的台数超出系统限额,您可以选择其他地域、实例规格或减少台数重新购买,也可以前往ECS管理控制台或配额中心申请提高限额。
403QuotaExceed.ElasticQuotaThe number of the specified ECS instances has exceeded the quota of the specified instance type.您在当前地域选择的实例规格所要创建的台数超出系统限额,您可以选择其他地域、实例规格或减少台数重新购买,也可以前往ECS管理控制台或配额中心申请提高限额。
403QuotaExceed.ElasticQuotaThe number of vCPUs assigned to the ECS instances has exceeded the quota in the zone.您的全实例规格vCPU配额超出系统限额,您可以前往ECS管理控制台或配额中心申请提高限额。
403QuotaExceed.ElasticQuotaThe number of the specified ECS instances has exceeded the quota of the specified instance type, or the number of vCPUs assigned to the ECS instances has exceeded the quota in the zone.您在当前地域选择的实例规格所要创建的台数超出系统限额,或者全实例规格vCPU配额超出系统限额,您可以前往ECS管理控制台或配额中心申请提高限额。
403PeriodNotSupported.InstanceOnManagedPrivateSpaceThe instance on ManagedPrivateSpace is not supported to modify chargeType.-
403UnsupportedIspChargeType%s-
404InvalidInstanceId.NotFoundThe specified instanceId does not exist.指定的实例ID未找到。
500InternalErrorThe request processing has failed due to some unknown error, exception or failure.内部错误,请重试。
500InternalErrorThe request processing has failed due to some unknown error.内部错误,请重试。
500InvalidInstanceType.ValueUnauthorizedThe specified InstanceType is not authorized.指定的实例规格未授权使用。

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

变更历史

变更时间变更内容概要操作
2023-07-21OpenAPI 错误码发生变更看变更集
变更项变更内容
错误码OpenAPI 错误码发生变更
    错误码 500 变更
    删除错误码:400
    删除错误码:403
    删除错误码:404
  • 本页导读 (1)
文档反馈