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

Querying EIPs

Function

This API is used to query all EIPs of the current region.

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

GET /v3/{project_id}/eip/publicips

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Maximum: 32

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

marker

No

String

Definition

A resource ID for pagination query, indicating that the query starts from the next record of the specified resource ID. If this parameter is left blank, the first page is queried.

Constraints

N/A

Range

Up to 36 characters.

Default Value

N/A

offset

No

Integer

Definition

Start resource number of pagination query.

Constraints

N/A

Range

0 to 99999

Default Value

N/A

limit

No

Integer

Definition

Number of resources returned on each page.

Constraints

N/A

Range

0 to 2000

Default Value

N/A

fields

No

Array of strings

Definition

Query field, in the format of fields=id&fields=owner&...

Constraints

Supported fields: id, project_id, ip_version, type, public_ip_address, public_ipv6_address, network_type, status, description, created_at, updated_at, vnic, bandwidth, associate_instance_type, associate_instance_id, lock_status, billing_info, tags, enterprise_project_id, publicip_pool_name, allow_share_bandwidth_types, alias, publicip_pool_id, and public_border_group

Range

Array length: 0 to 999

Default Value

N/A

sort_key

No

String

Definition

Sorting field.

Constraints

The format is sort_key=id.

Range

Supported fields: id, public_ip_address, public_ipv6_address, ip_version, created_at, updated_at, and public_border_group

Default Value

N/A

sort_dir

No

String

Definition

Sorting order.

Constraints

N/A

Range

  • asc: ascending order

  • desc: descending order

Default Value

N/A

id

No

Array of strings

Definition

The ID that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

ip_version

No

Array of integers

Definition

EIP version.

Constraints

The value must be a type supported by the system. If this parameter is left blank or set to an empty string, an IPv4 EIP will be assigned by default.

Range

The value can be 4 or 6. 6 indicates that the NAT64 capability is enabled.

Default Value

4

public_ip_address

No

Array of strings

Definition

The IPv4 EIP that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

public_ip_address_like

No

String

Definition

The IPv4 EIP that will be used to filter resources. Fuzzy search is supported.

Constraints

N/A

Range

The value can contain 0 to 64 characters.

Default Value

N/A

public_ipv6_address

No

Array of strings

Definition

The IPv6 EIP that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

public_ipv6_address_like

No

String

Definition

The IPv6 EIP that will be used to filter resources. Fuzzy search is supported.

Constraints

N/A

Range

The value can contain 0 to 64 characters.

Default Value

N/A

type

No

Array of strings

Definition

The type that will be used to filter resources.

Constraints

N/A

Range

  • EIP: EIP

  • DUALSTACK: IPv6 EIP

Default Value

N/A

network_type

No

Array of strings

Definition

The network type that will be used to filter resources.

Constraints

N/A

Range

5_telcom, 5_union, 5_bgp, 5_sbgp, 5_ipv6, or 5_graybgp

Default Value

N/A

publicip_pool_name

No

Array of strings

Definition

The EIP pool name that will be used to filter resources.

Constraints

N/A

Range

5_telcom, 5_union, 5_bgp, 5_sbgp, 5_ipv6, 5_graybgp, and dedicated pool names

Default Value

N/A

status

No

Array of strings

Definition

Status that will be used to filter resources.

Constraints

N/A

Range

FREEZED, DOWN, ACTIVE, ERROR

Default Value

N/A

alias_like

No

String

Definition

Alias that will be used for fuzzy search.

Constraints

N/A

Range

0 to 64 characters

Default Value

N/A

alias

No

Array of strings

Definition

Alias that will be used for filtering.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

description

No

Array of strings

Definition

Description that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.private_ip_address

No

Array of strings

Definition

The private IP address that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.private_ip_address_like

No

String

Definition

The private IP address that will be used for fuzzy search.

Constraints

N/A

Range

0 to 64 characters

Default Value

N/A

vnic.device_id

No

Array of strings

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. Filtering by device_id is supported.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.device_owner

No

Array of strings

Definition

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

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.vpc_id

No

Array of strings

Definition

VPC ID that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.port_id

No

Array of strings

Definition

Port ID that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.device_owner_prefixlike

No

String

Definition

Fuzzy search by device_owner_prefixlike.

Constraints

