Updated on 2026-11-06 GMT+08:00

Updating an EIP

Function

This API is used to update an EIP.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permissions are required for calling this API.

URI

PUT /v3/{project_id}/eip/publicips/{publicip_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Maximum: 32

publicip_id

Yes

String

EIP ID

Minimum: 36

Maximum: 36

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

publicip

Yes

UpdatePublicipOption object

EIP object.

Table 3 UpdatePublicipOption

Parameter

Mandatory

Type

Description

alias

No

String

  • Definition: EIP name

Minimum: 0

Maximum: 64

description

No

String

  • Definition: Supplementary information about the EIP.

  • Range: The value can contain 0 to 255 characters and cannot contain the following special characters: <>

Minimum: 0

Maximum: 255

associate_instance_type

No

String

  • Definition: Type of the instance with an EIP bound.

  • Range:

    • PORT (Instance type, including ECS, BMS, and CCE)

    • NATGW (NAT gateway type)

    • ELB (Load balancer type)

    • ELBV1 (ELB V1 load balancer type)

    • VPN (VPN instance type)

  • Constraints:

    • If both associate_instance_type and associate_instance_id are not left empty, the EIP is bound to an instance.

    • If both associate_instance_type and associate_instance_id are null, an instance is unbound. You can configure associate_instance_type and associate_instance_id to null on API Explorer. For details, see the example request for unbinding an EIP from an instance.

    • A dual-stack EIP cannot have its bound instance changed.

Minimum: 0

Maximum: 36

associate_instance_id

No

String

  • Definition: ID of the bound instance, such as a load balancer ID or an ECS network interface ID.

  • Constraints:

    • If both associate_instance_type and associate_instance_id are not left empty, the EIP is bound to an instance.

    • If both associate_instance_type and associate_instance_id are null, an instance is unbound. You can configure associate_instance_type and associate_instance_id to null on API Explorer. For details, see the example request for unbinding an EIP from an instance.

    • A dual-stack EIP cannot have its bound instance changed.

Minimum: 0

Maximum: 36

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

request_id

String

Request ID.

publicip

PublicipUpdateResp object

Response object of updating an EIP

Table 5 PublicipUpdateResp

Parameter

Type

Description

id

String

  • Definition: EIP ID, which uniquely identifies the EIP.

project_id

String

  • Definition: Project ID.

ip_version

Integer

  • Definition: IP address version.

  • Range:

    • 4: IPv4 EIP

    • 6: IPv6 EIP

public_ip_address

String

  • Definition: EIP or IPv6 port address.

public_ipv6_address

String

  • Definition: IPv6 EIP. This parameter does not display when you assign an IPv4 EIP.

status

String

  • Definition: EIP status

  • Range:

    • FREEZED: frozen

    • BIND_ERROR: failed to be bound

    • BINDING: being bound

    • PENDING_DELETE: being released

    • PENDING_CREATE: being assigned

    • NOTIFYING: being assigned

    • NOTIFY_DELETE: being released

    • PENDING_UPDATE: being updated

    • DOWN: not bound

    • ACTIVE: bound

    • ELB: bound to a load balancer

    • VPN: bound to a VPN

    • ERROR: failed

description

String

  • Definition: Supplementary information about the EIP.

  • Constraints: You can customize this value to identify your EIP, which is not perceived by the system.

public_border_group

String

  • Definition: Whether the resource is in a central region or an edge site.

  • Range: The value can be center or an edge site name.

created_at

String

  • Definition: Time (UTC) when the resource was created.

  • Format: yyyy-MM-ddTHH:mm:ssZ

updated_at

String

  • Definition: Time (UTC) when the resource was updated.

  • Format: yyyy-MM-ddTHH:mm:ssZ

type

String

  • Definition: EIP type.

  • Constraints: N/A

  • Range:

    • EIP: IPv4 EIP.

    • DUALSTACK: IPv6 EIP.

  • Default Value: N/A

vnic

VnicInfo object

  • Definition: Port information of the instance that an EIP is bound to.

  • Constraints: If the instance has no port, the value is null.

bandwidth

PublicipBandwidthInfo object

Definition: Bandwidth of an EIP

enterprise_project_id

String

Definition: Enterprise project ID The value is 0 or a string that contains a maximum of 36 characters in the UUID format with hyphens (-). This is the ID of the enterprise project that you associate with the EIP when you assign the EIP.

billing_info

String

  • Definition: Order information of an EIP.

  • Constraints: Order information is available only for yearly/monthly resources. This parameter is left empty for pay-per-use resources.

lock_status

String

  • Definition: Frozen reason of the EIP.

  • Constraints: The metadata type is used.

  • Range:

    • POLICE: frozen due to public security issues

    • LOCKED: frozen due to common issues

    • ARREAR: frozen due to arrears

    • DELABLE: frozen and can be deleted

  • Default Value: N/A

associate_instance_type

String

  • Definition: Type of the instance with an EIP bound.

  • Range:

    • PORT (Instance type, including ECS, BMS, and CCE)

    • NATGW (NAT gateway type)

    • ELB (Load balancer type)

    • VPN (VPN instance type)

    - ELBV1 (ELB V1 load balancer type)

associate_instance_id

String

Definition: ID of the instance with an EIP bound.

publicip_pool_id

String

Definition: ID of the network that an EIP belongs to. It is the network ID corresponding to publicip_pool_name.

publicip_pool_name

String

  • Definition: Network type of an EIP, including common EIP pool (for example, 5_bgp or 5_sbgp) and dedicated EIP pool.

  • For details about a dedicated EIP pool, see the APIs about publicip_pool.

alias

String

  • Definition: EIP name

associate_mode

String

  • Definition: Passthrough mode. This parameter is available after the passthrough mode is enabled. (Not displayed by default)

Table 6 VnicInfo

Parameter

Type

Description

private_ip_address

String

Definition

Private IP address.

Range

N/A

device_id

String

Definition

ID of the device that the port belongs to. The device ID indicates the ID of the cloud service resource that uses the private IP address in the subnet, for example, the cloud server ID or load balancer ID. The system automatically sets this parameter.

Range

N/A

device_owner

String

Definition

Device that the port belongs to. It can be a cloud service resource that uses a private IP address in the subnet.

Range

  • network:dhcp: DHCP service

  • network:VIP_PORT: Virtual IP address

  • network:router_interface_distributed: Subnet gateway address

  • network:router_centralized_snat: SNAT gateway address

vpc_id

String

Definition

VPC ID.

Range

N/A

port_id

String

Definition

Port ID.

Range

N/A

port_profile

String

Definition

Port profile.

Range

N/A

mac

String

Definition

MAC address of the port.

Range

The system automatically sets this parameter.

vtep

String

Definition

VTEP IP address.

Range

N/A

vni

String

Definition

VXLAN ID.

Range

N/A

instance_id

String

Definition

The ID of the instance that the port belongs to, for example, RDS instance ID.

Range

The system automatically sets this parameter.

instance_type

String

Definition

Type of the instance that uses the port.

Range

  • PORT: elastic network interface

  • PEP_PORT: PEP elastic network interface

  • EVPN: Ethernet virtual private network

  • NATGW: NAT gateway

  • P2CVPN: P2C virtual private network

port_vif_details

String

Definition

Details about the virtual interface of the network interface.

Range

N/A

Table 7 PublicipBandwidthInfo

Parameter

Type

Description

id

String

Definition

Bandwidth ID.

Range

N/A

size

Integer

Definition

Bandwidth size.

Range

The value ranges from 5 Mbit/s to 2000 Mbit/s.

share_type

String

Definition

Whether the bandwidth is shared or dedicated.

Range

  • PER: dedicated bandwidth

  • WHOLE: shared bandwidth

charge_mode

String

Definition

The billing option of the bandwidth.

Range

  • bandwidth: billed by bandwidth

  • traffic: billed by traffic

  • 95peak_plus: billed by enhanced 95th percentile bandwidth

name

String

Definition

Bandwidth name.

Range

The value can contain 1 to 64 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).

