Creating a VPC Peering Connection
Sample Code
You can use the API to create a VPC peering connection. Sample code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // Import classes:
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.ClusterApi;
ClusterApi apiInstance = new ClusterApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String |
Integer clusterId = 56; // Integer |
CreatePeeringRequest body = new CreatePeeringRequest(); // CreatePeeringRequest | Create a VPC peering connection with request parameters being in the JSON format.
try {
CreatePeeringResponse result = apiInstance.createPeering(xProjectId, clusterId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ClusterApi#createPeering");
System.err.println(e.getResponseBody());
e.printStackTrace();
}
|
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| xProjectId | Yes | String | Project ID. This parameter is used to obtain the token for the project. |
| ClusterId | Yes | Integer | User ID. |
| body | Yes | - | Whether to create a VPC peering connection with request parameters being in the JSON format. For details about parameter types, see Table 2. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| vpcId | No | String | ID of a VPC. |
| name | No | String | Name of a VPC. |
| acceptTenantId | No | String | ID of the tenant to which the peer VPC belongs. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| peering | No | - | VPC peering connection information. For details about parameter types, see Table 4. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | No | String | Name of a VPC peering connection. |
| id | No | String | ID of a VPC peering connection. |
| requestVpcInfo | No | - | Information about the local VPC. For details, see Table 5. |
| acceptVpcInfo | No | - | Information about the peer VPC. For details, see Table 5. |
| status | No | String | Status of a VPC peering connection. |
Last Article: Obtaining User Quota Information About a Tenant
Next Article: Querying a VPC Peering Connection
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.