搜索本产品文档关键词
EIP实例
所有文档
menu
没有找到结果,请重新输入

弹性公网IP EIP

EIP实例

申请EIP

  • 申请一个EIP,可用于绑定到任意BCC、BLB等实例
  • 创建EIP需要实名认证,若未通过实名认证可以前往百度开放云官网控制台中的安全认证下的实名认证中进行认证。

函数声明

type CreateEipArgs struct {
	Name              string           `json:"name,omitempty"`
	BandWidthInMbps   int              `json:"bandwidthInMbps"`
	Billing           *Billing         `json:"billing"`
	Tags              []model.TagModel `json:"tags"`
	AutoRenewTimeUnit string           `json:"autoRenewTimeUnit,omitempty"`
	AutoRenewTime     int              `json:"autoRenewTime,omitempty"`
	RouteType         string           `json:"routeType,omitempty"`
	Idc               string           `json:"idc,omitempty"`
	ClientToken       string           `json:"-"`
}

type CreateEipResult struct {
	Eip string `json:"eip"`
}

func (c *Client) CreateEip(args *CreateEipArgs) (*CreateEipResult, error)

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Wjwvz30fv

返回值

操作成功:

{
    "eip":"180.181.3.133"
}

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_create_eip.go

EIP带宽扩缩容

  • 用于指定EIP的带宽扩缩容
  • 通过查询EIP列表查看EIP扩缩容状态是否完成

函数声明

type ResizeEipArgs struct {
	NewBandWidthInMbps int    `json:"newBandwidthInMbps"`
	ClientToken        string `json:"-"`
}

func (c *Client) ResizeEip(eip string, args *ResizeEipArgs) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Hjwvz325u

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_resize_eip.go

绑定EIP

  • 绑定EIP到某个实例
  • 只有available状态的EIP支持绑定操作
  • 被绑定的实例不能存在任何已有EIP绑定关系
  • 被绑定的实例不能处于欠费状态

函数声明

type BindEipArgs struct {
	InstanceType string `json:"instanceType"`
	InstanceId   string `json:"instanceId"`
	ClientToken  string `json:"-"`
}

func (c *Client) BindEip(eip string, args *BindEipArgs) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/9jwvz31gn

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_bind_eip.go

解绑EIP

  • 解除指定EIP的绑定关系
  • 被解绑的EIP必须已经绑定到任意实例

函数声明

