调用AllocateEipAddress接口申请弹性公网IP(Elastic IP Address,简称EIP)。

使用说明

请确保在使用本接口前,您已充分了解EIP的收费方式和价格。更多信息,请参见计费概述

调用本接口后将在指定的地域内随机获取一个状态为Available的弹性公网IP。弹性公网IP在传输层目前只支持解析ICMP、TCP和UDP协议内容,不支持解析IGMP和SCTP等协议内容。

调试

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

请求参数

名称 类型 是否必选 示例值 描述
Action String AllocateEipAddress

系统规定参数。取值:AllocateEipAddress

RegionId String cn-hangzhou

弹性公网IP所在的地域ID。

您可以通过调用DescribeRegions接口获取地域ID。

Bandwidth String 5

EIP的带宽峰值。单位:Mbps。

  • InstanceChargeType取值为PostPaid,且InternetChargeType取值为PayByBandwidth时,Bandwidth取值范围为1~500
  • InstanceChargeType取值为PostPaid,且InternetChargeType取值为PayByTraffic时,Bandwidth取值范围为1~200
  • InstanceChargeType取值为PrePaid时,Bandwidth取值范围为1~1000

默认值:5 Mbps。

Period Integer 1

购买时长。

PricingCycle取值Month时,Period取值范围为1~9

PricingCycle取值Year时,Period取值范围为1~5

InstanceChargeType参数的值为PrePaid时,该参数必选,当InstanceChargeType参数的值为PostPaid时,该参数不填。

ISP String BGP

线路类型。取值:

  • BGP(默认值):BGP(多线)线路。目前全部地域都支持BGP(多线)线路EIP。
  • BGP_PRO:BGP(多线)_精品线路。目前仅中国香港、新加坡、日本(东京)、马来西亚(吉隆坡)、菲律宾(马尼拉)、印度尼西亚(雅加达)和泰国(曼谷)地域支持BGP(多线)_精品线路EIP。

关于BGP(多线)线路和BGP(多线)_精品线路的更多信息,请参见EIP线路类型

  • 如果您是单线带宽的白名单用户,您还可以选择以下类型:
    • ChinaTelecom:中国电信
    • ChinaUnicom:中国联通
    • ChinaMobile:中国移动
    • ChinaTelecom_L2:中国电信L2
    • ChinaUnicom_L2:中国联通L2
    • ChinaMobile_L2:中国移动L2
  • 如果您是杭州金融云用户,该字段必填,取值:BGP_FinanceCloud
ActivityId Long 123456

特殊活动ID,无需配置此参数。

Netmode String public

网络类型,仅取值为public(默认值),表示公网。

AutoPay Boolean false

是否自动付费,取值:

  • false(默认值):不开启自动付费,生成订单后需要到订单中心完成支付。
  • true:开启自动付费,自动支付订单。

InstanceChargeType参数的值为PrePaid时,该参数必选;当InstanceChargeType参数的值为PostPaid时,该参数可不填。

PricingCycle String Month

包年包月的计费周期,取值:

  • Month(默认值):按月付费。
  • Year:按年付费。

InstanceChargeType参数的值为PrePaid时,该参数必选;当InstanceChargeType参数的值为PostPaid时,该参数可不填。

InstanceChargeType String PostPaid

EIP的计费方式,取值:

  • PrePaid:包年包月。
  • PostPaid(默认值):按量计费。

InstanceChargeType取值为PrePaid时,InternetChargeType必须取值PayByBandwidth;当InstanceChargeType取值为PostPaid时,InternetChargeType可取值PayByBandwidthPayByTraffic

InternetChargeType String PayByTraffic

EIP的计量方式,取值:

  • PayByBandwidth(默认值):按带宽计费。
  • PayByTraffic:按流量计费。

InstanceChargeType取值为PrePaid时,InternetChargeType必须取值PayByBandwidth

InstanceChargeType取值为PostPaid时,InternetChargeType可取值PayByBandwidthPayByTraffic

ResourceGroupId String rg-acfmxazffggds****

资源组ID。

ClientToken String 0c593ea1-3bea-11e9-b96b-88e9fe637760

客户端Token,用于保证请求的幂等性。

从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符。

说明 若您未指定,则系统自动使用API请求的RequestId作为ClientToken标识。每次API请求的RequestId不一样。
Name String EIP1

EIP实例的名称。

长度为1~128个字符,必须以字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-)。

说明 创建预付费的EIP实例时,不支持设置该参数。
Description String test

EIP实例的描述。

长度为2~256个字符,必须以字母或中文开头,但不能以http://https://开头。

说明 创建预付费的EIP实例时,不支持设置该参数。
SecurityProtectionTypes.N String AntiDDoS_Enhanced

安全防护级别。

  • 配置为空时,默认为DDoS防护(基础版)。
  • 配置为AntiDDoS_Enhanced时,表示DDoS防护(增强版)。

您最多可以设置10个安全防护级别。

PublicIpAddressPoolId String pippool-2vc0kxcedhquybdsz****

IP地址池ID。

