Peering Connections
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. The peering connection service is part of the VPC service and adopts the VPC service domain name.
Retrieve AK/SK
To use Baidu AI Cloud products, you need a Baidu AI Cloud account along with valid AK (Access Key ID) and SK (Secret Access Key) credentials for signature authorization. You can obtain and understand your AK/SK information through the following steps:
Create PeerConnClient
PeerConnClient is the client for the peering connections service, offering developers a range of methods to work with the service. To create a PeerConnClient, first set up a VPN PeerConnClient-type configuration instance using the endpoint, AK, and SK, then use this configuration instance to initialize the PeerConnClient. The specific configuration process is as follows:
1static final String HOST = "";
2static final String AK = "";
3static final String SK = "";
4PeerConnClientConfiguration config = new PeerConnClientConfiguration();
5config.setCredentials(new DefaultBceCredentials(ak, sk));
6config.setEndpoint(endpoint);
7PeerConnClient peerConnClient = new PeerConnClient(config);
Create peering connections
Function declaration
1public CreatePeerConnResponse createPeerConn(CreatePeerConnRequest request) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Creating Peering Connections
Response Value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "peerConnId": "peerconn-9td54fmx143e"
4}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to: ExampleCreatePeerConn.java
List of peering connections to be queried.
Function declaration
1public ListPeerConnResponse listPeerConn(ListPeerConnRequest request) {
2 ......
3}
Parameter meaning
Refer to the OpenAPI documentation: Request Parameters for Querying Peering Connection List
Response Value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "marker":"peerconn-9td54fmx143e",
4 "isTruncated": true,
5 "nextMarker": "peerconn-srbvvxmjn7ux",
6 "maxKeys": 1
7 "peerConns":[
8 {
9 "peerConnId":"peerconn-9td54fmx143e",
10 "role":"initiator",
11 "status":"active",
12 "bandwithInMbp":500,
13 "description":"peer_diff_account",
14 "localIfId":"qpif-ken2yc9j8x56",
15 "localIfName":"int-SpLVk25R",
16 "localVpcId":"vpc-13vuxu016dew",
17 "localRegion":"bj",
18 "peerVpcId":"vpc-jcvmhw9h1a35",
19 "peerRegion":"bj",
20 "peerAccountId":"75c14a239bb24b9e88b695e8e9e47952",
21 "dnsStatus":"close",
22 "paymentTiming":"Postpaid",
23 "createdTime" :"2018-08-07 19:46:55",
24 "expiredTime":expiredTime
25 }
26 ]
27}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to: ExampleListPeerConn.java
Query peering connections details
Function declaration
1public GetPeerConnResponse getPeerConn(GetPeerConnRequest request) {
2 ......
3}
Parameter Meaning
Refer to the OpenAPI documentation: Request Parameters for Querying Peering Connection Details
Response Value
- Operation succeeded
1{
2 "metadata": For details, refer to the metadata section in the appendix,
3 "peerConnId":"peerconn-cbp4xrtzk3fb",
4 "role":"initiator",
5 "status":"active",
6 "bandwithInMbp":1000,
7 "description":"mypeerconn",
8 "localIfId":"qpif-qz9a61ujsizt",
9 "localIfName":"dsds",
10 "localVpcId":"20fada00-f66e-40de-bed4-954af13dc0b2",
11 "localRegion":"bj",
12 "peerVpcId":"1aa1427d-92cf-45d0-bc31-ab4d9fe71425",
13 "peerRegion":"bj",
14 "peerAccountId":"75c14a239bb24b9e88b695e8e9e47952",
15 "createdTime": "2018-08-03 20:38:43"
16 "expiredTime":null,
17 "dnsStatus":"close",
18 "paymentTiming":"Postpaid",
19 "tags":[
20 {
21 "tagKey": "tagKey",
22 "tagValue": "tagValue"
23 }
24 ]
25}
- Operation failed
For response exception list of operation failure, refer to the Exception List.
Example code
For specific code examples, refer to: ExampleGetPeerConn.java
Update the local API name and remarks for peering connections
Function declaration
1public void modifyPeerConn(ModifyPeerConnRequest request) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Updating Peering Connection Local API Name and Remarks
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 ExampleModifyPeerConn.java
Application to process the peering connection
Function declaration
1// Accept peering connection request
2public void accept(PeerConnIdRequest request) {
3 ......
4}
5 // Reject peering connections request
6public void reject(PeerConnIdRequest request) {
7 ......
8}
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Processing Peering Connections
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 ExampleProcessPeerConnApply.java
Release peering connections
Function declaration
1public void release(PeerConnIdRequest request) {
2 ......
3}
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Releasing Peering Connections
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: ExampleDeletePeerConn.java
Bandwidth resizing for peering connections
Function declaration
1public void modifyBandwith(ModifyBandwidthRequest request) {
2 ......
3}
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Bandwidth Resizing of Peering Connections
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 ExampleModifyBandwith.java
Peering connection renewal
Function declaration
1public void purchaseReserved(PurchaseReservedPeerConnRequest request) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Renewing Peering Connections
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 ExamplePurchaseReserved.java
Enable DNS synchronization for the peering connections
Function declaration
1public void openSyncDns(SyncDnsRequest request) {
2 ......
3}
Parameter meaning
Please refer to the OpenAPI documentation: Request Parameters for Enabling Peering Connection Synchronized DNS
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 ExampleOpenSyncDns.java
Disable DNS synchronization for the peering connections.
Function declaration
1public void closeSyncDns(SyncDnsRequest request) {
2 ......
3}
Parameter Meaning
Please refer to the OpenAPI documentation: Request Parameters for Disabling Peering Connection Synchronized DNS
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 ExampleCloseSyncDns.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 }
