use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest.Builder in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method listAgents.
public List<InvertingProxyAgent> listAgents(String requestId, String actorCrn, String accountId, Optional<String> environmentCrnOpt) {
List<InvertingProxyAgent> result = new ArrayList<>();
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
Builder listAgentsRequestBuilder = ListAgentsRequest.newBuilder();
environmentCrnOpt.ifPresentOrElse(listAgentsRequestBuilder::setEnvironmentCrn, () -> listAgentsRequestBuilder.setAccountId(accountId));
ListAgentsRequest listAgentsRequest = listAgentsRequestBuilder.build();
PageToken nextPageToken = null;
int page = 0;
while (page == 0 || nextPageToken.getExclusiveStartKeyStringAttrsCount() > 0 || nextPageToken.getExclusiveStartKeyNumAttrsCount() > 0) {
++page;
LOGGER.debug("Calling listAgents with params accountId: '{}', environment CRN: '{}', page: '{}'", accountId, environmentCrnOpt, page);
ListAgentsResponse listAgentsResponse = client.listAgents(listAgentsRequest);
result.addAll(listAgentsResponse.getAgentsList());
nextPageToken = listAgentsResponse.getNextPageToken();
listAgentsRequestBuilder.setPageToken(nextPageToken);
listAgentsRequest = listAgentsRequestBuilder.build();
}
}
return result;
}
Aggregations