EIP将从该IP地址池中分配。

IP地址池功能默认不开放。如需使用,请在配额中心申请IP地址池功能权益配额。具体操作,请参见通过配额中心提升配额

Zone String cn-hangzhou-a

弹性公网IP的可用区。

返回数据

名称 类型 示例值 描述
RequestId String 4EC47282-1B74-4534-BD0E-403F3EE64CAF

请求ID。

OrderId Long 10

订单号。仅InstanceChargeType取值为PrePaid时返回。

ResourceGroupId String rg-acfmxazfdgdg****

资源组ID。仅InstanceChargeType取值为PostPaid时返回。

EipAddress String 192.0.XX.XX

分配的EIP。仅InstanceChargeType取值为PostPaid时返回。

AllocationId String eip-25877c70gddh****

EIP实例的ID。

示例

请求示例

http(s)://[Endpoint]/?Action=AllocateEipAddress
&RegionId=cn-hangzhou
&Bandwidth=5
&Period=1
&ISP=BGP
&ActivityId=123456
&Netmode=public
&AutoPay=false
&PricingCycle=Month
&InstanceChargeType=PostPaid
&InternetChargeType=PayByTraffic
&ResourceGroupId=rg-acfmxazffggds****
&ClientToken=0c593ea1-3bea-11e9-b96b-88e9fe637760
&Name=EIP1
&Description=test
&SecurityProtectionTypes=["AntiDDoS_Enhanced"]
&PublicIpAddressPoolId=pippool-2vc0kxcedhquybdsz****
&Zone=cn-hangzhou-a
&公共请求参数

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<AllocateEipAddressResponse>
    <RequestId>4EC47282-1B74-4534-BD0E-403F3EE64CAF</RequestId>
    <OrderId>10</OrderId>
    <ResourceGroupId>rg-acfmxazfdgdg****</ResourceGroupId>
    <EipAddress>192.0.XX.XX</EipAddress>
    <AllocationId>eip-25877c70gddh****</AllocationId>
</AllocateEipAddressResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "4EC47282-1B74-4534-BD0E-403F3EE64CAF",
  "OrderId" : 10,
  "ResourceGroupId" : "rg-acfmxazfdgdg****",
  "EipAddress" : "192.0.XX.XX",
  "AllocationId" : "eip-25877c70gddh****"
}

错误码

HttpCode 错误码 错误信息 描述
400 InvalidParameter Specified value of "Bandwidth" is not valid. 该带宽不合法。
400 InsufficientBalance Your account does not have enough balance. 账户余额不足,请先充值再操作。
400 QuotaExceeded.Eip Elastic IP address quota exceeded. 弹性公网IP的个数超过额度限制,如果您有更多额度的需求,建议您考虑使用NAT网关。
400 ReserveIpFail Reserve eip failed. EIP预留失败。
400 InvalidRegion.NotSupport The specified region does not support. 该 RegionId 不支持此操作。
400 InvalidResourceGroupId The specified ResourceGroupId does not exist. 资源组ID不存在。
400 OperationFailed.RiskControl Risk control check failed. 我们检测到您的付款方式存在安全风险。请通过电子邮件或控制台消息中的链接继续验证,并在验证后重新提交订单。
400 ORDER.QUANTITY_INVALID User quota has exceeded the limit. 您当前保有的EIP数量已达上限,可前往配额管理提升EIP数量配额
400 OrderError.EIP The Account failed to create order. 下单失败
400 CreditPayInsufficientBalance The balance is insufficient, please contact your channel partner to increase the balance 额度不足,请联系您的渠道合作伙伴提升额度。
400 OperationDenied.NotOpenDdosOriginProtectService The operation is not allowed because of you do not open Ddos Origin Protection Service 无法创建DDoS防护(增强版)Eip,因为没有购买DDoS原生防护服务
400 IncorrectStatus.PublicIpAddressPool The status of PublicIpAddressPool is incorrect. 地址池实例未处于稳态,不允许分配EIP。
400 IncorrectStatus.PublicIpAddressPool The status of %s [%s] is incorrect. 无法分配EIP,因为IP地址池状态不对
400 IllegalParam.Isp The param of %s is illegal. 无法分配EIP,因为ISP参数非法
400 AccountMoneyValidateError The available amount of the account is insufficient. 账号可用金额不足
400 OrderFailed.ConcurrentOperate Failed to create the order due to concurrent operations. 创建订单失败,因为并发操作。
400 OperationFailed.BasicInfoUncompleted Your information is incomplete. Complete your information before the operation. 您的基本信息尚未完成,请先完成信息填写。
400 OperationFailed.QuotaNotEnough Your quota is insufficient. Please contact your channel partner to increase your quota 您当前quota配额不足,请您可以联系渠道伙伴为您增加额度
403 Forbidden User not authorized to operate on the specified resource. 您没有权限操作指定资源,请申请权限后再操作。
409 OperationConflict Request was denied due to conflict with a previous request. 请求冲突,请稍后重试。
500 InternalError The request processing has failed due to some unknown error, exception or failure. 内部错误

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