Search in sources :

Example 1 with ListMachineUsersResponse

use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersResponse in project cloudbreak by hortonworks.

the class UmsClient method listMachineUsers.

/**
 * Wraps calls to ListMachineUsers with an Account ID.
 *
 * @param requestId                   the request ID for the request
 * @param accountId                   the account ID
 * @param machineUserNameOrCrnList    a list of users to list. If null or empty then all users will be listed
 * @param includeInternal             whether to include internal machine users
 * @param includeWorkloadMachineUsers whether to include workload machine users
 * @return the list of machine users
 */
public List<MachineUser> listMachineUsers(String requestId, String accountId, List<String> machineUserNameOrCrnList, boolean includeInternal, boolean includeWorkloadMachineUsers) {
    checkNotNull(requestId, "requestId should not be null.");
    validateAccountIdWithWarning(accountId);
    List<MachineUser> machineUsers = new ArrayList<>();
    ListMachineUsersRequest.Builder requestBuilder = ListMachineUsersRequest.newBuilder().setAccountId(accountId).setIncludeInternal(includeInternal).setIncludeWorkloadMachineUsers(includeWorkloadMachineUsers).setPageSize(umsClientConfig.getListMachineUsersPageSize());
    if (machineUserNameOrCrnList != null && !machineUserNameOrCrnList.isEmpty()) {
        requestBuilder.addAllMachineUserNameOrCrn(machineUserNameOrCrnList);
    }
    ListMachineUsersResponse response;
    do {
        response = newStub(requestId).listMachineUsers(requestBuilder.build());
        machineUsers.addAll(response.getMachineUserList());
        requestBuilder.setPageToken(response.getNextPageToken());
    } while (response.hasNextPageToken());
    return machineUsers;
}
Also used : ListMachineUsersResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersResponse) ArrayList(java.util.ArrayList) MachineUser(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.MachineUser) ListMachineUsersRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersRequest)

Aggregations

ListMachineUsersRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersRequest)1 ListMachineUsersResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListMachineUsersResponse)1 MachineUser (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.MachineUser)1 ArrayList (java.util.ArrayList)1