Help Center> Cloud Stream Service> SDK Reference> Getting Started with SDK (Java)> Cluster Management> Querying Information About IP-Domain Mappings of a Specified Cluster

Querying Information About IP-Domain Mappings of a Specified Cluster

Sample Code

You can use the API provided CS to query information about IP-domain mappings of a specified cluster. In this example, the query results are displayed in descending order and information about the IP-domain mappings with IDs less than the value of cursor is displayed. Sample code is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
// 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 | Project ID used for obtaining the token for the project.
Integer clusterId = 56; // Integer | ID of an exclusive cluster.
String queryString = "queryString_example"; // String | IP address or domain name to be queried.
Long cursor = 789L; // Long | Domain name ID.
Boolean next = true; // Boolean | Whether to turn to the previous or next page.
Integer limit = 10; // Integer | Number of returned data records.
String order = "desc"; // String | Query result display. The query results can be displayed in ascending or descending order.
try {
    QueryClusterHostsInfoResponse result = apiInstance.getHostsInfo(xProjectId, clusterId, queryString, cursor, next, limit, order);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling ClusterApi#getHostsInfo");
    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.

queryString

No

String

IP address or domain name to be queried.

cursor

No

Long

Domain ID cursor.

next

Yes

Boolean

Whether to switch to the previous or next page. The default value is true.

limit

No

Integer

Number of returned data records. The default value is 10.

order

No

String

Query result display. Value asc indicates that the query results are displayed in ascending order, and value desc indicates that the query results are displayed in descending order. The default value is desc.

Table 2 Parameters involved in QueryClusterHostsInfoResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Long

Current time, expressed by milliseconds.

payload

No

-

Information about the IP-domain mappings of the cluster. For details about parameter types, see Table 3.

Table 3 Parameters involved in ClusterHostsInfo

Parameter

Mandatory

Type

Description

hostsInfo

No

List<ClusterHostsInfoHostsInfo>

List of the IP-domain mappings of the cluster. For details about parameter types, see Table 4.

total

No

Integer

Total number of IP-domain mappings.

Table 4 Parameters involved in ClusterHostsInfoHostsInfo

Parameter

Mandatory

Type

Description

id

No

integer

Domain name ID.

info

No

-

Information about the IP-domain mapping. For details about parameter types, see Table 5.

Table 5 Parameters involved in HostIpInfo

Parameter

Mandatory

Type

Description

hostname

No

String

Information about the domain name.

ip

No

String

IP address.