use of com.cloudera.thunderhead.service.minasshdmanagement.MinaSshdManagementProto.ListMinaSshdServicesResponse in project cloudbreak by hortonworks.
the class MinaSshdManagementClient method listMinaSshdServices.
/**
* Wraps calls to listMinaSshdServices with an account ID.
*
* @param requestId the request ID for the request
* @param accountId the account ID
* @param serviceIds the minasshd services to list. if null or empty then all minasshd services will be listed
* @return the list of minasshd services
*/
public List<MinaSshdService> listMinaSshdServices(String requestId, String accountId, List<String> serviceIds) throws CcmException {
checkNotNull(requestId, "requestId should not be null.");
checkNotNull(accountId, "accountId should not be null.");
List<MinaSshdService> groups = new ArrayList<>();
MinaSshdManagementBlockingStub minaSshdManagementBlockingStub = newStub(requestId);
ListMinaSshdServicesRequest.Builder requestBuilder = ListMinaSshdServicesRequest.newBuilder().setAccountId(accountId).setPageSize(minaSshdManagementClientConfig.getListMinaSshdServicesPageSize());
if (serviceIds != null && !serviceIds.isEmpty()) {
requestBuilder.addAllId(serviceIds);
}
ListMinaSshdServicesResponse response;
do {
try {
LOGGER.debug("Calling listMinaSshdServices with requestId: {}, accountId: {}, serviceIds: [{}]", requestId, accountId, serviceIds);
response = minaSshdManagementBlockingStub.listMinaSshdServices(requestBuilder.build());
if (response == null) {
throw new CcmException("Got null response from MinaSshdManagementService listMinaSshdServices gRPC call", false);
} else {
List<MinaSshdService> minaSshdServices = response.getMinaSshdServiceList();
if (minaSshdServices == null) {
throw new CcmException("Got null minasshd services in MinaSshdManagementService listMinaSshdServices gRPC response", false);
} else {
groups.addAll(minaSshdServices);
}
}
} catch (StatusRuntimeException e) {
String message = "MinaSshdManagementService listMinaSshdServices gRPC call failed: " + e.getMessage();
Status status = e.getStatus();
Status.Code code = status.getCode();
boolean retryable = GrpcUtil.isRetryable(code);
LOGGER.debug("Got status code: {}, retryable: {}", code, retryable);
throw new CcmException(message, e, retryable);
}
requestBuilder.setPageToken(response.getNextPageToken());
} while (response.hasNextPageToken());
return groups;
}
Aggregations