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 access key
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:
PeerConnClient
PeerConnClient simplifies interactions with the peering connections service by encapsulating its API. Users can configure peering connections by calling the methods provided in PeerConnClient.
Create PeerConnClient
When creating PeerConnClient, first configure g_PeerConnConfigs using Endpoint, AK, and SK, then use g_PeerConnConfigs to configure PeerConnClient. The specific configuration method is as follows:
1$g_PeerConnConfigs = array(
2 'credentials' => array(
3 'ak' => '',
4 'sk' => '',
5 ),
6 'endpoint' => '',
7);
8public $client;
9client = new PeerConnClient($g_PeerConnConfigs);
Create peering connections
When creating peering connections, note the following:
- For peering connections within the same account, the system automatically accepts them on behalf of the peer.
- Cross-account peering connections require acceptance by the receiving end before becoming available.
- For peering connections within the same region, the billing parameter only supports the postpaid option (the billing parameter must be provided, though the billing amount will be 0).
- Only one peering connection is allowed between any two VPCs.
- The initiator's VPC and the acceptor's VPC must not be the same.
- A peering connection cannot be established if both the local and peer VPCs are relay VPCs.
The createPeerConn function can be used to create peering connections within a specified VPC. The function is defined as follows:
1public function createPeerConn($bandwidthInMbps, $localVpcId, $peerVpcId, $peerRegion, $billing, $peerAccountId = null, $peerIfName = null, $description = null, $localIfName = null, $clientToken = null, $options = array())
The parameter description is as follows:
| Parameter name | Types | Whether required | Description |
|---|---|---|---|
| bandwidthInMbps | int | Yes | Maximum bandwidth of peering connections (unit: mbps) |
| localVpcId | string | Yes | Local VPC ID |
| peerVpcId | string | Yes | Peer VPC ID |
| peerRegion | string | Yes | Peer region |
| description | string | No | Description |
| localIfName | string | No | Local API name |
| peerAccountId | string | No | Peer account ID |
| peerIfName | string | No | Peer API name |
| billing | Custom billing type | Yes | Billing method, supporting postpay and monthly prepay. For details, refer to Billing Description |
| clientToken | string | No | Idempotence Token, which is an ASCII string with a length not exceeding 64 bits. For details, refer to Idempotence Token. |
| options | array | No | Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient |
The custom billing type definition can be found in Billing.php Region parameters are as follows:
| Name | Value |
|---|---|
| Beijing | bj |
| Guangzhou | gz |
| Suzhou | su |
| Shanghai | fsh |
| Hong Kong | hkg |
| Baoding | bd |
| Duxiaoman Finance Zone | hb-fsg |
| Wuhan | fwh |
| Singapore | sin |
| Duxiaoman Finance Zone 2 | bjfsg |
List of peering connections to be queried.
The listPeerConns function can be used to query the peering connections list. The function is defined as follows:
1public function listPeerConns($vpcId, $marker = null, $maxKeys = 1000, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | vpcId | string |Yes |ID of VPC for the peering connection | |marker | string | No | Starting position for batch querying the list | |maxKeys | int | No |Maximum number of items per page, with a maximum not exceeding 1000. The default is 1,000| |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Query peering connections details
The getPeerConn function can be used to query the peering connection details. The function is defined as follows:
1public function getPeerConn($peerConnId, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Update the local API name and remarks for peering connections
The updatePeerConn function can be used to update peering connections. The function is defined as follows:
1public function updatePeerConn($peerConnId, $localIfId, $localIfName = null, $description = null, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | | localIfId | string | Yes | ID of the local API | |description|String|No|Description| |localIfName | string | No | Name of the local API| |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to idempotence token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Application to process the peering connection
- The timeout period for a connection request initiated by the initiator is 7 days. Once the timeout occurs, the status of the peering connection changes to "negotiation failure."
- If the acceptor rejects, the initiator's peering connection status changes to "negotiation failure."
The acceptPeerConnApply function can be used to accept peering connections. The function is defined as follows:
1public function acceptPeerConnApply($peerConnId, $clientToken = null, $options = array())
The rejectPeerConnApply function can be used to reject peering connections. The function is defined as follows:
1public function rejectPeerConnApply($peerConnId, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to Idempotence Token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Release peering connections
The releasePeerConn function can be used to release peering connections. The function is defined as follows:
1public function releasePeerConn($peerConnId, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to Idempotence Token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Bandwidth resizing for peering connections
The resizePeerConn function can be used to release peering connections. The function is defined as follows:
1public function resizePeerConn($peerConnId, $newBandwidthInMbps, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | | newBandwidthInMbps | int | Yes | Maximum bandwidth of peering connections (Unit: Mbps) | |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to Idempotence Token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Peering connection renewal
- Postpay peering connections cannot be renewed.
- In cross-account scenarios, only the initiator can perform renewal operations.
The purchaseReservedPeerConn function can be used to release peering connections. The function is defined as follows:
1public function purchaseReservedPeerConn($peerConnId, $billing, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | |billing | Custom billing type | Yes | Charge type, refer to Billing instructions for details | |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to idempotence token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Enable DNS synchronization for the peering connections
- DNS synchronization can only be enabled when the status of the peering connection is "available."
- DNS synchronization cannot be enabled if the DNS status of the peering connection is "synchronizing" or "disabling synchronization."
The openPeerConnSyncDns can be used to release peering connections. The function is defined as follows:
1public function openPeerConnSyncDns($peerConnId, $role, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | |role | string | Yes |"initiator" denotes the initiating end, "acceptor" denotes the initiating end | |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to Idempotence Token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
Disable DNS synchronization for the peering connections.
- DNS synchronization can only be disabled when the status of the peering connection is "available.\
- DNS synchronization cannot be turned off when the DNS status of peering connections is either synchronizing or in the process of being disabled.
The closePeerConnSyncDns can be used to release peering connections. The function is defined as follows:
1public function closePeerConnSyncDns($peerConnId, $role, $clientToken = null, $options = array())
The parameter description is as follows: | Parameter Name | Type | Required | Description | | --- | --- | --- | --- | | peerConnId | string | Yes | ID of the peering connection | |role | string | Yes |"initiator" denotes the initiating end, "acceptor" denotes the initiating end | |clientToken | string | No | idempotence token, which is an ASCII string with a length not exceeding 64 characters. For details, refer to Idempotence Token | |options | array | No |Additional configuration, where parameters in the option can be used to temporarily override the default parameters (AK, SK, endpoint) in NatClient|
