use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse in project cloudbreak by hortonworks.
the class MockUserManagementService method listUsers.
@Override
public void listUsers(ListUsersRequest request, StreamObserver<ListUsersResponse> responseObserver) {
LOGGER.info("List users for account: {}", request.getAccountId());
Builder userBuilder = ListUsersResponse.newBuilder();
if (request.getUserIdOrCrnCount() == 0) {
if (isNotEmpty(request.getAccountId())) {
ofNullable(accountUsers.get(request.getAccountId())).orElse(Set.of()).stream().map(userName -> createUser(request.getAccountId(), userName)).forEach(userBuilder::addUser);
for (int i = 0; i < MOCK_USER_COUNT; i++) {
User user = createUser(request.getAccountId(), "fakeMockUser" + i);
userBuilder.addUser(user);
}
}
responseObserver.onNext(userBuilder.build());
} else {
String userIdOrCrn = request.getUserIdOrCrn(0);
String[] splittedCrn = userIdOrCrn.split(":");
String userName = splittedCrn[6];
String accountId = splittedCrn[4];
responseObserver.onNext(userBuilder.addUser(createUser(accountId, userName)).build());
}
responseObserver.onCompleted();
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse in project cloudbreak by hortonworks.
the class UmsClient method listUsers.
/**
* Wraps calls to ListUsers with an Account ID.
*
* @param requestId the request ID for the request
* @param accountId the account ID
* @param userIdOrCrnList a list of users to list. If null or empty then all users will be listed
* @return the list of users
*/
public List<User> listUsers(String requestId, String accountId, List<String> userIdOrCrnList) {
checkNotNull(requestId, "requestId should not be null.");
validateAccountIdWithWarning(accountId);
List<User> users = new ArrayList<>();
ListUsersRequest.Builder requestBuilder = ListUsersRequest.newBuilder().setAccountId(accountId).setPageSize(umsClientConfig.getListUsersPageSize());
if (userIdOrCrnList != null && !userIdOrCrnList.isEmpty()) {
requestBuilder.addAllUserIdOrCrn(userIdOrCrnList);
}
ListUsersResponse response;
do {
response = newStub(requestId).listUsers(requestBuilder.build());
users.addAll(response.getUserList());
requestBuilder.setPageToken(response.getNextPageToken());
} while (response.hasNextPageToken());
return users;
}
Aggregations