func (c *Client) UnBindEip(eip, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Djwvz314s

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_unbind_eip.go

释放EIP

  • 释放指定EIP,被释放的EIP无法找回
  • 如果EIP被绑定到任意实例,需要先解绑才能释放

函数声明

func (c *Client) DeleteEip(eip, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Rjwvz32ig

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_delete_eip.go

查询EIP列表

  • 可根据多重条件查询EIP列表。
  • 如只需查询单个EIP的详情,只需提供eip参数即可。
  • 如只需查询绑定到指定类型实例上的EIP,提供instanceType参数即可。
  • 如只需查询指定实例上绑定的EIP的详情,提供instanceType及instanceId参数即可。
  • 若不提供查询条件,则默认查询覆盖所有EIP。
  • 返回结果为多重条件交集的查询结果,即提供多重条件的情况下,返回同时满足所有条件的EIP。
  • 以上查询结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定。

函数声明

type ListEipArgs struct {
	Eip          string
	InstanceType string
	InstanceId   string
	Marker       string
	MaxKeys      int
	Status       string
}

type ListEipResult struct {
	Marker      string     `json:"marker"`
	MaxKeys     int        `json:"maxKeys"`
	NextMarker  string     `json:"nextMarker"`
	IsTruncated bool       `json:"isTruncated"`
	EipList     []EipModel `json:"eipList"`
}

type EipModel struct {
	Name            string           `json:"name"`
	Eip             string           `json:"eip"`
	EipId           string           `json:"eipId"`
	Status          string           `json:"status"`
	EipInstanceType string           `json:"eipInstanceType"`
	InstanceType    string           `json:"instanceType"`
	InstanceId      string           `json:"instanceId"`
	ShareGroupId    string           `json:"shareGroupId"`
	ClusterId       string           `json:"clusterId"`
	BandWidthInMbps int              `json:"bandwidthInMbps"`
	PaymentTiming   string           `json:"paymentTiming"`
	BillingMethod   string           `json:"billingMethod"`
	CreateTime      string           `json:"createTime"`
	ExpireTime      string           `json:"expireTime"`
	Tags            []model.TagModel `json:"tags"`
}

func (c *Client) ListEip(args *ListEipArgs) (*ListEipResult, error)

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Pjwvz30qy

返回值

操作成功:

{
    "marker": "ip-xxxxxxxx",
    "maxKeys": 1000,
    "nextMarker": "",
    "isTruncated": false,
    "eipList": [
        {
            "name": "xxxx",
            "eip": "x.x.x.x",
            "eipId": "ip-xxxxxxxx",
            "status": "available",
            "eipInstanceType": "shared",
            "instanceType": "",
            "instanceId": "",
            "shareGroupId": "eg-xxxxxxxx",
            "clusterId": "",
            "bandwidthInMbps": 100,
            "paymentTiming": "share",
            "billingMethod": "share",
            "createTime": "2023-11-23T07:25:34Z",
            "expireTime": "",
            "tags": null
        },
        {
            "name": "yyyy",
            "eip": "y.y.y.y",
            "eipId": "ip-yyyyyyyy",
            "status": "available",
            "eipInstanceType": "shared",
            "instanceType": "",
            "instanceId": "",
            "shareGroupId": "eg-yyyyyyyy",
            "clusterId": "",
            "bandwidthInMbps": 100,
            "paymentTiming": "share",
            "billingMethod": "share",
            "createTime": "2023-11-23T07:25:34Z",
            "expireTime": "",
            "tags": null
        }
    ]

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_list_eips.go

EIP续费

  • 针对指定EIP的续费操作,延长过期时长
  • EIP扩缩容期间不能进行续费操作。

函数声明

type PurchaseReservedEipArgs struct {
	Billing     *Billing `json:"billing"`
	ClientToken string   `json:"clientToken"`
}

func (c *Client) PurchaseReservedEip(eip string, 
                                    args *PurchaseReservedEipArgs) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Yjwvz31ty

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_purchase_reserved_eip.go

EIP开启自动续费

  • EIP 计费方式为预付费类型
  • EIP 无计费变更任务
  • EIP 未开通自动续费

函数声明

type StartAutoRenewArgs struct {
	AutoRenewTimeUnit string `json:"autoRenewTimeUnit,omitempty"`
	AutoRenewTime     int    `json:"autoRenewTime,omitempty"`
	ClientToken       string `json:"-"`
}

func (c *Client) StartAutoRenew(eip string, args *StartAutoRenewArgs) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Sk9gykbek

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_start_auto_renew.go

EIP关闭自动续费

  • 需要EIP已经开通自动续费

函数声明

func (c *Client) StopAutoRenew(eip string, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Sk9gykbek

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_stop_auto_renew.go

开启EIP直通

  • 开启EIP直通
  • EIP必须绑定到某个BCC、DCC、ENI、BLB等实例

函数声明

func (c *Client) DirectEip(eip, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/aknohnbq1

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_direct_eip.go

关闭EIP直通

  • 关闭EIP直通
  • EIP必须已经开启直通功能

函数声明

func (c *Client) UnDirectEip(eip, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Pknohwcdb

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_undirect_eip.go

查询回收站内EIP列表

  • 查询用户账号下回收站内EIP信息
  • 支持按EIP的eip、name进行查询,eip、name 均支持模糊搜索
  • 若不提供查询条件,则默认查询覆盖所有EIP
  • 返回结果是多重条件交集的查询结果,即提供多重条件的情况下,返回同时满足所有条件的EIP
  • 结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定

函数声明

type ListRecycleEipArgs struct {
	Eip     string
	Name    string
	Marker  string
	MaxKeys int
}

type ListRecycleEipResult struct {
	Marker      string            `json:"marker"`
	MaxKeys     int               `json:"maxKeys"`
	NextMarker  string            `json:"nextMarker"`
	IsTruncated bool              `json:"isTruncated"`
	EipList     []RecycleEipModel `json:"eipList"`
}

type RecycleEipModel struct {
	Name                string `json:"name"`
	Eip                 string `json:"eip"`
	EipId               string `json:"eipId"`
	Status              string `json:"status"`
	RouteType           string `json:"routeType"`
	BandWidthInMbps     int    `json:"bandwidthInMbps"`
	PaymentTiming       string `json:"paymentTiming"`
	BillingMethod       string `json:"billingMethod"`
	RecycleTime         string `json:"recycleTime"`
	ScheduledDeleteTime string `json:"scheduledDeleteTime"`
}

func (c *Client) ListRecycleEip(args *ListRecycleEipArgs) (
                                *ListRecycleEipResult, error)

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/dl0anm1j8

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_list_recycle_eip.go

选择性释放EIP

  • 选择将指定EIP直接释放或放入回收站内,默认直接释放
  • 预付费已到期、后付费-按流量、后付费-按带宽状态的 EIP 实例可以选择放入回收站或直接释放
  • 释放指定EIP,被释放的EIP无法找回
  • 回收站内EIP实例保留7天,超过7天则自动释放不可恢复;7天内可以手动选择恢复或删除指定EIP
  • EIP实例如果被绑定到任意实例,需要先解绑才能直接释放
  • EIP实例进入回收站后,强制解除绑定关系,恢复实例后需重新配置
  • 在回收站的EIP有配额限制,默认在每个地域回收站保留10个EIP,按时间倒序。当回收站内EIP数额达到10个时,新进入的EIP会挤走之前的EIP
  • 若EIP实例为后付费已欠费,无论何种选择系统都将直接释放EIP实例

函数声明

func (c *Client) OptionalDeleteEip(eip string, clientToken string, 
                                    releaseToRecycle bool) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/zl0anqxgo

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_optional_delete_eip.go

释放回收站内EIP

  • 释放回收站内指定的EIP

函数声明

func (c *Client) DeleteRecycleEip(eip string, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/sl0anla1w

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_delete_recycle_eip.go

恢复回收站内EIP

  • 恢复回收站内指定EIP计费
  • 若EIP付款方式为预付费,则通过续费操作恢复计费,续费时长为1个月
  • 若EIP付款方式为后付费,则恢复原有计费方式

函数声明

func (c *Client) RestoreRecycleEip(eip string, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/Gl0anfp4g

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_restore_recycle_eip.go

预付费EIP退订

  • 预付费EIP释放并退款。
  • 只有预付费EIP支持退订,后付费EIP不支持退订,后付费EIP可调用释放EIP接口直接释放。
  • 正在封禁中的EIP不支持退订,可在解封后再操作。
  • 绑定了VPN、NAT的EIP不支持退订,可在解除绑定后再操作。
  • 绑有带宽包的EIP不支持退订,可将带宽包释放后再操作。
  • 共享带宽中的EIP不支持退订,可直接退订共享带宽或者将EIP移出共享带宽后释放。
  • EIP退款有惩罚机制,退款金额 = max(0, 总金额 - 已消费金额 * 1.5)。

函数声明

func (c *Client) RefundEip(eip, clientToken string) error

参数含义

请参考OpenAPI文档:https://cloud.baidu.com/doc/EIP/s/1lxk6gbpk

返回值

操作成功:

无特殊返回参数

操作失败:

抛出异常,异常列表参考:https://cloud.baidu.com/doc/EIP/s/nkcu555a4

代码示例

具体代码示例参考:example_eip_refund_eip.go

上一篇
初始化
下一篇
EipGroup实例