N/A

Range

0 to 64 characters

Default Value

N/A

vnic.instance_type

No

Array of strings

Definition

Instance type that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

vnic.instance_id

No

Array of strings

Definition

Instance ID that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

bandwidth.id

No

Array of strings

Definition

ID that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

bandwidth.name

No

Array of strings

Definition

Name that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

bandwidth.name_like

No

Array of strings

Definition

Name that will be used for fuzzy match.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

bandwidth.size

No

Array of integers

Definition

Size that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

bandwidth.share_type

No

Array of strings

Definition

Bandwidth type that will be used to filter resources.

Constraints

N/A

Range

  • PER: dedicated bandwidth

  • WHOLE: shared bandwidth

Default Value

N/A

bandwidth.charge_mode

No

Array of strings

Definition

Billing option that will be used for query.

Constraints

N/A

Range

  • bandwidth: billed by bandwidth

  • traffic: billed by traffic

  • 95peak_plus: billed by enhanced 95th percentile bandwidth

Default Value

N/A

billing_info

No

Array of strings

Definition

Billing information that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

billing_mode

No

String

Definition

Billing mode that will be used to filter resources.

Constraints

N/A

Range

  • YEARLY_MONTHLY: yearly/monthly

  • PAY_PER_USE: pay-per-use

Default Value

N/A

associate_instance_type

No

Array of strings

Definition

Type of the instance bound to the EIP. You can filter EIPs by the associate_instance_type field.

Constraints

N/A

Range

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

  • NATGW (NAT gateway type)

  • ELB (Load balancer type)

  • ELBV1 (ELBv1 instance type, classic ELBv1)

  • VPN (VPN instance type)

Default Value

N/A

associate_instance_id

No

Array of strings

Definition

ID of the instance that the EIP is bound to. You can filter EIPs by the associate_instance_id field.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

enterprise_project_id

No

Array of strings

Definition

Enterprise project ID that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

public_border_group

No

Array of strings

Definition

Public border group that will be used to filter resources.

Constraints

N/A

Range

Array length: 0 to 999

Default Value

N/A

allow_share_bandwidth_type_any

No

Array of strings

Definition

Shared bandwidth type. EIPs can be filtered by shared bandwidth type.

Constraints

You can specify multiple bandwidth types and separate them with commas (,).

Range

Array length: 0 to 999

Default Value

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

request_id

String

Definition

Request ID.

Range

0 to 36 characters

publicips

Array of PublicipSingleShowResp objects

Definition

EIP objects.

Range

N/A

page_info

PageInfoOption object

Definition

Page information.

Range

N/A

total_count

Integer

Definition

Total number of EIPs.

Range

0 to 999999

Table 4 PublicipSingleShowResp

Parameter

Type

Description

id

String

Definition

ID of the EIP.

Range

N/A

project_id

String

Definition

Project ID.

Range

N/A

ip_version

Integer

Definition

IP address version.

Range

  • 4: IPv4 address

  • 6: IPv6 address

public_ip_address

String

Definition

EIP. If type is DUALSTACK, 0.0.0.0 is returned, which is not a normal IPv4 EIP.

Range

N/A

public_ipv6_address

String

Definition

The obtained EIP if IPv6 EIPs are available. This parameter does not exist if only IPv4 EIPs are available.

Range

N/A

network_type

String

Definition

Network type of the EIP. This parameter is discarded and is not displayed by default. It is inherited by publicip_pool_name.

Range

N/A

status

String

Definition

EIP status.

Range

  • FREEZED: frozen

  • BIND_ERROR: binding failed

  • BINDING: being bound

  • PENDING_DELETE: being released

  • PENDING_CREATE: creating

  • NOTIFYING: creating

  • NOTIFY_DELETE: releasing

  • PENDING_UPDATE: updating

  • DOWN: not bound

  • ACTIVE: bound

-ELB: bound to a load balancer

  • VPN: bound to a VPN

  • ERROR: failed

description

String

Definition

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

Range

N/A

public_border_group

String

Definition

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

Range

Name of the central or edge site.

created_at

String

Definition

UTC time when a resource was created.

Range

Format: yyyy-MM-ddTHH:mm:ssZ

updated_at

String

Definition

UTC time when a resource was updated.

Range

