Query the List of Routes

Sample Code

You can use the API to query the list of routes in a cluster. 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 | 
String peeringId = "peeringId_example"; // String | 
try {
    GetRoutesResponse result = apiInstance.getRoutes(xProjectId, clusterId, peeringId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling ClusterApi#getRoutes");
    System.err.println(e.getResponseBody());
    e.printStackTrace();
}

Parameters

Table 1 Parameters

Parameter

Mandatory

Type

Description

xProjectId

Yes

String

Project ID. This parameter is used to obtain the token for the project.

clusterId

Yes

Integer

ID of an exclusive cluster.

peeringId

Yes

String

ID of a VPC peering connection.

Table 2 Parameters involved in GetRoutesResponse

Parameter

Mandatory

Type

Description

routes

No

-

Information about the list of routes. For details about parameter types, see Table 3.

Table 3 Parameters involved in Route

Parameter

Mandatory

Type

Description

type

No

String

Route type. Generally, this parameter is set to peering.

nexthop

No

String

Next-hop address, which is the ID of the VPC peering connection.

destination

No

String

DestinationCIDR of a route.

vpcId

No

String

ID of the VPC for which a route is to be added.

tenantId

No

String

ID of the tenant who requests to add a route.

id

No

String

ID of a route.