billing_info

String

Definition

Bill information. If billing_info is specified, the bandwidth is billed on a yearly/monthly basis.

Range

N/A

Example Requests

  • Update the alias and description of an EIP.

    {
      "publicip" : {
        "alias" : "abcd",
        "description" : "test!!!!"
      }
    }
  • Unbind an EIP from an instance.

    {
      "publicip" : {
        "associate_instance_type" : null,
        "associate_instance_id" : null
      }
    }

Example Responses

Status code: 200

{
  "publicip" : {
    "alias" : "abcd",
    "associate_instance_id" : null,
    "associate_instance_type" : null,
    "bandwidth" : {
      "billing_info" : "xxxx:xxxx:xxxx",
      "charge_mode" : "bandwidth",
      "id" : "80549ae1-cf7a-4f39-a45f-bdb8e194a1f4",
      "name" : "bandwidth-bd25-test",
      "share_type" : "WHOLE",
      "size" : 7
    },
    "billing_info" : null,
    "created_at" : "2020-06-18T14:05:32Z",
    "description" : "test!!!!",
    "enterprise_project_id" : "0",
    "public_border_group" : "center",
    "id" : "b0c42aa6-3d1d-4b39-9188-35ee6aa8d6f7",
    "ip_version" : 4,
    "lock_status" : null,
    "project_id" : "060576782980d5762f9ec014dd2f1148",
    "public_ip_address" : "xx.xx.xx.xx",
    "public_ipv6_address" : null,
    "publicip_pool_id" : "160576782980d5762f9ec014dd2f1148",
    "publicip_pool_name" : "5_mobile",
    "status" : "DOWN",
    "type" : "EIP",
    "updated_at" : "2020-06-18T14:05:32Z",
    "vnic" : null
  },
  "request_id" : "ead9f912bd1191e3d5f0037141098d91"
}

