High-availability virtual IP address (HAVIP)
Retrieve Endpoint
Before configuring the endpoint for SDK usage, please refer to the developer guide section on VPC Service Domain Name to understand endpoint-related concepts. Baidu AI Cloud currently supports multiple regions. Please refer to the VPC section in the Region Selection Guide. High-availability virtual IP address service is part of the VPC service and adopts the VPC service domain name.
Retrieve AK/SK
To use the Baidu AI Cloud products, you need a Baidu AI Cloud account, a valid AK (Access Key ID) and SK (Secret Access Key) for signature certification. Your AK/SK information can be obtained and understood through the following steps:
Create HaVipClient
When creating a HaVipClient, first configure a HaVipClientConfiguration-type config instance using endpoint, AK and SK, and then use the config instance to configure the HaVipClient. The specific configuration method is as follows:
1static final String HOST = "";
2static final String AK = "";
3static final String SK = "";
4HaVipClientConfiguration config = new HaVipClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(AK, SK));
6config.setEndpoint(HOST);
7HaVipClient haVipClient = new HaVipClient(config);
Create high-availability virtual IP address
Function declaration
1public CreateHaVipResponse createHaVip(CreateHaVipRequest createHaVipRequest) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Creating High-availability Virtual IP Address
Response value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "haVipId":"havip-w2d4kgc3x0y1"
4}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleCreateHaVip.java
Query high-availability virtual IP address list
Function declaration
1public ListHaVipResponse listHaVip(String vpcId) {
2 ......
3}
4public ListHaVipResponse listHaVip(ListHaVipRequest listHaVipRequest) {
5 ......
6}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Querying High-availability Virtual IP Address List
Response value
- Operation succeeded
1{
2 "haVips":[
3 {
4 "haVipId":"havip-jshdu47sk",
5 "name":"test_havip",
6 "description":"",
7 "vpcId":"vpc-r625rqw3wuer",
8 "subnetId":"sbn-i4d47zb73ztx",
9 "status":"available",
10 "privateIpAddress":"192.168.1.221",
11 "publicIpAddress":"180.76.245.166",
12 "createdTime":"2022-08-31T11:42:19Z"
13 }
14 ],
15 "marker": "havip-w2d4kgc3x0y1",
16 "isTruncated": true,
17 "nextMarker": "havip-wcd4jgc3x0y1",
18 "maxKeys": 1,
19 "metadata": For details, refer to the metadata section in the appendix
20}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleListHaVip.java
Query the specified high-availability virtual IP address
Function declaration
1public HaVipResponse getHaVip(String haVipId) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Querying Specified High-availability Virtual IP Address
Response value
- Operation succeeded
1{
2 "haVipId": "havip-jshdu47sk",
3 "name": "test_havip",
4 "description": "",
5 "vpcId": "vpc-r625rqw3wuer",
6 "subnetId": "sbn-i4d47zb73ztx",
7 "status": "available",
8 "privateIpAddress": "192.168.1.221",
9 "publicIpAddress": "180.76.245.166",
10 "createdTime": "2022-08-31T11:42:19Z",
11 "bindedInstances": [
12 {
13 "instanceId": "eni-w2kmnu1peqxg",
14 "instanceType": "ENI",
15 "master": true
16 },
17 {
18 "instanceId": "eni-7c9yzhkfn9c2",
19 "instanceType": "ENI",
20 "master": false
21 }
22 ],
23 "metadata": For details, refer to the metadata section in the appendix
24}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleGetHaVip.java
Delete high-availability virtual IP address
Function declaration
1public void deleteHaVip(DeleteHaVipRequest request) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Deleting High-availability Virtual IP Address
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleDeleteHaVip.java
Update high-availability virtual IP address
Function declaration
1public void updateHaVip(UpdateHaVipRequest updateHaVipRequest) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation Request Parameters for Updating High-availability Virtual IP Address
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleUpdateHaVip.java
Bind instance to high-availability virtual IP address
Function declaration
1public void bindInstance(BindInstanceRequest bindInstanceRequest) {
2 ......
3}
Parameter meaning
Refer to OpenAPI documentation: Request Parameters for Binding Instance for High-availability Virtual IP Address
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleHaVipBindInstance.java
Unbind instance from high-availability virtual IP address
Function declaration
1public void unBindInstance(UnBindInstanceRequest request) {
2 ......
3}
Parameter meaning
Refer to OpenAPI documentation: Request Parameters for Unbinding Instance from High-availability Virtual IP Address
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleHaVipUnbindInstance.java
Bind EIP to high-availability virtual IP address
Function declaration
1public void bindEip(BindEipRequest bindEipRequest) {
2 ......
3}
Parameter meaning
Refer to OpenAPI documentation: Request Parameters for Binding EIP to High-availability Virtual IP Address
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleHaVipBindEip.java
Unbind EIP from high-availability virtual IP address
Function declaration
1public void unBindEip(UnBindEipRequest unBindEipRequest) {
2 ......
3}
Parameter meaning
Refer to OpenAPI documentation: Request Parameters for Unbinding EIP from High-availability Virtual IP Address
Response value
- Operation succeeded
No response value
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to ExampleHaVipUnbindEip.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 }
