Search in sources :

Example 1 with RecipeRequest

use of com.sequenceiq.cloudbreak.api.model.RecipeRequest in project cloudbreak by hortonworks.

the class RecipeCreationTest method createRecipe.

private void createRecipe(String name, String script, RecipeType recipeType, String description) {
    RecipeRequest recipeRequest = new RecipeRequest();
    recipeRequest.setRecipeType(recipeType);
    recipeRequest.setName(name);
    recipeRequest.setContent(Base64.encodeBase64String(script.getBytes()));
    recipeRequest.setDescription(description);
    RecipeEndpoint recipeEndpoint = getCloudbreakClient().recipeEndpoint();
    Long id = recipeEndpoint.postPrivate(recipeRequest).getId();
    // then
    Assert.assertNotNull(id, "Recipe is not created.");
    addRecipeToContext(id);
}
Also used : RecipeRequest(com.sequenceiq.cloudbreak.api.model.RecipeRequest) RecipeEndpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.RecipeEndpoint)

Example 2 with RecipeRequest

use of com.sequenceiq.cloudbreak.api.model.RecipeRequest in project cloudbreak by hortonworks.

the class HostGroupDecorator method decorate.

public HostGroup decorate(HostGroup subject, HostGroupRequest hostGroupRequest, IdentityUser user, Long stackId, boolean postRequest, Boolean publicInAccount) {
    ConstraintJson constraintJson = hostGroupRequest.getConstraint();
    Set<Long> recipeIds = hostGroupRequest.getRecipeIds();
    Set<RecipeRequest> recipes = hostGroupRequest.getRecipes();
    Set<String> recipeNames = hostGroupRequest.getRecipeNames();
    LOGGER.debug("Decorating hostgroup on [{}] request.", postRequest ? "POST" : "PUT");
    Constraint constraint = conversionService.convert(constraintJson, Constraint.class);
    if (postRequest) {
        constraint = decorateConstraint(stackId, user, constraint, constraintJson.getInstanceGroupName(), constraintJson.getConstraintTemplateName());
        subject.setConstraint(constraint);
    } else {
        subject = getHostGroup(stackId, constraint, constraintJson, subject, user);
    }
    subject.getRecipes().clear();
    if (recipeIds != null) {
        prepareRecipesByIds(subject, recipeIds);
    }
    if (recipeNames != null && !recipeNames.isEmpty()) {
        prepareRecipesByName(subject, user, recipeNames);
    }
    if (recipes != null && !recipes.isEmpty()) {
        prepareRecipesByRequests(subject, user, recipes, publicInAccount);
    }
    return subject;
}
Also used : Constraint(com.sequenceiq.cloudbreak.domain.Constraint) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) RecipeRequest(com.sequenceiq.cloudbreak.api.model.RecipeRequest)

Example 3 with RecipeRequest

use of com.sequenceiq.cloudbreak.api.model.RecipeRequest in project cloudbreak by hortonworks.

the class RecipeToRecipeRequestConverter method convert.

@Override
public RecipeRequest convert(Recipe source) {
    RecipeRequest recipeRequest = new RecipeRequest();
    recipeRequest.setName("");
    recipeRequest.setDescription(source.getDescription());
    recipeRequest.setRecipeType(source.getRecipeType());
    recipeRequest.setContent(source.getContent());
    return recipeRequest;
}
Also used : RecipeRequest(com.sequenceiq.cloudbreak.api.model.RecipeRequest)

Example 4 with RecipeRequest

use of com.sequenceiq.cloudbreak.api.model.RecipeRequest in project cloudbreak by hortonworks.

the class HostGroupDecorator method prepareRecipesByRequests.

private void prepareRecipesByRequests(HostGroup subject, IdentityUser user, Iterable<RecipeRequest> recipes, Boolean publicInAccount) {
    for (RecipeRequest recipe : recipes) {
        Recipe convert = conversionService.convert(recipe, Recipe.class);
        convert.setPublicInAccount(publicInAccount);
        convert = recipeService.create(user, convert);
        subject.getRecipes().add(convert);
    }
}
Also used : Recipe(com.sequenceiq.cloudbreak.domain.Recipe) RecipeRequest(com.sequenceiq.cloudbreak.api.model.RecipeRequest)

Aggregations

RecipeRequest (com.sequenceiq.cloudbreak.api.model.RecipeRequest)4 RecipeEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.RecipeEndpoint)1 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)1 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)1 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)1