Format: yyyy-MM-ddTHH:mm:ssZ

type

String

Definition

EIP type.

Range

  • EIP: IPv4 EIP

  • DUALSTACK: IPv6 EIP

vnic

VnicInfo object

Definition

Port information if the instance has an EIP bound. If the instance has no port, the value is null.

Range

N/A

bandwidth

PublicipBandwidthInfo object

Definition

Bandwidth bound to an EIP.

Range

N/A

enterprise_project_id

String

Definition

Enterprise project ID. This is the ID of the enterprise project that you associate with the EIP when you assign the EIP.

Range

The value is 0 or a string that contains a maximum of 36 bytes in the UUID format with hyphens (-).

billing_info

String

Definition

Order information of the EIP.

Range

This parameter is available only for yearly/monthly EIPs.

lock_status

String

Definition

Frozen status of an EIP. The metadata type indicates that the EIP is frozen due to arrears or security reasons.

Range

  • police: frozen due to public security reasons

  • locked: resource locked

associate_instance_type

String

Definition

Type of the instance that the EIP is bound to. associate_instance_type can be used for filtering.

Range

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

  • NATGW (NAT gateway type)

  • ELB (Load balancer type)

  • ELBV1 (ELBv1 instance type, classic ELBv1)

  • VPN (VPN instance type)

associate_instance_id

String

Definition

ID of the instance to which the EIP is bound.

Range

N/A

publicip_pool_id

String

Definition

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

Range

N/A

publicip_pool_name

String

Definition

Network type of an EIP, including public EIP pools (for example, 5_bgp or 5_sbgp) and dedicated EIP pools. For details about a dedicated EIP pool, see the APIs about publicip_pool.

Range

N/A

alias

String

Definition

EIP name.

Range

N/A

profile

ProfileInfo object

Definition

EIP and metadata. The parameter is not displayed by default.

Range

N/A

fake_network_type

Boolean

Definition

Whether the BGP type of the EIP is sbgp.

Range

  • TRUE: The BGP type of the EIP can be changed.

  • FALSE: The BGP type of the EIP cannot be changed. The parameter is not displayed by default.

tags

Array of strings

Definition

User tags.

Range

N/A

associate_instance_metadata

String

Definition

Records the upper-level ownership of an instance. For example, if associate_instance_type is set to PORT, this parameter records the device_id and device_owner information of the port. This parameter only records information in limited scenarios. The parameter is not displayed by default.

Range

Array length: 0 to 9999

associate_mode

String

Definition

Passthrough mode. This parameter is available after the passthrough mode is enabled. The parameter is not displayed by default.

Range

N/A

allow_share_bandwidth_types

Array of strings

Definition

Types of the shared bandwidth that an EIP can be added to. If this parameter is left blank, the EIP cannot be added to any shared bandwidth. EIPs can be added only to the shared bandwidth of these types.

Range

Array length: 0 to 9999

cascade_delete_by_instance

Boolean

Definition

Whether an EIP can be released together with its instance. The parameter is not displayed by default.

Range

N/A

Table 5 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 6 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

Table 7 ProfileInfo

Parameter

Type

Description

local_network_port

String

Definition

port_id in the 5_xxx network (for example, 5_bgp) of an EIP.

Range

N/A

standalone

Boolean

Definition

Whether an EIP is assigned together with a VM.

Range

  • true: The EIP is assigned independently.

  • false: The EIP is assigned together with a VM.

notify_status

String

Definition

EIP assigning status, which is used internally by the EIP service.

Range

  • PENDING_CREATE

  • PENDING_UPDATE

  • NOTIFYING

  • NOTIFYED

  • NOTIFY_DELETE

create_time

String

Definition

Time when an EIP was assigned.

Range

N/A

fake_network_type

Boolean

Definition

This field is used only to indicate whether the BGP type of the EIP is sbgp.

Range

  • TRUE: The BGP type of the EIP can be changed.

  • FALSE: The BGP type of the EIP cannot be changed. The parameter is not displayed by default.

create_source

String

Definition

Type of the resource purchased together with an EIP.

Range

N/A

ecs_id

String

Definition

ID of the ECS purchased together with an EIP.

Range

N/A

lock_status

String

Definition

Lock status of an EIP.

