use of com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken in project cloudbreak by hortonworks.
the class GrpcUmsClient method listWorkloadAdministrationGroupsForMember.
/**
* Lists the workload administration groups a member belongs to.
*
* @param memberCrn the CRN of the user or machine user
* @param requestId request id for getting rights
* @return the workload administration groups associated with this user or machine user
*/
public List<String> listWorkloadAdministrationGroupsForMember(String memberCrn, Optional<String> requestId) {
requireNonNull(memberCrn);
List<String> wags = new ArrayList<>();
UmsClient client = makeClient(channelWrapper.getChannel());
LOGGER.debug("Getting workload administration groups for member {}", memberCrn);
ListWorkloadAdministrationGroupsForMemberResponse response;
Optional<PageToken> pageToken = Optional.empty();
do {
response = client.listWorkloadAdministrationGroupsForMember(RequestIdUtil.getOrGenerate(requestId), memberCrn, pageToken);
wags.addAll(response.getWorkloadAdministrationGroupNameList());
pageToken = Optional.ofNullable(response.getNextPageToken());
} while (response.hasNextPageToken());
LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn);
return wags;
}
use of com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken 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;
}
use of com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken in project cloudbreak by hortonworks.
the class GrpcUmsClient method listWorkloadAdministrationGroupsForMember.
/**
* Lists the workload administration groups a member belongs to.
*
* @param memberCrn the CRN of the user or machine user
* @param requestId request id for getting rights
* @return the workload administration groups associated with this user or machine user
*/
public List<String> listWorkloadAdministrationGroupsForMember(String memberCrn, Optional<String> requestId, RegionAwareInternalCrnGeneratorFactory regionAwareInternalCrnGeneratorFactory) {
requireNonNull(memberCrn);
List<String> wags = new ArrayList<>();
UmsClient client = makeClient(channelWrapper.getChannel(), regionAwareInternalCrnGeneratorFactory);
LOGGER.debug("Getting workload administration groups for member {}", memberCrn);
ListWorkloadAdministrationGroupsForMemberResponse response;
Optional<PageToken> pageToken = Optional.empty();
do {
response = client.listWorkloadAdministrationGroupsForMember(RequestIdUtil.getOrGenerate(requestId), memberCrn, pageToken);
wags.addAll(response.getWorkloadAdministrationGroupNameList());
pageToken = Optional.ofNullable(response.getNextPageToken());
} while (response.hasNextPageToken());
LOGGER.debug("{} workload administration groups found for member {}", wags.size(), memberCrn);
return wags;
}
use of com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method listAgents.
public List<InvertingProxyAgent> listAgents(String requestId, String actorCrn, String accountId, Optional<String> environmentCrnOpt) {
List<InvertingProxyAgent> result = new ArrayList<>();
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
Builder listAgentsRequestBuilder = ListAgentsRequest.newBuilder();
environmentCrnOpt.ifPresentOrElse(listAgentsRequestBuilder::setEnvironmentCrn, () -> listAgentsRequestBuilder.setAccountId(accountId));
ListAgentsRequest listAgentsRequest = listAgentsRequestBuilder.build();
PageToken nextPageToken = null;
int page = 0;
while (page == 0 || nextPageToken.getExclusiveStartKeyStringAttrsCount() > 0 || nextPageToken.getExclusiveStartKeyNumAttrsCount() > 0) {
++page;
LOGGER.debug("Calling listAgents with params accountId: '{}', environment CRN: '{}', page: '{}'", accountId, environmentCrnOpt, page);
ListAgentsResponse listAgentsResponse = client.listAgents(listAgentsRequest);
result.addAll(listAgentsResponse.getAgentsList());
nextPageToken = listAgentsResponse.getNextPageToken();
listAgentsRequestBuilder.setPageToken(nextPageToken);
listAgentsRequest = listAgentsRequestBuilder.build();
}
}
return result;
}
Aggregations