Search in sources :

Example 1 with CompactViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response in project cloudbreak by hortonworks.

the class EnvironmentServiceDecorator method prepareEnvironments.

public void prepareEnvironments(Set<ClusterTemplateViewV4Response> clusterTemplateViewV4Responses) {
    LOGGER.debug("Decorating with environment name the following cluster definition(s): {}", clusterTemplateViewV4Responses.stream().map(CompactViewV4Response::getName).collect(toSet()));
    Collection<SimpleEnvironmentResponse> responses = environmentClientService.list().getResponses();
    for (ClusterTemplateViewV4Response clusterTemplateViewV4Response : clusterTemplateViewV4Responses) {
        Optional<SimpleEnvironmentResponse> first = responses.stream().filter(x -> x.getCrn().equals(clusterTemplateViewV4Response.getEnvironmentCrn())).findFirst();
        first.ifPresentOrElse(simpleEnvironmentResponse -> clusterTemplateViewV4Response.setEnvironmentName(simpleEnvironmentResponse.getName()), () -> LOGGER.info("Unable to find environment name for cluster definition \"{}\"", clusterTemplateViewV4Response.getName()));
    }
}
Also used : Logger(org.slf4j.Logger) ClusterTemplateViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response) CompactViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) ClusterTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Inject(javax.inject.Inject) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) Service(org.springframework.stereotype.Service) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Optional(java.util.Optional) Collectors.toSet(java.util.stream.Collectors.toSet) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) CompactViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response) ClusterTemplateViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)

Example 2 with CompactViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response in project cloudbreak by hortonworks.

the class SdxService method fetchRecipesFromCore.

private Set<String> fetchRecipesFromCore() {
    String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
    RecipeViewV4Responses recipeResponses = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> recipeV4Endpoint.listInternal(WORKSPACE_ID_DEFAULT, initiatorUserCrn));
    Set<String> recipeNames = recipeResponses.getResponses().stream().map(CompactViewV4Response::getName).collect(Collectors.toSet());
    return recipeNames;
}
Also used : RecipeViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.responses.RecipeViewV4Responses)

Aggregations

ClusterTemplateV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response)1 ClusterTemplateViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)1 CompactViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 RecipeViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.responses.RecipeViewV4Responses)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)1 EnvironmentClientService (com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService)1 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)1 CredentialViewResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 SimpleEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Inject (javax.inject.Inject)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Service (org.springframework.stereotype.Service)1