Range

  • POLICE: frozen due to public security reasons

  • LOCKED: frozen due to common issues

    • ARREAR: frozen due to arrears

    • DELABLE: frozen and can be deleted

freezed_status

String

Definition

EIP frozen status.

Range

  • FREEZED: The EIP is frozen.

  • UNFREEZED: The EIP is not frozen.

bandwidth_info

BandwidthInfoResp object

Definition

Information about the bandwidth bound to the EIP.

Range

N/A

Table 8 BandwidthInfoResp

Parameter

Type

Description

bandwidth_name

String

Definition

Bandwidth name.

Range

N/A

bandwidth_number

Integer

Definition

Bandwidth size.

Range

N/A

bandwidth_type

String

Definition

Bandwidth type that will be used to filter resources.

Range

  • PER: dedicated bandwidth

  • WHOLE: shared bandwidth

bandwidth_id

String

Definition

Bandwidth ID.

Range

Format: [A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}

Table 9 PageInfoOption

Parameter

Type

Description

previous_marker

String

Definition

Marker value of the previous page.

Range

N/A

next_marker

String

Definition

Marker value of the next page.

Range

N/A

current_count

Integer

Definition

Total number of data records on the current page.

Range

0 to 99999

Example Requests

Query EIPs.

GET https://{Endpoint}/v3/{project_id}/eip/publicips

Example Responses

Status code: 200

{
  "page_info" : {
    "current_count" : 1,
    "next_marker" : "0490aeae-ab8f-4764-b012-45645e9c0aa9",
    "previous_marker" : "0490aeae-ab8f-4764-b012-45645e9c0aa9"
  },
  "publicips" : [ {
    "created_at" : "2022-03-17T09:46:22Z",
    "updated_at" : "2022-03-30T02:46:04Z",
    "lock_status" : null,
    "allow_share_bandwidth_types" : [ "bgp", "sbgp", "share", "share_yidongdanxian", "share_bgp_premium" ],
    "id" : "006343a1-32bf-4361-958a-efd158153dd0",
    "alias" : null,
    "project_id" : "060576787a80d5762fa2c00f07ddfcf4",
    "ip_version" : 4,
    "public_ip_address" : "88.88.1.141",
    "public_ipv6_address" : null,
    "status" : "DOWN",
    "description" : "",
    "enterprise_project_id" : "0",
    "billing_info" : null,
    "type" : "EIP",
    "vnic" : {
      "private_ip_address" : "172.16.1.235",
      "device_id" : "cdaba63f-d85d-4399-81c2-ee9764ad34dd",
      "device_owner" : "compute:regionB",
      "vpc_id" : "1c30f428-9741-48b2-a788-0b2f359705eb",
      "port_id" : "22d3576d-c042-4f3d-8c7c-1330a2724627",
      "mac" : "fa:16:3e:3a:22:66",
      "vtep" : "26.111.111.11",
      "vni" : 961184,
      "instance_id" : "",
      "instance_type" : "",
      "port_profile" : null,
      "port_vif_details" : "{\"primary_interface\": true}"
    },
    "bandwidth" : {
      "id" : "149ff19b-5de4-4436-958f-2eca39952e93",
      "size" : 100,
      "share_type" : "PER",
      "charge_mode" : "traffic",
      "name" : "bandwidth-xym-br-eqos",
      "billing_info" : ""
    },
    "associate_instance_type" : "PORT",
    "associate_instance_id" : "22d3576d-c042-4f3d-8c7c-1330a2724627",
    "publicip_pool_id" : "9af5f2e5-1765-4b86-b342-ece52e785c8b",
    "publicip_pool_name" : "5_union",
    "public_border_group" : "center",
    "tags" : [ "key=value" ]
  } ],
  "request_id" : "c4962d006b34af3c2343de7f88ef65e3",
  "total_count" : 100
}

SDK Sample Code

The SDK sample code is as follows.

Java

 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
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 ListPublicipsSolution {

    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();
        ListPublicipsRequest request = new ListPublicipsRequest();
        try {
            ListPublicipsResponse response = client.listPublicips(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

 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
# 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 = ListPublicipsRequest()
        response = client.list_publicips(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

 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
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.ListPublicipsRequest{}
	response, err := client.ListPublicips(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 GET operation

Error Codes

See Error Codes.