class GrpcUmsClient {

    public List<ServicePrincipalCloudIdentities> listServicePrincipalCloudIdentities(
            String actorCrn, String accountId, String environmentCrn, Optional<String> requestId) {

        List<ServicePrincipalCloudIdentities> spCloudIds = new ArrayList<>();

        try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
            UmsClient client = makeClient(channelWrapper.getChannel(), actorCrn);
            LOGGER.debug("Listing service principal cloud identities for account {} using request ID {}", accountId, requestId);
            UserManagementProto.ListServicePrincipalCloudIdentitiesResponse response;
            Optional<PagingProto.PageToken> pageToken = Optional.empty();
            do {
                response = client.listServicePrincipalCloudIdentities(
                        requestId.orElse(UUID.randomUUID().toString()), accountId, environmentCrn, pageToken);
                spCloudIds.addAll(response.getServicePrincipalCloudIdentitiesList());
                pageToken = Optional.ofNullable(response.getNextPageToken());
            } while (response.hasNextPageToken());
        }
        LOGGER.debug("{} ServicePrincipalCloudIdentities found for account {}", spCloudIds.size(), accountId);
        return spCloudIds;
    }

}