Search in sources :

Example 1 with ListGroupsResponse

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

the class UmsClient method listGroups.

/**
 * Wraps calls to ListGroups with an Account ID.
 *
 * @param requestId          the request ID for the request
 * @param accountId          the account ID
 * @param groupNameOrCrnList the groups to list. if null or empty then all groups will be listed
 * @return the list of groups
 */
public List<Group> listGroups(String requestId, String accountId, List<String> groupNameOrCrnList) {
    checkNotNull(requestId, "requestId should not be null.");
    validateAccountIdWithWarning(accountId);
    List<Group> groups = new ArrayList<>();
    ListGroupsRequest.Builder requestBuilder = ListGroupsRequest.newBuilder().setAccountId(accountId).setPageSize(umsClientConfig.getListGroupsPageSize());
    if (groupNameOrCrnList != null && !groupNameOrCrnList.isEmpty()) {
        requestBuilder.addAllGroupNameOrCrn(groupNameOrCrnList);
    }
    ListGroupsResponse response;
    do {
        response = newStub(requestId).listGroups(requestBuilder.build());
        groups.addAll(response.getGroupList());
        requestBuilder.setPageToken(response.getNextPageToken());
    } while (response.hasNextPageToken());
    return groups;
}
Also used : ListGroupsRequest(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsRequest) Group(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group) WorkloadAdministrationGroup(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup) ListGroupsResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsResponse) ArrayList(java.util.ArrayList)

Aggregations

Group (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.Group)1 ListGroupsRequest (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsRequest)1 ListGroupsResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListGroupsResponse)1 WorkloadAdministrationGroup (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.WorkloadAdministrationGroup)1 ArrayList (java.util.ArrayList)1