Search in sources :

Example 1 with UserManagementBlockingStub

use of com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub in project cloudbreak by hortonworks.

the class UmsClient method listResourceRoles.

public Set<String> listResourceRoles(String requestId, String accountId) {
    UserManagementBlockingStub stub = newStub(requestId);
    UserManagementProto.ListResourceRolesRequest.Builder requestBuilder = UserManagementProto.ListResourceRolesRequest.newBuilder().setAccountId(accountId);
    UserManagementProto.ListResourceRolesResponse response;
    Set<String> resourceRoles = Sets.newHashSet();
    do {
        response = stub.listResourceRoles(requestBuilder.build());
        resourceRoles.addAll(response.getResourceRoleList().stream().map(UserManagementProto.ResourceRole::getCrn).collect(Collectors.toSet()));
        requestBuilder.setPageToken(response.getNextPageToken());
    } while (response.hasNextPageToken());
    return resourceRoles;
}
Also used : UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) UserManagementBlockingStub(com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub)

Example 2 with UserManagementBlockingStub

use of com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub in project cloudbreak by hortonworks.

the class UmsClient method listRoles.

public Set<String> listRoles(String requestId, String accountId) {
    UserManagementBlockingStub stub = newStub(requestId);
    UserManagementProto.ListRolesRequest.Builder requestBuilder = UserManagementProto.ListRolesRequest.newBuilder().setAccountId(accountId);
    UserManagementProto.ListRolesResponse response;
    Set<String> roles = Sets.newHashSet();
    do {
        response = stub.listRoles(requestBuilder.build());
        roles.addAll(response.getRoleList().stream().map(UserManagementProto.Role::getCrn).collect(Collectors.toSet()));
        requestBuilder.setPageToken(response.getNextPageToken());
    } while (response.hasNextPageToken());
    return roles;
}
Also used : UserManagementProto(com.cloudera.thunderhead.service.usermanagement.UserManagementProto) UserManagementBlockingStub(com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub)

Aggregations

UserManagementBlockingStub (com.cloudera.thunderhead.service.usermanagement.UserManagementGrpc.UserManagementBlockingStub)2 UserManagementProto (com.cloudera.thunderhead.service.usermanagement.UserManagementProto)2