SDK Sample Code

The SDK sample code is as follows.

Java

  • Update the alias and description of an EIP.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.eip.v3.region.EipRegion;
    import com.huaweicloud.sdk.eip.v3.*;
    import com.huaweicloud.sdk.eip.v3.model.*;
    
    
    public class UpdatePublicipSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            EipClient client = EipClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(EipRegion.valueOf("<YOUR REGION>"))
                    .build();
            UpdatePublicipRequest request = new UpdatePublicipRequest();
            request.withPublicipId("{publicip_id}");
            UpdatePublicipsRequestBody body = new UpdatePublicipsRequestBody();
            UpdatePublicipOption publicipbody = new UpdatePublicipOption();
            publicipbody.withAlias("abcd")
                .withDescription("test!!!!");
            body.withPublicip(publicipbody);
            request.withBody(body);
            try {
                UpdatePublicipResponse response = client.updatePublicip(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • Unbind an EIP from an instance.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.eip.v3.region.EipRegion;
    import com.huaweicloud.sdk.eip.v3.*;
    import com.huaweicloud.sdk.eip.v3.model.*;
    
    
    public class UpdatePublicipSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            EipClient client = EipClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(EipRegion.valueOf("<YOUR REGION>"))
                    .build();
            UpdatePublicipRequest request = new UpdatePublicipRequest();
            request.withPublicipId("{publicip_id}");
            try {
                UpdatePublicipResponse response = client.updatePublicip(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    

Python

  • Update the alias and description of an EIP.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkeip.v3.region.eip_region import EipRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkeip.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = EipClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(EipRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = UpdatePublicipRequest()
            request.publicip_id = "{publicip_id}"
            publicipbody = UpdatePublicipOption(
                alias="abcd",
                description="test!!!!"
            )
            request.body = UpdatePublicipsRequestBody(
                publicip=publicipbody
            )
            response = client.update_publicip(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Unbind an EIP from an instance.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkeip.v3.region.eip_region import EipRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkeip.v3 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = EipClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(EipRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = UpdatePublicipRequest()
            request.publicip_id = "{publicip_id}"
            response = client.update_publicip(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    

Go

  • Update the alias and description of an EIP.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        eip "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eip/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eip/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eip/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := eip.EipClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := eip.NewEipClient(hcClient)
    
        request := &model.UpdatePublicipRequest{}
    	request.PublicipId = "{publicip_id}"
    	aliasPublicip:= "abcd"
    	descriptionPublicip:= "test!!!!"
    	publicipbody := &model.UpdatePublicipOption{
    		Alias: &aliasPublicip,
    		Description: &descriptionPublicip,
    	}
    	request.Body = &model.UpdatePublicipsRequestBody{
    		Publicip: publicipbody,
    	}
    	response, err := client.UpdatePublicip(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Unbind an EIP from an instance.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        eip "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eip/v3"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eip/v3/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/eip/v3/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth, err := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            SafeBuild()
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        hcClient, err := eip.EipClientBuilder().
             WithRegion(region.ValueOf("<YOUR REGION>")).
             WithCredential(auth).
             SafeBuild()
    
    
        if err != nil {
            fmt.Println(err)
            return
        }
    
        client := eip.NewEipClient(hcClient)
    
        request := &model.UpdatePublicipRequest{}
    	request.PublicipId = "{publicip_id}"
    	response, err := client.UpdatePublicip(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

More

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Normal response to the PUT operation

Error Codes

See Error Codes.