查询租户下辅助弹性网卡详情
功能介绍
当您的辅助弹性网卡创建成功后,您可以通过该接口查询单个辅助弹性网卡的详细信息,包括辅助弹性网卡的IP地址、VLAN ID等。
调用方法
请参见如何调用API。
URI
GET /v3/{project_id}/vpc/sub-network-interfaces/{sub_network_interface_id}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 辅助弹性网卡所属的项目ID。获取方式请参见获取项目ID。 取值范围: 不涉及。 |
sub_network_interface_id |
是 |
String |
参数解释: 辅助弹性网卡的资源ID。 取值范围: 不涉及。 |
请求参数
无
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
request_id |
String |
参数解释: 请求ID。 取值范围: 不涉及。 |
sub_network_interface |
SubNetworkInterface 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 |
参数解释: 辅助弹性网卡安全使能标记,如果不使能则安全组不生效。 取值范围: 不涉及。 |
请求示例
查询id为2be868f2-f7c9-48db-abc0-eea0b9105b0的辅助弹性网卡详情。
GET https://{Endpoint}/v3/8c6fb137a48a428aaf9a0229dca4edb3/vpc/sub-network-interfaces/2be868f2-f7c9-48db-abc0-eea0b9105b0d
响应示例
状态码:200
GET操作正常返回,更多状态码请参见状态码。
{ "sub_network_interface" : { "id" : "2be868f2-f7c9-48db-abc0-eea0b9105b0d", "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" }, "request_id" : "16fe2bcb91bd7ad03a895adbc63bf44e" }
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 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.vpc.v3.region.VpcRegion; import com.huaweicloud.sdk.vpc.v3.*; import com.huaweicloud.sdk.vpc.v3.model.*; public class ShowSubNetworkInterfaceSolution { 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(); ShowSubNetworkInterfaceRequest request = new ShowSubNetworkInterfaceRequest(); request.withSubNetworkInterfaceId("{sub_network_interface_id}"); try { ShowSubNetworkInterfaceResponse response = client.showSubNetworkInterface(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 32 |
# 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 = ShowSubNetworkInterfaceRequest() request.sub_network_interface_id = "{sub_network_interface_id}" response = client.show_sub_network_interface(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 38 |
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.ShowSubNetworkInterfaceRequest{} request.SubNetworkInterfaceId = "{sub_network_interface_id}" response, err := client.ShowSubNetworkInterface(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
GET操作正常返回,更多状态码请参见状态码。 |
错误码
请参见错误码。