Search in sources :

Example 1 with ListServicePrincipalCloudIdentitiesResponse

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

the class GrpcUmsClient method listServicePrincipalCloudIdentities.

/**
 * Retrieves list of service principal cloud identities for an environment from UMS.
 *
 * @param accountId      the account Id
 * @param environmentCrn the environment crn
 * @param requestId      an optional request Id
 * @return list of service principal cloud identities for an environment
 */
public List<ServicePrincipalCloudIdentities> listServicePrincipalCloudIdentities(String accountId, String environmentCrn, Optional<String> requestId) {
    List<ServicePrincipalCloudIdentities> spCloudIds = new ArrayList<>();
    UmsClient client = makeClient(channelWrapper.getChannel(), regionAwareInternalCrnGeneratorFactory);
    LOGGER.debug("Listing service principal cloud identities for account {} using request ID {}", accountId, requestId);
    ListServicePrincipalCloudIdentitiesResponse response;
    Optional<PageToken> pageToken = Optional.empty();
    do {
        response = client.listServicePrincipalCloudIdentities(RequestIdUtil.getOrGenerate(requestId), 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;
}
Also used : ServicePrincipalCloudIdentities(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ServicePrincipalCloudIdentities) ArrayList(java.util.ArrayList) PageToken(com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken) ListServicePrincipalCloudIdentitiesResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesResponse)

Aggregations

PageToken (com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken)1 ListServicePrincipalCloudIdentitiesResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesResponse)1 ServicePrincipalCloudIdentities (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ServicePrincipalCloudIdentities)1 ArrayList (java.util.ArrayList)1