Search in sources :

Example 1 with PageToken

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;
}
Also used : ArrayList(java.util.ArrayList) PageToken(com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken) ListWorkloadAdministrationGroupsForMemberResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse)

Example 2 with PageToken

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;
}
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)

Example 3 with PageToken

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;
}
Also used : ArrayList(java.util.ArrayList) PageToken(com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken) ListWorkloadAdministrationGroupsForMemberResponse(com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse)

Example 4 with PageToken

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;
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Builder(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest.Builder) ArrayList(java.util.ArrayList) ListAgentsRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest) PageToken(com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub) ListAgentsResponse(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsResponse)

Aggregations

PageToken (com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken)4 ArrayList (java.util.ArrayList)4 ListWorkloadAdministrationGroupsForMemberResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListWorkloadAdministrationGroupsForMemberResponse)2 ClusterConnectivityManagementV2BlockingStub (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)1 InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)1 ListAgentsRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest)1 Builder (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest.Builder)1 ListAgentsResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsResponse)1 ListServicePrincipalCloudIdentitiesResponse (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListServicePrincipalCloudIdentitiesResponse)1 ServicePrincipalCloudIdentities (com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ServicePrincipalCloudIdentities)1 ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)1 ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)1