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