查询租户下辅助弹性网卡列表
功能介绍
当您的辅助弹性网卡创建成功后,您可以通过该接口查询所有辅助弹性网卡信息,包括辅助弹性网卡的IP地址、VLAN ID等。
调用方法
请参见如何调用API。
URI
GET /v3/{project_id}/vpc/sub-network-interfaces
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 辅助弹性网卡所属的项目ID。获取方式请参见获取项目ID。 取值范围: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
limit |
否 |
Integer |
参数解释: 每页返回的资源个数。 取值范围: 0-2000。 |
marker |
否 |
String |
参数解释: 分页查询起始的资源ID,为空时查询第一页。 取值范围: 辅助弹性网卡资源ID。 |
id |
否 |
Array of strings |
参数解释: 辅助弹性网卡ID,可以通过ID字段精确过滤辅助弹性网卡,支持传入多个ID过滤。 取值范围: 不涉及。 |
description |
否 |
Array of strings |
参数解释: 辅助弹性网卡的描述信息,可以通过描述信息过滤辅助弹性网卡,支持传入多个描述进行过滤。 取值范围: 不涉及。 |
vpc_id |
否 |
Array of strings |
参数解释: 辅助弹性网卡所属VPC的ID,可以通过此字段过滤单个或多个VPC下的辅助弹性网卡,支持传入多个VPC ID过滤。 取值范围: 不涉及。 |
virsubnet_id |
否 |
Array of strings |
参数解释: 辅助弹性网卡所属虚拟子网的ID,可以通过此字段过滤单个或多个虚拟子网下的辅助弹性网卡,支持传入多个虚拟子网ID过滤。 取值范围: 不涉及。 |
parent_id |
否 |
Array of strings |
参数解释: 辅助弹性网卡所挂载的弹性网卡的ID,可以通过此字段过滤单个或多个弹性网卡下的辅助弹性网卡,支持传入多个弹性网卡ID过滤。 取值范围: 不涉及。 |
private_ip_address |
否 |
Array of strings |
参数解释: 辅助弹性网卡的私有IPv4地址,可以通过此字段过滤辅助弹性网卡,支持传入多个IP地址过滤。 取值范围: 不涉及。 |
mac_address |
否 |
Array of strings |
参数解释: 辅助弹性网卡的MAC地址,可以通过此字段过滤辅助弹性网卡,支持传入多个MAC地址过滤。 取值范围: 不涉及。 |
enable_eip |
否 |
Boolean |
参数解释: 辅助弹性网卡是否关联EIP,可以通过此字段过滤辅助弹性网卡,不支持传入多个值进行过滤。 取值范围: true,false |
scope |
否 |
String |
参数解释: 辅助弹性网卡所在站点的公网出口信息,可以通过此字段过滤辅助弹性网卡。 取值范围: 不涉及。 |
security_groups |
否 |
Array of strings |
参数解释: 辅助弹性网卡关联的安全组ID,可以通过此字段过滤辅助弹性网卡,支持传入多个安全组ID过滤。 取值范围: 不涉及。 |
parent_device_id |
否 |
Array of strings |
参数解释: 辅助弹性网卡的宿主网卡所属的设备ID,可以通过此字段过滤辅助弹性网卡,支持传入多个ID过滤。 取值范围: 不涉及。 |
vlan_id |
否 |
Array of integers |
参数解释: 辅助弹性网卡的VLAN ID,可以通过此字段过滤辅助弹性网卡,支持传入多个VLAN ID过滤。 取值范围: 1-4094。 |
state |
否 |
Array of strings |
参数解释: 辅助弹性网卡的状态,可以通过此字段过滤辅助弹性网卡,支持传入多个状态过滤。 取值范围: NORMAL, UNBOUND |
ipv6_ip_address |
否 |
Array of strings |
参数解释: 辅助弹性网卡的IPv6地址,可以通过此字段过滤辅助弹性网卡,支持传入多个IP地址过滤。 取值范围: 不涉及。 |
instance_id |
否 |
Array of strings |
参数解释: 辅助弹性网卡所属云服务实例的ID,例如RDS实例的ID,可以通过此字段过滤辅助弹性网卡,支持传入多个ID过滤。 取值范围: 不涉及。 |
instance_type |
否 |
Array of strings |
参数解释: 辅助弹性网卡所属云服务实例的类型,例如“RDS”,可以通过此字段过滤辅助弹性网卡,支持传入多个实例类型过滤。 取值范围: 不涉及。 |
请求参数
无
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
request_id |
String |
参数解释: 请求ID。 取值范围: 不涉及。 |
sub_network_interfaces |
Array of SubNetworkInterface objects |
参数解释: 查询辅助弹性网卡列表的响应体。 取值范围: 不涉及。 |
page_info |
PageInfo object |
参数解释: 分页信息。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
参数解释: 辅助弹性网卡的资源ID。辅助弹性网卡创建成功后,会生成一个辅助弹性网卡 ID,是辅助弹性网卡对应的唯一标识。 取值范围: 带“-”的标准UUID格式。 |
virsubnet_id |
String |
参数解释: 辅助弹性网卡所在的虚拟子网ID。 取值范围: 带“-”的标准UUID格式。 |
private_ip_address |
String |
参数解释: 辅助弹性网卡的私有IPv4地址。 取值范围: 不涉及。 |
ipv6_ip_address |
String |
参数解释: 辅助弹性网卡的私有IPv6地址。 取值范围: 不涉及。 |
mac_address |
String |
参数解释: 辅助弹性网卡的MAC地址。 取值范围: 合法的MAC地址,系统随机分配。 |
parent_device_id |
String |
参数解释: 辅助弹性网卡的宿主网卡所属的设备ID。 取值范围: 带“-”的标准UUID格式。 |
parent_id |
String |
参数解释: 辅助弹性网卡所挂载的弹性网卡的ID。 取值范围: 带“-”的标准UUID格式。 |
description |
String |
参数解释: 辅助弹性网卡的描述信息。 取值范围: 0-255个字符,不能包含“<”和“>”。 |
vpc_id |
String |
参数解释: 辅助弹性网卡所属VPC的ID。 取值范围: 带“-”的标准UUID格式。 |
vlan_id |
Integer |
参数解释: 辅助弹性网卡的VLAN ID。 取值范围: 1-4094 |
security_groups |
Array of strings |
参数解释: 辅助弹性网卡关联的安全组的ID列表。例如:"security_groups": ["a0608cbf-d047-4f54-8b28-cd7b59853fff"]。 取值范围: 如果请求时不指定此参数,辅助弹性网卡创建后会自动关联默认安全组。 |
tags |
Array of ResponseTag objects |
参数解释: 辅助弹性网卡的标签信息,包括标签键和标签值,可用来分类和标识资源。详情请参见Tag对象。 取值范围: 不涉及。 |
project_id |
String |
参数解释: 辅助弹性网卡所属的项目ID。 取值范围: 不涉及。 |
created_at |
String |
参数解释: 辅助弹性网卡的创建时间。 取值范围: UTC时间格式,yyyy-MM-ddTHH:mm:ssZ。 |
allowed_address_pairs |
Array of AllowedAddressPair objects |
参数解释: 辅助弹性网卡的IP/Mac对列表,详情请参见“AllowedAddressPair”对象表。 取值范围: 不涉及。 |
state |
String |
参数解释: 辅助弹性网卡的状态。 取值范围:
|
instance_id |
String |
参数解释: 辅助弹性网卡所属的云服务实例ID,例如RDS实例ID。 取值范围: 不涉及。 |
instance_type |
String |
参数解释: 辅助弹性网卡所属的云服务实例类型,例如“RDS”。 取值范围: 不涉及。 |
scope |
String |
参数解释: 辅助弹性网卡所在站点的公网出口信息。 取值范围:
|
security_enabled |
Boolean |
参数解释: 辅助弹性网卡安全使能标记,如果不使能则安全组不生效。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
key |
String |
参数解释: 标签键。 取值范围:
|
value |
String |
参数解释: 标签值。 取值范围:
|
请求示例
-
使用辅助弹性网卡ID过滤查询辅助弹性网卡列表。
GET https://{Endpoint}/v3/8c6fb137a48a428aaf9a0229dca4edb3/vpc/sub-network-interfaces?id=022b5c53-20e1-4f4b-b90c-0575a5e97412&id=056d6cb4-b436-460d-9a63-67666bf3ea9c
-
多条件组合过滤查询辅助弹性网卡
https://{Endpoint}/v3/8c6fb137a48a428aaf9a0229dca4edb3/vpc/sub-network-interfaces?virsubnet_id=3eae2c96-de45-4c41-bf2d-e4ad53a2acb4&private_ip_address=192.168.22.177&parent_id=5eb9dc59-8159-4197-88ea-f3507ad8e0a7
-
分页查询辅助弹性网卡列表
GET https://{Endpoint}/v3/8c6fb137a48a428aaf9a0229dca4edb3/vpc/sub-network-interfaces?limit=2
响应示例
状态码:200
GET操作正常返回,更多状态码请参见状态码。
{ "request_id" : "db2bd86cad7519610d9d405228e63076", "sub_network_interfaces" : [ { "id" : "022b5c53-20e1-4f4b-b90c-0575a5e97412", "project_id" : "8c6fb137a48a428aaf9a0229dca4edb3", "virsubnet_id" : "3c15c3b0-0df4-4115-9c18-e67a8a0d7702", "private_ip_address" : "192.168.0.160", "ipv6_ip_address" : null, "mac_address" : "fa:16:3e:26:7e:1e", "parent_device_id" : "285b2e45-2968-4f4c-8992-54e0d4c8da1d", "security_enabled" : false, "security_groups" : [ ], "allowed_address_pairs" : [ ], "vpc_id" : "c10e1e02-9db2-4bd0-89ef-52536952627e", "instance_id" : "", "instance_type" : "", "description" : "", "parent_id" : "00336617-4552-48c5-9856-f539f4e9aca2", "vlan_id" : 3413, "state" : null, "tags" : [ ], "scope" : "center", "created_at" : "2025-02-10T08:21:16Z" }, { "id" : "056d6cb4-b436-460d-9a63-67666bf3ea9c", "project_id" : "8c6fb137a48a428aaf9a0229dca4edb3", "virsubnet_id" : "3c15c3b0-0df4-4115-9c18-e67a8a0d7702", "private_ip_address" : "192.168.0.20", "ipv6_ip_address" : null, "mac_address" : "fa:16:3e:26:7e:92", "parent_device_id" : "285b2e45-2968-4f4c-8992-54e0d4c8da1d", "security_enabled" : false, "security_groups" : [ ], "allowed_address_pairs" : [ ], "vpc_id" : "c10e1e02-9db2-4bd0-89ef-52536952627e", "instance_id" : "", "instance_type" : "", "description" : "", "parent_id" : "00336617-4552-48c5-9856-f539f4e9aca2", "vlan_id" : 595, "state" : null, "tags" : [ ], "scope" : "center", "created_at" : "2025-02-10T08:21:16Z" } ], "page_info" : { "previous_marker" : "4c2b455a-4c75-4c4d-bada-727be4d0f7b5", "current_count" : 2 } }
SDK代码示例
SDK代码示例如下。
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.vpc.v3.region.VpcRegion; import com.huaweicloud.sdk.vpc.v3.*; import com.huaweicloud.sdk.vpc.v3.model.*; public class ListSubNetworkInterfacesSolution { 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); VpcClient client = VpcClient.newBuilder() .withCredential(auth) .withRegion(VpcRegion.valueOf("<YOUR REGION>")) .build(); ListSubNetworkInterfacesRequest request = new ListSubNetworkInterfacesRequest(); try { ListSubNetworkInterfacesResponse response = client.listSubNetworkInterfaces(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()); } } } |
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 huaweicloudsdkvpc.v3.region.vpc_region import VpcRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkvpc.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 = VpcClient.new_builder() \ .with_credentials(credentials) \ .with_region(VpcRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListSubNetworkInterfacesRequest() response = client.list_sub_network_interfaces(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" vpc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/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 := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := vpc.NewVpcClient( vpc.VpcClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListSubNetworkInterfacesRequest{} response, err := client.ListSubNetworkInterfaces(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
GET操作正常返回,更多状态码请参见状态码。 |
错误码
请参见错误码。