Elastic network interface
Initialization
Confirm Endpoint
When confirming SDK usage and configuring endpoint, understand the related concepts of endpoint. Baidu AI Cloud currently supports multiple regions. Please refer toRegion Selection Guide. North China - Beijing, South China-Guangzhou, East China - Suzhou, Hong Kong, Central China-Wuhan (Financial) and North China - Baoding are supported currently. Corresponding endpoint details are as follows:
| Access region | Endpoint |
|---|---|
| North China-Beijing | bcc.bj.baidubce.com |
| South China-Guangzhou | bcc.gz.baidubce.com |
| East China-Suzhou | bcc.su.baidubce.com |
| Hong Kong | bcc.hkg.baidubce.com |
| Central China-Wuhan (Financial) | bcc.fwh.baidubce.com |
| North China-Baoding | bcc.bd.baidubce.com |
Retrieve access key
To use the security group of Baidu AI Cloud, you need a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. AK/SK are system-assigned strings used to identify users and perform signature certification for BOS. Your AK/SK information can be obtained and understood through the following steps: Register a Baidu AI Cloud account Create AK/SK
Create ENIClient
EniClient functions as the client for ENI services, providing developers with a variety of methods to interact with ENI services.
When creating an EniClient, first configure an ACL clientconfiguration-type config instance using Endpoint, AK and SK, and then use the config instance to configure the EniClient. The specific configuration method is as follows:
1 static final String HOST = "";
2 static final String AK = "";
3 static final String SK = "";
4 EniClientConfiguration config = new EniClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(AK, SK));
6 config.setEndpoint(HOST);
7 EniClien eniClient = new EniClien(config);
Create elastic network interface
Function declaration
1public CreateEniResponse createEni(CreateEniRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Creating Eni
Response Value
- Operation succeeded
1{
2 "metadata":"Refer to the metadata section in the appendix for metadata format",
3 "eniId":"eni-58djsuahfkj"
4}
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleCreateEni.java
Update elastic network interface
Function declaration
1 public void updateEni(EniUpdateRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Updating Eni
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleUpdateEni.java
Delete elastic network interface
Function declaration
1 public void deleteEni(String eniId) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Deleting Eni
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleDeleteEni.java
Query elastic network interface list
Function declaration
1public ListEniResponse listEni(ListEniRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Listing ENI
Response Value
- Operation succeeded
1{
2 "metadata":"Refer to the metadata section in the appendix for metadata format",
3 "maxKeys": 1000,
4 "isTruncated": false,
5 "enis": [
6 {
7 "eniId": "eni-hkd58ti0vc6e",
8 "name": "testEni",
9 "vpcId": "vpc-b9ycwxxisrb7",
10 "subnetId": "sbn-6ha6gp1vczuv",
11 "zoneName": "cn-bj-a",
12 "description": "desc",
13 "createdTime": "2023-12-04T02:58:44Z",
14 "macAddress": "fa:f6:00:13:7f:ba",
15 "status": "available",
16 "networkInterfaceTrafficMode": "standard",
17 "privateIpSet": [
18 {
19 "primary": true,
20 "privateIpAddress": "192.168.0.8"
21 }
22 ],
23 "ipv6PrivateIpSet": []
24 }
25 ]
26}
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleListEni.java
Add Intranet IP to elastic network interface
Function declaration
1 public void addPrivateIp(EniPrivateIpOperateRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Creating Eni Intranet IP
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniAddPrivateIp.java
Delete Intranet IP from elastic network interface
Function declaration
1public void deletePrivateIp(EniPrivateIpOperateRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Deleting Eni Intranet IP
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniDelPrivateIp.java
Query the specified elastic network interface
Function declaration
1public EniDetail getEniDetail(GetEniDetailRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Querying Specified Eni
Response Value
- Operation succeeded
1{
2 "metadata":"Refer to the metadata section in the appendix for metadata format",
3 "eniId": "eni-gu14mqxy6vz1",
4 "name": "a1",
5 "vpcId": "vpc-5zmchpfuc03w",
6 "subnetId": "sbn-tzgpvbmuk69d",
7 "zoneName": "cn-bj-a",
8 "description": "aa1",
9 "createdTime": "2022-04-06T08:04:31Z",
10 "macAddress": "fa:f6:00:0f:93:25",
11 "status": "available",
12 "networkInterfaceTrafficMode": "standard",
13 "privateIpSet": [
14 {
15 "primary": true,
16 "privateIpAddress": "192.168.0.7"
17 }
18 ],
19 "ipv6PrivateIpSet": [],
20 "securityGroupIds": [
21 "g-j2kg6vmvn7zm"
22 ],
23 "enterpriseSecurityGroupIds": []
24}
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniDetail.java
Attach elastic network interface to cloud host
Function declaration
1public void attachEniInstance(EniInstanceOperateRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Attaching Eni to Cloud Host
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniAttachVm.java
Detach elastic network interface from cloud host
Function declaration
1public void detachEniInstance(EniInstanceOperateRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Attaching Eni to Cloud Host
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniDetachVm.java
Elastic network interface binds to EIP
Function declaration
1public void bindEniPublicIp(EniBindEipRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation Request Parameters for Binding EIP to Eni
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniBindEip.java
Elastic network interface unbinds from EIP
Function declaration
1public void unBindEniPublicIp(EniUnBindEipRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Unbinding EIP from Eni
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniUnBindEip.java
Update elastic network interface with regular security group
Function declaration
1public void updateEniSecurityGroup(EniUpdateSecurityGroupRequest request) {
2 }
Parameter description
Please refer to the OpenAPI documentation: Request Parameters for Updating Regular Security Group of Eni
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniUpdateSecurityGroups.java
Update elastic network interface with enterprise security group
Function declaration
1 public void updateEniEnterpriseSecurityGroup(EniUpdateEnterpriseSecurityGroupRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Updating Enterprise Security Group of Eni
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniUpdateEnterpriseSecurityGroups.java
Delete Intranet IP from elastic network interface in batches
Function declaration
1public void batchDeletePrivateIp(EniPrivateIpBatchOperateRequest request) {
2 }
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Deleting IPs from Eni in Batches
Response Value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniBatchDelPrivateIp.java
Add intranet IP to elastic network interface in batches
Function declaration
1public void batchAddPrivateIp(EniPrivateIpBatchAddRequest request) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation Request Parameters for Adding IPs from Eni in Batches
Response value
- Operation succeeded
1{
2 "metadata":"Refer to the metadata section in the appendix for metadata format",
3 "eniId":"eni-58djsuahfkj"
4}
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleEniBatchAddPrivateIp.java
Query elastic network interface status
Function declaration
1 public EniStatusResponse getEniStatus(String eniId) {
2 }
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Querying Eni Status
Response Value
- Operation succeeded
1{
2 "metadata":"Refer to the metadata section in the appendix for metadata format",
3 "eniStatus":"inuse"
4}
- Operation failed
For response exception list of operation failure, refer to the Eni Exception List.
Code example
For specific code examples, refer to ExampleGetEniStatus.java
Appendix
Public response information in Metadata format
1 {
2 "bceRequestId":"f5f0821d-45fe-439b-bbf4-fc48b639f84a",
3 "contentLength":28,
4 "contentType":"application/json;charset=UTF-8",
5 "date":1701917695000,
6 "server":"openresty/1.15.8.1"
7 }
