
# 查询租户下辅助弹性网卡详情 - ShowSubNetworkInterface
#### 功能介绍
当您的辅助弹性网卡创建成功后，您可以通过该接口查询单个辅助弹性网卡的详细信息，包括辅助弹性网卡的IP地址、VLAN ID等。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-vpc/vpc_api00_0007.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-vpc/vpc_permission_0000.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                          | 访问级别 | 资源类型（\*为必须）            | 条件键                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | vpc:subNetworkInterfaces:get | Read | subNetworkInterface \* | - g:EnterpriseProjectId   - g:ResourceTag/\<tag-key\>   - vpc:SubnetId   - vpc:SubNetworkInterfaceId   - vpc:VpcId    | -  | -      |
     
  
 
#### URI
GET /v3/{project_id}/vpc/sub-network-interfaces/{sub_network_interface_id}
表1路径参数 
| 参数                       | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| project_id               | 是    | String | **参数解释**： 辅助弹性网卡所属的项目ID。获取方式请参见[获取项目ID](https://support.huaweicloud.com/api-vpc/vpc_api_0011.html)。 **取值范围**： 不涉及。 |
| sub_network_interface_id | 是    | String | **参数解释**： 辅助弹性网卡的资源ID。 **取值范围**： 不涉及。                                                                              |
   
#### 请求参数
无
#### 响应参数
**状态码：200**
表2响应Body参数 
| 参数                    | 参数类型                                                                                 | 描述                                                                                                                                                                        |
|:---|:---|:---|
| request_id            | String                                                                               | **参数解释**： 请求ID。 **取值范围**： 不涉及。           |
| sub_network_interface | [SubNetworkInterface] object | **参数解释**： 查询辅助弹性网卡详情的响应体。 **取值范围**： 不涉及。 |
   
 表3SubNetworkInterface 
| 参数                    | 参数类型                                                                                         | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|
| 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                                                                                       | **参数解释**： 辅助弹性网卡的创建时间。 **取值范围**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                         |
| allowed_address_pairs | Array of [AllowedAddressPair] objects | **参数解释**： 辅助弹性网卡的IP/Mac对列表，详情请参见"AllowedAddressPair"对象表。 **取值范围**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                       |
| state                 | String                                                                                       | **参数解释**： 辅助弹性网卡的状态。 **取值范围**： - NORMAL：表示辅助弹性网卡已挂载在弹性网卡上。   - UNBOUND：表示辅助弹性网卡未挂载在弹性网卡上。    |
| instance_id           | String                                                                                       | **参数解释**： 辅助弹性网卡所属的云服务实例ID，例如RDS实例ID。 **取值范围**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                          |
| instance_type         | String                                                                                       | **参数解释**： 辅助弹性网卡所属的云服务实例类型，例如"RDS"。 **取值范围**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                            |
| scope                 | String                                                                                       | **参数解释**： 辅助弹性网卡所在站点的公网出口信息。 **取值范围**： - center：默认值，表示作用域为中心。   - 某个AZ ID：表示作用域为具体的AZ。       |
| security_enabled      | Boolean                                                                                      | **参数解释**： 辅助弹性网卡安全使能标记，如果不使能则安全组不生效。 **取值范围**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                           |
   
 表4ResponseTag 
| 参数    | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|:---|:---|:---|
| key   | String | **参数解释**： 标签键。 **取值范围**： - 最大长度128个unicode字符， key不能为空。   - 同一资源的key不能重复。   - 可以包含的字符范围： - 英文字母   - 数字   - 特殊字符：下划线（_）、点（.）、冒号（:）、加号（+）、中划线（-）、等号（=）   - 中文字符      |
| value | String | **参数解释**： 标签值。 **取值范围**： - 每个值最大长度255个unicode字符，value可以为空。   - 可以包含的字符范围： - 英文字母   - 数字   - 特殊字符：下划线（_）、点（.）、冒号（:）、加号（+）、中划线（-）、等号（=）   - 中文字符                                                                                                                                                                       |
   
 表5AllowedAddressPair 
| 参数          | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|:---|:---|:---|
| ip_address  | String | **参数解释**： 后端ECS网卡的IP地址。 **取值范围**： - 单个IP地址：例如192.168.21.25。   - IP网段：例如192.168.21.0/24。    |
| mac_address | String | **参数解释**： MAC地址。默认使用辅助弹性网卡的MAC地址。 **取值范围**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                            |
   
#### 请求示例
查询id为2be868f2-f7c9-48db-abc0-eea0b9105b0的辅助弹性网卡详情。
```
GET https://{Endpoint}/v3/8c6fb137a48a428aaf9a0229dca4edb3/vpc/sub-network-interfaces/2be868f2-f7c9-48db-abc0-eea0b9105b0d
```
#### 响应示例
**状态码：200**
GET操作正常返回，更多状态码请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
```
{
  "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" : "NORMAL",
    "tags" : [ ],
    "scope" : "center",
    "created_at" : "2025-02-10T08:21:16Z"
  },
  "request_id" : "16fe2bcb91bd7ad03a895adbc63bf44e"
}
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  ```
  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());
          }
      }
  }
  ```
- [Python]
  ```
  # 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)
  ```
- [Go]
  ```
  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, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          WithProjectId(projectId).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := vpc.VpcClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := vpc.NewVpcClient(hcClient)
      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](https://console.huaweicloud.com/apiexplorer/#/openapi/VPC/sdk?api=ShowSubNetworkInterface&version=v3)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述                                                                                  |
|:---|:---|
| 200 | GET操作正常返回，更多状态码请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
