use of com.cloudera.thunderhead.service.publicendpointmanagement.PublicEndpointManagementProto.GenerateManagedDomainNamesResponse in project cloudbreak by hortonworks.
the class MockPublicEndpointManagementService method generateManagedDomainNames.
@Override
public void generateManagedDomainNames(PublicEndpointManagementProto.GenerateManagedDomainNamesRequest request, StreamObserver<GenerateManagedDomainNamesResponse> responseObserver) {
ProtocolStringList subDomains = request.getSubdomainsList();
String environmentName = request.getEnvironmentName();
String accountId = request.getAccountId();
checkArgument(!Strings.isNullOrEmpty(environmentName));
checkArgument(!Strings.isNullOrEmpty(accountId));
checkArgument(!subDomains.isEmpty());
LOGGER.info("Generating mock managed domain for environment: '{}', accountid: '{}' with provided domains: '{}', ", environmentName, accountId, String.join(",", subDomains));
String generatedManagedDomain = environmentNameBasedDomainNameProvider.getDomainName(environmentName, MockUserManagementService.ACCOUNT_SUBDOMAIN);
GenerateManagedDomainNamesResponse response = GenerateManagedDomainNamesResponse.newBuilder().putDomains("*", generatedManagedDomain).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
use of com.cloudera.thunderhead.service.publicendpointmanagement.PublicEndpointManagementProto.GenerateManagedDomainNamesResponse in project cloudbreak by hortonworks.
the class GrpcClusterDnsClient method generateManagedDomain.
public GenerateManagedDomainNamesResponse generateManagedDomain(String environmentName, List<String> subDomains, String accountId, Optional<String> requestId) {
String requestIdValue = requestId.orElse(UUID.randomUUID().toString());
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterDnsClient client = makeClient(channelWrapper.getChannel(), regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString());
LOGGER.info("Generating managed domain names for environment: '{}', subdomain: '{}', account id: '{}', requestId: '{}'", environmentName, String.join(",", subDomains), accountId, requestId);
GenerateManagedDomainNamesResponse response = client.generateManagedDomainNames(requestIdValue, environmentName, subDomains, accountId);
LOGGER.info("Domain names generation has been finished, returned values: '{}'", response.getDomainsMap());
return response;
}
}
use of com.cloudera.thunderhead.service.publicendpointmanagement.PublicEndpointManagementProto.GenerateManagedDomainNamesResponse in project cloudbreak by hortonworks.
the class DnsManagementService method generateManagedDomain.
public String generateManagedDomain(String accountId, String environmentName) {
String wildCardSubDomain = "*";
List<String> subDomains = List.of(wildCardSubDomain);
LOGGER.debug("Generating managed domain names for environment: '{}', subdomain: '{}'", environmentName, String.join(",", subDomains));
Optional<String> requestIdOptional = Optional.ofNullable(MDCBuilder.getOrGenerateRequestId());
GenerateManagedDomainNamesResponse response = grpcClusterDnsClient.generateManagedDomain(environmentName, subDomains, accountId, requestIdOptional);
Map<String, String> domainsMap = Optional.ofNullable(response).map(GenerateManagedDomainNamesResponse::getDomainsMap).orElse(new HashMap<>());
LOGGER.info("Domain names has been generated: '{}'", domainsMap);
String environmentDomain = domainsMap.getOrDefault(wildCardSubDomain, null);
if (StringUtils.isNotEmpty(environmentDomain) && environmentDomain.startsWith(wildCardSubDomain)) {
environmentDomain = environmentDomain.replace(wildCardSubDomain + DOMAIN_NAME_PART_DELIMITER, "");
}
return environmentDomain;
}
Aggregations