CreateEips

1. 接口描述

本接口(CreateEips)用于创建弹性公网IP。

注意事项

2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

参数名称
必选
类型
描述

regionId

String

创建EIP所在的节点ID。

name

String

EIP的名称。

范围2到63个字符。

仅支持输入字母、数字、-/_和英文句点(.)。

且必须以数字或字母开头和结尾。

internetChargeType

公网弹性IP的网络计费方式。

amount

Integer

需要创建EIP的数量。

可选值范围:[1, +)。

默认值:1。

eipV4Type

公网弹性IP的线路类型。

primaryIsp

主公网IP的运营商。

该字段仅作用于三线IP(ThreeLine)。

bandwidth

Integer

公网弹性IP的带宽限速。

单位:Mbps。

可选值范围:[1, +)。

cidrId

String

指定CIDR ID,使用CIDR内分配弹性IP。

该字段和eipV4Type不能同时指定。

publicIp

String

从CIDR里指定公网起始IP地址开始创建弹性IP。

该字段仅在指定cidrId时生效。

resourceGroupId

String

弹性公网IP所放的资源组ID,如不指定则放入默认资源组。

flowPackage

Float

公网IPv6的流量包大小。

单位为TB。

值要求为0或0.1的倍数。

当子网的堆栈类型包括V6且为公网时,且网络计费方式是流量计费(ByTrafficPackage)需要指定。

可选值范围:[0.0, +)。

clusterId

String

公网IPv6所指定的共享带宽包ID。

当子网的堆栈类型包括V6且为公网时,且网络计费方式是共享带宽包计费(BandwidthCluster)需要指定。

peerRegionId

String

远端的节点ID。

marketingOptions

市场营销的相关选项。

tags

弹性公网IP绑定的标签。

注意:实例关联标签键不能重复。

3. 响应结果

参数名称
类型
描述

requestId

String

唯一请求 ID。

每次请求都会返回。定位问题时需要提供该次请求的 requestId。

eipIds

Array of String

创建的弹性公网IP ID列表。

orderNumber

String

本次创建的订单编号。

4. 代码示例

1. 创建一个BGP线路的公网弹性IP, 使用流量包计费。流量包大小为10TB。带宽限速为50Mbps。

POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateEips
<Common Request Params>

Request:
{
  "regionId": "asia-east-1",
  "amount": 1,
  "name": "Test-EIP",
  "internetChargeType": "ByTrafficPackage",
  "eipV4Type": "BGPLine",
  "bandwidth": 50,
  "flowPackage": 10
}

**2. 从CIDR里分配2个公网弹性IP, 使用固定带宽计费。带宽限速为50Mbps。**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateEips
<Common Request Params>

Request:
{
  "regionId": "asia-east-1",
  "amount": 2,
  "name": "Test-EIP",
  "internetChargeType": "ByBandwidth",
  "cidrId": "<cidrId>",
  "bandwidth": 50
}
  
Response:
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>", "<eipId2>"],
    "orderNumber": "<orderNumber>"
  }
}

3. 创建一个Remote IP,远端节点为asia-southwest-1, 使用共享带宽包计费。

POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateEips
<Common Request Params>

Request:
{
  "regionId": "asia-east-1",
  "amount": 1,
  "name": "Test-RemoteIP",
  "internetChargeType": "BandwidthCluster",
  "eipV4Type": "BGPLine",
  "bandwidth": 50,
  "clusterId" "<clusterId>",
  "resourceGroupId": "xxxx",
  "peerRegionId": "asia-southwest-1"
}

Response:
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "eipIds": ["<eipId>"],
    "orderNumber": "<orderNumber>"
  }
}

5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的开发工具集(SDK),未来会陆续支持更多开发语言,方便快速接入和使用Zenlayer的产品和服务。

6. 错误码

下面包含业务逻辑中遇到的错误码,其他错误码见公共错误码

HTTP状态码
错误码
说明

404

INVALID_CIDR_NOT_FOUND

CIDR地址段不存在。

400

OPERATION_DENIED_EIP_UNSUPPORT_NETWORK_TYPE

EIP网络计费方式不支持。

400

INVALID_PARAMETER_BANDWIDTH_EXCEED

带宽限速值超过最大限制。

404

INVALID_REGION_NOT_FOUND

指定的可用区不存在。

最后更新于