EIP Instance
Apply for EIP
- Apply for an EIP, which can be bound to any BCC or BLB instances.
- Certification is required for creating EIP. Those who have not passed certification can go to the certification under security certification in the Baidu Open Cloud Official Website Console for certification.
Function declaration
1type CreateEipArgs struct {
2 IpVersion string `json:"ipVersion,omitempty"`
3 Name string `json:"name,omitempty"`
4 BandWidthInMbps int `json:"bandwidthInMbps"`
5 Billing *Billing `json:"billing"`
6 Tags []model.TagModel `json:"tags"`
7 AutoRenewTimeUnit string `json:"autoRenewTimeUnit,omitempty"`
8 AutoRenewTime int `json:"autoRenewTime,omitempty"`
9 RouteType string `json:"routeType,omitempty"`
10 Idc string `json:"idc,omitempty"`
11 ClientToken string `json:"-"`
12}
13type CreateEipResult struct {
14 Eip string `json:"eip"`
15}
16func (c *Client) CreateEip(args *CreateEipArgs) (*CreateEipResult, error)
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Wjwvz30fv
Response Value
Operation succeeded:
1{
2 "eip":"180.181.3.133"
3}
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_create_eip.go
EIP bandwidth scaling
- Used for scaling the bandwidth of a specified EIP
- Check the EIP scaling status by querying the EIP list
Function declaration
1type ResizeEipArgs struct {
2 NewBandWidthInMbps int `json:"newBandwidthInMbps"`
3 ClientToken string `json:"-"`
4}
5func (c *Client) ResizeEip(eip string, args *ResizeEipArgs) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Hjwvz325u
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_resize_eip.go
Bind EIP
- Bind EIP to an instance
- Binding is supported only for available EIP
- The bound instance must not have any existing EIP binding relationships
- The bound instance cannot be in debt status
Function declaration
1type BindEipArgs struct {
2 InstanceType string `json:"instanceType"`
3 InstanceId string `json:"instanceId"`
4 ClientToken string `json:"-"`
5}
6func (c *Client) BindEip(eip string, args *BindEipArgs) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/9jwvz31gn
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_bind_eip.go
Unbind EIP
- Unbind a specified EIP
- The unbound EIP must have been bound to any instance
Function declaration
1func (c *Client) UnBindEip(eip, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Djwvz314s
Response Value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_unbind_eip.go
Release EIP
- The release of a specified EIP cannot be recovered once it is released
- If an EIP is bound to any instance, it must be unbound before release
Function declaration
1func (c *Client) DeleteEip(eip, clientToken string) error
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Rjwvz32ig
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_delete_eip.go
Query EIP list
- The EIP list can be filtered using various criteria.
- To view details of a specific EIP, only the eip parameter is needed.
- To see EIPs linked to a particular instance type, only the instanceType parameter is required.
- To view details of EIPs tied to a specific instance, you need to provide both the instanceType and instanceId parameters.
- If no specific criteria are specified, all EIPs will be listed by default.
- The returned results are based on the overlap of multiple conditions, meaning that if multiple conditions are set, the query will return only the EIPs that meet all conditions.
- The query results support marker-based pagination, with a default page size of 1,000. You can adjust this by setting the maxKeys parameter.
Function declaration
1type ListEipArgs struct {
2 IpVersion string
3 Eip string
4 InstanceType string
5 InstanceId string
6 Status string
7 EipIds []string
8 Marker string
9 MaxKeys int
10}
11type ListEipResult struct {
12 Marker string `json:"marker"`
13 MaxKeys int `json:"maxKeys"`
14 NextMarker string `json:"nextMarker"`
15 IsTruncated bool `json:"isTruncated"`
16 EipList []EipModel `json:"eipList"`
17}
18type EipModel struct {
19 Name string `json:"name"`
20 Eip string `json:"eip"`
21 EipId string `json:"eipId"`
22 Status string `json:"status"`
23 EipInstanceType string `json:"eipInstanceType"`
24 InstanceType string `json:"instanceType"`
25 InstanceId string `json:"instanceId"`
26 ShareGroupId string `json:"shareGroupId"`
27 ClusterId string `json:"clusterId"`
28 BandWidthInMbps int `json:"bandwidthInMbps"`
29 PaymentTiming string `json:"paymentTiming"`
30 BillingMethod string `json:"billingMethod"`
31 CreateTime string `json:"createTime"`
32 ExpireTime string `json:"expireTime"`
33 Region string `json:"region"`
34 RouteType string `json:"routeType"`
35 Tags []model.TagModel `json:"tags"`
36 DeleteProtect bool `json:"deleteProtect"`
37}
38func (c *Client) ListEip(args *ListEipArgs) (*ListEipResult, error)
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Pjwvz30qy
Response value
Operation succeeded:
1{
2 "marker": "ip-xxxxxxxx",
3 "maxKeys": 1000,
4 "nextMarker": "",
5 "isTruncated": false,
6 "eipList": [
7 {
8 "name": "xxxx",
9 "eip": "x.x.x.x",
10 "eipId": "ip-xxxxxxxx",
11 "status": "available",
12 "eipInstanceType": "shared",
13 "instanceType": "",
14 "instanceId": "",
15 "shareGroupId": "eg-xxxxxxxx",
16 "clusterId": "",
17 "bandwidthInMbps": 100,
18 "paymentTiming": "share",
19 "billingMethod": "share",
20 "createTime": "2023-11-23T07:25:34Z",
21 "expireTime": "",
22 "tags": null,
23 "region":"bj",
24 "routeType":"BGP",
25 "deleteProtect":false
26 },
27 {
28 "name": "yyyy",
29 "eip": "y.y.y.y",
30 "eipId": "ip-yyyyyyyy",
31 "status": "available",
32 "eipInstanceType": "shared",
33 "instanceType": "",
34 "instanceId": "",
35 "shareGroupId": "eg-yyyyyyyy",
36 "clusterId": "",
37 "bandwidthInMbps": 100,
38 "paymentTiming": "share",
39 "billingMethod": "share",
40 "createTime": "2023-11-23T07:25:34Z",
41 "expireTime": "",
42 "tags": null,
43 "region":"bj",
44 "routeType":"BGP",
45 "deleteProtect":false
46 }
47 ]
48}
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_list_eips.go
Renew EIP
- Renewal operation for specified EIP; extend the expiration period.
- EIP scaling prevents renewal operations from being executed.
Function declaration
1type PurchaseReservedEipArgs struct {
2 Billing *Billing `json:"billing"`
3 ClientToken string `json:"clientToken"`
4}
5func (c *Client) PurchaseReservedEip(eip string, args *PurchaseReservedEipArgs) error
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Yjwvz31ty
Response Value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_purchase_reserved_eip.go
EIP auto-renewal has been enabled
- The EIP charge type is prepay
- The EIP is not been assigned with shift charge tasks
- The EIP has not been enabled with auto-renewal function
Function declaration
1type StartAutoRenewArgs struct {
2 AutoRenewTimeUnit string `json:"autoRenewTimeUnit,omitempty"`
3 AutoRenewTime int `json:"autoRenewTime,omitempty"`
4 ClientToken string `json:"-"`
5}
6func (c *Client) StartAutoRenew(eip string, args *StartAutoRenewArgs) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Sk9gykbek
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, refer to example_eip_start_auto_renew.go
Disable EIP auto-renewal
- Require EIP to have enabled auto-renewal
Function declaration
1func (c *Client) StopAutoRenew(eip string, clientToken string) error
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Sk9gykbek
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_stop_auto_renew.go
Enable EIP direct
- Enable EIP direct
- The EIP must have been bound to a BCC, DCC, ENI or BLB instance.
Function declaration
1func (c *Client) DirectEip(eip, clientToken string) error
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/aknohnbq1
Response Value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_direct_eip.go
Disable EIP direct
- Disable EIP direct
- The EIP direct must have been enabled
Function declaration
1func (c *Client) UnDirectEip(eip, clientToken string) error
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Pknohwcdb
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_undirect_eip.go
Query EIP list in bucket trash
- Query EIP information in the bucket trash under the user account
- Support querying by EIP address or name, with fuzzy search supported by both scenarios
- If no query criteria are provided, all EIPs will be queried by default
- The returned results are based on the intersection of multiple conditions, to be specific, when multiple conditions are provided, it returns EIPs that satisfy all conditions simultaneously
- Results support marker-based pagination, with a default page size of 1000, which can be specified via the maxKeys parameter.
Function declaration
1type ListRecycleEipArgs struct {
2 Eip string
3 Name string
4 Marker string
5 MaxKeys int
6}
7type ListRecycleEipResult struct {
8 Marker string `json:"marker"`
9 MaxKeys int `json:"maxKeys"`
10 NextMarker string `json:"nextMarker"`
11 IsTruncated bool `json:"isTruncated"`
12 EipList []RecycleEipModel `json:"eipList"`
13}
14type RecycleEipModel struct {
15 Name string `json:"name"`
16 Eip string `json:"eip"`
17 EipId string `json:"eipId"`
18 Status string `json:"status"`
19 RouteType string `json:"routeType"`
20 BandWidthInMbps int `json:"bandwidthInMbps"`
21 PaymentTiming string `json:"paymentTiming"`
22 BillingMethod string `json:"billingMethod"`
23 RecycleTime string `json:"recycleTime"`
24 ScheduledDeleteTime string `json:"scheduledDeleteTime"`
25}
26func (c *Client) ListRecycleEip(args *ListRecycleEipArgs) (*ListRecycleEipResult, error)
Parameter Meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/dl0anm1j8
Response Value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, refer to example_eip_list_recycle_eip.go
Selective release of EIP
- Select to directly release the specified EIP or move it to the bucket trash, defaulted as direct release
- EIP Instances with expired prepay, postpay-by-traffic, or postpay-by-bandwidth status can be moved to the bucket trash or directly released
- The release of a specified EIP cannot be recovered once it is released
- EIP Instances in the bucket trash are retained for 7 days. After 7 days, they will be automatically released and cannot be recovered. Within 7 days, you can manually select to restore or delete a specific EIP
- If an EIP instance is bound to any instance, it must be unbound before it can be directly released
- When an EIP instance enters the bucket trash, binding relationships are forcibly removed and must be reconfigured after restoration
- EIPs moved to the bucket trash are subject to a cap of 10 EIPs per region, retained in reverse chronological order by default. When this limit is reached, newly added EIPs will replace the oldest ones.
- If the EIP instance is in debt under postpay mode, the system will directly release the EIP instance regardless of the selection
Function declaration
1func (c *Client) OptionalDeleteEip(eip string, clientToken string, releaseToRecycle bool) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/zl0anqxgo
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_optional_delete_eip.go
Release EIPs in the bucket trash
- Release specified EIPs in the bucket trash
Function declaration
1func (c *Client) DeleteRecycleEip(eip string, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/sl0anla1w
Response Value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_delete_recycle_eip.go
Restore EIPs in the bucket trash
- Restore billing for the specified EIP in the bucket trash
- If the EIP payment type is prepay, billing will be resumed through renewal, with a renewal duration of 1 month
- If the EIP payment type is postpayment, the original charge type will be restored
Function declaration
1func (c *Client) RestoreRecycleEip(eip string, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/Gl0anfp4g
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_restore_recycle_eip.go
Unsubscribe prepaid EIP
- Releasing and refunding prepaid EIPs.
- Only prepaid EIPs can be unsubscribed, whereas postpaid EIPs cannot be unsubscribed and can only be directly released via the Release EIP API.
- EIPs that are actively blocked cannot be unsubscribed. Please try again after unblocking the EIP.
- EIPs that are bound to a VPN or NAT cannot be unsubscribed. Please retry after unbinding the EIP from the VPN or NAT.
- EIPs associated with bandwidth packages cannot be unsubscribed. Please retry after releasing the bandwidth package.
- EIPs within an EIPGROUP cannot be unsubscribed directly. You need to unsubscribe from the EIPGROUP or remove the EIP from the group before releasing it.
- The EIP refund policy includes a penalty mechanism, calculated as follows: refund amount = max(0, total payment - consumed value * 1.5).
Function declaration
1func (c *Client) RefundEip(eip, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/EIP/s/1lxk6gbpk
Response value
Operation succeeded:
There are no special response parameters
Operation failed:
Throw an exception. For the exception list, refer to https://cloud.baidu.com/doc/EIP/s/nkcu555a4
Code example
For specific code examples, please refer to example_eip_refund_eip.go
